#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# HOWMANY is the number of bytes looked at by file
CFLAGS += -DHOWMANY=0x18000

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		--prefix=/usr \
		--datadir=\$${prefix}/share \
		--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
		--mandir=\$${prefix}/share/man \
		--enable-fsect-man5 \
		--enable-static \
		--disable-silent-rules CFLAGS="$(CFLAGS)"

override_dh_auto_install:
	dh_auto_install

	mv debian/tmp/usr/share/misc debian/tmp/usr/share/file

	install -D -m 0644 magic/magic.local debian/tmp/etc/magic
	install -D -m 0644 magic/magic.local debian/tmp/etc/magic.mime

	# Install additional headers
	mkdir -p debian/libmagic-dev/usr/include/file
	cp src/file.h debian/libmagic-dev/usr/include/file

	# Remove useless files
	rm -f debian/tmp/usr/lib/*/*.la

override_dh_missing:
	dh_missing --fail-missing

override_dh_shlibdeps:
	dh_shlibdeps -Llibmagic1 -ldebian/libmagic1/usr/lib
