fix a stupid compile error when CONFIG_FEATURE_INSMOD_VERSION_CHECKING
[oweals/busybox.git] / debian / rules
1 #!/usr/bin/make -f
2
3 # Uncomment this to turn on verbose mode.
4 #export DH_VERBOSE=1
5
6 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
7 DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
8 DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
9
10 VERSION = $(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
11
12 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
13         CONFIG_DEBUG = true
14 endif
15 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
16 endif
17
18 PACKAGE_PREFIX = busybox-cvs
19
20 ARCH_FLOPPY_UDEB = $(shell sh debian/control-extract Architecture $(PACKAGE_PREFIX)-floppy-udeb)
21
22 PACKAGES_DEB = $(PACKAGE_PREFIX) $(PACKAGE_PREFIX)-static
23 PACKAGES_UDEB = $(PACKAGE_PREFIX)-udeb
24 ifneq ($(filter $(DEB_HOST_ARCH),$(ARCH_FLOPPY_UDEB)),)
25 PACKAGES_UDEB += $(PACKAGE_PREFIX)-floppy-udeb
26 endif
27 PACKAGES = $(PACKAGES_DEB) $(PACKAGES_UDEB)
28
29 DEBHELPER_PACKAGES_DEB = $(patsubst %,-p%,$(PACKAGES_DEB))
30 DEBHELPER_PACKAGES_UDEB = $(patsubst %,-p%,$(PACKAGES_UDEB))
31
32 CONFIG = $(firstword $(wildcard ./debian/config-$(1)-$(DEB_HOST_GNU_SYSTEM)-$(DEB_HOST_GNU_CPU) ./debian/config-$(1)-$(DEB_HOST_GNU_SYSTEM) ./debian/config-$(1)))
33 CONFIG_DEB = $(call CONFIG,deb)
34 CONFIG_STATIC = $(call CONFIG,static)
35 CONFIG_UDEB = $(call CONFIG,udeb)
36 CONFIG_FLOPPY_UDEB = $(call CONFIG,floppy-udeb)
37
38 configure: configure-stamp
39 configure-stamp:
40         sh ./configure
41
42         touch $@
43
44 build-arch: build-arch-deb-all build-arch-udeb-all
45 build-arch-deb-all: build-arch-deb build-arch-static build-arch-doc
46 build-arch-udeb-all: build-arch-udeb build-arch-floppy-udeb
47
48 build-arch-deb: build-arch-deb-stamp
49 build-arch-deb-stamp: configure-stamp
50         $(MAKE) clean
51
52         cp $(CONFIG_DEB) .config
53
54         $(MAKE) dep
55         $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
56
57         install -d install-$(PACKAGE_PREFIX)/bin
58         install busybox install-$(PACKAGE_PREFIX)/bin/busybox
59
60         touch $@
61
62 build-arch-static: build-arch-static-stamp
63 build-arch-static-stamp: configure-stamp
64         $(MAKE) clean
65
66         cp $(CONFIG_STATIC) .config
67
68         $(MAKE) dep
69         $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
70
71         install -d install-$(PACKAGE_PREFIX)-static/bin
72         install busybox install-$(PACKAGE_PREFIX)-static/bin/busybox
73
74         touch $@
75
76 build-arch-udeb: build-arch-udeb-stamp
77 build-arch-udeb-stamp: configure-stamp
78         $(MAKE) clean
79
80         cp $(CONFIG_UDEB) .config
81
82         $(MAKE) dep
83         $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
84
85         $(MAKE) PREFIX=$(CURDIR)/install-$(PACKAGE_PREFIX)-udeb install
86         # Remove init link, but init support is still compiled in to be
87         # used.
88         rm -f $(CURDIR)/install-$(PACKAGE_PREFIX)-udeb/sbin/init
89
90         touch $@
91
92 build-arch-floppy-udeb: build-arch-floppy-udeb-stamp
93 build-arch-floppy-udeb-stamp: configure-stamp
94 ifneq ($(filter $(DEB_HOST_ARCH),$(ARCH_FLOPPY_UDEB)),)
95         $(MAKE) clean
96
97         cp $(CONFIG_FLOPPY_UDEB) .config
98
99         $(MAKE) dep
100         $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
101
102         $(MAKE) PREFIX=$(CURDIR)/install-$(PACKAGE_PREFIX)-floppy-udeb install
103 endif
104
105         touch $@
106
107 build-arch-doc: build-arch-doc-stamp
108 build-arch-doc-stamp: configure-stamp
109         $(MAKE) docs/BusyBox.1
110
111         cp docs/BusyBox.1 busybox.1
112
113         touch $@
114
115 build: build-arch
116
117 clean:
118         dh_testdir
119         dh_testroot
120         rm -f build-*-stamp configure-stamp debian/files~
121
122         -$(MAKE) distclean
123         -rm -rf busybox-deb busybox-static install* busybox.1
124
125         dh_clean
126
127 install-deb: build-arch-deb-all
128         dh_testdir
129         dh_testroot
130         dh_clean -k $(DEBHELPER_PACKAGES_DEB)
131         dh_installdirs $(DEBHELPER_PACKAGES_DEB)
132
133         for i in $(PACKAGES_DEB); do \
134         ( \
135                 cd install-$$i; \
136                 find -type d -exec install -d $(CURDIR)/debian/$$i/{} \;; \
137                 find \( -type f -o -type l \) -exec cp -a {} $(CURDIR)/debian/$$i/{} \;; \
138         ); \
139         done
140
141         install -m644 debian/$(PACKAGE_PREFIX)-static.override \
142                 debian/$(PACKAGE_PREFIX)-static/usr/share/lintian/overrides/$(PACKAGE_PREFIX)-static
143
144 install-udeb: build-arch-udeb-all
145         dh_testdir
146         dh_testroot
147         dh_clean -k $(DEBHELPER_PACKAGES_UDEB)
148         dh_installdirs $(DEBHELPER_PACKAGES_UDEB)
149
150         for i in $(PACKAGES_UDEB); do \
151         ( \
152                 cd install-$$i; \
153                 find -type d -exec install -d $(CURDIR)/debian/$$i/{} \;; \
154                 find \( -type f -o -type l \) -exec cp -a {} $(CURDIR)/debian/$$i/{} \;; \
155         ); \
156         done
157
158 binary-arch: binary-arch-deb binary-arch-udeb
159
160 # Build architecture-dependent files here.
161 binary-arch-deb: build-arch-deb-all install-deb
162         dh_testdir
163         dh_testroot
164         dh_installdocs $(DEBHELPER_PACKAGES_DEB)
165         dh_installman $(DEBHELPER_PACKAGES_DEB)
166         dh_installchangelogs Changelog $(DEBHELPER_PACKAGES_DEB)
167         dh_strip $(DEBHELPER_PACKAGES_DEB)
168         dh_link $(DEBHELPER_PACKAGES_DEB)
169         dh_compress $(DEBHELPER_PACKAGES_DEB)
170         dh_fixperms $(DEBHELPER_PACKAGES_DEB)
171         dh_installdeb $(DEBHELPER_PACKAGES_DEB)
172         dh_shlibdeps $(DEBHELPER_PACKAGES_DEB)
173         dh_gencontrol $(DEBHELPER_PACKAGES_DEB)
174         dh_md5sums $(DEBHELPER_PACKAGES_DEB)
175         dh_builddeb $(DEBHELPER_PACKAGES_DEB)
176
177 # Build architecture-dependent files here.
178 binary-arch-udeb: build-arch-udeb-all install-udeb
179         dh_testdir
180         dh_testroot
181         dh_strip $(DEBHELPER_PACKAGES_UDEB)
182         dh_link $(DEBHELPER_PACKAGES_UDEB)
183         dh_compress $(DEBHELPER_PACKAGES_UDEB)
184         dh_fixperms $(DEBHELPER_PACKAGES_UDEB)
185         dh_installdeb $(DEBHELPER_PACKAGES_UDEB)
186         dh_shlibdeps $(DEBHELPER_PACKAGES_UDEB)
187         dh_gencontrol $(DEBHELPER_PACKAGES_DEB)
188
189         $(foreach PACKAGE, $(PACKAGES_UDEB), \
190         dh_gencontrol -p$(PACKAGE) -- -fdebian/files~; \
191         dpkg-distaddfile $(PACKAGE)_$(VERSION)_$(DEB_HOST_ARCH).udeb debian-installer extra; \
192         dh_builddeb -p$(PACKAGE) --filename=$(PACKAGE)_$(VERSION)_$(DEB_HOST_ARCH).udeb; \
193         )
194
195 binary: binary-arch
196 .PHONY: build clean binary-indep binary-arch binary install