#!/usr/bin/make -f
## debian/rules for neko.

%:
	dh $@ --no-parallel --with apache2,bash-completion

## Both AMD64 and all kFreeBSDs seem to have problems with the type
## punning used in the Neko source.
ifeq (amd64,$(DEB_HOST_ARCH))
export DEB_CFLAGS_MAINT_APPEND = -fno-strict-aliasing
endif
ifeq (kfreebsd,$(DEB_HOST_ARCH_OS))
export DEB_CFLAGS_MAINT_APPEND = -fno-strict-aliasing
endif

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_INSTALL_INCLUDEDIR=include/$(DEB_HOST_MULTIARCH) \
		-DCMAKE_INSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \
		-DRELOCATABLE=OFF \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DRUN_LDCONFIG=OFF
	echo "LoadModule neko_module /usr/lib/$(DEB_HOST_MULTIARCH)/neko/mod_neko2.ndll" > debian/neko.load

# dh_shlibdeps does not see the ndll files as libraries, so we call dpkg-shlibdeps manually
override_dh_shlibdeps:
	dh_shlibdeps
	dpkg-shlibdeps -Tdebian/neko.substvars debian/neko/usr/bin/* debian/neko/usr/lib/*/neko/*.ndll

override_dh_missing:
	dh_missing --fail-missing
