#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk
include /usr/share/cdbs/1/rules/utils.mk

DEB_CONFIGURE_SCRIPT_ENV += LDFLAGS="-Wl,-O1 -Wl,--as-needed"
DEB_COMPRESS_EXCLUDE = .c
DEB_CONFIGURE_EXTRA_FLAGS := --disable-gtk-doc

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g -O0
	CONFIGURE_EXTRA_FLAGS += --enable-debug=yes
else
	CONFIGURE_EXTRA_FLAGS += --enable-debug=no --disable-cast-checks
endif

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

post-patches:: debian/stamp-gen-configure
debian/stamp-gen-configure:
	# -V option will cause configure to exit
	ACLOCAL="aclocal-1.10" AUTOMAKE="automake-1.10" ./autogen.sh -V
	touch $@

clean::
	rm -f debian/stamp-gen-configure

common-binary-predeb-arch:: list-missing
