#!/usr/bin/make -f

DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

export V=

%:
	dh $@

override_dh_auto_configure:
	# README:
	# The maximum sane configuration is "make defconfig": allyesconfig isn't
	CFLAGS="$(CFLAGS) $(CPPFLAGS) $(LDFLAGS)" make defconfig

	# Go for insanely overpowered toys!
	# allyesconfig add build-depends: libssl-dev zlib1g-dev
	#CFLAGS="$(CFLAGS) $(CPPFLAGS) $(LDFLAGS)" make allyesconfig

	# Hardening and such FLAGS
	echo $(CFLAGS) > generated/cflags
	echo $(CPPFLAGS) >> generated/cflags

override_dh_auto_install:
	# We need relative paths
	PREFIX="." make install

override_dh_installman:
	# Automated manpages generation
	help2man -n 'Toybox - BSD-licensed Linux command line utilities' ./toybox > toybox.1

	dh_installman
