#!/usr/bin/make -f

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

# Import the multiarch variable (e.g., x86_64-linux-gnu or i386-linux-gnu)
include /usr/share/dpkg/architecture.mk

#export DH_VERBOSE = 1


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

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

# Fix FTBFS with cmake 4.
export CMAKE_POLICY_VERSION_MINIMUM = 3.5

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	dh $@ --buildsystem=cmake


# 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 -- \
		-DBUILD_SHARED_LIBS=OFF \
		-DCMAKE_BUILD_RPATH_USE_ORIGIN=ON \
		-DENABLE_BOOST_STATIC_LIBS=OFF \
		-DUSE_SYSTEM_PHYSFS=ON \
		-DIS_SUPERTUX_RELEASE=ON \
		-DCMAKE_INSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
		-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_install:
	# Fix lintian warning script-not-executable
	if [ -f $(CURDIR)/debian/tmp/usr/share/games/supertux2/sounds/normalize.sh ]; then \
		chmod +x $(CURDIR)/debian/tmp/usr/share/games/supertux2/sounds/normalize.sh; \
	fi
	# Remove unneeded files
	rm -rf $(CURDIR)/debian/tmp/usr/share/doc/supertux2
	# Prepare the icon for installation
	cp $(CURDIR)/data/images/engine/icons/supertux-256x256.png supertux.png
	dh_install --exclude=COPYING

override_dh_installchangelogs:
	dh_installchangelogs NEWS.md

override_dh_clean:
	dh_clean
	$(RM) supertux.png