#!/usr/bin/make -f
# debian/rules for aribas

#export DH_VERBOSE=1

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	OPTFLAGS=-O0 
else	
	OPTFLAGS=-O
endif	

build: build-stamp 

build-stamp:
	if [ "$(DEB_BUILD_ARCH)" = "i386" ];\
	then \
		cp src/LINUX/arito386.S src;\
		ASSOBJECTS="arito386.S";\
		EXTRAFLAGS="-DLiNUX -DPROTO";\
	else \
		ASSOBJECTS="";\
		EXTRAFLAGS="-DUNiX -DPROTO";\
	fi;\
	cd src && make -f LINUX/Makefile.linux\
			CC=gcc\
			CFLAGS="$(OPTFLAGS) $$EXTRAFLAGS"\
			ASSOBJECTS="$$ASSOBJECTS"
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	cd src; make clean; rm -f aribas arito386.S
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	install -m 755 src/aribas debian/aribas/usr/bin
	cp src/EL/aribas.el debian/aribas/usr/share/emacs/site-lisp/aribas
	cp src/aribas.hlp debian/aribas/usr/lib/aribas
	cp CHANGES*.txt debian/aribas/usr/share/doc/aribas/changelog

binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installexamples examples/*
	dh_installemacsen
	dh_installman doc/aribas.1
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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