#!/usr/bin/make -f

#export DH_VERBOSE=1

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

CFLAGS              := $(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS            := $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS             := $(shell dpkg-buildflags --get LDFLAGS)

CFLAGS  += -Wall

build: build-arch build-indep
build-indep:
build-arch: build-stamp

make.aee: create.mk.aee
	CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' CPPFLAGS='$(CPPFLAGS)' ./create.mk.aee

xae_dir/make.xae: create.mk.xae
	CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' CPPFLAGS='$(CPPFLAGS)' ./create.mk.xae

build-stamp: make.aee xae_dir/make.xae
	dh_testdir
	$(MAKE) -f make.aee
	$(MAKE) -C xae_dir -f make.xae
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp make.aee xae_dir/make.xae
	$(MAKE) clean
	dh_clean

binary-arch: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	dh_install
	dh_installchangelogs
	dh_installdocs
	dh_installmenu
	dh_install debian/xae.desktop /usr/share/applications
	dh_installman aee.1 debian/xae.1
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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