#!/usr/bin/make -f
# -*- makefile -*-
# Package building rules for the SimGrid Debian Package.
# Strongly inspirated from the sample debhelper file, originally written by Joey Hess and Craig Small.
# Adapted to SimGrid by Lucas Nussbaum and Martin Quinson.

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

CFLAGS += $(shell dpkg-buildflags --get CFLAGS)
# build with -O3 everywhere except on ia64 (#640538) since it is upstream
# policy to do so.
ifneq (ia64,$(shell dpkg-architecture -qDEB_HOST_ARCH))
  CFLAGS += -O3
endif

LDFLAGS += $(shell dpkg-buildflags --get LDFLAGS)

%:
	dh  $@

# -Dprefix needed because SimGrid doesn't use CMAKE_INSTALL_PREFIX
override_dh_auto_configure:
	dh_auto_configure -Scmake -- \
		-Dprefix=/usr -Denable_smpi=on \
		-Dcustom_flags="$(CFLAGS) $(LDFLAGS)"
		

# FIXME renable tests at some point
override_dh_auto_test:
	dh_auto_test || true

override_dh_auto_install:
	dh_auto_install
	chrpath -d debian/simgrid/usr/bin/graphicator
	chrpath -d debian/simgrid/usr/bin/gras_stub_generator
	chrpath -d debian/simgrid/usr/bin/tesh
	# move doc to correct place
	mkdir -p debian/simgrid/usr/share/doc/simgrid
	mv debian/simgrid/usr/doc/simgrid/* debian/simgrid/usr/share/doc/simgrid/
	rm -rf debian/simgrid/usr/doc
