#!/usr/bin/make -f
# $Id: rules,v 1.1.1.1 2004/04/07 09:05:52 louistsai Exp $

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
CDEF = -g -O2 -Wall -DBSD=1 -DSMALL -D_GNU_SOURCE \
       -DGLOB_BROKEN \
       -D__COPYRIGHT\(x\)= -D__RCSID\(x\)= -D_DIAGASSERT\(x\)=
CDEFSM = -Os -fomit-frame-pointer -Wall -DBSD=1 -DSMALL -D_GNU_SOURCE \
       -DGLOB_BROKEN \
       -D__COPYRIGHT\(x\)= -D__RCSID\(x\)= -D_DIAGASSERT\(x\)=

sh.hetio:
	chmod u+x debian/bsdyacc
	rm -f *.o
	pmake CFLAGS='$(CDEF)' HETIO= YACC=`pwd`/debian/bsdyacc
	mv sh sh.hetio

sh:
	chmod u+x debian/bsdyacc
	rm -f *.o
	pmake CFLAGS='$(CDEF)' YACC=`pwd`/debian/bsdyacc

sh.udeb:
	chmod u+x debian/bsdyacc
	rm -f *.o
	pmake CFLAGS='$(CDEFSM)' YACC=`pwd`/debian/bsdyacc
	mv sh sh.udeb

build: build-stamp
build-stamp: sh.hetio sh.udeb sh
	dh_testdir

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	pmake clean HETIO=
	rm -f sh.cat1 mksignames signames.h sh.hetio sh.udeb

	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

	install sh debian/tmp/bin/ash
	install -m 644 sh.1 debian/tmp/usr/share/man/man1/ash.1
	install sh.hetio debian/ash-medium/usr/bin/ash.medium
	install -m 644 sh.1 debian/ash-medium/usr/share/man/man1/ash.medium.1
	install sh.udeb debian/ash-udeb/bin/ash
	ln -s ash debian/ash-udeb/bin/sh

	dh_installdocs -Nash-udeb
	dh_installexamples
	dh_installmenu
#	dh_installinit
	dh_installcron
#	dh_installmanpages
#	dh_undocumented
	dh_installchangelogs -Nash-udeb
	dh_strip
	dh_compress
	dh_fixperms
	dh_suidregister
	dh_installdeb -Nash-udeb
	dh_shlibdeps
	dh_gencontrol
#	dh_makeshlibs
	dh_md5sums
	dh_builddeb
	for i in ../ash-udeb_*.deb; do mv $$i $${i%deb}udeb; done
	sed '/^[^ ]*\.udeb/d; s/^\(ash-udeb_[^ ]*\.\)deb/\1udeb/' \
		debian/files > debian/files.new
	mv debian/files.new debian/files

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
