#!/usr/bin/make -f
export DH_VERBOSE = 1

DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)

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

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

ifeq ($(DEB_BUILD_ARCH),amd64)
CUFLAGS += -O3 -mfpmath=sse -fexcess-precision=fast -msse -mno-sse4 -mno-sse3 -msse2  -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fomit-frame-pointer
endif
ifeq ($(DEB_BUILD_ARCH),i386)
CUFLAGS += -O3 -march=i586 -mtune=generic -mmmx -mno-sse4 -mno-sse3 -fexcess-precision=fast -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fomit-frame-pointer
endif
ifeq ($(DEB_BUILD_ARCH),i386)
CUFLAGS += -O3 -march=i586 -mtune=generic -mmmx -mno-sse4 -mno-sse3 -fexcess-precision=fast -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize -fomit-frame-pointer
endif

endif

export CFLAGS=$(CUFLAGS)
export CXXFLAGS=$(CUFLAGS)

CFLAGS=$(CUFLAGS)
CXXFLAGS=$(CUFLAGS)

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
	        --prefix=/usr \
	        --with-lx \
	        --with-gtktheme \
	        --with-pmenu

override_dh_auto_install:
	dh_auto_install -- prefix=/usr DESTDIR=$$(pwd)/debian/jgmenu CONTRIB_DIRS="pmenu gtktheme lx"
#	$(MAKE) prefix=/usr install CONTRIB_DIRS="pmenu gtktheme lx"

override_dh_install:
	dh_install --list-missing

override_dh_auto_test:
	# fail with lx i d k why

override_dh_auto_build:
	dh_auto_build -- CONTRIB_DIRS="pmenu gtktheme lx"

