#!/usr/bin/make -f
# -*- makefile -*-

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

# Enable hardening build flags
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

export TOPDIR=$(CURDIR)
export CFG=debug

# Don't treat format-security as an error, caused build failure.
CFLAGS += -Wno-error=format-security

UPSTREAM_VERSION = $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(.*\)-.*/\1/p' | sed -e 's/\+.*//; s/^[0-9]://')

%:
	dh $@ --with autoreconf --parallel

override_dh_auto_clean:
	if [ -e config/common.mak ]; then \
		dh_auto_clean ; \
	fi

override_dh_auto_configure:
	dh_auto_configure -- \
		 --libdir=$(CURDIR)/debian/tmp/usr/lib \
		 --with-expat=yes \
		 --with-expatinc=/usr/include \
		 --with-expatlib=-lexpat \
		 --with-proj=yes \
		 --with-projinc=/usr/include \
		 --with-projlib=-lproj \
		 --with-zlib=yes \
		 --with-zlibinc=/usr/include \
		 --with-zliblib=-lz

override_dh_auto_build:
	dh_auto_build --max-parallel=1

override_dh_auto_install:
	dh_auto_install -- prefix=$(CURDIR)/debian/tmp/usr

	$(RM) $(CURDIR)/debian/tmp/usr/lib/ogdi/libskeleton.so

override_dh_install:
	dh_install --list-missing

override_dh_makeshlibs:
	dh_makeshlibs -- -v$(UPSTREAM_VERSION)

