Debian Codegraph @

debian/rules

raw symbols SCIP
1 #!/usr/bin/make -f
2 #-
3 # Possible flavourisation in DEB_BUILD_OPTIONS (in addition
4 # to stock Debian rules):
5 # - static (use with system libc; default for all others)
6 # - shared (use with klibc or musl)
7 # - diet, klibc, musl
8 # - debug (adds -Og -g3)
9 # - nopwnam (aids static linkage)
10 # - nofpu (default with klibc or dietlibc)
11 # - nommu
12 # - nolibs (use with system libc; default for all others)
13 # - noautotools (on systems lacking autotools-dev)
14 # - noselinux
15 # The 'nostrip' and 'parallel=n' options are supported as well.
16 #
17 # Targetting:
18 # - (none) ⇒ sid, bullseye, buster; focal, bionic
19 # - wheezy ⇒ wheezy, jessie, stretch; trusty, xenial
20 # - lenny ⇒ lenny, squeeze; precise
21 # - sarge ⇒ sarge, etch
22 #
23 # Using a non-system libc disables -O0/-O2 and -g and, if unset,
24 # sets CC. Cross-compiling also sets CC if unset.
25 #
26 # Statically linking violates the Policy requirement of having a
27 # Built-Using header, but since that is only used in local rebuilds
28 # and not in the Debian archive, it constitutes no Policy violation.
29
30 ifeq (,$(filter terse,${DEB_BUILD_OPTIONS}))
31 export DH_VERBOSE=1
32 export V=1
33 export VERBOSE=1
34 endif
35
36 LC_ALL:=C
37 export LC_ALL
38
39 shellescape='$(subst ','\'',$(1))'
40 shellexport=$(1)=$(call shellescape,${$(1)})
41
42 USE_LIBC:=
43 ifneq (,$(filter diet,${DEB_BUILD_OPTIONS}))
44 USE_LIBC+= dietlibc
45 endif
46 ifneq (,$(filter klibc,${DEB_BUILD_OPTIONS}))
47 USE_LIBC+= klibc
48 endif
49 ifneq (,$(filter musl,${DEB_BUILD_OPTIONS}))
50 USE_LIBC+= musl
51 endif
52 ifeq (,$(filter diet,${DEB_BUILD_OPTIONS})$(filter klibc,${DEB_BUILD_OPTIONS})$(filter musl,${DEB_BUILD_OPTIONS}))
53 USE_LIBC+= system
54 endif
55 ifneq ($(strip ${USE_LIBC}),$(firstword ${USE_LIBC}))
56 $(error multiple libcs (${USE_LIBC}) found in (${DEB_BUILD_OPTIONS}))
57 endif
58 USE_LIBC:=$(strip ${USE_LIBC})
59
60 ifeq (${USE_LIBC},system)
61 USE_SHARED:=1
62 USE_LIBS:=1
63 else
64 USE_SHARED:=0
65 USE_LIBS:=0
66 endif
67
68 ifneq (,$(filter shared,${DEB_BUILD_OPTIONS}))
69 USE_SHARED:=1
70 endif
71 ifneq (,$(filter static,${DEB_BUILD_OPTIONS}))
72 USE_SHARED:=0
73 endif
74
75 USE_PWNAM:=1
76 ifneq (,$(filter nopwnam,${DEB_BUILD_OPTIONS}))
77 USE_PWNAM:=0
78 endif
79
80 USE_FPU:=1
81 ifneq (,$(filter nofpu,${DEB_BUILD_OPTIONS}))
82 USE_FPU:=0
83 endif
84
85 USE_MMU:=1
86 ifneq (,$(filter nommu,${DEB_BUILD_OPTIONS}))
87 USE_MMU:=0
88 endif
89
90 ifneq (,$(filter nolibs,${DEB_BUILD_OPTIONS}))
91 USE_LIBS:=0
92 endif
93
94 USE_SELINUX:=1
95 ifneq (,$(filter noselinux,${DEB_BUILD_OPTIONS}))
96 USE_SELINUX:=0
97 endif
98 ifeq (0,${USE_LIBS})
99 USE_SELINUX:=0
100 endif
101
102 ifneq (,$(wildcard /usr/share/dpkg/architecture.mk))
103 include /usr/share/dpkg/architecture.mk
104 else
105 DEB_BUILD_ARCH?=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
106 DEB_BUILD_GNU_TYPE?=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
107 DEB_HOST_ARCH?=$(shell dpkg-architecture -qDEB_HOST_ARCH)
108 DEB_HOST_GNU_TYPE?=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
109 endif
110
111 ifneq (,$(wildcard /usr/share/dpkg/buildtools.mk))
112 include /usr/share/dpkg/buildtools.mk
113 else
114 # is ${CC} defined anywhere (other than implicit rules?)
115 ifneq (,$(filter $(origin CC),default undefined))
116 # no - then default to gcc (or cross-gcc)
117 ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
118 CC= ${DEB_HOST_GNU_TYPE}-gcc
119 else
120 CC= gcc
121 endif
122 endif
123 endif
124 # other libc choices override this
125 ifeq (${USE_LIBC},dietlibc)
126 CC= diet -Os gcc
127 endif
128 ifeq (${USE_LIBC},klibc)
129 CC= klcc
130 endif
131 ifeq (${USE_LIBC},musl)
132 CC= musl-gcc
133 endif
134
135 EXTRA_CFLAGS:=
136 EXTRA_LDFLAGS:=
137
138 # GCC 15 defaults to C23; joe and jupp need K&R-style polymorphism atm
139 EXTRA_CFLAGS+= -std=gnu99
140
141 ifneq (,$(filter debug,${DEB_BUILD_OPTIONS}))
142 EXTRA_CFLAGS+= -Og -g3
143 endif
144
145 EXTRA_CFLAGS+= -Wall -Wformat
146 EXTRA_CFLAGS+= -fno-omit-frame-pointer -fno-strict-aliasing
147 ifeq (,$(filter sarge,${DEB_BUILD_OPTIONS}))
148 EXTRA_CFLAGS+= -fwrapv
149 EXTRA_CFLAGS+= -Wextra
150 EXTRA_CFLAGS+= -Wno-pointer-sign
151 else
152 EXTRA_CFLAGS+= -W
153 endif
154 EXTRA_CFLAGS+= -Wno-unused-parameter
155 EXTRA_CFLAGS+= -Wno-strict-prototypes
156
157 DSF:= 3.0 (quilt)
158 SUBST_EP:= -e '/@PRIO@EXTRA@/d'
159 HOMEPAGE:= http://www.mirbsd.org/jupp.htm
160 SUBST_HP:= -e '/@HP@DOT@/d' -e '/@HP@OLD@/d' -e 's@HP@MODERN@${HOMEPAGE}'
161 SELINUX_DEP:= libselinux1-dev [linux-any]
162 MENU_SUBST:= cat
163 USE_MENU:= 0
164
165 BREAKS:= Breaks
166 SUBST_VARS+= BREAKS
167
168 # buster, bullseye, sid
169 DEBHELPER_COMPAT:= 13
170 SUBST_R3:= -e 's/@@R3@@/Rules-Requires-Root: no/'
171 # wheezy, jessie, stretch
172 ifneq (,$(filter wheezy,${DEB_BUILD_OPTIONS}))
173 DEBHELPER_COMPAT:= 9
174 USE_MENU:= 1
175 SUBST_R3:= -e '/@@R3@@/d'
176 endif
177 # lenny, squeeze, sarge, etch
178 ifneq (,$(filter lenny,${DEB_BUILD_OPTIONS})$(filter sarge,${DEB_BUILD_OPTIONS}))
179 DEBHELPER_COMPAT:= 5
180 USE_MENU:= 1
181 DSF:= 1.0
182 SUBST_EP:= -e 's/@PRIO@EXTRA@/Priority: extra/'
183 BREAKS:= Conflicts
184 SUBST_R3:= -e '/@@R3@@/d'
185 SELINUX_DEP:= libselinux1-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386]
186 # sarge, etch
187 ifneq (,$(filter sarge,${DEB_BUILD_OPTIONS}))
188 SELINUX_DEP:= libselinux1-dev
189 SUBST_HP:= -e '/@HP@MODERN@/d' -e '/^VCS-[gB][ir][to][:w]/d' \
190 -e 's/@HP@DOT@//' -e 's@HP@OLD@${HOMEPAGE}'
191 MENU_SUBST:= sed 's!"Applications/!"Apps/!'
192 endif
193 endif
194
195 DEBHELPER_VERSION?= ${DEBHELPER_COMPAT}
196 ifeq (,$(filter ${DEBHELPER_COMPAT},10 9 5 4))
197 DSC_DEPS:= debhelper-compat (= ${DEBHELPER_COMPAT})
198 ifneq (${DEBHELPER_VERSION},${DEBHELPER_COMPAT})
199 DSC_DEPS:= ${DSC_DEPS}, debhelper (>= ${DEBHELPER_VERSION})
200 endif
201 else
202 DSC_DEPS:= debhelper (>= ${DEBHELPER_VERSION})
203 endif
204 SUBST_VARS+= DSC_DEPS
205
206 ifeq (${USE_LIBC},dietlibc)
207 DSC_DEPS:= ${DSC_DEPS}, dietlibc-dev
208 USE_SHARED:=0
209 USE_FPU:=0
210 EXTRA_CFLAGS+= -fno-stack-protector
211 endif
212
213 ifeq (${USE_LIBC},klibc)
214 DSC_DEPS:= ${DSC_DEPS}, libklibc-dev
215 USE_FPU:=0
216 EXTRA_CFLAGS+= -fno-stack-protector
217 ifeq (1,${USE_SHARED})
218 CC+= -shared
219 endif
220 endif
221
222 ifeq (${USE_LIBC},musl)
223 DSC_DEPS:= ${DSC_DEPS}, musl-tools
224 EXTRA_CFLAGS+= -Os
225 ifeq (0,${USE_SHARED})
226 EXTRA_LDFLAGS+= -static
227 endif
228 CONFIGURE_ENV+= ac_cv_header_sys_termios_h=no
229 endif
230
231 ifeq (${USE_LIBC},system)
232 ifeq (0,${USE_SHARED})
233 EXTRA_LDFLAGS+= -static
234 endif
235 endif
236
237 ifneq (,$(wildcard /usr/share/dpkg/buildflags.mk))
238 # dpkg-dev (>= 1.16.1~)
239 dpkgbuildflagsmkescape=$(subst \,\\\,$(1))
240 export DEB_CFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${EXTRA_CFLAGS})
241 export DEB_LDFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${EXTRA_LDFLAGS})
242 ifneq (${USE_LIBC},system)
243 export DEB_CFLAGS_MAINT_STRIP=-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -g -g1 -g2 -g3 -ggdb -gdwarf -gstabs
244 export DEB_CFLAGS_MAINT_STRIP+=-specs=/usr/share/dpkg/no-pie-compile.specs
245 export DEB_LDFLAGS_MAINT_STRIP+=-specs=/usr/share/dpkg/no-pie-link.specs
246 # do not use PIE with strange libcs
247 export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie optimize=-lto
248 else
249 ifneq (,$(filter static,${DEB_BUILD_OPTIONS}))
250 # cannot mix PIE with static linkage
251 export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie optimize=-lto
252 else
253 export DEB_BUILD_MAINT_OPTIONS=hardening=+all optimize=-lto
254 endif
255 endif
256 include /usr/share/dpkg/buildflags.mk
257 else
258 # old-fashioned way to determine build flags
259 ifneq (${USE_LIBC},system)
260 CFLAGS=
261 else
262 CFLAGS= -O$(if $(filter noopt,${DEB_BUILD_OPTIONS}),0,2) -g
263 endif
264 CFLAGS+= ${EXTRA_CFLAGS}
265 LDFLAGS+= ${EXTRA_LDFLAGS}
266 endif
267
268 ifneq (,$(filter parallel,${DEB_BUILD_OPTIONS}))
269 MAKE_ARGS+= -j
270 else ifneq (,$(filter parallel=%,${DEB_BUILD_OPTIONS}))
271 MAKE_ARGS+= -j$(patsubst parallel=%,%,$(filter parallel=%,${DEB_BUILD_OPTIONS}))
272 endif
273
274 CONFIGURE_ARGS= --build=${DEB_BUILD_GNU_TYPE} \
275 --host=${DEB_HOST_GNU_TYPE} \
276 --prefix=/usr \
277 --sysconfdir=/etc \
278 --mandir=/usr/share/man \
279 --disable-dependency-tracking
280
281 ifeq (0,${USE_PWNAM})
282 CONFIGURE_ARGS+= --disable-getpwnam
283 endif
284
285 ifeq (0,${USE_FPU})
286 CONFIGURE_ARGS+= --disable-fpu
287 endif
288
289 ifeq (0,${USE_MMU})
290 CONFIGURE_ARGS+= --disable-fork
291 endif
292
293 ifeq (0,${USE_LIBS})
294 CONFIGURE_ARGS+= --disable-search-libs \
295 --disable-terminfo
296 else
297 ifneq (,$(filter ${DEBHELPER_COMPAT},10 9 5 4))
298 DSC_DEPS:= ${DSC_DEPS}, libtinfo-dev | libncurses-dev
299 else
300 DSC_DEPS:= ${DSC_DEPS}, libncurses-dev
301 endif
302 endif
303
304 ifeq (1,${USE_SELINUX})
305 DSC_DEPS:= ${DSC_DEPS}, $(strip ${SELINUX_DEP})
306 endif
307
308 ifeq (,$(filter noautotools,${DEB_BUILD_OPTIONS}))
309 ifneq (,$(filter ${DEBHELPER_COMPAT},10 9 5 4))
310 DSC_DEPS:= ${DSC_DEPS}, autotools-dev
311 endif
312 endif
313
314 CONFIGURE_ARGS+= --disable-termidx \
315 --enable-sysconfjoesubdir=/jupp
316
317 debian/.configure_stamp: debian/.control_stamp
318 dh_testdir
319 -rm -f debian/.*_stamp
320 :>debian/.control_stamp # to avoid building twice
321 -rm -rf builddir
322 # apply autotools-dev if it exists
323 for x in config.guess config.sub; do \
324 test -e /usr/share/misc/$$x || continue; \
325 rm -f $$x; \
326 cp /usr/share/misc/$$x .; \
327 done
328 mkdir builddir
329 cd builddir && exec env ${CONFIGURE_ENV} \
330 $(foreach i,CC CFLAGS CPPFLAGS LDFLAGS,$(call shellexport,$i)) \
331 sh ../configure ${CONFIGURE_ARGS}
332 @:>$@
333
334 debian/.build_stamp: debian/.configure_stamp
335 dh_testdir
336 cd builddir && exec ${MAKE}
337 ln -f builddir/joe builddir/jupp
338 ln -f builddir/joe.1 builddir/jupp.1
339 @:>$@
340
341 debian/.control_stamp:
342 @(if test -e debian/control.in; then exit 0; else \
343 echo 'dh_testdir: "debian/control.in" not found.' \
344 Are you sure you are in the correct directory\?; \
345 exit 1; \
346 fi)
347 @mkdir -p debian/source
348 echo '${DSF}' >debian/source/format
349 ifneq (,$(filter ${DEBHELPER_COMPAT},10 9 5 4))
350 echo ${DEBHELPER_COMPAT} >debian/compat
351 endif
352 -rm -f debian/source.lintian-overrides
353 ifneq (,$(filter ${DEBHELPER_COMPAT},10 9 5 4))
354 sed --posix \
355 -e 's! debian-watch-does-not-check-gpg-signature! debian-watch-may-check-gpg-signature!g' \
356 <debian/source/lintian-overrides >debian/source.lintian-overrides
357 endif
358 ifneq (,$(filter 1,${USE_MENU}))
359 ${MENU_SUBST} <debian/joe-jupp.menu.in >debian/joe-jupp.menu
360 ${MENU_SUBST} <debian/jupp.menu.in >debian/jupp.menu
361 endif
362 sed ${SUBST_EP} ${SUBST_HP} ${SUBST_R3} \
363 $(foreach v,${SUBST_VARS},-e 's@@'$(call shellescape,$v)'@@'$(call shellescape,$(strip ${$v}))'') \
364 <debian/control.in >debian/.gencontrol_stamp
365 : bail out if these differ: in those cases,
366 : retry the build, after regenerating debian/control
367 : with cp debian/.gencontrol_stamp debian/control
368 diff -Nu debian/control debian/.gencontrol_stamp
369 : you made it, no worries
370 @:>$@
371
372 debian/control:
373 -debian/rules debian/.control_stamp
374 cp debian/.gencontrol_stamp debian/control
375 -rm -f debian/.control_stamp debian/.gencontrol_stamp
376
377 remove/control:
378 -rm -f debian/.control_stamp debian/.gencontrol_stamp \
379 debian/source/format debian/compat debian/control \
380 debian/source.lintian-overrides \
381 debian/joe-jupp.menu debian/jupp.menu
382
383 ifeq (,$(filter ${DEBHELPER_COMPAT},10 9 5 4))
384 # dh7-style build-ish
385 %:
386 dh $@
387
388 override_dh_auto_configure: debian/.configure_stamp
389 @:
390
391 override_dh_auto_build-arch: debian/.build_stamp
392 @:
393
394 override_dh_auto_build-indep: debian/.configure_stamp
395 cd builddir && exec ${MAKE} jmacsrc joerc jpicorc jstarrc rjoerc
396
397 execute_after_dh_auto_clean:
398 -rm -f debian/.*_stamp
399 -rm -rf builddir
400 # unapply autotools-dev if it exists
401 for x in config.guess config.sub; do \
402 test -e /usr/share/misc/$$x || continue; \
403 rm -f $$x; \
404 done
405
406 ifeq (,$(filter 1,${USE_MENU}))
407 override_dh_installmenu-indep:
408 dh_install -pjoe-jupp \
409 debian/menu/org.mirbsd.Jupp.jmacs.desktop \
410 debian/menu/org.mirbsd.Jupp.joe.desktop \
411 debian/menu/org.mirbsd.Jupp.jpico.desktop \
412 debian/menu/org.mirbsd.Jupp.jstar.desktop \
413 usr/share/applications/
414
415 override_dh_installmenu-arch:
416 dh_install -pjupp \
417 debian/menu/org.mirbsd.Jupp.jupp.desktop \
418 usr/share/applications/
419 endif
420
421 execute_before_dh_link-indep:
422 # will be replaced by links to jupp
423 rm -rf debian/joe-jupp/usr/share/doc/joe-jupp
424
425 else
426 # dh5-style build
427 build: build-arch build-indep
428 build-arch: debian/.build_stamp
429
430 build-indep: debian/.configure_stamp
431 cd builddir && exec ${MAKE} jmacsrc joerc jpicorc jstarrc rjoerc
432
433 clean: debian/.control_stamp
434 dh_testdir
435 -rm -f debian/.*_stamp
436 -rm -rf builddir
437 # unapply autotools-dev if it exists
438 for x in config.guess config.sub; do \
439 test -e /usr/share/misc/$$x || continue; \
440 rm -f $$x; \
441 done
442 dh_clean
443
444 binary-indep: build-indep
445 dh_testdir
446 dh_testroot
447 if command -v dh_prep >/dev/null 2>&1; then dh_prep -i; else dh_clean -i -k; fi
448 dh_installchangelogs -i
449 dh_install -i
450 ifneq (,$(filter 1,${USE_MENU}))
451 dh_installmenu -i
452 else
453 dh_install -pjoe-jupp \
454 debian/menu/org.mirbsd.Jupp.jmacs.desktop \
455 debian/menu/org.mirbsd.Jupp.joe.desktop \
456 debian/menu/org.mirbsd.Jupp.jpico.desktop \
457 debian/menu/org.mirbsd.Jupp.jstar.desktop \
458 usr/share/applications/
459 endif
460 # will be replaced by links to jupp
461 rm -rf debian/joe-jupp/usr/share/doc/joe-jupp
462 if command -v dh_lintian >/dev/null 2>&1; then dh_lintian -i; fi
463 dh_link -i
464 dh_fixperms -i
465 dh_installdeb -i
466 dh_gencontrol -i
467 dh_md5sums -i
468 dh_builddeb -i
469
470 # no -Njupp because that's the only arch:any package
471 binary-arch: build-arch
472 dh_testdir
473 dh_testroot
474 if command -v dh_prep >/dev/null 2>&1; then dh_prep -a; else dh_clean -a -k; fi
475 dh_installchangelogs -a
476 dh_installdocs -a
477 dh_install -a
478 ifneq (,$(filter 1,${USE_MENU}))
479 dh_installmenu -a
480 else
481 dh_install -pjupp \
482 debian/menu/org.mirbsd.Jupp.jupp.desktop \
483 usr/share/applications/
484 endif
485 dh_installman -a
486 if command -v dh_lintian >/dev/null 2>&1; then dh_lintian -a; fi
487 dh_link -a
488 dh_strip -a
489 dh_compress -a
490 dh_fixperms -a
491 dh_installdeb -a
492 dh_shlibdeps -a
493 dh_gencontrol -a
494 dh_md5sums -a
495 dh_builddeb -a
496
497 binary: binary-arch binary-indep
498
499 .PHONY: binary binary-arch binary-indep build build-arch build-indep clean
500 endif
501
502 ifneq (,$(strip ${___DISPLAY_MAKEVARS}))
503 $(foreach var,${___DISPLAY_MAKEVARS},$(info $(strip ${var})=${$(strip ${var})}))
504 $(error ___DISPLAY_MAKEVARS finished for ${___DISPLAY_MAKEVARS})
505 endif
506
507 # useful combinations to test:
508 # DEB_BUILD_OPTIONS= debian/rules debian/.control_stamp
509 # DEB_BUILD_OPTIONS='diet' debian/rules debian/.control_stamp
510 # DEB_BUILD_OPTIONS='klibc' debian/rules debian/.control_stamp
511 # DEB_BUILD_OPTIONS='musl' debian/rules debian/.control_stamp
512 # DEB_BUILD_OPTIONS='static nopwnam' debian/rules debian/.control_stamp
513 # DEB_BUILD_OPTIONS='static nopwnam nolibs' debian/rules debian/.control_stamp
514 # DEB_BUILD_OPTIONS='nommu nolibs' debian/rules debian/.control_stamp
515 # DEB_BUILD_OPTIONS='nofpu nommu nolibs' debian/rules debian/.control_stamp
516 # DEB_BUILD_OPTIONS='wheezy' debian/rules debian/.control_stamp
517 # DEB_BUILD_OPTIONS='lenny' debian/rules debian/.control_stamp
518 # DEB_BUILD_OPTIONS='lenny diet' debian/rules debian/.control_stamp
519 # DEB_BUILD_OPTIONS='sarge' debian/rules debian/.control_stamp