blob: e77b4ef96099c610b96df71a091fb8397808d408 [file] [log] [blame]
Eric Andersenb108a5b2000-06-19 09:21:34 +00001#!/usr/bin/make -f
2
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +00003# Uncomment this to turn on verbose mode.
4#export DH_VERBOSE=1
5
Glenn L McGrath4957fc72003-04-06 15:35:52 +00006DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
Glenn L McGratha43facc2004-01-01 00:23:01 +00007DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
8DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
Glenn L McGrath4957fc72003-04-06 15:35:52 +00009
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +000010VERSION = $(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +000011
Glenn L McGrath1b16bf62002-11-23 07:14:55 +000012ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
Eric Andersene5272072003-07-22 22:15:21 +000013 CONFIG_DEBUG = true
Glenn L McGrath1b16bf62002-11-23 07:14:55 +000014endif
Glenn L McGrathb9e57f42002-12-01 20:16:01 +000015ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
Glenn L McGrath1b16bf62002-11-23 07:14:55 +000016endif
Eric Andersenb108a5b2000-06-19 09:21:34 +000017
Glenn L McGrath4957fc72003-04-06 15:35:52 +000018PACKAGE_PREFIX = busybox-cvs
19
Glenn L McGratha43facc2004-01-01 00:23:01 +000020ARCH_FLOPPY_UDEB = $(shell sh debian/control-extract Architecture $(PACKAGE_PREFIX)-floppy-udeb)
21
Glenn L McGrath4957fc72003-04-06 15:35:52 +000022PACKAGES_DEB = $(PACKAGE_PREFIX) $(PACKAGE_PREFIX)-static
23PACKAGES_UDEB = $(PACKAGE_PREFIX)-udeb
Glenn L McGratha43facc2004-01-01 00:23:01 +000024ifneq ($(filter $(DEB_HOST_ARCH),$(ARCH_FLOPPY_UDEB)),)
25PACKAGES_UDEB += $(PACKAGE_PREFIX)-floppy-udeb
Glenn L McGrath4957fc72003-04-06 15:35:52 +000026endif
27PACKAGES = $(PACKAGES_DEB) $(PACKAGES_UDEB)
Glenn L McGrath4957fc72003-04-06 15:35:52 +000028
Glenn L McGratha43facc2004-01-01 00:23:01 +000029DEBHELPER_PACKAGES_DEB = $(patsubst %,-p%,$(PACKAGES_DEB))
30DEBHELPER_PACKAGES_UDEB = $(patsubst %,-p%,$(PACKAGES_UDEB))
31
32CONFIG = $(firstword $(wildcard ./debian/config-$(1)-$(DEB_HOST_GNU_SYSTEM)-$(DEB_HOST_GNU_CPU) ./debian/config-$(1)-$(DEB_HOST_GNU_SYSTEM) ./debian/config-$(1)))
33CONFIG_DEB = $(call CONFIG,deb)
34CONFIG_STATIC = $(call CONFIG,static)
35CONFIG_UDEB = $(call CONFIG,udeb)
36CONFIG_FLOPPY_UDEB = $(call CONFIG,floppy-udeb)
37
38configure: configure-stamp
39configure-stamp:
40 sh ./configure
41
42 touch $@
43
44build-arch: build-arch-deb-all build-arch-udeb-all
45build-arch-deb-all: build-arch-deb build-arch-static build-arch-doc
46build-arch-udeb-all: build-arch-udeb build-arch-floppy-udeb
Glenn L McGrath4957fc72003-04-06 15:35:52 +000047
48build-arch-deb: build-arch-deb-stamp
Glenn L McGratha43facc2004-01-01 00:23:01 +000049build-arch-deb-stamp: configure-stamp
Glenn L McGrath1b16bf62002-11-23 07:14:55 +000050 $(MAKE) clean
Glenn L McGrath4957fc72003-04-06 15:35:52 +000051
Glenn L McGratha43facc2004-01-01 00:23:01 +000052 cp $(CONFIG_DEB) .config
Glenn L McGrath4957fc72003-04-06 15:35:52 +000053
Glenn L McGrath1b16bf62002-11-23 07:14:55 +000054 $(MAKE) dep
Eric Andersene5272072003-07-22 22:15:21 +000055 $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
Eric Andersenb108a5b2000-06-19 09:21:34 +000056
Glenn L McGrath4957fc72003-04-06 15:35:52 +000057 install -d install-$(PACKAGE_PREFIX)/bin
58 install busybox install-$(PACKAGE_PREFIX)/bin/busybox
59
60 touch $@
61
62build-arch-static: build-arch-static-stamp
Glenn L McGratha43facc2004-01-01 00:23:01 +000063build-arch-static-stamp: configure-stamp
Glenn L McGrath1b16bf62002-11-23 07:14:55 +000064 $(MAKE) clean
Glenn L McGrath4957fc72003-04-06 15:35:52 +000065
Glenn L McGratha43facc2004-01-01 00:23:01 +000066 cp $(CONFIG_STATIC) .config
Glenn L McGrath4957fc72003-04-06 15:35:52 +000067
Glenn L McGrath1b16bf62002-11-23 07:14:55 +000068 $(MAKE) dep
Eric Andersene5272072003-07-22 22:15:21 +000069 $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
Glenn L McGrath1b16bf62002-11-23 07:14:55 +000070
Glenn L McGrath4957fc72003-04-06 15:35:52 +000071 install -d install-$(PACKAGE_PREFIX)-static/bin
72 install busybox install-$(PACKAGE_PREFIX)-static/bin/busybox
73
74 touch $@
75
76build-arch-udeb: build-arch-udeb-stamp
Glenn L McGratha43facc2004-01-01 00:23:01 +000077build-arch-udeb-stamp: configure-stamp
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +000078 $(MAKE) clean
Glenn L McGrath4957fc72003-04-06 15:35:52 +000079
Glenn L McGratha43facc2004-01-01 00:23:01 +000080 cp $(CONFIG_UDEB) .config
Glenn L McGrath4957fc72003-04-06 15:35:52 +000081
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +000082 $(MAKE) dep
Eric Andersene5272072003-07-22 22:15:21 +000083 $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
Eric Andersene2f6e122000-12-01 19:55:04 +000084
Glenn L McGrath4957fc72003-04-06 15:35:52 +000085 $(MAKE) PREFIX=$(CURDIR)/install-$(PACKAGE_PREFIX)-udeb install
Glenn L McGratha43facc2004-01-01 00:23:01 +000086 # Remove init link, but init support is still compiled in to be
87 # used.
88 rm -f $(CURDIR)/install-$(PACKAGE_PREFIX)-udeb/sbin/init
Glenn L McGrath4957fc72003-04-06 15:35:52 +000089
90 touch $@
91
Glenn L McGratha43facc2004-01-01 00:23:01 +000092build-arch-floppy-udeb: build-arch-floppy-udeb-stamp
93build-arch-floppy-udeb-stamp: configure-stamp
94ifneq ($(filter $(DEB_HOST_ARCH),$(ARCH_FLOPPY_UDEB)),)
Glenn L McGrath4957fc72003-04-06 15:35:52 +000095 $(MAKE) clean
96
Glenn L McGratha43facc2004-01-01 00:23:01 +000097 cp $(CONFIG_FLOPPY_UDEB) .config
Glenn L McGrath4957fc72003-04-06 15:35:52 +000098
99 $(MAKE) dep
Eric Andersene5272072003-07-22 22:15:21 +0000100 $(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000101
Glenn L McGratha43facc2004-01-01 00:23:01 +0000102 $(MAKE) PREFIX=$(CURDIR)/install-$(PACKAGE_PREFIX)-floppy-udeb install
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000103endif
104
105 touch $@
106
107build-arch-doc: build-arch-doc-stamp
Glenn L McGratha43facc2004-01-01 00:23:01 +0000108build-arch-doc-stamp: configure-stamp
Glenn L McGrathc4698b32002-12-08 20:45:47 +0000109 $(MAKE) docs/BusyBox.1
110
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000111 cp docs/BusyBox.1 busybox.1
112
113 touch $@
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000114
Glenn L McGrathc4698b32002-12-08 20:45:47 +0000115build: build-arch
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000116
117clean:
Glenn L McGrath12371f92002-11-26 02:16:06 +0000118 dh_testdir
119 dh_testroot
Glenn L McGratha43facc2004-01-01 00:23:01 +0000120 rm -f build-*-stamp configure-stamp debian/files~
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000121
Glenn L McGratha43facc2004-01-01 00:23:01 +0000122 -$(MAKE) distclean
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000123 -rm -rf busybox-deb busybox-static install* busybox.1
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000124
125 dh_clean
126
Glenn L McGratha43facc2004-01-01 00:23:01 +0000127install-deb: build-arch-deb-all
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000128 dh_testdir
129 dh_testroot
Glenn L McGratha43facc2004-01-01 00:23:01 +0000130 dh_clean -k $(DEBHELPER_PACKAGES_DEB)
131 dh_installdirs $(DEBHELPER_PACKAGES_DEB)
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000132
Glenn L McGratha43facc2004-01-01 00:23:01 +0000133 for i in $(PACKAGES_DEB); do \
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000134 ( \
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
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000140
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000141 install -m644 debian/$(PACKAGE_PREFIX)-static.override \
142 debian/$(PACKAGE_PREFIX)-static/usr/share/lintian/overrides/$(PACKAGE_PREFIX)-static
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000143
Glenn L McGratha43facc2004-01-01 00:23:01 +0000144install-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
158binary-arch: binary-arch-deb binary-arch-udeb
159
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000160# Build architecture-dependent files here.
Glenn L McGratha43facc2004-01-01 00:23:01 +0000161binary-arch-deb: build-arch-deb-all install-deb
162 dh_testdir
163 dh_testroot
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000164 dh_installdocs $(DEBHELPER_PACKAGES_DEB)
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000165 dh_installman $(DEBHELPER_PACKAGES_DEB)
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000166 dh_installchangelogs Changelog $(DEBHELPER_PACKAGES_DEB)
Glenn L McGratha43facc2004-01-01 00:23:01 +0000167 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)
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000173 dh_gencontrol $(DEBHELPER_PACKAGES_DEB)
174 dh_md5sums $(DEBHELPER_PACKAGES_DEB)
175 dh_builddeb $(DEBHELPER_PACKAGES_DEB)
Glenn L McGrathc4698b32002-12-08 20:45:47 +0000176
Glenn L McGratha43facc2004-01-01 00:23:01 +0000177# Build architecture-dependent files here.
178binary-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
Glenn L McGrath4957fc72003-04-06 15:35:52 +0000189 $(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 )
Glenn L McGrath12371f92002-11-26 02:16:06 +0000194
Glenn L McGrathc4698b32002-12-08 20:45:47 +0000195binary: binary-arch
Glenn L McGrath6fc6d7f2002-12-01 02:09:19 +0000196.PHONY: build clean binary-indep binary-arch binary install