#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/class/gnome.mk
include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/gnome-pkg-tools/1/rules/uploaders.mk
include /usr/share/gnome-pkg-tools/1/rules/gnome-get-source.mk

# Let's get failing tests' stdout and stderr so we have some information when
# a build fails
export VERBOSE=1
DEB_MAKE_CHECK_TARGET = check

DEB_CONFIGURE_EXTRA_FLAGS += --disable-static \
                             --with-libproxy \
                             --with-gnutls \
                             --with-pkcs11 \
                             --enable-installed-tests \
                             --enable-always-build-tests \

# Don't strip translations from the installed tests; makes them environment dependent.
DEB_DH_TRANSLATIONS_ARGS = -Xinstalled-tests


ifneq (,$(findstring amd64,$(DEB_BUILD_ARCH)))
export DEB_BUILD_MAINT_OPTIONS = hardening=+fortify,-stackprotector,+relro,+bindnow,-pie
else
export DEB_BUILD_MAINT_OPTIONS = hardening=+fortify,-stackprotector,+relro,+bindnow,+pie
endif

devi := $(shell lsb_release -r -s | cut -d '.'  -f1)
DEBVE1=no
ifeq ($(shell if [ $(devi) -gt 7 ] ; then echo gt ; else echo lt ; fi),gt)
DEBVE1=yes
endif
DEBVE2=no
ifeq ($(shell if [ $(devi) -gt 8 ] ; then echo gt ; else echo lt ; fi),gt)
DEBVE2=yes
endif

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

OPTI_FLAGS_LIBONLY := -fomit-frame-pointer
ifeq ($(DEB_HOST_ARCH),i386)
ifeq ($(DEBVE1),yes)
    OPTI_FLAGS_LIBONLY += -march=i686 -mtune=generic -mmmx -msse -mfpmath=sse -fexcess-precision=fast
 
else
    OPTI_FLAGS_LIBONLY += -march=i586 -mtune=generic -mmmx -mno-sse -fexcess-precision=fast 
endif
else
ifeq ($(DEB_HOST_ARCH),i486)
ifeq ($(DEBVE1),yes)
    OPTI_FLAGS_LIBONLY += -march=i686 -mtune=generic -mmmx -msse -mfpmath=sse -fexcess-precision=fast
 
else
    OPTI_FLAGS_LIBONLY += -march=i586 -mtune=generic -mmmx -mno-sse -fexcess-precision=fast 
endif
endif
endif

ifeq ($(DEB_HOST_ARCH),amd64)
    OPTI_FLAGS_LIBONLY += -mmmx -msse -msse2 -mfpmath=sse -fexcess-precision=fast 
endif

CFLAGS= -O2 $(OPTI_FLAGS_LIBONLY)
export CFLAGS= -O2 $(OPTI_FLAGS_LIBONLY)
CXXFLAGS= -O2 $(OPTI_FLAGS_LIBONLY)
export CXXFLAGS= -O2 $(OPTI_FLAGS_LIBONLY)

endif

