#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# See FEATURE AREAS in dpkg-buildflags(1).
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

## Enable compiler hardening flags.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic

## Build Rawtherapee with C++11
export DEB_CXXFLAGS_MAINT_APPEND = -std=c++11

## Strangely -fPIC is missing, this makes the build fail on some archs
export DEB_CXXFLAGS_MAINT_APPEND = -fPIC
export DEB_CFLAGS_MAINT_APPEND = -fPIC

# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	dh $@


# dh_make generated override targets.
# This is an example for Cmake (see <https://bugs.debian.org/641051>).
#override_dh_auto_configure:
#	dh_auto_configure -- \
#	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_auto_configure:
	dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DCREDITSDIR=/usr/share/doc/rawtherapee -DLICENCEDIR=/usr/share/doc/rawtherapee -DPROC_FORCED_LABEL=generic -DCACHE_NAME_SUFFIX="" -DWITH_JXL="ON" -DWITH_SYSTEM_LIBRAW="ON"

override_dh_install-arch:
	dh_install
	# Make build reproducible
	sed -i -e 's@ [^ ]*-f\(file\|debug\)-prefix-map=[^ ]*@@g' debian/rawtherapee/usr/share/doc/rawtherapee/AboutThisBuild.txt

override_dh_install-indep:
	dh_install
	rm debian/rawtherapee-data/usr/share/rawtherapee/languages/LICENSE
	rm debian/rawtherapee-data/usr/share/rawtherapee/languages/README