#!/usr/bin/make -f

BUILDDIR = build_dir

build:
	mkdir $(BUILDDIR)
	cd $(BUILDDIR); cmake -DCMAKE_BUILD_TYPE=Release -DOPT_DOUBLE_PRECISION=ON -DOPT_BUILD_PACKAGE_DEFAULT=ON -DCMAKE_INSTALL_PREFIX=/usr ..
	$(MAKE) -C $(BUILDDIR) preinstall
	touch build

binary: binary-indep binary-arch

binary-indep: build

binary-arch: build
	cd $(BUILDDIR); cmake -DCOMPONENT=Unspecified -DCMAKE_INSTALL_PREFIX=../debian/tmp/usr -P cmake_install.cmake
	mkdir -p debian/tmp/DEBIAN
	dpkg-gensymbols -pcollada-dom2.4-dp
	cd $(BUILDDIR); cmake -DCOMPONENT=collada-dom2.4-dp-base -DCMAKE_INSTALL_PREFIX=../debian/collada-dom2.4-dp-base/usr -P cmake_install.cmake
	mkdir -p debian/collada-dom2.4-dp-base/DEBIAN
	dpkg-gensymbols -pcollada-dom2.4-dp-base -Pdebian/collada-dom2.4-dp-base
	cd $(BUILDDIR); cmake -DCOMPONENT=collada-dom2.4-dp-dev -DCMAKE_INSTALL_PREFIX=../debian/collada-dom2.4-dp-dev/usr -P cmake_install.cmake
	mkdir -p debian/collada-dom2.4-dp-dev/DEBIAN
	dpkg-gensymbols -pcollada-dom2.4-dp-dev -Pdebian/collada-dom2.4-dp-dev
	cd $(BUILDDIR); cmake -DCOMPONENT=collada-dom-dev -DCMAKE_INSTALL_PREFIX=../debian/collada-dom-dev/usr -P cmake_install.cmake
	mkdir -p debian/collada-dom-dev/DEBIAN
	dpkg-gensymbols -pcollada-dom-dev -Pdebian/collada-dom-dev
	dh_shlibdeps
	dh_strip
	dpkg-gencontrol -pcollada-dom2.4-dp
	dpkg --build debian/tmp ..
	dpkg-gencontrol -pcollada-dom2.4-dp-base -Pdebian/collada-dom2.4-dp-base -Tdebian/collada-dom2.4-dp-base.substvars
	dpkg --build debian/collada-dom2.4-dp-base ..
	dpkg-gencontrol -pcollada-dom2.4-dp-dev -Pdebian/collada-dom2.4-dp-dev -Tdebian/collada-dom2.4-dp-dev.substvars
	dpkg --build debian/collada-dom2.4-dp-dev ..
	dpkg-gencontrol -pcollada-dom-dev -Pdebian/collada-dom-dev -Tdebian/collada-dom-dev.substvars
	dpkg --build debian/collada-dom-dev ..

clean:
	rm -f build
	rm -rf $(BUILDDIR)

.PHONY: binary binary-arch binary-indep clean
