#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow
# Needed to inject correctly the python versions supported
export PYBUILD_SYSTEM=cmake
export PYBUILD_CONFIGURE_ARGS=-DPYVER={version} \
		-DUSE_HOST_SSE_FLAGS:BOOL=False \
		-DUSE_IGN_RECOMMENDED_FLAGS:BOOL=False \
		-DUSE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION=ON \
		-DUSE_DIST_PACKAGES_FOR_PYTHON=ON \
		-DUSE_SYSTEM_PATHS_FOR_RUBY_INSTALLATION=ON

# The build consumes high ammounts of RAM, only x32/x64 arches seems able to
# deal with it. There is a lintian warning about using DEB_BUILD_OPTIONS but
# I did not find a better way. Patches are welcome.
ifeq (,$(filter $(DEB_HOST_ARCH), amd64 i386))
export DEB_BUILD_OPTIONS='parallel=1'
endif

ifeq ($(DEB_HOST_ARCH),i386)
  CXXFLAGS += -ffloat-store
endif

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_install:
	# Manually replace build path by install location in tag file
	sed -i -e 's#$(CURDIR)/include/#/usr/include/ignition/math6/#g;s#$(CURDIR)/eigen3/include/#/usr/include/ignition-math6/#g' debian/tmp/usr/share/ignition/ignition-math6/ignition-math6.tag.xml
