#!/usr/bin/make -f

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

# Add here any variable or target overrides you need
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk

DEB_CONFIGURE_NORMAL_ARGS += --enable-shared --enable-static

# Automatic detection doesn't fallback to working atomic type.
# Force it to pthread for architectures not having specific code.
ifeq (,$(filter $(DEB_HOST_ARCH_CPU), arm amd64 i386 mips mipsel powerpc))
DEB_CONFIGURE_NORMAL_ARGS += --with-atomictype=pthread 
endif

ifeq (armhf,$(DEB_HOST_ARCH))
DEB_CONFIGURE_NORMAL_ARGS += --with-atomictype=pthread 
endif

# Actually, rebuilding the whole build chain is a bit overkill
# currently.  It used to be necessary since we did changes to
# configure.in and Makefile.am files.
configure:
	autoreconf -i -s

post-patches:: configure

clean::
	rm -f configure aclocal.m4 config.* depcomp install-sh ltmain.sh missing libtool
	find . -name Makefile.in -exec rm '{}' ';'
	rm -f src/config.h.in
	rm -f m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4

binary-post-install/libcxxtools7::
	rm -f debian/libcxxtools7/usr/share/doc/libcxxtools6/README #just some installation notes

binary-post-install/libcxxtools-dev::
	rm -f debian/libcxxtools-dev/usr/share/doc/libcxxtools-dev/README #just some installation notes
