#!/usr/bin/make -f

# verbose build output
export V=1

# build with PIE explicitly where appropriate
export CFLAGS_uftrace=-fPIE
export CFLAGS_traceevent=-fPIE
export LDFLAGS_uftrace=-pie

# no colors in test executable
export TESTARG=-n

%:
	dh $@

override_dh_auto_configure:
	LDFLAGS=-Wl,-z,now,-z,relro ./configure --prefix=/usr --libdir=/usr/lib/uftrace

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp/

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	@# having the wrong LDFLAGS (in particular, the one set by debian
	@# machinery or an empty one) breaks the tests.
	env -u LDFLAGS $(MAKE) -j1 test
endif

override_dh_auto_clean:
	dh_auto_clean
	$(RM) .config
	$(MAKE) -C check-deps check-clean
