#!/usr/bin/make -f

CFLAGS = -Wall -g

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

configure: 
	dh_testdir
	# No config to do for now

build: configure
	dh_testdir
	cc -o accelemymote accelemymote.c uinput.c inih/ini.c -lm

clean:
	dh_testdir
	dh_testroot
	dh_clean accelemymote 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_install

	# For now accelemymote uses a dirty hack to control startup/shutdown: 
	# a script wrapper that creates and deletes a live-trigger file that 
	# the daemon watches.
	dh_install debian/accelemymote.sh opt/maemo/usr/bin/

	# *Accelemymote will fail without fixing udev rule!*
	#  /etc/udev/rules.d/50-udev.rules makes uinput belong to root, so
	#  add a rule with higher priority that makes it belong to a group
	#  that the user is also part of (type "groups")--plugdev possibly
	dh_install debian/49-uinput-accelemymote.rules etc/udev/rules.d/


# 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
