optifying only in maemo5
[drnoksnes] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3 # Sample debian/rules that uses debhelper.
4 # This file was originally written by Joey Hess and Craig Small.
5 # As a special exception, when this file is copied by dh-make into a
6 # dh-make output file, you may use that output file without restriction.
7 # This special exception was added by Craig Small in version 0.37 of dh-make.
8
9 # Uncomment this to turn on verbose mode.
10 #export DH_VERBOSE=1
11
12 # These are used for cross-compiling and for saving the configure script
13 # from having to guess our platform (since we know it already)
14 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
15 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
16 ARCH                            ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
17
18 # Determine Maemo version
19 MAEMO_VERSION := $(shell cut -d"." -f1 /etc/maemo_version)
20
21 # Determine app version from debian changelog
22 GAME_VERSION := $(shell head -n 1 debian/changelog | sed 's/[^0-9.-]//g')
23
24 # Default CFLAGS
25 CFLAGS = -Wall -g -DMAEMO -DMAEMO_VERSION=$(MAEMO_VERSION)
26 GUI_CFLAGS := -std=c99 -fPIC -shared $(CFLAGS)
27 LDFLAGS = -Wl,-z,defs
28 GUI_LDFLAGS := -export-dynamic -avoid-version -module -shared $(LDFLAGS)
29 ASFLAGS = -g
30
31 M4=m4
32 M4DEFS=-DMAEMO_MAJOR=$(MAEMO_VERSION)
33
34 # Architecture specific CFLAGS
35 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
36         CFLAGS += -O0
37 else ifneq (,$(findstring armel,$(ARCH)))
38         CFLAGS += -O2
39         GUI_CFLAGS += -Os
40         ifneq (,$(findstring vfp,$(DEB_BUILD_OPTIONS)))
41                 CFLAGS += -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp
42                 ASFLAGS += -march=armv6j -mfpu=vfp -mfloat-abi=softfp
43         endif
44         # Fixes hang while exiting in Diablo.
45         CFLAGS += -static-libgcc
46 else ifneq (,$(findstring i386,$(ARCH)))
47         CFLAGS += -O2
48         GUI_CFLAGS += -O2
49 else
50         # Don't support anything else yet
51         crash
52 endif
53
54 debian/control: debian/control.m4
55         $(M4) $(M4DEFS) debian/control.m4 > debian/control
56
57 configure: configure-stamp
58 configure-stamp:
59         dh_testdir
60         $(M4) $(M4DEFS) debian/control.m4 > debian/control
61         $(M4) $(M4DEFS) debian/drnoksnes.postinst.m4 > debian/drnoksnes.postinst
62         
63         echo ARCH="$(ARCH)" > config.mk
64 ifeq ($(shell expr "$(MAEMO_VERSION)" ">" 4), 1)
65         # Maemo 5 devices do not support Xsp
66         echo CONF_XSP=0 >> config.mk
67 endif
68         echo ASFLAGS="$(ASFLAGS)" >> config.mk
69         echo CFLAGS="$(CFLAGS)" >> config.mk
70         echo CXXFLAGS="$(CFLAGS)" >> config.mk
71         echo LDFLAGS="$(LDFLAGS)" >> config.mk
72         
73         echo CFLAGS="$(GUI_CFLAGS)" > gui/config.mk
74         echo LDFLAGS="$(GUI_LDFLAGS)" >> gui/config.mk
75         echo MAEMO_VERSION="$(MAEMO_VERSION)" >> gui/config.mk
76         echo GAME_VERSION="$(GAME_VERSION)" >> gui/config.mk
77         
78         touch configure-stamp
79
80 build: build-stamp
81 build-stamp: configure-stamp 
82         dh_testdir
83         $(MAKE)
84         touch $@
85
86 clean:
87         dh_testdir
88         dh_testroot
89         rm -f build-stamp configure-stamp
90         -$(MAKE) clean
91         rm -f config.mk gui/config.mk
92         dh_clean
93
94 install: build
95         dh_testdir
96         dh_testroot
97         dh_clean -k 
98         dh_installdirs
99         $(MAKE) DESTDIR=$(CURDIR)/debian/drnoksnes GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1 install
100
101 # Build architecture-independent files here.
102 binary-indep: build install
103 # We have nothing to do by default.
104
105 # Build architecture-dependent files here.
106 binary-arch: build install
107         dh_testdir
108         dh_testroot
109 #       dh_installchangelogs 
110 #       dh_installdocs
111 #       dh_installexamples
112 #       dh_installman
113         dh_gconf
114 #       Fixes a nasty bug with dh_gconf & busybox
115         rm -f $(CURDIR)/debian/drnoksnes.postrm.debhelper
116         dh_link
117         dh_strip --dbg-package=drnoksnes-dbg
118         dh_compress
119         dh_fixperms
120         dh_installdeb
121         dh_shlibdeps
122         dh_gencontrol
123 ifeq ($(shell expr "$(MAEMO_VERSION)" ">" 4), 1)
124 #       Optify only in Maemo 5
125         maemo-optify
126 endif
127         dh_md5sums
128         dh_builddeb
129
130 binary: binary-indep binary-arch
131 .PHONY: build clean binary-indep binary-arch binary install configure