#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

CFLAGS   := $(shell dpkg-buildflags --get CFLAGS)
CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS)
LDFLAGS  := $(shell dpkg-buildflags --get LDFLAGS)
# Substitute CXXFLAGS from -O2 to -O3
# https://www.gnu.org/software/make/manual/html_node/Text-Functions.html
CXXFLAGS := $(subst -O2,-O3,$(CXXFLAGS))

# In Precise 12.04
# $ dpkg-buildflags --get CXXFLAGS
# -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security
# After substitution
# -g -O3 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security

%:
	dh $@ 

# https://wiki.debian.org/IntroDebianPackaging
# http://ubuntu.aspcode.net/view/635400140124705175673786/debian-package-creation-without-a-configure-script

override_dh_auto_build:
	# dh_auto_build -- CXXFLAGS="$(CXXFLAGS)"
	cd $(CURDIR)

overrride_dh_auto_install:
	$(MAKE) DESTDIR=$$(pwd)/debian/fotoxx-maps prefix=/usr install

override_dh_builddeb:
	# remove the man page file in the /usr/share/doc/fotoxx-maps folder
	$ rm $(CURDIR)/debian/fotoxx-maps/usr/share/doc/fotoxx-maps/fotoxx-maps.man
	dh_builddeb
