update hardening build flags config
[debian/cc1111] / debian / rules
1 #!/usr/bin/make -f
2
3 export DH_VERBOSE=1
4
5 # These are used for cross-compiling and for saving the configure script
6 # from having to guess our platform (since we know it already)
7 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
8 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
9
10 export HOME=$(CURDIR)/build
11
12 CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
13 CFLAGS = $(shell dpkg-buildflags --get CFLAGS)
14 CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS)
15 LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
16
17 CFLAGS += -Wall -Wno-comment
18
19 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
20         CFLAGS += -g -O0
21         export STRIP=true
22 endif
23 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
24         INSTALL_PROGRAM += -s
25 endif
26
27 clean:
28         dh_testdir
29         dh_testroot
30         # Clean up files that Makefile should have cleaned
31         rm -rf $(CURDIR)/build
32         rm -f support/cpp/configargs.h,.log
33         rm -f support/cpp/config.log
34         rm -f support/cpp/config.status
35         rm -f sim/ucsim/config.guess
36         rm -f sim/ucsim/config.sub
37         rm -f sim/ucsim/config.status
38         rm -f sim/ucsim/config.log
39         rm -f config.log
40         rm -f device/lib/small-stack-auto/Makefile
41         rm -f as/link/asxxxx_config.h
42         rm -f device/lib/large/*.asm
43         rm -f device/lib/medium/*.asm
44         rm -f device/lib/small/*.asm
45         rm -f device/lib/small-stack-auto/*.asm
46         rm -f support/cpp/configargs.h
47         find -type f -name '*.o' -exec rm -f {} \;
48         find -type f -name '.stamp' -exec rm -f {} \;
49         find . -name '*.rel' -exec rm -f {} \;
50         #find 'device/lib/{small*,large,medium}' -name *.asm -exec rm -f {} \;
51         find . -name '*.sym' -exec rm -f {} \;
52         find . -name '*.lst' -exec rm -f {} \;
53         # Clean up the Debian specific files
54         rm -f config.status doc/sdccman.ps
55         rm -f build-stamp configure-stamp install-arch-stamp install-indep-stamp install-stamp
56         rm -f as/link/lk_readnl.c       # Remove in next version
57         rm -f as/link/lk_readnl.h       # Remove in next version
58         [ ! -f Makefile ] || $(MAKE) distclean
59         dh_clean
60
61 configure: configure-stamp
62 configure-stamp: 
63         dh_testdir
64         mkdir -p $(CURDIR)/build
65         cp /usr/share/misc/config.sub sim/ucsim/config.sub
66         cp /usr/share/misc/config.guess sim/ucsim/config.guess
67         cp debian/lk_readnl.h as/link/lk_readnl.h       # Remove in next version
68         cp debian/lk_readnl.c as/link/lk_readnl.c       # Remove in next version
69         ./configure \
70                 --host=$(DEB_HOST_GNU_TYPE) \
71                 --build=$(DEB_BUILD_GNU_TYPE) \
72                 --prefix=/usr \
73                 --disable-avr-port \
74                 --disable-ds390-port \
75                 --disable-ds400-port \
76                 --disable-gbz80-port \
77                 --disable-hc08-port \
78                 --enable-mcs51-port \
79                 --disable-pic-port \
80                 --disable-pic16-port \
81                 --disable-xa51-port \
82                 --disable-z80-port \
83                 --disable-z80-port 
84         touch $@
85
86 build: build-arch build-indep
87 build-arch: build-stamp
88 build-indep: build-stamp
89 build-stamp: configure-stamp
90         dh_testdir
91         $(MAKE)
92 #       cd doc && lyx -e ps sdccman.lyx
93         touch $@
94
95 install: install-stamp
96 install-stamp: build
97         dh_testdir
98         dh_testroot
99         dh_installdirs 
100         dh_prep
101         $(MAKE) install prefix=$(CURDIR)/debian/tmp/usr
102         mkdir -p debian/tmp/usr/share/doc/cc1111
103 #       install -o root -g root -m 644 doc/sdccman.ps debian/tmp/usr/share/doc/cc1111
104         mv debian/tmp/usr/share/doc/sdcc/* debian/tmp/usr/share/doc/cc1111/
105         # Add some scripts
106         mkdir -p debian/tmp/usr/share/sdcc/scripts
107         install -o root -g root -m 755  support/scripts/inc2h.pl       debian/tmp/usr/share/sdcc/scripts
108         install -o root -g root -m 755  support/scripts/keil2sdcc.pl   debian/tmp/usr/share/sdcc/scripts
109
110         #Remove extra license file
111         rm -f $(CURDIR)/debian/tmp/usr/share/sdcc/lib/src/pic16/COPYING
112         # Remove empty dirs:
113         find $(CURDIR)/debian/tmp -type d -empty -delete
114
115         #Clean up unnecessary directories
116         rm -rf `find $(CURDIR)/debian/tmp -type d -name .deps`
117
118         dh_install --sourcedir=debian/tmp
119
120
121         mkdir -p $(CURDIR)/debian/cc1111/usr/share/lintian/overrides/
122         install -p -o root -g root -m 644 $(CURDIR)/debian/cc1111.overrides \
123                 $(CURDIR)/debian/cc1111/usr/share/lintian/overrides/cc1111
124         # Install examples
125         cp -a device/examples $(CURDIR)/debian/cc1111/usr/share/doc/cc1111
126         rm -rf $(CURDIR)/debian/cc1111/usr/share/doc/cc1111/examples/ds400
127         rm -rf $(CURDIR)/debian/cc1111/usr/share/doc/cc1111/examples/ds390
128         rm -rf $(CURDIR)/debian/cc1111/usr/share/doc/cc1111/examples/xa51
129         # clean up things cc1111 doesn't need
130         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/lib/src/pic
131         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/lib/src/pic16
132         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/lib/src/ds400
133         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/lib/src/hc08
134         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/lib/src/z80
135         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/lib/src/ds390
136         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/lib/src/gbz80
137         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/include/ds400rom.h
138         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/include/*390*
139         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/include/asm/pic
140         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/include/asm/pic16
141         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/include/asm/z80
142         rm -rf $(CURDIR)/debian/cc1111/usr/share/sdcc/include/asm/gbz80
143         touch $@
144
145 # Must not depend on anything. This is to be called by binary-arch/binary-indep
146 # in another 'make' thread.
147 binary-common:
148         dh_testdir
149         dh_testroot
150         dh_installchangelogs ChangeLog
151         dh_installdocs
152         dh_installman
153         dh_installemacsen
154         dh_link
155         dh_strip -Xusr/share/sdcc/lib/
156         dh_compress 
157         dh_fixperms
158         dh_installdeb
159         dh_shlibdeps
160         dh_gencontrol
161         dh_md5sums
162         dh_builddeb
163
164 # Build architecture-independent files here.
165 binary-indep: install
166         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
167
168 # Build architecture-dependent files here.
169 binary-arch: install
170         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
171
172 binary: binary-arch binary-indep
173 .PHONY: build-indep build-arch build clean binary-indep binary-arch binary install install-arch install-indep