#!/usr/bin/make -f

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

# DEB_BUILD_OPTIONS
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
        CXXFLAGS += -O0
else
        CXXFLAGS += -O2
endif
# DEB_BUILD_OPTIONS


# special issues on architectures
ifeq (hppa,$(DEB_BUILD_ARCH))
        CXXFLAGS += -ffunction-sections -mlong-calls
endif
# special issues on architectures


%:
	dh $@ --buildsystem=cmake --with quilt

override_dh_auto_configure:
	dh_auto_configure -- \
                -DCMAKE_CXX_FLAGS=$(CXXFLAGS) \
		-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF

override_dh_auto_build:
	dh_auto_build --parallel

override_dh_auto_install:
	dh_auto_install

#	Strip plugins and libraries, dh_link doesn't work with all of them
	find debian/tmp/usr/lib -name \*.module -exec strip --strip-unneeded --remove-section=.comment --remove-section=.note {} \;

#	Remove files, we're not going to ship them because it would be only
#	useful for plugin developers and upstream discourages it
	rm -fr debian/tmp/usr/include
	rm -f debian/tmp/usr/lib/*so

#	Quell lintian warning "duplicate-font-file" by removing the files and
#	symlinking to the ones in the package tff-bitstream-vera.  Use dh_link,
#	since paths must be relative when elements in the path are common
#	(e.g. /usr/)
	rm -f debian/tmp/usr/share/k3d/fonts/Vera*ttf

override_dh_shlibdeps:
	dh_shlibdeps -- debian/k3d/usr/lib/k3d/plugins/*.module
