#!/usr/bin/make -f

CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

configure: configure-stamp
configure-stamp:
	dh_testdir
	touch configure-stamp

build: build-stamp

build-stamp: configure-stamp 
	dh_testdir
	make NOASM=1 NO_OPENGL=1 # OPTIMIZE=0 (defaults to treating 
				# warnings as errors)
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	make clean
	rm -rf obj mame
	dh_clean build-stamp configure-stamp

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	# Put everything in opt 
	dh_installdirs usr/share/applications/hildon usr/share/icons/hicolor/64x64/apps
	dh_installdirs opt/sdlmame opt/sdlmame/roms

	cp -v mame debian/sdlmame/opt/sdlmame/
#	cp -vr content debian/uqm/opt/uqm/

	# Move the wrapper script with the default options to the game directory
#	cp -v debian/uqm-default debian/uqm/opt/uqm/
#	chmod u+x debian/uqm/opt/uqm/uqm-default

#	cp -v uqm.lsm debian/uqm/opt/uqm 
#	cp -v README debian/sdlmame/opt/sdlmame 
	cp -v debian/copyright debian/sdlmame/opt/sdlmame
#	cp -v ChangeLog debian/sdlmame/opt/sdlmame 

	cp debian/sdlmame.desktop debian/sdlmame/usr/share/applications/hildon/

	uudecode ./debian/sdlmame-64.png.uu
	mv sdlmame-64.png ./debian/sdlmame/usr/share/icons/hicolor/64x64/apps/


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

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
#	dh_installchangelogs ChangeLog
	dh_installdocs
#	dh_installdebconf	
#	dh_installlogrotate
#	dh_installinfo
	dh_link
	dh_strip
#	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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