#!/usr/bin/make -f
# Made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Christoph Lameter.
# $Id: rules,v 1.17 1998/11/05 07:23:15 che Exp $


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

build: build-stamp
build-stamp: Makefile.in
	dh_testdir

	mkdir build
#	cd build && CC=egcc CXX=g++ CXXFLAGS="-g -Wall -D_POSIX_C_SOURCE=199309" ../configure --disable-nls --disable-static --prefix=/usr
	cd build && CXXFLAGS="-g -Wall -D_POSIX_C_SOURCE=199309" ../configure --disable-nls --disable-static --prefix=/usr
	cd build && make all-hdr
	cd build && make -s
	
	# Add here commands to compile the package.
#	$(MAKE) CFLAGS="-O2 -g -Wall"

	touch build-stamp

clean:
	dh_testdir
#	dh_testroot
	rm -f build-stamp debian/ChangeLog

	# Add here commands to clean up after the build process.
#	-$(MAKE) distclean
	rm -rf build
	dh_clean

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

# Build architecture-dependent files here.
binary-arch: build
#	dh_testversion
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the files into debian/tmp
#	$(MAKE) install DESTDIR=`pwd`/debian/tmp
	cd build && make install prefix=`pwd`/../debian/tmp/usr
	rm -rf debian/tmp/usr/include
	rm -f debian/tmp/usr/doc/apt/*.{sgml,text}*
	mv debian/tmp/usr/bin/http debian/tmp/usr/lib/apt/methods/
	mv debian/tmp/usr/bin/ftp debian/tmp/usr/lib/apt/methods/
	find methods/dselect -type f -maxdepth 1 -exec cp -p {} debian/tmp/usr/lib/dpkg/methods/apt/ \;
	cp debian/sources.list debian/tmp/etc/apt/
	head -n 500 ChangeLog > debian/ChangeLog

	dh_installdocs NEWS README TODO debian/ChangeLog
#	dh_installexamples
#	dh_installmenu
#	dh_installinit
#	dh_installcron
	dh_installmanpages

	# Remove apt and libdeity from package since they're non-functional
	rm -f debian/tmp/usr/bin/apt debian/tmp/usr/man/man8/apt.8*
	rm -f debian/tmp/usr/lib/libdeity*
	rm -f debian/tmp/usr/lib/*.so

#	dh_undocumented
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_suidregister
	dh_installdeb
	LD_LIBRARY_PATH=debian/tmp/usr/lib dh_shlibdeps
	dh_gencontrol
	dh_makeshlibs
	dh_md5sums
	dh_builddeb

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

# Update from CVS
l33ch: really-clean
	cvs update
	utils/mkChangeLog

# Update from CVS and then configure for build
super-l33ch: l33ch Makefile.in

Makefile.in:
	aclocal -I .
	autoconf
	autoheader
	gettextize -f -c
	libtoolize -f -c
	automake -a
	cd pkglib && ln -sf deb/*.cc .

l33ch-stamp: super-l33ch
	touch l33ch-stamp

really-clean: clean
	-find -name Makefile.in -print0 | xargs -0r rm -f
	find -name ChangeLog | xargs rm -f
	rm -f l33ch-stamp

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

# $Log: rules,v $
# Revision 1.17  1998/11/05 07:23:15  che
# Updates for 0.1.9
#
# Revision 1.16  1998/10/16 02:24:21  che
# d'oh, fixed braino with the rm of the sgml/text files
#
# Revision 1.15  1998/10/16 02:16:33  che
# dh_installchangelogs won't install an upstream changelog for a
# native Debian package. *sigh* moved call to dh_installdocs
#
# Revision 1.14  1998/10/16 02:06:53  che
# ChangeLog was really big. Now we do a head -n 500 of it for installing.
#
# Revision 1.13  1998/10/16 02:01:13  che
# remove design docs, they're not useful to people and take up lots of space
#
# Revision 1.12  1998/07/17 05:13:45  che
# Updated debian/ files for 0.1.2 release.
#
# Revision 1.11  1998/05/26 14:34:34  scott
# Remove libpkg.so link to placate lintian (and since we don't really need it)
#
# Revision 1.10  1998/05/18 13:48:51  scott
# Removed hardcoded egcc in build.
#
# Revision 1.9  1998/05/12 13:13:50  scott
# Added autoconf/automake/libtool/gettext files
# Modified rules to make files in archive real instead of symlinks.
#
# Revision 1.8  1998/05/08 13:48:33  scott
# Install new FTP method for apt.
#
# Revision 1.7  1998/04/23 02:20:16  scott
# Remove apt and libdeity from final package since they're non-functional.
#
# Revision 1.6  1998/04/06 17:50:35  scott
# Replace installation of undocumented(7) links with the real manpage.
#
# Revision 1.5  1998/04/04 19:07:26  scott
# Update rules file to setup package for building if it hasn't been done so
# already when the build rule is called.
#
# Revision 1.4  1998/04/03 15:14:33  scott
# Add prefix to configure.
#
# Revision 1.3  1998/04/03 14:32:29  scott
# Add undocumented manpage links.
# Create shlibs file to keep lintian happy.
#
# Revision 1.2  1998/04/02 22:10:05  scott
# Updated rules files to actually build an apt package.
# Run debian/rules super-l33ch before building.
#
# Revision 1.1  1998/03/31 18:07:43  scott
# Added code files in debian/ directory.  Not functional to build the package
# yet however.
#
