#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

#export CMAKE_INSTALL_PREFIX=$(CURDIR)/debian/tmp


%:
	dh $@

override_dh_auto_configure:
	mkdir build
	cd build ; CXX=g++ cmake ..

override_dh_auto_build:
	$(MAKE) -C build


override_dh_install:
	mkdir -p $(CURDIR)/debian/libschroedinger-maeparser1/usr/lib/$$(dpkg-architecture -qDEB_BUILD_MULTIARCH)
	mkdir -p $(CURDIR)/debian/libschroedinger-maeparser-dev/usr/lib/$$(dpkg-architecture -qDEB_BUILD_MULTIARCH)
	mv build/libm*.so.* $(CURDIR)/debian/libschroedinger-maeparser1/usr/lib/$$(dpkg-architecture -qDEB_BUILD_MULTIARCH)/
	mv build/libm*.so $(CURDIR)/debian/libschroedinger-maeparser-dev/usr/lib/$$(dpkg-architecture -qDEB_BUILD_MULTIARCH)/
	cp *.hpp $(CURDIR)/debian/libschroedinger-maeparser-dev/usr/include/maeparser/

#override_dh_auto_install:
#	dh_install
#	# Fails - and should not be performed because of
#	#         stripping
#	#$(MAKE) -C build install
#
override_dh_auto_clean:
	dh_auto_clean
	rm -rf build

override_dh_auto_test:
	$(MAKE) -C build test CTEST_OUTPUT_ON_FAILURE=1

