#!/usr/bin/make -f

# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

# set the platform for configure script, especially useful for cross-compiling
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
ifeq ($(DEB_HOST_GNU_TYPE), $(DEB_BUILD_GNU_TYPE))
	CONFFLAGS += --build=$(DEB_BUILD_GNU_TYPE)
else
	CONFFLAGS += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
endif
# for more information, see /usr/share/doc/autotools-dev/README.Debian.gz

# set compiler flags, enable warning and debug
CFLAGS += -W -g
CXXFLAGS += -W -g
# set optimization level
ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O
	CXXFLAGS += -O
else
	CFLAGS += -O0
	CXXFLAGS += -O0
endif

# shared library versions, option 1
version=2.0.5
major=2

config.status:
	dh_testdir
	# auto reconf
	./autogen.sh
	# run configure with all necessary definitions and options
	./configure \
		CFLAGS="$(CFLAGS)" \
		CXXFLAGS="$(CXXFLAGS)" \
		--prefix=/usr \
		--sysconfdir=/etc

build: build-stamp
build-stamp: config.status
	dh_testdir
	dh_clean
	$(MAKE)
	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
	rm -f debian/tmp/usr/lib/libchewing.la
	dh_install --sourcedir=debian/tmp --fail-missing
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	# only run "make clean" if a Makefile exists
	[ ! -f Makefile ] || $(MAKE) clean
	# remove existent config.{guess,sub} as we use the ones from
	# autotools-dev package
	rm -f config.guess config.sub
	dh_clean 

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

# Build architecture-dependent files here.
binary-arch: build
	dh_testdir
	dh_testroot
	dh_installchangelogs -a ChangeLog
	dh_link
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	maemo-optify
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary build-stamp config.status
