#!/usr/bin/make -f

# set this to the name of the main shlib's binary package
PACKAGE = code_reset

DEB_HOST_ARCH      ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
d_b_o:=$(shell echo "$$DEB_BUILD_OPTIONS"|sed 's/[^-_=[:alnum:]]/ /g'|tr a-z- A-Z_)
$(foreach o, $(d_b_o), $(if $(findstring =,$o),$(eval DEB_BUILD_OPT_$o),$(eval DEB_BUILD_OPT_$o=1)))
MAKE_-J += $(addprefix -j, $(DEB_BUILD_OPT_PARALLEL))
ifeq ($(DEB_HOST_ARCH), armel)
	arch += arm
else
	arch += ia32
endif


build: build-stamp
build-stamp:
	dh_testdir
	gcc -lcrypt -lcal code_reset.c -o code_reset
	touch build-stamp

clean:  
	dh_testdir
	dh_testroot
	rm -f build-stamp
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	mkdir -p $(CURDIR)/debian/tmp/bin/
	cp code_reset $(CURDIR)/debian/tmp/bin/
	
# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot

	dh_install --sourcedir=debian/tmp
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_shlibdeps
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-independent files here.
binary-indep: build install
# Nothing to do

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