#!/usr/bin/make -f
# Copyright 2003 Goedson Teixeira Paixao <goedson@debian.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.

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

DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
OPTI_FLAGS_LIBONLY := -fomit-frame-pointer -falign-functions=0 -falign-jumps=0 -falign-loops=0
### PICCORO optimizer flags for i386 x86 machines
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
    CFLAGS += -O0
else

ifeq ($(DEB_HOST_ARCH),i386)
    OPTI_FLAGS_LIBONLY += -march=i586 -mtune=pentium -mmmx 
endif
ifeq ($(DEB_HOST_ARCH),i486)
    OPTI_FLAGS_LIBONLY += -march=i586 -mtune=pentium -mmmx 
endif

ifeq ($(DEB_HOST_ARCH),amd64)
    OPTI_FLAGS_LIBONLY += -mmmx -msse -msse2
endif

CFLAGS= -O3 $(OPTI_FLAGS_LIBONLY)
export CFLAGS= -O3 $(OPTI_FLAGS_LIBONLY)

CPPFLAGS= -O3 $(OPTI_FLAGS_LIBONLY)
export CPPFLAGS= -O3 $(OPTI_FLAGS_LIBONLY)

CXXFLAGS= -O3 $(OPTI_FLAGS_LIBONLY)
export CXXFLAGS= -O3 $(OPTI_FLAGS_LIBONLY)

endif

LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)

makebuilddir::
	[ -f $(CURDIR)/configure.backup ] || cp $(CURDIR)/configure $(CURDIR)/configure.backup
	sed -i -r 's/(hardcode_into_libs)=.*$$/\1=no/;s/(hardcode_libdir_flag_spec)=.*--rpath.*$$//' $(CURDIR)/configure
clean::
	-rm po/*.gmo
	[ ! -f $(CURDIR)/configure.backup ] || mv $(CURDIR)/configure.backup $(CURDIR)/configure

install/gpaint::
	# Rename executable
	mv $(CURDIR)/debian/gpaint/usr/bin/gpaint-2 $(CURDIR)/debian/gpaint/usr/bin/gpaint

	# Install GNOME menu item
	mkdir -p debian/gpaint/usr/share/applications
	install -o root -g root -m 644 gpaint.desktop debian/gpaint/usr/share/applications/gpaint.desktop
	mkdir -p debian/gpaint/usr/share/pixmaps
	install -o root -g root -m 644 debian/gpaint.xpm debian/gpaint/usr/share/pixmaps/gpaint.xpm
	mkdir -p debian/gpaint/usr/share/icons/hicolor/scalable/apps/
	install -o root -g root -m 644 debian/gpaint.svg debian/gpaint/usr/share/icons/hicolor/scalable/apps/gpaint.svg

	# Install manpage
	mkdir -p debian/gpaint/usr/share/man/man1/
	install -o root -g root -m 644 debian/gpaint.1 debian/gpaint/usr/share/man/man1/


