#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk

DEB_TAR_SRCDIR:=hercules-3.07

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

IS_FREMANTLE=$(shell if grep Fremantle /etc/maemo_version &> /dev/null; then echo y; else echo n; fi)

ifeq ($(IS_FREMANTLE),y)
DEB_OPT_FLAG_armel:=-O2 -fomit-frame-pointer -pipe -mcpu=cortex-a8
DEB_CONFIGURE_NORMAL_ARGS:=--prefix=/opt --enable-cckd-bzip2 --enable-het-bzip2 --enable-optimization=yes --disable-shared
else
DEB_OPT_FLAG_armel:=-O2 -fomit-frame-pointer -pipe -mcpu=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp
DEB_CONFIGURE_NORMAL_ARGS:=--prefix=/usr --enable-cckd-bzip2 --enable-het-bzip2 --enable-optimization=yes --disable-shared
endif

DEB_MAKE_INSTALL_TARGET=install DESTDIR=$(DEB_DESTDIR)

DEB_OPT_FLAG_i386:=-O2 -fomit-frame-pointer -pipe -march=i686 -mtune=pentium2
DEB_OPT_FLAG:=$(DEB_OPT_FLAG_$(DEB_HOST_ARCH))

install/hercules::
ifeq ($(IS_FREMANTLE),y)
	install -d -m 755 $(DEB_DESTDIR)/usr/bin
	install -d -m 755 $(DEB_DESTDIR)/usr/lib/hercules

	ln -sf /opt/bin/hercules $(DEB_DESTDIR)/usr/bin/
	install -m 644 $(DEB_BUILDDIR)/hercules.cnf $(DEB_DESTDIR)/opt/share/hercules/
else
	install -m 644 $(DEB_BUILDDIR)/hercules.cnf $(DEB_DESTDIR)/usr/share/hercules/
endif
