#!/usr/bin/make -f

$(info DEB_BUILD_OPTIONS:$(origin DEB_BUILD_OPTIONS)=$(DEB_BUILD_OPTIONS))

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	test_makeflags = -j$(NUMJOBS)
endif

cppflags := $(shell dpkg-buildflags --get CPPFLAGS)
cflags := $(shell dpkg-buildflags --get CFLAGS) $(cppflags)
cxxflags := $(shell dpkg-buildflags --get CXXFLAGS) $(cppflags)
fflags := $(shell dpkg-buildflags --get FFLAGS)
ldflags := $(shell dpkg-buildflags --get LDFLAGS)
ldflags += -Wl,--as-needed

# Explicitly set builddir directory
builddir := obj-$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

%:
	dh $@ --with quilt --parallel

override_dh_auto_configure:
	autoreconf -i
	dh_auto_configure -- --includedir=/usr/include/opt++ --disable-static --enable-shared

override_dh_auto_install:
	dh_auto_install

override_dh_compress:
	dh_compress -X.pdf -X.svn -X.py

override_dh_auto_test:
	make check

get-orig-source:
	uscan --force-download --verbose
	mv ../openturn*.tar.[gzbz2]* ../tarballs
