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