#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

DEB_CONFIGURE_EXTRA_FLAGS := --enable-software-16-x11			\
							 --enable-software-x11			\
							 --disable-scale-smooth			\
							 --disable-pthreads			\
							 --enable-no-dither-mask		\
							 --enable-small-dither-mask		\
							 --disable-fb				\
							 --disable-xrender-x11			\
							 --disable-image-loader-tiff		\
							 --disable-image-loader-edb		\
							 --disable-image-loader-xpm		\
							 --disable-image-loader-svg		\
							 --disable-convert-yuv			\
							 --disable-convert-8-rgb-332		\
							 --disable-convert-8-rgb-666		\
							 --disable-convert-8-rgb-232		\
							 --disable-convert-8-rgb-222		\
							 --disable-convert-8-rgb-221		\
							 --disable-convert-8-rgb-121		\
							 --disable-convert-8-rgb-111		\
							 --disable-convert-16-bgr-565		\
							 --disable-convert-16-rgb-555		\
							 --disable-convert-16-rgb-444		\
							 --disable-convert-16-rgb-ipq		\
							 --disable-convert-24-rgb-888 		\
							 --disable-convert-24-bgr-888 		\
							 --disable-convert-32-rgb-8888 		\
							 --disable-convert-32-rgbx-8888 	\
							 --disable-convert-32-bgr-8888 		\
							 --disable-convert-32-bgrx-8888 	\
							 --disable-convert-32-rgb-rot-0 	\
							 --disable-convert-32-rgb-rot-180 	\
							 --disable-convert-32-rgb-rot-270 	\
							 --disable-convert-32-rgb-rot-90	\
							 --disable-sdl


CFLAGS+=-I/usr/X11R6/include

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

ifeq ($(DEB_BUILD_ARCH),armel)
	COMMON_CFLAGS=-DNDEBUG=1 -fomit-frame-pointer -O2 -ffast-math -funsafe-math-optimizations -fno-math-errno -fsingle-precision-constant
	N770_CFLAGS=-mcpu=arm926ej-s
	N8x0_CFLAGS=-mfpu=vfp -mfloat-abi=softfp -mcpu=arm1136jf-s
	ifneq ($(DEB_BUILD_OPTIONS),)
		ifneq (,$(findstring n8x0,$(DEB_BUILD_OPTIONS)))
			SPECIFIC_CFLAGS=$(N8x0_CFLAGS)
		else
			ifneq (,$(findstring n770,$(DEB_BUILD_OPTIONS)))
				SPECIFIC_CFLAGS=$(N770_CFLAGS)
			endif
		endif
	endif
    ifeq ($(SPECIFIC_CFLAGS),)
        ifeq (0,$(shell test -e /etc/osso_software_version; echo $$?))
            SW_VERSION?=$(shell cat /etc/osso_software_version|cut -d_ -f2)
			ifneq (,$(findstring $(SW_VERSION),OSSO1.1 2008SE DIABLO))
				SPECIFIC_CFLAGS=$(N8x0_CFLAGS)
            endif
		endif
    	ifeq ($(SPECIFIC_CFLAGS),)
            # Our last hope is to look at the value returned by `sb-conf current`
            SB_CURRENT?=$(shell sb-conf current|cut -d_ -f1)
			ifneq (,$(findstring $(SB_CURRENT),GREGALE BORA CHINOOK DIABLO))
				ifeq ($(SB_CURRENT),GREGALE)
					SPECIFIC_CFLAGS=$(N770_CFLAGS)
				else
					SPECIFIC_CFLAGS=$(N8x0_CFLAGS)
				endif
			else
				COMMON_CFLAGS=
			endif
        endif
    endif
endif

CFLAGS+=$(COMMON_CFLAGS) $(SPECIFIC_CFLAGS)

