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