#!/usr/bin/make -f
#
# Debhelper rules for bomstrip, the UTF-8 BOM strip utility
# Written by Peter Pentchev in 2008.
# This file is hereby placed into the public domain.

# Aim for the top, adapt if anything should break on the buildds.
DEB_BUILD_MAINT_OPTIONS=	hardening=+all
export DEB_BUILD_MAINT_OPTIONS

DEB_CPPFLAGS_MAINT_APPEND=	-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
DEB_CFLAGS_MAINT_APPEND=	-pipe -Wall -W -ansi -pedantic -Wbad-function-cast \
		-Wcast-align -Wcast-qual -Wchar-subscripts -Winline \
		-Wmissing-prototypes -Wnested-externs -Wpointer-arith \
		-Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings
ifneq (,$(filter werror,$(DEB_BUILD_OPTIONS)))
	DEB_CFLAGS_MAINT_APPEND+=	-Werror
endif
export DEB_CFLAGS_MAINT_APPEND DEB_CPPFLAGS_MAINT_APPEND

include /usr/share/dpkg/buildtools.mk

override_dh_auto_build:
	${CC} -c ${CPPFLAGS} ${CFLAGS} bomstrip.c
	${CC} ${LDFLAGS} -o bomstrip bomstrip.o
	sed -e "s@'bomstrip'@/usr/bin/bomstrip@" < debian/bomstrip-files.sh > bomstrip-files

override_dh_auto_test:
	env BOM=./bomstrip sh test.sh

%:
	dh $@
