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

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


DEBIAN_DIR = $(CURDIR)/debian
BUILD_DIR = $(CURDIR)

LIB_PACKAGE = libmstoolkit77
VERSION = 77.0.0
LIB_VERSION = $(VERSION)

# This is the only method that actually worked...
# Combined with the CFLAGS += <new flags> in the Makefile.
CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)

%:
	dh $@

override_dh_auto_clean:
	make clean
	rm -f libmstoolkit.3

manpage:
	docbook-to-man debian/libmstoolkit.sgml > debian/libmstoolkit.3

override_dh_auto_build: manpage
	make solib
	make arlib

override_dh_makeshlibs:
	mkdir -p $(DEBIAN_DIR)/$(LIB_PACKAGE)/DEBIAN
	dpkg-gensymbols -p$(LIB_PACKAGE) \
	-v$(LIB_VERSION) \
	-c2 -d \
	-e$(BUILD_DIR)/libmstoolkitlite.so.$(LIB_VERSION) \
	-e$(BUILD_DIR)/libmstoolkit.so.$(LIB_VERSION) \
	-O$(DEBIAN_DIR)/$(LIB_PACKAGE)/DEBIAN/symbols

	dh_makeshlibs -a

override_dh_strip:
	dh_strip --dbg-package=$(LIB_PACKAGE)-dbg -a
