#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# 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

build: build-stamp

build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	cd squashfs-tools ; $(MAKE)
	cd squashfs3.0/squashfs-tools ; $(MAKE)
	cd squashfs2.2-r2/squashfs-tools ; $(MAKE)
	xsltproc -''-nonet /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl debian/mksquashfs.dbk

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	# Add here commands to clean up after the build process.
	cd squashfs-tools ; rm -f mksquashfs *.o unsquashfs
	cd squashfs3.0/squashfs-tools ; rm -f mksquashfs *.o unsquashfs
	cd squashfs2.2-r2/squashfs-tools ; rm -f mksquashfs *.o

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	# Add here commands to install the package into debian/squashfs.
	install -m 755 squashfs-tools/mksquashfs debian/squashfs/usr/bin/
	install -m 755 squashfs-tools/unsquashfs debian/squashfs/usr/bin/
	install -m 755 squashfs2.2-r2/squashfs-tools/mksquashfs debian/squashfs/usr/bin/mksquashfs-2.2
	install -m 755 squashfs3.0/squashfs-tools/mksquashfs debian/squashfs/usr/bin/mksquashfs-3.0
	install -m 755 squashfs3.0/squashfs-tools/unsquashfs debian/squashfs/usr/bin/unsquashfs-3.0

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs CHANGES
	dh_installdocs
	dh_installexamples
	dh_installman mksquashfs.1
	dh_link /usr/share/man/man1/mksquashfs.1.gz /usr/share/man/man1/unsquashfs.1.gz
	dh_link /usr/share/man/man1/mksquashfs.1.gz /usr/share/man/man1/mksquashfs-2.2.1.gz
	dh_link /usr/share/man/man1/mksquashfs.1.gz /usr/share/man/man1/mksquashfs-3.0.1.gz
	dh_link /usr/share/man/man1/mksquashfs.1.gz /usr/share/man/man1/unsquashfs-3.0.1.gz
	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
