#!/usr/bin/make -f

# !! IMPORTANT !!           | here is no space allowed between libparagui & # 
# !! IMPORTANT !!           | same thing counts for PDW 
package		:= libparagui# the .deb package name (not really needed)
PWD		:= $(shell pwd)# is an internal variable (you may use it too)
CFLAGS		:= -O2          # just provided as an addition (may be cut out)
INSTALL_PROGRAM	:= install -m755 # used when doing the install
INSTALL_DATA	:= install -m644 # also not really needed

# Some special build options (also optional)
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -g
endif

# the directoryname in that the tar.ball extracts (if not set it is assumed
# that it extracts to .)
TAR_DIR := paragui-1.0.1
# includ the dbs makefile (so add unpack, patch and make_patch targets)
include debian/scripts/dbs-build.mk

# docbook2man rules (for additional debian manpages)
include debian/scripts/docbook.mk

# libtool library helper
libname:=$(package)
include debian/scripts/libtool.mk

# dpkg-arch rules (optional), hmm I really don't know if this is needed\
# see man dpkg-architecture ... 
#ifeq (,$(DEB_BUILD_GNU_TYPE))
#  include debian/scripts/dpkg-arch.mk
#endif

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

# This is the debhelper compatability version to use.
export DH_COMPAT=3

# where to install all files to (optional)
export INTERNAL_DESTDIR=debian/tmp

# the configure target
# stamp in stampdir already set ?
configure: $(STAMP_DIR)/stamp-configure
$(STAMP_DIR)/stamp-configure: $(patched) # no then unpack & patch source
	dh_testdir # test for right directory
	dpkg-checkbuilddeps
# step into the unpacked source & configure it
	cd $(BUILD_TREE) && \
	if [ ! -e configure ]; then ./autogen.sh; fi && \
	./configure --prefix=/usr --mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/man
# create a stamp (in the stamp directory)
	touch $@

# build target
# stamp in stampdir already set ?
build: configure $(STAMP_DIR)/stamp-build
$(STAMP_DIR)/stamp-build: $(patched)
#otherwise patch & configure
	dh_testdir # right directory?
# step into the unpacked & configured source and build the binaries
	cd $(BUILD_TREE) && \
        $(MAKE)
# debian additional build instructions
# create a stamp (in the stamp directory)
	touch $@
#$(STAMP_DIR)/stamp-build

# target libparagui-clean is created by libtool.mk
clean: libparagui-clean docbook-clean dbs-clean
	dh_testdir
	dh_testroot
	dh_clean

# target libparagui is created by libtool.mk
install: build $(dh_mak_deps) $(dh_manpages) libparagui
# generic install commands
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
# again change to builddir and then invoke install routines
	cd $(BUILD_TREE) && \
	    $(MAKE) INSTALL_PROGRAM="$(INSTALL_PROGRAM)" \
	    install DESTDIR=$(PWD)/$(INTERNAL_DESTDIR)
#		includedir=\${prefix}/include	    
# generic command again
	dh_movefiles --source=$(INTERNAL_DESTDIR)
#	echo $(libparagui-lt_release)
	mv debian/libparagui$(libparagui-lt_release)-dev/usr/include/paragui \
	    debian/libparagui$(libparagui-lt_release)-dev/usr/include/paragui-$(libparagui-lt_release)

install-indep: build $(dh_mak_deps)
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

# install our independet stuff (after changing to builddir)
	cd $(BUILD_TREE) && $(MAKE) \
		SUBDIRS="doc" \
		INSTALL_PROGRAM="$(INSTALL_PROGRAM)" \
		install prefix=$(PWD)/$(INTERNAL_DESTDIR) \
		datadir=/usr/share/doc

# the rest of the debian/rules file is business as usual and
# only added for completeness.

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

# Build architecture-dependent files here.
binary-arch: build install $(dh_mak_deps)
	dh_testdir
	dh_testroot

	dh_installdocs
	dh_installexamples
	dh_installman
	dh_installchangelogs
	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 $(dh_mak_deps)

.PHONY: configure build clean binary-indep binary-arch binary install checkbuild \
version copyright





