#! /usr/bin/make -f
#   -*- mode: makefile; -*-
#
# Last updated: Sat Dec 17 10:52:20 EST 1994 by imurdock.
#
# To make the binary distribution package, the ``Debianized'' source package
# and the context diff to the original package, type `./debian.rules dist'.
# Make sure that `debian.rules' is executable before the final distribution
# is made.
#
# Invoke each target with `./debian.rules <target>'.  All targets should be
# invoked with the package root as the current directory.
#
# The `binary' target must be run as root, as it needs to install files with
# specific ownerships.  The `diff' target assumes that you have the original
# source package available, unpacked, in ../$(p)-$(v).orig, or that you have
# the previous revision of the ``Debianized'' source package and context diff
# in the parent directory.

CC = gcc

#gcc doesn't support optimisation with exeptions.
CXXFLAGS = -g -fhandle-exceptions



p = menu


build:
	make -C .           CXXFLAGS="$(CXXFLAGS)"       
	make -C menu-method CXXFLAGS="$(CXXFLAGS)"
	make -C fvwmgen     CXXFLAGS="$(CXXFLAGS)"
	make -C doc
	touch build


clean:	
	#Undoes the effect of `make -f debian.rules build'.
	#make distclean
	#rm -f docs/Makefile docs/latextut/Makefile
	-rm -rf debian/tmp build menu doc/menu.html/* doc/menu.info
	make -C . clean
	make -C menu-method clean
	make -C fvwmgen clean

binary-indep:   checkroot build
        $(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.


binary-arch:
	rm -rf debian/tmp
	install -d -g root -m 755 -o root debian/tmp/DEBIAN
	install -d -g root -m 755 -o root debian/tmp/usr/{bin,sbin}
	install -d -g root -m 755 -o root debian/tmp/usr/man/man{1,5}
	install -d -g root -m 755 -o root debian/tmp/usr/lib/menu/default
	install -d -g root -m 755 -o root debian/tmp/usr/X11R6/include/X11/pixmaps
	install -d -g root -m 755 -o root \
	     debian/tmp/usr/doc/menu/{examples,html}
	install -d -g root -m 755 -o root debian/tmp/etc/menu-methods
	install -d -g root -m 755 -o root debian/tmp/etc/menu
	#
	install -g root -o root -m 755 \
	   debian/postinst debian/tmp/DEBIAN/postinst
	install -g root -o root -m 755 \
	   debian/prerm debian/tmp/DEBIAN/prerm
	#
	install -s -g root -o root -m 0755 \
	   update-menus debian/tmp/usr/bin/update-menus
	install -s -g root -o root -m 0755 \
           fvwmgen/fvwmgen  debian/tmp/usr/sbin/install-fvwmgenmenu
	install -s -g root -o root -m 0755 \
	   menu-method/menu-method  debian/tmp/usr/sbin/install-menu
	install  -g root -o root -m 0755 \
	   su-to-root  debian/tmp/usr/sbin/su-to-root
	#install  -g root -o root -m 0755 \
	#   convert-menuentry debian/tmp/usr/bin/convert-menuentry
	install  -g root -o root -m 0644 \
	   debian/menu debian/tmp/usr/lib/menu/
	#
	cp examples/* debian/tmp/usr/doc/menu/examples
	cp default/* debian/tmp/usr/lib/menu/default
	cp -a doc/menu.html/* debian/tmp/usr/doc/menu/html
	cp cmap.xpm debian/tmp/usr/X11R6/include/X11/pixmaps
	install -g root -o root -m 644 \
	   translate_menus menu.h debian/tmp/etc/menu-methods/
	#
	install -g root -o root -m 644 \
	   doc/menu.sgml README.changes BUGS debian/tmp/usr/doc/menu/
	install -g root -o root -m 644 \
	   README.config-menus debian/tmp/etc/menu/README
	install -g root -o root -m 644 \
	   README.menu-methods debian/tmp/etc/menu-methods/README
	install -g root -o root -m 644 \
	   README.package-menus debian/tmp/usr/lib/menu/README
	install -g root -o root -m 644 \
	   debian/copyright debian/tmp/usr/doc/menu/copyright
	install -g root -o root -m 644 \
	   debian/changelog debian/tmp/usr/doc/menu/changelog.Debian
	gzip -9 debian/tmp/usr/doc/menu/changelog.Debian
	install -g root -o root -m 644 \
	   update-menus.1 debian/tmp/usr/man/man1/update-menus.1
	gzip -9 debian/tmp/usr/man/man1/update-menus.1
	install -g root -o root -m 644 \
	   menufile.5 debian/tmp/usr/man/man5/menufile.5
	gzip -9 debian/tmp/usr/man/man5/menufile.5
	install -g root -o root -m 755 \
	   ./debian/wm-menu-config debian/tmp/usr/sbin/wm-menu-config
	#
	cp debian/conffiles debian/tmp/DEBIAN/conffiles
	dpkg-shlibdeps ./update-menus ./menu-method/menu-method ./fvwmgen/fvwmgen
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

binary:	 binary-indep binary-arch


checkroot:
	$(checkdir)
	test root = "`whoami`"



