#!/usr/bin/make -f
# -*- makefile -*-

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

CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
# Compile at -O1 instead of -O2 for now to work around:
# /usr/include/wx-3.0/wx/ctrlsub.h:144: undefined reference to `non-virtual thunk to wxListBoxBase::IsSorted() const'
CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS|sed 's/-O2//') $(CPPFLAGS)
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) -Wl,-Bsymbolic-functions

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@

override_dh_auto_build:
	CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" $(MAKE)

override_dh_auto_install:
	$(MAKE) DESTDIR=$(CURDIR)/debian/gspiceui/usr install
	rm -f debian/gspiceui/usr/share/gspiceui/Install
	mv -f debian/gspiceui/usr/share/gspiceui/* debian/gspiceui/usr/share/doc/gspiceui/
	rmdir debian/gspiceui/usr/share/gspiceui
	mkdir -p debian/gspiceui/usr/share/applications
	cp -a debian/gspiceui.desktop debian/gspiceui/usr/share/applications/
	rm -f debian/gspiceui/usr/share/doc/gspiceui/ChangeLog
