Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2 # Copyright © 2002,2003 Colin Walters <[email protected]>
3 # Copyright © 2003 Daniel Stone <[email protected]>
4 # Copyright © 2006 Sjoerd Simons <[email protected]>
5 # Copyright © 2011 Michael Biebl <[email protected]>
6
7 export DEB_BUILD_MAINT_OPTIONS = hardening=+pie,+bindnow
8
9 include /usr/share/dpkg/default.mk
10
11 %:
12 dh $@ $(dh_options)
13
14 libdbusN := $(shell sed -rn 's/Package:[[:space:]]*(libdbus-[0-9-]+)[[:space:]]*$$/\1/p' debian/control | head -n 1)
15 libdbus_soname := $(patsubst libdbus-1-%,libdbus-1.so.%,$(libdbusN))
16 debug_build_prefix := /usr/lib/dbus-1.0/debug-build
17 binaries := $(shell dh_listpackages)
18
19 export DEB_LDFLAGS_MAINT_APPEND = -Wl,--gc-sections
20
21 dh_options = \
22 --builddirectory=debian/build-main \
23 --buildsystem=meson \
24 --with xml-core \
25 --without autoreconf \
26 $(NULL)
27
28 common_configure_flags := \
29 --libexecdir=lib/dbus-1.0 \
30 -Dmessage_bus=true \
31 -Dsystem_socket=/run/dbus/system_bus_socket \
32 -Dtools=true \
33 -Dtraditional_activation=true \
34 $(NULL)
35
36
37 ifeq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
38 common_configure_flags += --native-file $(CURDIR)/debian/meson-binaries.txt
39 else
40 common_configure_flags += --cross-file $(CURDIR)/debian/meson-binaries.txt
41 endif
42
43 normal_configure_flags := \
44 -Ddefault_library=both \
45 $(NULL)
46
47 ifeq ($(DEB_HOST_ARCH_OS),linux)
48 # Non-bootstrap build on Linux: add Linux-specifics
49 common_configure_flags += \
50 -Dapparmor=enabled \
51 -Dlibaudit=enabled \
52 -Dselinux=enabled\
53 -Dsession_socket_dir=/tmp \
54 -Dsystemd=enabled \
55 -Dsystemd_system_unitdir=/usr/lib/systemd/system \
56 -Dtest_socket_dir=/tmp \
57 $(NULL)
58 normal_configure_flags += \
59 -Dsystemd_user_unitdir=/usr/lib/systemd/user \
60 -Duser_session=true \
61 $(NULL)
62 endif
63
64 debug_configure_flags := \
65 -Dasserts=true \
66 -Dchecks=true \
67 -Ddefault_library=both \
68 -Ddoxygen_docs=disabled \
69 -Dducktype_docs=disabled \
70 -Dvalgrind=auto \
71 -Dverbose_mode=true \
72 -Dxml_docs=disabled \
73 --bindir='${debug_build_prefix}/bin' \
74 --libdir='${debug_build_prefix}/lib' \
75 --libexecdir='${debug_build_prefix}/libexec' \
76 $(NULL)
77
78 udeb_configure_flags := \
79 $(normal_configure_flags) \
80 -Dapparmor=disabled \
81 -Dasserts=false \
82 -Dchecks=false \
83 -Ddefault_library=shared \
84 -Ddoxygen_docs=disabled \
85 -Dducktype_docs=disabled \
86 -Dinstalled_tests=false \
87 -Dlibaudit=disabled \
88 -Doptimization=s \
89 -Dselinux=disabled \
90 -Dstats=false \
91 -Dsystemd=disabled \
92 -Duser_session=false \
93 -Dverbose_mode=false \
94 -Dxml_docs=disabled \
95 $(NULL)
96
97 ifneq ($(filter dbus-tests,$(binaries)),)
98 common_configure_flags += -Dinstalled_tests=true
99 else
100 common_configure_flags += -Dinstalled_tests=false
101 endif
102
103 # Some features are needed whenever we have build-time *or* installed tests
104 ifneq ($(filter nocheck,$(DEB_BUILD_OPTIONS))$(filter dbus-tests,$(binaries)),nocheck)
105 debug_configure_flags += -Dintrusive_tests=true
106 endif
107
108 ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
109 normal_configure_flags += -Dxml_docs=enabled
110 else
111 normal_configure_flags += -Dxml_docs=disabled
112 endif
113
114 ifneq ($(filter dbus-1-doc,$(binaries)),)
115 normal_configure_flags += -Ddoxygen_docs=enabled
116 normal_configure_flags += -Dducktype_docs=enabled
117 else
118 normal_configure_flags += -Ddoxygen_docs=disabled
119 normal_configure_flags += -Dducktype_docs=disabled
120 endif
121
122 override_dh_auto_configure:
123 dh_auto_configure \
124 -- \
125 $(common_configure_flags) \
126 $(normal_configure_flags) \
127 $(NULL)
128 ifneq ($(filter dbus-tests,$(binaries)),)
129 LDFLAGS='$(LDFLAGS) -Wl,-rpath,${debug_build_prefix}/lib' \
130 dh_auto_configure \
131 --builddirectory=debian/build-debug \
132 -- \
133 $(common_configure_flags) \
134 $(debug_configure_flags) \
135 $(NULL)
136 endif
137 ifneq ($(filter dbus-udeb,$(binaries)),)
138 dh_auto_configure \
139 --builddirectory=debian/build-udeb \
140 -- \
141 $(common_configure_flags) \
142 $(udeb_configure_flags) \
143 $(NULL)
144 endif
145
146 override_dh_auto_build:
147 dh_auto_build
148 ifneq ($(filter dbus-tests,$(binaries)),)
149 dh_auto_build --builddirectory=debian/build-debug
150 endif
151 ifneq ($(filter dbus-udeb,$(binaries)),)
152 dh_auto_build --builddirectory=debian/build-udeb
153 endif
154
155 meson_test_flags = \
156 --timeout-multiplier 3 \
157 -v \
158 $(NULL)
159
160 handle-test-failure:
161 ifeq ($(DEB_HOST_ARCH_OS),linux)
162 @echo "Build-time tests failed, please debug"
163 @false
164 else
165 @echo "Ignoring build-time test failure on non-Linux for now"
166 endif
167
168 test_env = \
169 -u DISPLAY \
170 DBUS_TEST_HOMEDIR=$${HOME} \
171 LD_PRELOAD=libnss_wrapper.so \
172 NSS_WRAPPER_HOSTS=$(CURDIR)/debian/hosts \
173 $(NULL)
174
175 override_dh_auto_test-arch:
176 ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
177 env $(test_env) \
178 dh_auto_test -- $(meson_test_flags) \
179 || make -f debian/rules handle-test-failure
180 ifneq ($(filter dbus-tests,$(binaries)),)
181 env $(test_env) \
182 dh_auto_test --builddirectory=debian/build-debug -- $(meson_test_flags) \
183 || make -f debian/rules handle-test-failure
184 endif
185 ifneq ($(filter dbus-udeb,$(binaries)),)
186 env $(test_env) \
187 dh_auto_test --builddirectory=debian/build-udeb -- $(meson_test_flags) \
188 || make -f debian/rules handle-test-failure
189 endif
190 endif
191
192 override_dh_auto_test-indep:
193 :
194
195 override_dh_auto_install:
196 ifneq ($(filter dbus-udeb,$(binaries)),)
197 # udeb build
198 dh_auto_install --builddirectory=debian/build-udeb --destdir=$(CURDIR)/debian/tmp-udeb
199 cd $(CURDIR)/debian/tmp-udeb && find | LC_ALL=C sort
200 endif
201 ifneq ($(filter dbus-tests,$(binaries)),)
202 # debug build
203 dh_auto_install --builddirectory=debian/build-debug --destdir=$(CURDIR)/debian/tmp
204 rm -rfv debian/tmp/etc
205 rm -rfv debian/tmp/usr/include
206 rm -rfv debian/tmp/usr/lib/systemd
207 rm -rfv debian/tmp/usr/lib/sysusers.d
208 rm -rfv debian/tmp/usr/share/dbus-1
209 rm -rfv debian/tmp/usr/share/doc
210 rm -rfv debian/tmp/usr/share/man
211 rm -rfv debian/tmp/usr/share/xml
212 mv debian/tmp/usr/share/installed-tests/dbus \
213 debian/tmp/usr/share/installed-tests/dbus-debug-build
214 sed -i -e \
215 "s,^Exec=,Exec=sh -c 'export PATH=/usr/lib/dbus-1.0/debug-build/bin:\$$PATH; exec \"\$$@\"' sh ," \
216 debian/tmp/usr/share/installed-tests/dbus-debug-build/*.test
217 rm -f debian/tmp/${debug_build_prefix}/libexec/installed-tests/dbus/data/sha-1/Readme.txt
218 cd $(CURDIR)/debian/tmp && find | LC_ALL=C sort
219 endif
220 # normal build (do this last so that it overwrites the others)
221 dh_auto_install
222 rm -f debian/tmp/usr/lib/dbus-1.0/installed-tests/dbus/data/sha-1/Readme.txt
223 ifeq ($(filter nodoc pkg.dbus.minimal,$(DEB_BUILD_PROFILES)),)
224 # Reproducible build: sed out the generated dates from the man pages.
225 sed -i \
226 -e '/^\.\\\" *Date: .*/d' \
227 -e 's/^\(.TH "[^"]*" "[^"]*" \)"[^"]*"/\1""/' \
228 debian/tmp/usr/share/man/man?/*
229 endif
230 ifeq ($(filter dbus-tests,$(binaries)),)
231 # noinsttest builds dbus-test-tool but not dbus-tests
232 rm -f debian/tmp/usr/bin/dbus-test-tool
233 endif
234 ifeq ($(filter dbus-1-doc,$(binaries)),)
235 # nodoc builds still install a bit of documentation
236 rm -fr debian/tmp/usr/share/doc/dbus
237 endif
238 # Remove the legacy bus configuration files. We move their old
239 # versions out of the way, include the moved names in the new
240 # bus setup instead of the old names, and replace the old names
241 # with a symlink to the new bus setup so that old dbus-daemons
242 # can still reload their configuration.
243 rm -f debian/tmp/etc/dbus-1/session.conf
244 rm -f debian/tmp/etc/dbus-1/system.conf
245
246 ifeq ($(DEB_DISTRIBUTION),UNRELEASED)
247 # We can't expect the install files to be fully up to date for a snapshot.
248 dh_missing_options += --list-missing
249 else
250 dh_missing_options += --fail-missing
251 endif
252
253 override_dh_missing:
254 dh_missing $(dh_missing_options)
255
256 # Yes, we do need both --no- options here. https://bugs.debian.org/837528
257 override_dh_installinit:
258 dh_installinit -pdbus --no-stop-on-upgrade --no-restart-after-upgrade
259 override_dh_installsystemd:
260 dh_installsystemd -pdbus --no-stop-on-upgrade --no-restart-after-upgrade
261
262 override_dh_installdocs:
263 dh_installdocs --all AUTHORS NEWS README
264
265 debian/$(libdbusN).symbols: debian/$(libdbusN).symbols.in
266 sed -e 's/$${DEB_VERSION}/${DEB_VERSION}/g' \
267 < $< > $@
268
269 ifeq ($(DEB_DISTRIBUTION),UNRELEASED)
270 # We can't expect the symbols file to be fully up to date for a snapshot,
271 # so only fail if we broke ABI. This overrides the -c4 below.
272 export DPKG_GENSYMBOLS_CHECK_LEVEL = 1
273 endif
274
275 override_dh_makeshlibs: debian/$(libdbusN).symbols
276 dh_makeshlibs -Ndbus-tests -V --add-udeb=$(libdbusN)-udeb -- -c4
277
278 override_dh_shlibdeps:
279 ifneq ($(filter dbus-tests,$(binaries)),)
280 dh_shlibdeps -pdbus-tests -l'debian/dbus-tests${debug_build_prefix}/lib'
281 endif
282 dh_shlibdeps --remaining-packages