#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.

#export DH_VERBOSE=1

export DEB_BUILD_HARDENING=1

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

CFLAGS = -Wall -g

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

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

build-stamp:
	dh_testdir
	ln -sf /usr/share/misc/config.sub config.sub
	ln -sf /usr/share/misc/config.guess config.guess
	cd X11 && ( CFLAGS="$(CFLAGS)" ./configure \
		--host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr --mandir=/usr/share/man )
	cd X11 && $(MAKE) CFLAGS="$(CFLAGS)"
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	[ ! -f X11/Makefile ] || ( cd X11 && $(MAKE) distclean )
	dh_clean config.sub config.guess

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs usr/share/man/man1 usr/bin
	cd X11 && $(MAKE) install_prefix=$(CURDIR)/debian/xdaliclock install

binary-indep: build install
# We have nothing to do by default.

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs README
	dh_installmenu
	dh_installman
	dh_installchangelogs
	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 build-arch build-indep binary-indep binary-arch binary install
