#!/usr/bin/make -f
# Made with the aid of debhelper by by Joey Hess,
# based on the sample debian/rules file for GNU hello by Ian Jackson.
#
# This is free software; see the GNU General Public Licence
# version 2 or later for copying conditions.  There is NO warranty.
#
# Currently maintained by Roland Stigge <stigge@antcom.de>
# for Debian GNU/Linux.

SHELL = /bin/sh

package = musixtex

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

CFLAGS = -Wall -g
INSTALL = install
INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755

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

# to propagate to $(MAKE):
export CFLAGS

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp:
	dh_testdir
	$(MAKE)
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp
	$(MAKE) -C examples proper
	$(MAKE) distclean
	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	$(MAKE) DESTDIR=`pwd`/debian/$(package) debian=true install

	dh_installtex map=MixedMap,musix.map formatfile=debian/musixtex.cnf=40

	cp debian/musixtex.lintian `pwd`/debian/musixtex/usr/share/lintian/overrides/musixtex

	touch install-stamp

# Build architecture-independent files here.
binary-indep: build install
# Nothing to do.

# Build architecture-dependent files here.
# (for $(package))
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs debian/README.examples
	dh_installman
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress -X.dvi -X.tex
	dh_fixperms
	dh_installdeb
	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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