#!/usr/bin/make -f

# dir where to install the deb-package
INSTALLDIR = $(CURDIR)/debian/gtk2-engines-magicchicken

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)


ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS = "-Wall -g -O0"
else
	CFLAGS = "-Wall -g -O2"
endif


build/config.status:
	dh_testdir
	cp -f /usr/share/misc/config.sub . 
	cp -f /usr/share/misc/config.guess .
	cp COPYING COPYING~
	autoreconf -ivf
	mv -f COPYING~ COPYING
	mkdir -p build/
	cd build && CFLAGS=$(CFLAGS) \
	../configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
	--prefix=/usr --mandir=\$${prefix}/share/man \


build: build/stamp

build/stamp: build/config.status
	dh_testdir
	$(MAKE) -C build/
	touch $(@)

clean:
	dh_testdir
	dh_testroot
	dh_clean
	$(RM) INSTALL
	rm -Rf autom4te.cache/
	rm -Rf build/

install: build
	dh_testdir
	dh_testroot
	dh_prep
	$(MAKE) -C build/ install prefix=$(INSTALLDIR)/usr
	find $(INSTALLDIR) -name '*.so' | grep . > /dev/null
	find $(INSTALLDIR) -name '*.la' -delete

binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs ChangeLog
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
