#!/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

export DEB_CXXFLAGS_MAINT_APPEND := -Wall -Werror -pedantic

%:
	dh $@ --with autoreconf

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

override_dh_auto_clean:
	dh_auto_clean
	$(RM) -r libltdl

override_dh_auto_configure:
	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr --mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info \
		--disable-update-makefiles \
		--with-ltdl-include=/usr/include --with-ltdl-lib=/usr/lib/$(DEB_HOST_MULTIARCH) \
		CXXFLAGS="$(CXXFLAGS)" # LDFLAGS="-Wl,-z,defs"

override_dh_auto_test:
	# run all internal tests
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) check CXXFLAGS="$(filter-out -Werror, $(CXXFLAGS))"
endif

override_dh_auto_install:
	dh_auto_install

	sed -i "/dependency_libs/ s/'.*'/''/" `find . -name '*.la'`
	
	#pkg-config .pc install:
	install -d $(CURDIR)/debian/tmp/usr/lib/pkgconfig
	install -m 644 debian/*.pc $(CURDIR)/debian/tmp/usr/lib/pkgconfig

