#!/usr/bin/make -f

# Use hardening options to build the package
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

CFLAGS = -Wall -g

ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
endif

%:
	dh $@

override_dh_auto_build:
	$(MAKE) prefix=/usr CFLAGS="$(CFLAGS) $(CPPFLAGS) $(CXXFLAGS)" OFLAGS="$(LDFLAGS)"

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

override_dh_installchangelogs:
	dh_installchangelogs RELEASES

override_dh_auto_clean:
	dh_auto_clean
	rm -f doc/gpscorrelate-manpage.xml gpscorrelate gpscorrelate-gui gpscorrelate.1
