#!/usr/bin/make -f

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

# IMPORTANT: This package deliberately uses CDBS; please do not switch
# to modern dh.  We (Debian GNUstep team) need at least one CDBS-based
# library package under our control in order to test and improve the
# GNUstep cdbs rules.

DEB_GS_FRAMEWORKS = PopplerKit

DEB_GS_CURRENT_VERSION_NAME_PopplerKit = 1.0
DEB_GS_DEVPKG_NAME_PopplerKit = libpopplerkit-dev

include /usr/share/cdbs/1/rules/gnustep.mk
include /usr/share/cdbs/1/class/gnumakefile.mk

DEB_GS_AUTO_DH_INSTALL = y

DEB_DH_SHLIBDEPS_INCLUDE = $(d_lib)/$(GS_LIBS_DIR)

framework = PopplerKit
d_lib = debian/$(DEB_GS_LIBPKG_NAME_$(framework))
frameworkver = $(DEB_GS_CURRENT_VERSION_NAME_$(framework))

# List of fonts used internally by the library which have to be
# symlinked as we use those from the fonts-urw-base35 package.  It has
# to be updated whenever they change; see debian-fonts.patch.
fonts := \
  NimbusMonoPS-Regular NimbusMonoPS-Bold NimbusMonoPS-BoldItalic \
  NimbusMonoPS-Italic NimbusSans-Regular NimbusSans-Bold NimbusSans-BoldItalic \
  NimbusSans-Italic StandardSymbolsPS NimbusRoman-Bold NimbusRoman-BoldItalic \
  NimbusRoman-Italic NimbusRoman-Regular D050000L

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

LDFLAGS += -Wl,-z,defs -Wl,--as-needed
# Support "noopt" and "terse" in DEB_BUILD_OPTIONS.
DEB_MAKE_EXTRA_ARGS += OBJCFLAGS="$(CFLAGS)" CCFLAGS="$(CFLAGS)" \
                         $(verbose) $(optim)

clean::
	rm -f config.make

binary-post-install/libpopplerkit0::
# Create symlinks for the fonts from fonts-urw-base35.  This must be
# done after the gsdh_gnustep run; see #1035984.
	for i in $(fonts); do \
	  ln -s /usr/share/fonts/X11/Type1/$$i.pfb \
	    $(d_lib)/$(GS_FRAMEWORKS_DIR)/$(framework).framework/Versions/$(frameworkver)/Resources/$$i.pfb; \
	done
	dh_link -plibpopplerkit0
