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

package=libsdl-draw

build:
	$(checkdir)
	

	#
	# First build the shared library
	#
	#$(MAKE) shared CFLAGS="-O2 -fPIC -pipe"
	
	#
	# Build the static library (it does not need Position Independent Code,
	# which reserves one register; thus, without -fPIC we get more efficient
	# code).
	#
	#-rm -f src/*.o
	#$(MAKE) static CFLAGS="-O2 -pipe" LDFLAGS="-s"
	./configure --prefix=/usr
	$(MAKE)
	touch build

clean:
	$(checkdir)
	-rm -rf static shared
	-rm -f build
	-$(MAKE) clean
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp `find debian/* -type d ! -name CVS` debian/files* core
	-rm -f 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 `find debian/* -type d ! -name CVS`
	install -d debian/tmp
	cd debian/tmp && install -d `cat ../dirs`

	$(MAKE) install DESTDIR=`pwd`/debian/tmp
	
	debstd
	#Copying the header and the doc
	mkdir `pwd`/debian/tmp/usr/include/SDL
	cp -a include/SDL_draw.h `pwd`/debian/tmp/usr/include/SDL
	cp -a README `pwd`/debian/tmp/usr/share/doc/libsdl-draw

	dpkg-gencontrol -isp -plibsdl-draw1.2
	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
