aboutsummaryrefslogtreecommitdiff
path: root/debian/rules
blob: e77b4ef96099c610b96df71a091fb8397808d408 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)

VERSION = $(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CONFIG_DEBUG = true
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
endif

PACKAGE_PREFIX = busybox-cvs

ARCH_FLOPPY_UDEB = $(shell sh debian/control-extract Architecture $(PACKAGE_PREFIX)-floppy-udeb)

PACKAGES_DEB = $(PACKAGE_PREFIX) $(PACKAGE_PREFIX)-static
PACKAGES_UDEB = $(PACKAGE_PREFIX)-udeb
ifneq ($(filter $(DEB_HOST_ARCH),$(ARCH_FLOPPY_UDEB)),)
PACKAGES_UDEB += $(PACKAGE_PREFIX)-floppy-udeb
endif
PACKAGES = $(PACKAGES_DEB) $(PACKAGES_UDEB)

DEBHELPER_PACKAGES_DEB = $(patsubst %,-p%,$(PACKAGES_DEB))
DEBHELPER_PACKAGES_UDEB = $(patsubst %,-p%,$(PACKAGES_UDEB))

CONFIG = $(firstword $(wildcard ./debian/config-$(1)-$(DEB_HOST_GNU_SYSTEM)-$(DEB_HOST_GNU_CPU) ./debian/config-$(1)-$(DEB_HOST_GNU_SYSTEM) ./debian/config-$(1)))
CONFIG_DEB = $(call CONFIG,deb)
CONFIG_STATIC = $(call CONFIG,static)
CONFIG_UDEB = $(call CONFIG,udeb)
CONFIG_FLOPPY_UDEB = $(call CONFIG,floppy-udeb)

configure: configure-stamp
configure-stamp:
	sh ./configure

	touch $@

build-arch: build-arch-deb-all build-arch-udeb-all
build-arch-deb-all: build-arch-deb build-arch-static build-arch-doc
build-arch-udeb-all: build-arch-udeb build-arch-floppy-udeb

build-arch-deb: build-arch-deb-stamp
build-arch-deb-stamp: configure-stamp
	$(MAKE) clean

	cp $(CONFIG_DEB) .config

	$(MAKE) dep
	$(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)

	install -d install-$(PACKAGE_PREFIX)/bin
	install busybox install-$(PACKAGE_PREFIX)/bin/busybox

	touch $@

build-arch-static: build-arch-static-stamp
build-arch-static-stamp: configure-stamp
	$(MAKE) clean

	cp $(CONFIG_STATIC) .config

	$(MAKE) dep
	$(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)

	install -d install-$(PACKAGE_PREFIX)-static/bin
	install busybox install-$(PACKAGE_PREFIX)-static/bin/busybox

	touch $@

build-arch-udeb: build-arch-udeb-stamp
build-arch-udeb-stamp: configure-stamp
	$(MAKE) clean

	cp $(CONFIG_UDEB) .config

	$(MAKE) dep
	$(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)

	$(MAKE) PREFIX=$(CURDIR)/install-$(PACKAGE_PREFIX)-udeb install
	# Remove init link, but init support is still compiled in to be
	# used.
	rm -f $(CURDIR)/install-$(PACKAGE_PREFIX)-udeb/sbin/init

	touch $@

build-arch-floppy-udeb: build-arch-floppy-udeb-stamp
build-arch-floppy-udeb-stamp: configure-stamp
ifneq ($(filter $(DEB_HOST_ARCH),$(ARCH_FLOPPY_UDEB)),)
	$(MAKE) clean

	cp $(CONFIG_FLOPPY_UDEB) .config

	$(MAKE) dep
	$(MAKE) CONFIG_DEBUG=$(CONFIG_DEBUG)

	$(MAKE) PREFIX=$(CURDIR)/install-$(PACKAGE_PREFIX)-floppy-udeb install
endif

	touch $@

build-arch-doc: build-arch-doc-stamp
build-arch-doc-stamp: configure-stamp
	$(MAKE) docs/BusyBox.1

	cp docs/BusyBox.1 busybox.1

	touch $@

build: build-arch

clean:
	dh_testdir
	dh_testroot
	rm -f build-*-stamp configure-stamp debian/files~

	-$(MAKE) distclean
	-rm -rf busybox-deb busybox-static install* busybox.1

	dh_clean

install-deb: build-arch-deb-all
	dh_testdir
	dh_testroot
	dh_clean -k $(DEBHELPER_PACKAGES_DEB)
	dh_installdirs $(DEBHELPER_PACKAGES_DEB)

	for i in $(PACKAGES_DEB); do \
	( \
		cd install-$$i; \
		find -type d -exec install -d $(CURDIR)/debian/$$i/{} \;; \
		find \( -type f -o -type l \) -exec cp -a {} $(CURDIR)/debian/$$i/{} \;; \
	); \
	done

	install -m644 debian/$(PACKAGE_PREFIX)-static.override \
		debian/$(PACKAGE_PREFIX)-static/usr/share/lintian/overrides/$(PACKAGE_PREFIX)-static

install-udeb: build-arch-udeb-all
	dh_testdir
	dh_testroot
	dh_clean -k $(DEBHELPER_PACKAGES_UDEB)
	dh_installdirs $(DEBHELPER_PACKAGES_UDEB)

	for i in $(PACKAGES_UDEB); do \
	( \
		cd install-$$i; \
		find -type d -exec install -d $(CURDIR)/debian/$$i/{} \;; \
		find \( -type f -o -type l \) -exec cp -a {} $(CURDIR)/debian/$$i/{} \;; \
	); \
	done

binary-arch: binary-arch-deb binary-arch-udeb

# Build architecture-dependent files here.
binary-arch-deb: build-arch-deb-all install-deb
	dh_testdir
	dh_testroot
	dh_installdocs $(DEBHELPER_PACKAGES_DEB)
	dh_installman $(DEBHELPER_PACKAGES_DEB)
	dh_installchangelogs Changelog $(DEBHELPER_PACKAGES_DEB)
	dh_strip $(DEBHELPER_PACKAGES_DEB)
	dh_link $(DEBHELPER_PACKAGES_DEB)
	dh_compress $(DEBHELPER_PACKAGES_DEB)
	dh_fixperms $(DEBHELPER_PACKAGES_DEB)
	dh_installdeb $(DEBHELPER_PACKAGES_DEB)
	dh_shlibdeps $(DEBHELPER_PACKAGES_DEB)
	dh_gencontrol $(DEBHELPER_PACKAGES_DEB)
	dh_md5sums $(DEBHELPER_PACKAGES_DEB)
	dh_builddeb $(DEBHELPER_PACKAGES_DEB)

# Build architecture-dependent files here.
binary-arch-udeb: build-arch-udeb-all install-udeb
	dh_testdir
	dh_testroot
	dh_strip $(DEBHELPER_PACKAGES_UDEB)
	dh_link $(DEBHELPER_PACKAGES_UDEB)
	dh_compress $(DEBHELPER_PACKAGES_UDEB)
	dh_fixperms $(DEBHELPER_PACKAGES_UDEB)
	dh_installdeb $(DEBHELPER_PACKAGES_UDEB)
	dh_shlibdeps $(DEBHELPER_PACKAGES_UDEB)
	dh_gencontrol $(DEBHELPER_PACKAGES_DEB)

	$(foreach PACKAGE, $(PACKAGES_UDEB), \
	dh_gencontrol -p$(PACKAGE) -- -fdebian/files~; \
	dpkg-distaddfile $(PACKAGE)_$(VERSION)_$(DEB_HOST_ARCH).udeb debian-installer extra; \
	dh_builddeb -p$(PACKAGE) --filename=$(PACKAGE)_$(VERSION)_$(DEB_HOST_ARCH).udeb; \
	)

binary: binary-arch
.PHONY: build clean binary-indep binary-arch binary install