#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

PROG=lsparisc

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

build: build-stamp
build-stamp:
	dh_testdir
	$(MAKE)
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	-rm -rf build-stamp install-stamp .git .config debian/lsparisc
	$(MAKE) distclean
	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	mkdir -p debian/lsparisc/usr/bin

	install -p ${PROG} \
		debian/lsparisc/usr/bin
	
	dh_install

	touch install-stamp

binary-indep: build install
# nothing

binary-common: 
	dh_testdir 
	dh_testroot
	dh_installchangelogs
	dh_installman
	dh_installdocs
	dh_strip
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

common:
	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-common

# Build architecture dependant packages using the common target.
binary-arch: build install common

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