#!/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

# IS_DIABLO=$(shell if grep Diablo /etc/maemo_version &> /dev/null; then echo y; else echo n; fi)
IS_FREMANTLE=$(shell if grep Fremantle /etc/maemo_version &> /dev/null; then echo y; else echo n; fi)
IS_HARMATTAN=$(shell if grep unstable /etc/debian_version &> /dev/null; then echo y; else echo n; fi)

# LDFLAGS= 
DEB_TAR_SRCDIR:=wine-1.3.31
DEB_CONFIGURE_NORMAL_ARGS:=--prefix=/opt/wine --sysconfdir=/etc \
	--disable-tests \
	--without-oss \
	--without-xinerama \
	--without-sane \
	--without-ldap \
	--without-gphoto -C

DEB_OPT_FLAG_armel:=-O1 -pipe

ifeq ($(IS_FREMANTLE),y)
DEB_OPT_FLAG_armel:=-O1 -pipe -mcpu=cortex-a8 -mfloat-abi=softfp -mfpu=neon
endif

ifeq ($(IS_HARMATTAN),y)
DEB_OPT_FLAG_armel:=-O2 -pipe -mcpu=cortex-a8 -mfpu=neon
endif

DEB_OPT_FLAG_i386:=-O2 -pipe
DEB_OPT_FLAG:=$(DEB_OPT_FLAG_$(DEB_HOST_ARCH))
DEB_DESTDIR=$(CURDIR)/debian/tmp

# try 1, fix build on autobuilder
export LD_LIBRARY_PATH=$(DEB_DESTDIR)/opt/wine/lib:/usr/lib

include /usr/share/cdbs/1/rules/tarball.mk

install/wine::
ifeq ($(IS_FREMANTLE),y)
	install -d -m 755 -o root -g root $(DEB_DESTDIR)/usr/share/applications/hildon
	install -m 644 -o root -g root debian/winemine.desktop $(DEB_DESTDIR)/usr/share/applications/hildon
	install -m 644 -o root -g root debian/winenotepad.desktop $(DEB_DESTDIR)/usr/share/applications/hildon
	ln -s /opt/wine/share/applications/wine.desktop $(DEB_DESTDIR)/usr/share/applications/hildon
else
	install -d -m 755 -o root -g root $(DEB_DESTDIR)/usr/share/applications
	install -m 644 -o root -g root debian/winemine.desktop $(DEB_DESTDIR)/usr/share/applications
	install -m 644 -o root -g root debian/winenotepad.desktop $(DEB_DESTDIR)/usr/share/applications
	ln -s /opt/wine/share/applications/wine.desktop $(DEB_DESTDIR)/usr/share/applications
endif
