#! /usr/bin/make -f
#   -*- mode: makefile; -*-
#

CC = gcc

#gcc doesn't support optimisation with exeptions.
#but egcs does!
CXXFLAGS = -g -O2 -Wall

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: build
	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 0644 \
	   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 \
	   install-menu.1 \
	   install-fvwmgenmenu.1 \
	   su-to-root.1 \
	   wm-menu-config.1  \
	   debian/tmp/usr/man/man1
	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`"



