#!/usr/bin/make -f
include /usr/share/dpkg/buildflags.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
CXXFLAGS += $(CPPFLAGS) -fPIE
LDFLAGS += -pie
DEB_TARGET_ARCH ?= $(shell dpkg-architecture -qDEB_TARGET_ARCH)
ifeq ($(DEB_TARGET_ARCH),armel)
LDFLAGS += -latomic
endif
%:
	dh $@ --buildsystem=ninja --builddirectory=out

override_dh_auto_configure:
	python3 $(CURDIR)/build/gen.py

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(CURDIR)/out/gn_unittests
endif

override_dh_auto_install:
	#noop

VERSION = $(shell out/gn --version)
execute_before_dh_installdocs:
	help2man --version-string="gn $(VERSION)" --name="Meta-build system that generates build files for Ninja" -N -o out/gn.1 out/gn
