#! /usr/bin/make -f
#   -*- mode: makefile; -*-
#
# Based on the sample file shipped with debhelper.

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

arch    := $(shell dpkg-architecture -qDEB_HOST_ARCH)

CXXFLAGS = -g -Wall
CFLAGS = -g -Wall

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

build: build-stamp
build-stamp:
	dh_testdir
	./configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man
	$(MAKE) CXXFLAGS="$(CXXFLAGS)" CFLAGS="$(CFLAGS)" 
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp config.log

	# Add here commands to clean up after the build process.
	[ ! -f Makefile ] || $(MAKE) distclean

	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs \
		   etc/menu-methods \
		   etc/menu \
		   usr/share/menu \
		   usr/share/man/man1 \
		   usr/share/bug/menu
		   

	# Add here commands to install the package into debian/menu.
	$(MAKE) install DESTDIR=`pwd`/debian/menu/

	cp examples/translate_menus examples/menu.h po-sections/lang.h\
	   examples/menu.config debian/menu/etc/menu-methods 
	#
	install -g root -o root -m 644 \
	   doc/README.config-menus debian/menu/etc/menu/README
	install -g root -o root -m 644 \
	   doc/README.menu-methods debian/menu/etc/menu-methods/README
	install -g root -o root -m 644 \
	   doc/README.package-menus debian/menu/usr/share/menu/README
	#
	install -g root -o root -m 644 \
	   debian/bug.presubj debian/menu/usr/share/bug/menu/presubj
	#
	touch install-stamp

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do here, no architecture independant packages here.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installman doc/update-menus.fr.1 doc/su-to-root.fr.1 \
	              doc/menufile.fr.5
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
#	refuse debhelper V3 conffiles behaviour.
	cp debian/conffiles debian/menu/DEBIAN
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb


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