#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

THEMES=usplash-theme-taibah

build: build-stamp

build-stamp:
	dh_testdir
	$(foreach theme, ${THEMES}, $(MAKE) -C $(theme); )
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	$(foreach theme, ${THEMES}, $(MAKE) -C $(theme) clean; )
	$(foreach theme, ${THEMES}, sed -e "s/#THEME#/$(theme)/g" debian/postinst.in > debian/$(theme).postinst; )
	$(foreach theme, ${THEMES}, sed -e "s/#THEME#/$(theme)/g" debian/prerm.in > debian/$(theme).prerm; )
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(foreach theme, ${THEMES}, $(MAKE) -C $(theme) DESTDIR=$(CURDIR)/debian/$(theme) install; )

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir -i
	dh_testroot -i
	dh_installchangelogs -i
	dh_installdocs -i
	dh_link -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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