#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# This version is for a hypothetical package that builds an
# architecture-dependant package, as well as an architecture-independant
# package.

# Uncomment this to turn on verbose mode. 
#export DH_VERBOSE=1
prefix=$(shell expr `pwd`/debian/tmp)
xp-prefix=$(shell expr `pwd`/debian/xproc)
lp-prefix=$(shell expr `pwd`/debian/libproc-dev)

build: build-stamp
build-stamp:
	dh_testdir
	# Add here commands to compile the pacckage.
	-mkdir static 
	cd proc ; $(MAKE)      
	cp proc/libproc.* static
	cd proc ; $(MAKE) clean
	-$(MAKE)
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -rf static
	rm -f build-stamp
	# Add here commands to clean up after the build process.
	-$(MAKE) distclean
	dh_clean

# Build architecture-independent files here.
binary-indep: build

# Build architecture-dependent files here.
# This is to build procps, see below for the other packages
binary-arch: build
	dh_testdir -a
	dh_testroot -a
	dh_clean -a -k
	dh_installdirs -a
	# Add here commands to install the files into debian/tmp
	#$(MAKE) prefix=`pwd`/debian/tmp install
	$(MAKE) install DESTDIR=$(prefix)
	(cd $(prefix)/usr/bin ; mv w w.procps )
	(cd $(prefix)/usr/man/man1 ; mv w.1 w.procps.1 )
	# Next is the xproc stuff
	install -m 755 -o root -g root xproc/XConsole.man $(xp-prefix)/usr/X11R6/man/man1/XConsole.1x
	# 
	# Finally, the libproc-dev stuff
	install -m 644 -o root -g root static/libproc.a $(lp-prefix)/usr/lib
	for i in `ls proc/*.h` ; do install -m 644 -o root -g root $$i $(lp-prefix)/usr/include/proc ; done
	(cd $(lp-prefix)/usr/lib && ln -sf /lib/libproc.so.1.2.6 libproc.so )
	#
	#
	dh_movefiles -a
	dh_installdocs -a
	dh_installexamples -a
	dh_installmenu -a
#	dh_installinit -a
#	dh_installmanpages -a
#	dh_undocumented
	dh_installchangelogs -a NEWS
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_suidregister -a
	dh_installdeb -a
	dh_shlibdeps -pprocps -u"-Ldebian/procps.shlibs.local"
	dh_shlibdeps -plibproc-dev
	dh_shlibdeps -pxproc
	dh_gencontrol -a 
	dh_makeshlibs -a -m1.2.6 -V'procps (>> 1:1.2.7-0), procps (<< 1:1.2.8-0)'
	dh_md5sums -a
	dh_builddeb -a

binary-xproc: checkroot build
	dh_testdir -a
	dh_testroot -a
	dh_clean -a -k
	dh_installdirs -a
	# Add here commands to install the files into debian/tmp
	#$(MAKE) prefix=`pwd`/debian/tmp install
	prefix=`pwd`/debian/xproc
	install xproc/XConsole $(prefix)/usr/X11R6/bin
	install xcpustate/xcpustate $(prefix)/usr/X11R6/bin
	install xproc/XConsole.man $(prefix)/usr/X11R6/man/man1/XConsole.1x
	install xcpustate/xcpustate.man $(prefix)/usr/X11R6/man/man1/xcpustate.1x
	-gzip -9vfr $(prefix)/usr/X11R6/man
	dh_installdocs -a
	dh_installchangelogs -a
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_suidregister -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a


binary-libproc: checkroot build
	dh_testdir -a
	dh_testroot -a
	dh_clean -a -k
	dh_installdirs -a
	# Add here commands to install the files into debian/tmp
	#$(MAKE) prefix=`pwd`/debian/tmp install
	prefix=`pwd`/debian/libproc-dev
	install -m 644 proc/libproc.3 $(prefix)/usr/man/man3
	install -m 644 proc/libproc_dev.3 $(prefix)/usr/man/man3
	install -m 644 proc/libproc_output.3 $(prefix)/usr/man/man3
	install -m 644 proc/openproc.3 $(prefix)/usr/man/man3
	install -m 644 proc/readproc.3 $(prefix)/usr/man/man3
	install -m 644 proc/readproctab.3 $(prefix)/usr/man/man3
	install -m 644 proc/templ.3 $(prefix)/usr/man/man3
	-gzip -9vfr $(prefix)/usr/man
	dh_installdocs -a
	dh_installchangelogs -a
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_suidregister -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

	

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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