Debian Codegraph @

debian/rules

raw symbols SCIP
1 #!/usr/bin/make -f
2 SHELL = /bin/sh -e
3
4 # in order to keep output non-intermixed together, disable parallel building
5 # of different targets in this d/rules but allow running parallel submakes
6 .NOTPARALLEL:
7 # DEB_BUILD_OPTIONS=parallel=N
8 MAKEFLAGS += $(subst parallel=,-j,$(filter parallel=%,${DEB_BUILD_OPTIONS}))
9
10 # Uncomment this to turn on verbose mode.
11 #export DH_VERBOSE=1
12 V = $(if $(filter terse, ${DEB_BUILD_OPTIONS}),,1)
13
14 # Activate full hardening build flags
15 export DEB_BUILD_MAINT_OPTIONS := hardening=+all
16 # Fast version of dpkg/architecture.mk defining all vars in one go
17 ifeq (${DEB_HOST_MULTIARCH},)
18 $(foreach d, $(shell dpkg-architecture | sed 's/=/?=/'), $(eval export $d))
19 endif
20 include /usr/share/dpkg/default.mk
21
22 ##############################################################################
23
24 TESTSUITE_ENV = SKIP_KNOWN_BUGS=y
25 #TESTSUITE_ENV = VERBOSE=y
26 # always run tests in UTF8 mode to verify unicode support
27 TESTSUITE_ENV += LANG=C.UTF-8 LC_ALL=C.UTF-8
28 TESTSUITE_ENV += SKIP_INTERNET_TESTS=y
29 # Required for testsuite/taskset.tests
30 TESTSUITE_ENV += SHELL='${SHELL}'
31 # dash echo does not understand -e, bb builds its own in this case
32 TESTSUITE_ENV += ECHO=/bin/echo
33
34 # build directory
35 b = b
36
37 # which flavours to build
38 flavours = deb static udeb
39
40 ifneq (${DEB_HOST_GNU_TYPE},${DEB_BUILD_GNU_TYPE})
41 export CROSS_COMPILE = ${DEB_HOST_GNU_TYPE}-
42 endif
43
44 # We filter the following from CFLAGS:
45 # -O2
46 # to use the optimization setting from busybox's configuration and build
47 # system, causing it to use -Os. This reduces built binaries' size
48 # considerably, making it easier to fit on space constrained systems.
49 CFLAGS := $(filter-out -O2, ${CFLAGS})
50
51 # Avoid Kconfig outputting the timestamp into generated configuration files. We
52 # use this to compare against the configuration files in debian/config/pkg for
53 # builds on Linux so that we can detect upstream configuration changes (e.g.
54 # added applets).
55 export KCONFIG_NOTIMESTAMP=1
56
57 install-indep install-arch install \
58 binary-indep binary-arch binary \
59 : %:
60 dh $@
61
62 ##############################################################################
63
64 configure: $(patsubst %,$b/%/.stamp-setup, ${flavours})
65 $(addprefix configure-,${flavours}): configure-%: $b/%/.stamp-setup
66 .PHONY: configure $(addprefix configure-,${flavours})
67
68 $b/%/.stamp-setup: d = $b/$*
69 $b/%/.stamp-setup:
70 rm -rf $d
71 mkdir -p $d
72
73 # Generate the .config file. First variable assignment wins.
74 # Several steps..
75
76 # 1, put any arch-specific overrides so they will have higher precedence
77 # should be empty for linux
78 cat debian/config/os/${DEB_HOST_ARCH_OS} > $d/.config
79
80 # 2, use the flavour-specific base config file.
81 cat debian/config/pkg/$* >> $d/.config
82
83 # 3, sort out the result using oldconfig Kbuild machinery and generate Makefile
84 yes "" | ${MAKE} -C $d -f "${CURDIR}/Makefile" KBUILD_SRC="${CURDIR}" silentoldconfig V=$V
85
86 # 4, on linux platform only, compare the re-generated config to the shipped
87 # config in the package in order to catch new/changed upstream options.
88 ifeq (linux,${DEB_HOST_ARCH_OS})
89 diff -u debian/config/pkg/$* $d/.config
90 endif
91
92 ln -s .config $@
93
94 ##############################################################################
95
96 build-arch: $(patsubst %,$b/%/.stamp-build, ${flavours})
97 build: build-arch
98 $(addprefix build-,${flavours}): build-%: $b/%/.stamp-build
99 build-indep:
100 .PHONY: build build-arch build-indep $(addprefix build-,${flavours})
101
102 # busybox build procedure is very sensitive for (environment) variables, it will
103 # remake everything if CFLAGS or LD has changed between build and install phases
104 # (and install depends on build, so busybox will be rebuilt during install if
105 # any env var has changed).
106 # Another problem is that upstream build system (as of 1.35) can not take more
107 # than a single target to build when building in parallel, the build fails in
108 # this case. So we can not ask it for `all install' for example.
109 # To work around this, we use the upstream makefile only at the build stage,
110 # providing all environment explicitly in a single place.
111 # And installing will be done without the help from upstream makefiles,
112 # based on the information in the generated busybox.links file.
113
114 $b/%/.stamp-build: d = $b/$*
115 $b/%/.stamp-build: $b/%/.stamp-setup
116 ${MAKE} -C $d all \
117 SKIP_STRIP=y \
118 BB_EXTRA_VERSION="${DEB_VENDOR} ${DEB_VERSION}" \
119 CONFIG_EXTRA_CFLAGS='${CFLAGS} ${CPPFLAGS}' \
120 CONFIG_EXTRA_LDFLAGS='${CFLAGS} ${LDFLAGS}' \
121 V=$V
122 ${MAKE} -C $d busybox.links
123 ln -sf busybox $@
124
125 ##############################################################################
126
127 build-arch: $(if $(filter nocheck,${DEB_BUILD_OPTIONS}),,test-deb)
128 $(addprefix test-,${flavours}): test-%: $b/%/.stamp-test
129 .PHONY: $(addprefix test-,${flavours})
130
131 $b/%/.stamp-test: d = $b/$*
132 $b/%/.stamp-test: $b/%/.stamp-build
133 @echo ======== running testsuite in $d ========
134 @if [ ! -f $d/testsuite/.setup ]; then \
135 rm -rf $d/testsuite ; \
136 cp -al testsuite $d/ ; \
137 rm -f $d/testsuite/mdev.tests; \
138 [ ! -f debian/testsuite-${DEB_HOST_ARCH_OS}.diff ] || \
139 patch -p1 -d $d/ \
140 < debian/testsuite-${DEB_HOST_ARCH_OS}.diff ; \
141 touch $d/testsuite/.setup ; \
142 fi
143 cd $d/testsuite && ${TESTSUITE_ENV} ./runtest
144 touch $@
145
146 ##############################################################################
147
148 clean:
149 dh_clean $b/
150 rm -f .kernelrelease # leftover from the build process
151 .PHONY: clean
152
153 ##############################################################################
154
155 override_dh_auto_install:
156
157 execute_after_dh_link-arch:
158 # for udeb we also need links. But we can not easily use `make install'
159 # (see comment above). So we run the install rules directly here:
160 dh_link -pbusybox-udeb \
161 $$(grep -v sbin/init $b/udeb/busybox.links | \
162 sed -e 's|/usr/|/|' -e 's|^|/usr/bin/busybox /usr|')
163
164 execute_before_dh_gencontrol-arch:
165 # after shlibdeps finished, grab ${shlibs:Depends} from busybox package
166 # and transform it into Built-Using field (also dpkg-query bug #588505)
167 pkgs=$$(sed -n -e's/([^)]*)//g' -e's/,//g' -e's/^shlibs:Depends=//p' debian/busybox.substvars); \
168 srcs=; for p in $$pkgs; do \
169 srcs="$$srcs $$(dpkg-query -f '$${source:Package} (= $${source:Version}),' -W $$p)"; \
170 done ; \
171 echo "built-using=$$srcs" >> debian/busybox-static.substvars
172
173 # install busybox-klogd startup scripts
174 execute_before_dh_installinit:
175 dh_installinit -pbusybox-syslogd --name=busybox-klogd
176 override_dh_installsystemd:
177 # explicitly list all packages with .service files here
178 dh_installsystemd -pbusybox-syslogd --name=busybox-klogd
179 dh_installsystemd -pbusybox-syslogd
180 dh_installsystemd -pudhcpd --no-enable