adding omit-frame-pointer to cflags
[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 CXXFLAGS := -Wall -g -DMAEMO -DMAEMO_VERSION=$(MAEMO_VERSION)
27 GUI_CFLAGS := -std=c99 -fPIC -shared $(CFLAGS)
28 LDFLAGS := -Wl,-z,defs -Wl,-O1
29 GUI_LDFLAGS := -export-dynamic -avoid-version -module -shared $(LDFLAGS)
30 ASFLAGS := -g
31
32 # Compiler optimization settings
33 OPT_CFLAGS := -O2 -fomit-frame-pointer -ffast-math
34 OPT_CXXFLAGS := $(OPT_CFLAGS) -fno-exceptions -fno-rtti
35
36 M4=m4
37 M4DEFS=-DMAEMO_MAJOR=$(MAEMO_VERSION)
38
39 # Architecture specific CFLAGS
40 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
41         CFLAGS += -O0
42         CXXFLAGS += -O0
43         GUI_CFLAGS += -O0
44 else ifneq (,$(findstring armel,$(ARCH)))
45         CFLAGS += $(OPT_CFLAGS)
46         CXXFLAGS += $(OPT_CXXFLAGS)
47         GUI_CFLAGS += -Os
48         ifneq (,$(findstring vfp,$(DEB_BUILD_OPTIONS)))
49                 CFLAGS += -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp
50                 ASFLAGS += -march=armv6j -mfpu=vfp -mfloat-abi=softfp
51         endif
52         ifeq ($(shell expr "$(MAEMO_VERSION)" "<" 5), 1)
53                 # Fixes hang while exiting in Diablo.
54                 CFLAGS += -static-libgcc
55         endif
56 else ifneq (,$(findstring i386,$(ARCH)))
57         CFLAGS += $(OPT_CFLAGS)
58         CXXFLAGS += $(OPT_CXXFLAGS)
59         GUI_CFLAGS += -O2
60 else
61         # Don't support anything else
62         crash
63 endif
64
65 debian/control: debian/control.m4
66         $(M4) $(M4DEFS) debian/control.m4 > debian/control
67
68 configure: configure-stamp
69 configure-stamp:
70         dh_testdir
71         $(M4) $(M4DEFS) debian/control.m4 > debian/control
72         $(M4) $(M4DEFS) debian/drnoksnes.postinst.m4 > debian/drnoksnes.postinst
73         
74         echo ARCH="$(ARCH)" > config.mk
75         echo CONF_GUI=1 >> config.mk
76 ifeq ($(shell expr "$(MAEMO_VERSION)" ">" 4), 1)
77         # Maemo 5 devices do not support Xsp
78         # But they support hildon compositing stuff
79         echo CONF_HD=1 >> config.mk
80 else
81         echo CONF_XSP=1 >> config.mk
82 endif
83         echo CONF_ZEEMOTE=1 >> config.mk
84         echo ASFLAGS="$(ASFLAGS)" >> config.mk
85         echo CFLAGS="$(CFLAGS)" >> config.mk
86         echo CXXFLAGS="$(CXXFLAGS)" >> config.mk
87         echo LDFLAGS="$(LDFLAGS)" >> config.mk
88         
89         echo CONF_NLS=1 > gui/config.mk
90         echo CFLAGS="$(GUI_CFLAGS)" >> gui/config.mk
91         echo LDFLAGS="$(GUI_LDFLAGS)" >> gui/config.mk
92         echo MAEMO_VERSION="$(MAEMO_VERSION)" >> gui/config.mk
93         echo GAME_VERSION="$(GAME_VERSION)" >> gui/config.mk
94         
95         touch configure-stamp
96
97 build: build-stamp
98 build-stamp: configure-stamp 
99         dh_testdir
100         $(MAKE)
101         touch $@
102
103 clean:
104         dh_testdir
105         dh_testroot
106         rm -f build-stamp configure-stamp
107         -$(MAKE) clean
108         rm -f config.mk gui/config.mk
109         dh_clean
110
111 install: build
112         dh_testdir
113         dh_testroot
114         dh_clean -k 
115         dh_installdirs
116         $(MAKE) DESTDIR=$(CURDIR)/debian/drnoksnes GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1 install
117
118 # Build architecture-independent files here.
119 binary-indep: build install
120 # We have nothing to do by default.
121
122 # Build architecture-dependent files here.
123 binary-arch: build install
124         dh_testdir
125         dh_testroot
126 #       dh_installchangelogs 
127 #       dh_installdocs
128 #       dh_installexamples
129 #       dh_installman
130         dh_gconf
131 #       Fixes a nasty bug with dh_gconf & busybox
132         rm -f $(CURDIR)/debian/drnoksnes.postrm.debhelper
133         dh_link
134         dh_strip --dbg-package=drnoksnes-dbg
135         dh_compress
136         dh_fixperms
137         dh_installdeb
138         dh_shlibdeps
139         dh_gencontrol
140         dh_md5sums
141         dh_builddeb
142
143 binary: binary-indep binary-arch
144 .PHONY: build clean binary-indep binary-arch binary install configure