#!/usr/bin/make -f
# aribas debian build rules
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.
 
package=aribas

ddir=`pwd`/debian/tmp
arch=$(shell dpkg --print-architecture)

CC := $(shell if [ -x /usr/bin/egcc ]; then echo egcc; else echo cc; fi)

build:
	$(checkdir)
ifeq ($(arch),i386)
	 cd src; make CC=$(CC) CFLAGS="-g -DLiNUX -DPROTO -O3 -Wall -pedantic" \
	  ASSOBJECTS=arito386.o
else 
	  cd src; make CC=$(CC) CFLAGS="-g -DUNiX  -DPROTO -O3 -Wall -pedantic"
endif

clean:
	$(checkdir)
	-rm -f build
	cd src; rm -f *.o aribas
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/files* core debian/substvars

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: checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp/usr/bin
	install -d debian/tmp/usr/man/man1
	install -d debian/tmp/usr/doc/$(package)/examples
	install -d debian/tmp/usr/lib/$(package)
	strip src/aribas
	install -m 755 src/aribas debian/tmp/usr/bin
	cp examples/* debian/tmp/usr/doc/$(package)/examples
	chmod 644 debian/tmp/usr/doc/$(package)/examples/*
	cp src/aribas.hlp debian/tmp/usr/lib/$(package)
	chmod 644 debian/tmp/usr/lib/$(package)/*
	debstd doc/aribas.doc doc/aribas.tut  README  
	dpkg-shlibdeps src/aribas
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

binary: binary-indep binary-arch

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

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




