Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 include /usr/share/dpkg/architecture.mk
4 include /usr/share/dpkg/pkg-info.mk
5
6 unexport LANG LC_ALL LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC LC_MESSAGES
7 unexport CFLAGS CXXFLAGS LDFLAGS CPPFLAGS
8
9 export SHELL = /bin/bash
10
11 # Uncomment this to turn on verbose mode.
12 #export DH_VERBOSE=1
13
14 ifeq ($(DEB_HOST_ARCH_OS),linux)
15 PLAT = linux
16 else ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
17 PLAT = gnukfreebsd10
18 else ifeq ($(DEB_HOST_ARCH_OS),hurd)
19 PLAT = gnu0
20 else
21 $(warning unhandled operating system name: $(DEB_HOST_ARCH_OS))
22 PLAT = unknown
23 endif
24
25 SPHINXOPTS := -D today='$(shell LC_ALL=C date -u +'%B %d, %Y' -d '@$(SOURCE_DATE_EPOCH)')'
26 SPHINXOPTS += -D html_last_updated_fmt='$(shell LC_ALL=C date -u +'%B %d, %Y' -d '@$(SOURCE_DATE_EPOCH)')'
27 export SPHINXOPTS
28
29 on_buildd := $(shell [ -f /CurrentlyBuilding -o "$$LOGNAME" = buildd -o "$$USER" = buildd ] && echo yes)
30
31 dh_compat2 := $(shell dpkg --compare-versions "$$(dpkg-query -f '$${Version}' -W debhelper)" lt 9.20150811ubuntu2 && echo DH_COMPAT=2)
32
33 ifneq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
34 WITHOUT_CHECK := yes
35 endif
36 WITHOUT_BENCH :=
37 ifneq (,$(findstring nobench, $(DEB_BUILD_OPTIONS)))
38 WITHOUT_BENCH := yes
39 endif
40 ifeq ($(on_buildd),yes)
41 ifneq (,$(filter $(DEB_HOST_ARCH), armel hppa mips mipsel mips64 mips64el riscv64 s390)$(filter $(DEB_HOST_ARCH_OS), hurd kfreebsd))
42 WITHOUT_CHECK := yes
43 endif
44 ifneq (,$(filter $(DEB_HOST_ARCH), armel hppa mips mipsel mips64 mips64el riscv64 s390)$(filter $(DEB_HOST_ARCH_OS), hurd kfreebsd))
45 WITHOUT_BENCH := yes
46 endif
47 endif
48 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
49 WITHOUT_BENCH := yes
50 WITHOUT_CHECK := yes
51 endif
52
53 SPACE = $(EMPTY) $(EMPTY)
54 COMMA = ,
55 ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
56 NUM_JOBS := $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
57 NJOBS := -j $(NUM_JOBS)
58 # limit the number of tests running in parallel ...
59 NUM_TEST_JOBS := 2
60 NJOBS_TEST := -j $(shell if test $(NUM_JOBS) -lt $(NUM_TEST_JOBS); then echo $(NUM_JOBS); else echo $(NUM_TEST_JOBS); fi)
61 endif
62
63 distribution := $(shell lsb_release -is)
64 distrelease := $(shell lsb_release -cs)
65 derivative := $(shell \
66 if dpkg-vendor --derives-from Ubuntu; then echo Ubuntu; \
67 elif dpkg-vendor --derives-from Debian; then echo Debian; \
68 else echo Unknown; fi)
69
70 # we inject our own lto flags
71 DPKG_OPTIMIZE = optimize=-lto
72 dpkg_buildflags = DEB_BUILD_MAINT_OPTIONS="hardening=-pie $(DPKG_OPTIMIZE)" dpkg-buildflags
73 dpkg_pieflags = DEB_BUILD_MAINT_OPTIONS="hardening=-pie $(DPKG_OPTIMIZE)"dpkg-buildflags
74 ifeq (,$(filter $(distrelease),stretch buster bullseye trusty xenial bionic focal impish))
75 with_nopie := yes
76 dpkg_pieflags = DEB_BUILD_MAINT_OPTIONS="hardening=-pie $(DPKG_OPTIMIZE)" dpkg-buildflags
77 endif
78
79 # FIXME: remove sid when uploading to unstable, after bookworm is released
80 #ifneq (,$(filter $(distrelase), jessie stretch buster bullseye bookworm sid precise trusty xenial bionic focal groovy hirsute))
81 with_dbmmodule = yes
82 bd_dbm = libdb-dev
83 dbmliborder = bdb:gdbm
84 #else
85 # bd_dbm = libgdbm-compat-dev
86 # dbmliborder = gdbm:bdb
87 #endif
88
89 ifneq (,$(filter valgrind, $(shell dpkg-query --show -f '$${Depends}\n' valgrind-if-available)))
90 valgrind_configure_args = --with-valgrind
91 endif
92
93 VER=3.14
94 SVER=3.14.1
95 NVER=3.15
96 PVER=python$(VER)
97 EXT_VER=$(subst .,,$(VER))
98 PRIORITY=$(shell echo $(VER) | tr -d '.')0
99
100 PREVVER := $(shell awk '/^python/ && NR > 1 {print substr($$2,2,length($$2)-2); exit}' debian/changelog)
101
102 # default versions are built from the python-defaults source package
103 # keep the definition to adjust package priorities.
104 DEFAULT_VERSION = no
105 STATIC_PYTHON=yes
106
107 MIN_MODS := $(shell awk '/^ / && $$2 == "module" { print $$1 }' \
108 debian/PVER-minimal.README.Debian.in)
109 MIN_EXTS := $(shell awk '/^ / && $$2 ~ /^extension/ { print $$1 }' \
110 debian/PVER-minimal.README.Debian.in)
111 MIN_BUILTINS := $(shell awk '/^ / && $$2 == "builtin" { print $$1 }' \
112 debian/PVER-minimal.README.Debian.in)
113 MIN_PACKAGES := $(shell awk '/^ / && $$2 == "package" { print $$1 }' \
114 debian/PVER-minimal.README.Debian.in)
115 MIN_ENCODINGS := $(foreach i, \
116 $(filter-out \
117 big5% bz2% cp932.py cp949.py cp950.py euc_% \
118 gb% iso2022% johab.py shift_jis% , \
119 $(shell cd Lib/encodings && echo *.py)), \
120 encodings/$(i)) \
121 codecs.py stringprep.py
122
123 with_tk := yes
124 with_gdbm := yes
125 with_interp := static
126 #with_interp := shared
127
128 PY_INTERPRETER = /usr/bin/python$(VER)
129
130 ifeq ($(DEFAULT_VERSION),yes)
131 PY_PRIO = standard
132 #PYSTDDEP = , python (>= $(VER))
133 else
134 PY_PRIO = optional
135 endif
136 ifeq ($(distribution),Ubuntu)
137 PY_MINPRIO = required
138 PY_MINPRIO = optional
139 #with_udeb = yes
140 # test_ssl assumes that openssl is compiled with security level set to 1
141 # make it so, during the build
142 export OPENSSL_CONF = $(CURDIR)/debian/openssl.cnf
143 else
144 PY_MINPRIO = $(PY_PRIO)
145 endif
146 ifeq (,$(filter $(distrelease),lenny etch squeeze wheezy lucid maverick natty oneiric))
147 bd_qual = :any
148 endif
149 ifeq (,$(filter $(distrelease),lenny etch squeeze wheezy lucid maverick natty oneiric))
150 ma_filter = cat
151 else
152 ma_filter = grep -v '^Multi-Arch:'
153 endif
154 ifeq (,$(filter $(distrelease),lenny etch squeeze wheezy lucid maverick natty oneiric precise quantal raring saucy trusty))
155 bd_dpkgdev = dpkg-dev (>= 1.17.11),
156 endif
157
158 CC=$(DEB_HOST_GNU_TYPE)-gcc
159 CXX=$(DEB_HOST_GNU_TYPE)-g++
160 ifneq (,$(filter $(distrelease),bionic))
161 CC=$(DEB_HOST_GNU_TYPE)-gcc-8
162 CXX=$(DEB_HOST_GNU_TYPE)-g++-8
163 bd_gcc = g++-8,
164 endif
165
166 AR=$(DEB_HOST_GNU_TYPE)-ar
167 RANLIB=$(DEB_HOST_GNU_TYPE)-ranlib
168
169 LLVM_ARCHS = amd64 arm64
170 LLVM_VERSION = 21
171
172 # configure and dtrace consume these
173 export CC CXX
174
175 # These variables are needed for the ELF package metadata (set via LDFLAGS)
176 DEB_BUILD_OS_RELEASE_ID=$(shell . /usr/lib/os-release && echo $$ID)
177 export DEB_BUILD_OS_RELEASE_ID
178 export DEB_HOST_ARCH
179 export DEB_SOURCE
180 export DEB_VERSION
181
182 DPKG_CPPFLAGS= $(shell $(dpkg_buildflags) --get CPPFLAGS)
183 DPKG_CFLAGS := $(shell $(dpkg_buildflags) --get CFLAGS)
184 DPKG_CFLAGS := $(subst -fstack-protector-strong,-fstack-protector,$(DPKG_CFLAGS))
185 DPKG_LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS)
186 OPT_CFLAGS := $(filter-out -O%,$(DPKG_CFLAGS)) # default is -O3
187 DEBUG_CFLAGS := $(patsubst -O%,-Og,$(DPKG_CFLAGS))
188
189 DPKG_PIE_CPPFLAGS= $(shell $(dpkg_pieflags) --get CPPFLAGS)
190 DPKG_PIE_CFLAGS := $(shell $(dpkg_pieflags) --get CFLAGS)
191 DPKG_PIE_CFLAGS := $(subst -fstack-protector-strong,-fstack-protector,$(DPKG_PIE_CFLAGS))
192 DPKG_PIE_LDFLAGS = $(shell $(dpkg_pieflags) --get LDFLAGS)
193 OPT_PIE_CFLAGS := $(filter-out -O%,$(DPKG_PIE_CFLAGS)) # default is -O3
194
195 ifeq ($(DEB_HOST_ARCH),ia64)
196 DPKG_CPPFLAGS += -DWITH_PYMALLOC_RADIX_TREE=0
197 DPKG_PIE_CPPFLAGS += -DWITH_PYMALLOC_RADIX_TREE=0
198 endif
199
200 ifneq (,$(filter $(DEB_HOST_ARCH), ppc64 ppc64el))
201 OPT_CFLAGS += -fexceptions
202 OPT_PIE_CFLAGS += -fexceptions
203 DEBUG_CFLAGS += -fexceptions
204 endif
205
206 ifneq (,$(filter $(DEB_HOST_ARCH), m68k))
207 OPT_CFLAGS += -fno-thread-jumps
208 OPT_PIE_CFLAGS += -fno-thread-jumps
209 endif
210
211 ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
212 ifeq ($(DEB_HOST_ARCH_OS),linux)
213 ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel armhf arm64 i386 powerpc ppc64 ppc64el s390x))
214 with_pgo := yes
215 endif
216 endif
217 endif
218
219 ifneq (,$(filter $(DEB_HOST_ARCH), amd64 armel armhf arm64 i386 powerpc ppc64 ppc64el s390x))
220 with_lto := yes
221 endif
222
223 ifneq (,$(findstring nopgo, $(DEB_BUILD_OPTIONS)))
224 with_pgo :=
225 endif
226
227 ifneq (,$(findstring nolto, $(DEB_BUILD_OPTIONS)))
228 with_lto :=
229 endif
230
231 ifneq (,$(findstring noopt, $(DEB_BUILD_OPTIONS)))
232 OPT_CFLAGS := $(filter-out -O%, $(OPT_CFLAGS)) -O0
233 with_pgo =
234 with_lto =
235 endif
236
237 BASE_LTO_CFLAGS = -g -fwrapv -O3
238 ifeq ($(with_lto),yes)
239 LTO_CFLAGS = $(BASE_LTO_CFLAGS) -flto -fuse-linker-plugin
240 with_fat_lto := $(shell dpkg --compare-versions $$($(CC) --version \
241 | sed -n '/^$(CC)/s,.* ,,p') ge 4.9 && echo yes)
242 ifeq ($(with_fat_lto),yes)
243 LTO_CFLAGS += -ffat-lto-objects -frandom-seed=$(DEB_VERSION)
244 endif
245 OPT_CFLAGS += $(LTO_CFLAGS)
246 OPT_PIE_CFLAGS += $(LTO_CFLAGS)
247 AR=$(DEB_HOST_GNU_TYPE)-gcc-ar
248 RANLIB=$(DEB_HOST_GNU_TYPE)-gcc-ranlib
249 endif
250
251 sysconfig_substflags = \
252 $(if $(with_lto),$(foreach i,-flto=auto -flto -fuse-linker-plugin -ffat-lto-objects -frandom-seed=$(DEB_VERSION),-e 's/$(i)//g')) \
253 -e '/^OPT/s,-O3,-O2,' \
254 -e 's/-O3/-O2/g' \
255 -e 's/-fprofile-use *-fprofile-correction//g' \
256 -e "s/-specs=[^ '\"]*//g" \
257 -e "s/-fdebug-prefix-map=[^ '\"]*//g" \
258 -e "s/-ffile-prefix-map=[^ '\"]*//g" \
259 -e 's,^RUNSHARED *=.*,RUNSHARED=,' \
260 -e '/BLDLIBRARY/s/-L\. //'
261
262 ifeq ($(derivative),Ubuntu)
263 arch_substvars =
264 else ifeq ($(derivative),Debian)
265 arch_substvars = # '-Vpython38:Breaks=$(shell tr '\n' ' ' < debian/py38-breaks.$(derivative))'
266 endif
267
268 make_build_target = $(if $(filter yes, $(with_pgo)),profile-opt)
269
270 buildd_static := $(CURDIR)/build-static
271 buildd_nopie := $(CURDIR)/build-nopie
272 buildd_shared := $(CURDIR)/build-shared
273 buildd_debug := $(CURDIR)/build-debug
274 buildd_shdebug := $(CURDIR)/build-shdebug
275
276 d := debian/tmp
277 scriptdir = usr/share/lib/python$(VER)
278 scriptdir = usr/share/python$(VER)
279 scriptdir = usr/lib/python$(VER)
280
281 # package names and directories
282 p_base := $(PVER)
283 p_npie := $(PVER)-nopie
284 p_min := $(PVER)-minimal
285 p_lib := lib$(PVER)
286 p_gdbm := $(PVER)-gdbm
287 p_tk := $(PVER)-tk
288 p_dev := $(PVER)-dev
289 p_exam := $(PVER)-examples
290 p_idle := idle-$(PVER)
291 p_doc := $(PVER)-doc
292 p_dbg := $(PVER)-dbg
293 p_udeb := $(PVER)-udeb
294 p_venv := $(PVER)-venv
295 p_full := $(PVER)-full
296
297 p_lbase := lib$(PVER)-stdlib
298 p_lmin := lib$(PVER)-minimal
299 p_ldev := lib$(PVER)-dev
300 p_ldbg := lib$(PVER)-dbg
301 p_ltst := lib$(PVER)-testsuite
302
303 d_base := debian/$(p_base)
304 d_min := debian/$(p_min)
305 d_npie := debian/$(p_npie)
306 d_lib := debian/$(p_lib)
307 d_gdbm := debian/$(p_gdbm)
308 d_tk := debian/$(p_tk)
309 d_dev := debian/$(p_dev)
310 d_exam := debian/$(p_exam)
311 d_idle := debian/$(p_idle)
312 d_doc := debian/$(p_doc)
313 d_dbg := debian/$(p_dbg)
314 d_udeb := debian/$(p_udeb)
315 d_venv := debian/$(p_venv)
316 d_full := debian/$(p_full)
317
318 d_lbase := debian/$(p_lbase)
319 d_lmin := debian/$(p_lmin)
320 d_ldev := debian/$(p_ldev)
321 d_ldbg := debian/$(p_ldbg)
322 d_ltst := debian/$(p_ltst)
323
324 build-arch: stamps/stamp-build
325 build-indep: stamps/stamp-build-doc
326 build: build-arch
327 stamps/stamp-build: stamps/stamp-build-static \
328 $(if $(filter yes, $(with_nopie)),stamps/stamp-build-nopie) \
329 stamps/stamp-mincheck \
330 stamps/stamp-build-shared stamps/stamp-build-debug \
331 stamps/stamp-build-shared-debug \
332 stamps/stamp-check stamps/stamp-pybench
333 touch $@
334
335 PROFILE_EXCLUDES = test_compiler test_subprocess \
336 test_multiprocessing test_socket test_socketserver \
337 test_thread test_threaded_import test_threadedtempfile \
338 test_threading test_threading_local test_threadsignals \
339 test_concurrent_futures test_ctypes \
340 test_dbm_dumb test_dbm_ndbm test_pydoc test_sundry \
341 test_signal test_ioctl test_gdb test_ensurepip test_venv
342
343 # TODO: these hang/fail with new OpenSSL
344 PROFILE_EXCLUDES += \
345 test_asyncio test_ftplib test_httplib test_imaplib test_nntplib test_poplib test_ssl
346
347 # TODO: these fail in the profile build
348 PROFILE_EXCLUDES += \
349 test_cmd_line_script test_zipimport_support
350
351 # these take a long time to run ...
352 PROFILE_EXCLUDES += \
353 test_multiprocessing_fork test_multiprocessing_forkserver test_multiprocessing_spawn
354
355 # relying on external dependencies
356 PROFILE_EXCLUDES += test_cppext test_tools
357
358 # TODO: update profiled-build.diff to support --next
359 # --next=20
360 PROFILE_TASK = ../Lib/test/regrtest.py \
361 -s \
362 -j 1 -unone,decimal \
363 -x $(sort $(TEST_EXCLUDES) $(PROFILE_EXCLUDES))
364
365
366 run-profile-task:
367 $(MAKE) -C $(buildd_static) \
368 PROFILE_TASK='$(PROFILE_TASK)' run_profile_task
369
370
371 common_configure_args = \
372 --prefix=/usr \
373 --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
374 --enable-ipv6 \
375 --enable-loadable-sqlite-extensions \
376 --with-dbmliborder=$(dbmliborder) \
377 --with-computed-gotos \
378 --without-ensurepip \
379 --with-system-expat \
380 $(if $(or $(filter hurd,$(DEB_HOST_ARCH_OS)),$(filter hppa,$(DEB_HOST_ARCH))),,--with-dtrace) \
381 --with-ssl-default-suites=openssl \
382 --with-system-libmpdec=no \
383 --with-wheel-pkg-dir=/usr/share/python-wheels/ \
384 MKDIR_P="/bin/mkdir -p" \
385
386 # FIXME, only temporaray
387 #common_configure_args += \
388 # --without-builtin-hashlib-hashes
389
390 ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64))
391 common_configure_args += --enable-experimental-jit=yes-off
392 endif
393
394 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
395 common_configure_args += --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE)
396 common_configure_args += --with-build-python
397 config_site = ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=yes
398 ifeq (,$(filter $(DEB_HOST_ARCH),arm m68k))
399 ifeq ($(DEB_HOST_ARCH_ENDIAN),little)
400 config_site += ac_cv_little_endian_double=yes
401 else
402 config_site += ac_cv_big_endian_double=yes
403 endif
404 endif
405 endif
406
407 stamps/stamp-configure-shared: stamps/stamp-patch
408 rm -rf $(buildd_shared)
409 mkdir -p $(buildd_shared)
410 cd $(buildd_shared) && \
411 AR="$(AR)" RANLIB="$(RANLIB)" LLVM_VERSION="$(LLVM_VERSION)" \
412 CFLAGS_NODIST="$(DPKG_CPPFLAGS) $(OPT_CFLAGS)" \
413 LDFLAGS_NODIST="$(DPKG_LDFLAGS) $(LTO_CFLAGS)" \
414 $(config_site) \
415 ../configure \
416 --enable-shared \
417 $(common_configure_args)
418
419 $(call __post_configure,$(buildd_shared))
420
421 @echo XXXXXXX pyconfig.h
422 -cat $(buildd_shared)/pyconfig.h
423
424 touch $@
425
426 stamps/stamp-build-static: stamps/stamp-configure-static
427 dh_testdir
428 $(MAKE) $(NJOBS) -C $(buildd_static) \
429 PROFILE_TASK='$(PROFILE_TASK)' $(make_build_target)
430
431 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
432 : # check that things are correctly built
433 ifneq (,$(filter $(DEB_HOST_ARCH_OS), linux))
434 cd $(buildd_static) && ./python -c 'from _multiprocessing import SemLock'
435 endif
436 cd $(buildd_static) && ./python -c 'import _decimal'
437 cd $(buildd_static) && ./python -c 'import math, cmath'
438 endif
439 touch $@
440
441 stamps/stamp-build-shared: stamps/stamp-configure-shared
442 dh_testdir
443 $(MAKE) $(NJOBS) -C $(buildd_shared)
444
445 : # build a static library with PIC objects
446 $(MAKE) $(NJOBS) -C $(buildd_shared) \
447 LIBRARY=libpython$(VER)-pic.a libpython$(VER)-pic.a
448 touch $@
449
450 stamps/stamp-configure-static: stamps/stamp-patch
451 rm -rf $(buildd_static)
452 mkdir -p $(buildd_static)
453 cd $(buildd_static) && \
454 AR="$(AR)" RANLIB="$(RANLIB)" LLVM_VERSION="$(LLVM_VERSION)" \
455 CFLAGS_NODIST="$(DPKG_PIE_CPPFLAGS) $(OPT_PIE_CFLAGS)" \
456 LDFLAGS_NODIST="$(DPKG_PIE_LDFLAGS) $(LTO_CFLAGS)" \
457 $(config_site) \
458 ../configure \
459 $(common_configure_args)
460
461 $(call __post_configure,$(buildd_static))
462 touch $@
463
464 stamps/stamp-configure-nopie: stamps/stamp-patch
465 rm -rf $(buildd_nopie)
466 mkdir -p $(buildd_nopie)
467 cd $(buildd_nopie) && \
468 AR="$(AR)" RANLIB="$(RANLIB)" LLVM_VERSION="$(LLVM_VERSION)" \
469 CFLAGS_NODIST="$(DPKG_CPPFLAGS) $(OPT_CFLAGS)" \
470 LDFLAGS_NODIST="$(DPKG_LDFLAGS) $(LTO_CFLAGS)" \
471 $(config_site) \
472 ../configure \
473 $(common_configure_args)
474
475 $(call __post_configure,$(buildd_nopie))
476 touch $@
477
478 stamps/stamp-build-nopie: stamps/stamp-configure-nopie
479 dh_testdir
480 $(MAKE) $(NJOBS) -C $(buildd_nopie) \
481 PROFILE_TASK='$(PROFILE_TASK)' $(make_build_target)
482
483 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
484 : # check that things are correctly built
485 ifneq (,$(filter $(DEB_HOST_ARCH_OS), linux))
486 cd $(buildd_nopie) && ./python -c 'from _multiprocessing import SemLock'
487 endif
488 cd $(buildd_nopie) && ./python -c 'import _decimal'
489 cd $(buildd_nopie) && ./python -c 'import math, cmath'
490 endif
491 touch $@
492
493 stamps/stamp-configure-debug: stamps/stamp-patch
494 rm -rf $(buildd_debug)
495 mkdir -p $(buildd_debug)
496 cd $(buildd_debug) && \
497 AR="$(AR)" RANLIB="$(RANLIB)" LLVM_VERSION="$(LLVM_VERSION)" \
498 CFLAGS_NODIST="$(DPKG_CPPFLAGS) $(DEBUG_CFLAGS)" \
499 LDFLAGS_NODIST="$(DPKG_LDFLAGS)" \
500 $(config_site) \
501 ../configure \
502 $(common_configure_args) \
503 $(valgrind_configure_args) \
504 --with-pydebug
505
506 $(call __post_configure,$(buildd_debug))
507 touch $@
508
509 stamps/stamp-build-debug: stamps/stamp-configure-debug
510 dh_testdir
511 $(MAKE) $(NJOBS) -C $(buildd_debug)
512
513 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
514 cd $(buildd_static) && ./python -c 'import _decimal'
515 cd $(buildd_debug) && ./python -c 'import math, cmath'
516 endif
517 touch $@
518
519 stamps/stamp-configure-shared-debug: stamps/stamp-patch
520 rm -rf $(buildd_shdebug)
521 mkdir -p $(buildd_shdebug)
522 cd $(buildd_shdebug) && \
523 AR="$(AR)" RANLIB="$(RANLIB)" LLVM_VERSION="$(LLVM_VERSION)" \
524 CFLAGS_NODIST="$(DPKG_CPPFLAGS) $(DEBUG_CFLAGS)" \
525 LDFLAGS_NODIST="$(DPKG_LDFLAGS)" \
526 $(config_site) \
527 ../configure \
528 $(common_configure_args) \
529 --enable-shared \
530 $(valgrind_configure_args) \
531 --with-pydebug
532
533 $(call __post_configure,$(buildd_shdebug))
534 touch $@
535
536 stamps/stamp-build-shared-debug: stamps/stamp-configure-shared-debug
537 dh_testdir
538 : # build the shared debug library
539 $(MAKE) $(NJOBS) -C $(buildd_shdebug)
540 touch $@
541
542
543 define __post_configure
544 egrep \
545 "^#($$(awk -v ORS='|' '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in)XX)" \
546 Modules/Setup \
547 | sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \
548 >> $(1)/Modules/Setup.local
549
550 : # unconditionally run makesetup
551 cd $(1) && \
552 ../Modules/makesetup -c ../Modules/config.c.in -s Modules \
553 Modules/Setup.local Modules/Setup.bootstrap Modules/Setup.stdlib ../Modules/Setup
554 mv $(1)/config.c $(1)/Modules/
555
556 : # and fix the timestamps
557 $(MAKE) -C $(1) Makefile Modules/config.c
558
559 : # this second rule doesn't build with -fPIC, remove it.
560 sed '/^Modules\/_math.o: .*PY_STDMODULE_CFLAGS/d' $(1)/Makefile > $(1)/Makefile.fixed
561 touch -r $(1)/Makefile $(1)/Makefile.fixed
562 mv -f $(1)/Makefile.fixed $(1)/Makefile
563 endef
564
565 stamps/stamp-mincheck: stamps/stamp-build-static debian/PVER-minimal.README.Debian.in
566 ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
567 for m in $(MIN_MODS) $(MIN_PACKAGES) $(MIN_EXTS) $(MIN_BUILTINS); do \
568 echo "import $$m"; \
569 done > $(buildd_static)/minmods.py
570 cd $(buildd_static) && ./python -S ../debian/pymindeps.py minmods.py \
571 > mindeps.txt
572 -if [ -x /usr/bin/dot ]; then \
573 cd $(buildd_static) && ./python -S ../debian/depgraph.py \
574 < mindeps.txt > mindeps.dot; \
575 dot -Tpng -o mindeps.png mindeps.dot; \
576 else true; fi
577 cd $(buildd_static) && ./python -S ../debian/mincheck.py \
578 minmods.py mindeps.txt
579 endif
580 touch stamps/stamp-mincheck
581
582 TEST_DIR := $(shell [ -f debian/testdir ] || mktemp -d > debian/testdir; cat debian/testdir)
583
584 TEST_RESOURCES = all
585 ifeq ($(on_buildd),yes)
586 TEST_RESOURCES := $(TEST_RESOURCES),-network,-urlfetch
587 endif
588 TESTOPTS = $(NJOBS_TEST) -w -u$(TEST_RESOURCES) --timeout=3600
589 TEST_EXCLUDES =
590 TEST_EXCLUDES += test_ensurepip test_venv
591 ifeq ($(on_buildd),yes)
592 TEST_EXCLUDES += test_tcl test_codecmaps_cn test_codecmaps_hk \
593 test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw \
594 test_normalization test_ossaudiodev
595 endif
596 ifeq (,$(wildcard /dev/dsp))
597 TEST_EXCLUDES += test_linuxaudiodev test_ossaudiodev
598 endif
599 ifneq (,$(filter $(DEB_HOST_ARCH), hppa))
600 TEST_EXCLUDES += test_fork1 test_multiprocessing test_socketserver test_threading test_wait3 test_wait4 test_gdb
601 endif
602 # hangs on Aarch64, see LP: #1264354
603 ifneq (,$(filter $(DEB_HOST_ARCH),arm64))
604 TEST_EXCLUDES += test_faulthandler
605 endif
606 ifneq (,$(filter $(DEB_HOST_ARCH), arm))
607 TEST_EXCLUDES += test_ctypes
608 endif
609 TEST_EXCLUDES += test_socket
610 ifneq (,$(filter $(DEB_HOST_ARCH), arm armel m68k))
611 ifeq ($(on_buildd),yes)
612 TEST_EXCLUDES += test_compiler
613 endif
614 endif
615 TEST_EXCLUDES += test_ttk_guionly
616 # https://buildd.debian.org/status/logs.php?pkg=python3.5&ver=3.5.1-1&arch=alpha&suite=sid
617 ifneq (,$(filter $(DEB_HOST_ARCH), alpha))
618 TEST_EXCLUDES += test_signal
619 endif
620 ifneq (,$(filter $(DEB_HOST_ARCH), sparc sparc64))
621 TEST_EXCLUDES += test_gdb
622 endif
623
624 ifneq (,$(filter $(DEB_HOST_ARCH), alpha armhf riscv64 sparc64))
625 TEST_EXCLUDES += test_concurrent_futures
626 endif
627
628 # fail/hang with new OpenSSL
629 TEST_EXCLUDES += test_asyncio test_ftplib test_httplib test_imaplib test_nntplib test_poplib test_ssl
630
631 # TODO: re-enable once fixed, see #708652
632 ifneq (,$(filter $(DEB_HOST_ARCH_OS), hurd))
633 TEST_EXCLUDES += test_asyncore test_curses test_exceptions \
634 test_faulthandler test_imaplib test_io test_logging test_mmap \
635 test_random test_signal test_socket test_socketserver test_ssl \
636 test_threading test_pydoc test_runpy test_telnetlib test_tk
637 endif
638
639 # TODO: re-enable once fixed, see #708653
640 ifneq (,$(filter $(DEB_HOST_ARCH_OS), kfreebsd))
641 TEST_EXCLUDES += test_io test_signal test_socket test_socketserver \
642 test_threading test_threadsignals test_threaded_import \
643 test_time test_pty test_curses
644 endif
645
646 # for debug builds only
647 TEST_EXCLUDES += test_gdb
648
649 ifneq (,$(TEST_EXCLUDES))
650 TESTOPTS += -x $(sort $(TEST_EXCLUDES))
651 endif
652
653 ifneq (,$(wildcard /usr/bin/localedef))
654 SET_LOCPATH = LOCPATH=$(CURDIR)/locales
655 endif
656
657 stamps/stamp-check:
658 ifeq ($(WITHOUT_CHECK),yes)
659 echo "check run disabled for this build" > $(buildd_static)/test_results
660 else
661 @echo ========== test environment ============
662 @env
663 @echo ========================================
664
665 ifeq (,$(findstring $(DEB_HOST_ARCH), alpha))
666 ( \
667 echo '#! /bin/sh'; \
668 echo 'set -x'; \
669 echo 'export $(SET_LOCPATH)'; \
670 echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test TESTOPTS="$(filter-out test_gdb,$(TESTOPTS))"'\'; \
671 echo 'echo DONE'; \
672 ) > $(buildd_debug)/run_tests
673 chmod 755 $(buildd_debug)/run_tests
674 @echo "BEGIN test debug"
675 mkdir -p $(TEST_DIR)/debug/.local/lib/$(PVER)/site-packages
676 -cd $(buildd_debug) && HOME=$(TEST_DIR)/debug time xvfb-run -a -e xvfb-run.log ./run_tests
677 find $(TEST_DIR)/debug
678 rm -rf $(TEST_DIR)/debug
679 @echo "END test debug"
680 endif
681
682 ( \
683 echo '#! /bin/sh'; \
684 echo 'set -x'; \
685 echo 'export $(SET_LOCPATH)'; \
686 echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test TESTOPTS="$(TESTOPTS)"'\'; \
687 echo 'echo DONE'; \
688 ) > $(buildd_static)/run_tests
689 chmod 755 $(buildd_static)/run_tests
690 @echo "BEGIN test static"
691 mkdir -p $(TEST_DIR)/static/.local/lib/$(PVER)/site-packages
692 -cd $(buildd_static) && HOME=$(TEST_DIR)/static time xvfb-run -a -e xvfb-run.log ./run_tests
693 find $(TEST_DIR)/static
694 rm -rf $(TEST_DIR)/static
695 @echo "END test static"
696
697 ( \
698 echo '#! /bin/sh'; \
699 echo 'set -x'; \
700 echo 'export $(SET_LOCPATH)'; \
701 echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test TESTOPTS="$(TESTOPTS)"'\'; \
702 echo 'echo DONE'; \
703 ) > $(buildd_shared)/run_tests
704 chmod 755 $(buildd_shared)/run_tests
705 @echo "BEGIN test shared"
706 mkdir -p $(TEST_DIR)/shared/.local/lib/$(PVER)/site-packages
707 -cd $(buildd_shared) && HOME=$(TEST_DIR)/shared time xvfb-run -a -e xvfb-run.log ./run_tests
708 find $(TEST_DIR)/shared
709 rm -rf $(TEST_DIR)/shared
710 @echo "END test shared"
711 endif
712 cp -p $(buildd_static)/test_results debian/
713 touch stamps/stamp-check
714
715 stamps/stamp-pybench:
716 echo "pybench run disabled for this build" > $(buildd_static)/pybench.log
717
718 #ifeq (,$(filter $(DEB_HOST_ARCH), arm armel hppa mips mipsel mips64 mips64el m68k))
719 pybench_options = -C 2 -n 5 -w 4
720 #endif
721
722 stamps/stamp-pybenchx:
723 ifeq ($(WITHOUT_BENCH),yes)
724 echo "pybench run disabled for this build" > $(buildd_static)/pybench.log
725 else
726 @echo "BEGIN pybench static"
727 cd $(buildd_static) \
728 && time ./python ../Tools/pybench/pybench.py -f run1.pybench $(pybench_options)
729 cd $(buildd_static) \
730 && ./python ../Tools/pybench/pybench.py -f run2.pybench -c run1.pybench $(pybench_options)
731 @echo "END pybench static"
732 @echo "BEGIN pybench shared"
733 cd $(buildd_shared) \
734 && LD_LIBRARY_PATH=. ./python ../Tools/pybench/pybench.py -f run1.pybench $(pybench_options)
735 cd $(buildd_shared) \
736 && LD_LIBRARY_PATH=. ./python ../Tools/pybench/pybench.py -f run2.pybench -c run1.pybench $(pybench_options)
737 @echo "END pybench shared"
738 @echo "BEGIN shared/static comparision"
739 $(buildd_static)/python Tools/pybench/pybench.py \
740 -s $(buildd_static)/run2.pybench -c $(buildd_shared)/run2.pybench \
741 | tee $(buildd_static)/pybench.log
742 @echo "END shared/static comparision"
743 endif
744 touch stamps/stamp-pybench
745
746 minimal-test:
747 rm -rf mintest
748 mkdir -p mintest/lib mintest/dynlib mintest/testlib mintest/all-lib
749 cp -p $(buildd_static)/python mintest/
750 cp -p $(foreach i,$(MIN_MODS),Lib/$(i).py) \
751 mintest/lib/
752 cp -a $(foreach i,$(MIN_PACKAGES),Lib/$(i)) \
753 mintest/lib/
754 cp -p $(wildcard $(foreach i,$(MIN_EXTS),$(buildd_static)/build/lib*/$(i).*.so)) \
755 mintest/dynlib/
756 cp -p Lib/unittest.py mintest/lib/
757 cp -pr Lib/test mintest/lib/
758 cp -pr Lib mintest/all-lib
759 cp -p $(buildd_static)/build/lib*/*.so mintest/all-lib/
760 ( \
761 echo "import sys"; \
762 echo "sys.path = ["; \
763 echo " '$(CURDIR)/mintest/lib',"; \
764 echo " '$(CURDIR)/mintest/dynlib',"; \
765 echo "]"; \
766 cat Lib/test/regrtest.py; \
767 ) > mintest/lib/test/mintest.py
768 cd mintest && ./python -E -S lib/test/mintest.py \
769 -x test_codecencodings_cn test_codecencodings_hk \
770 test_codecencodings_jp test_codecencodings_kr \
771 test_codecencodings_tw test_codecs test_multibytecodec \
772
773 stamps/stamp-doc-html:
774 dh_testdir
775 $(MAKE) -C Doc html
776 @mkdir -p stamps
777 touch stamps/stamp-doc-html
778
779 stamps/stamp-doc-info:
780 dh_testdir
781 rm -rf Doc/build/texinfo
782 $(MAKE) -C Doc texinfo
783 # - Change name of info file (@setfilename) to include the version.
784 # - Change the directory entry to include the version and point to the
785 # correct filename.
786 # - Change image links (@image) to point to a subdirectory.
787 # - Remove trailing whitespace.
788 sed -e 's/^@setfilename .*/@setfilename $(PVER).info/' \
789 -e '/^@direntry/,/^@/s/^\*[^:]*: ([^)]*)/* Python $(VER): ($(PVER))/' \
790 -e 's,@image{,@image{$(PVER)/,g' \
791 -e 's/ *$$//' \
792 < Doc/build/texinfo/python.texi \
793 > Doc/build/texinfo/$(PVER).texi
794 rm -f Doc/build/texinfo/python.texi
795 # - Create a symbolic link so that makeinfo will be able to find the
796 # image files.
797 ln -s . Doc/build/texinfo/$(PVER)
798 $(MAKE) -C Doc/build/texinfo
799 @mkdir -p stamps
800 touch stamps/stamp-doc-info
801
802 build-doc: stamps/stamp-patch stamps/stamp-build-doc
803 stamps/stamp-build-doc: stamps/stamp-doc-html stamps/stamp-doc-info
804 @mkdir -p stamps
805 touch stamps/stamp-build-doc
806
807 control-file:
808 sed -e "s/@PVER@/$(PVER)/g" \
809 -e "s/@VER@/$(VER)/g" \
810 -e "s/@PYSTDDEP@/$(PYSTDDEP)/g" \
811 -e "s/@PRIO@/$(PY_PRIO)/g" \
812 -e "s/@MINPRIO@/$(PY_MINPRIO)/g" \
813 -e "s/@bd_qual@/$(bd_qual)/g" \
814 -e "s/@bd_gcc@/$(bd_gcc)/g" \
815 -e "s/@bd_dbm@/$(bd_dbm)/g" \
816 -e "s/@bd_dpkgdev@/$(bd_dpkgdev)/g" \
817 -e "s/@LLVM_VERSION@/$(LLVM_VERSION)/g" \
818 -e "s/@LLVM_ARCHS@/$(LLVM_ARCHS)/g" \
819 debian/control.in \
820 debian/control.stdlib \
821 $(if $(with_udeb),debian/control.udeb) \
822 | $(ma_filter) \
823 > debian/control.tmp
824 ifeq ($(distribution),Ubuntu)
825 ifneq (,$(findstring ubuntu, $(DEB_VERSION)))
826 m='Ubuntu Core Developers <[email protected]>'; \
827 sed -i "/^Maintainer:/s/\(.*\)/Maintainer: $$m\nXSBC-Original-\1/" \
828 debian/control.tmp
829 endif
830 endif
831 [ -e debian/control ] \
832 && cmp -s debian/control debian/control.tmp \
833 && rm -f debian/control.tmp && exit 0; \
834 mv debian/control.tmp debian/control
835
836
837
838 clean: control-file
839 dh_testdir
840 dh_testroot
841 rm -rf stamps
842 rm -f debian/test_results
843
844 $(MAKE) -C Doc clean
845 sed 's/^@/#/' Makefile.pre.in | $(MAKE) -f - srcdir=. distclean
846 rm -rf $(buildd_static) $(buildd_shared) $(buildd_debug) $(buildd_shdebug) $(buildd_nopie)
847 find -name '*.py[co]' | xargs -r rm -f
848 rm -f Lib/dist-packages
849 rm -rf locales
850 rm -rf $(d)-dbg
851 rm -f configure
852 rm -f netlify.toml
853 rm -rf $(TEST_DIR) debian/testdir
854
855 for f in debian/*.in; do \
856 f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \
857 if [ $$f2 != debian/control ] && [ $$f2 != debian/source.lintian-overrides ]; then \
858 rm -f $$f2; \
859 fi; \
860 done
861 rm -rf debian/__pycache__
862
863 dh_clean
864
865 stamps/stamp-control:
866 : # We have to prepare the various control files
867
868 for f in debian/*.in; do \
869 f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \
870 if [ $$f2 != debian/control ]; then \
871 sed -e "s/@PVER@/$(PVER)/g;s/@VER@/$(VER)/g;s/@SVER@/$(SVER)/g" \
872 -e "s/@PRIORITY@/$(PRIORITY)/g" \
873 -e "s,@SCRIPTDIR@,/$(scriptdir),g" \
874 -e "s,@INFO@,$(info_docs),g" \
875 -e "s,@HOST_QUAL@,:$(DEB_HOST_ARCH),g" \
876 <$$f >$$f2; \
877 fi; \
878 done
879
880 install: build-arch stamps/stamp-install
881 stamps/stamp-install: stamps/stamp-build control-file stamps/stamp-control
882 dh_testdir
883 dh_testroot
884 dh_prep
885 dh_installdirs
886
887 : # make install into tmp and subsequently move the files into
888 : # their packages' directories.
889 install -d $(d)/usr
890 install -d $(d)/$(scriptdir)/lib-dynload
891 ifeq ($(with_interp),static)
892 $(MAKE) -C $(buildd_static) install DESTDIR=$(CURDIR)/$(d)
893 ls -l $(d)/$(scriptdir)/_sysconfigdata*
894 sed $(sysconfig_substflags) \
895 $(buildd_shared)/$(shell cat $(buildd_shared)/pybuilddir.txt)/_sysconfigdata__$(PLAT)_$(DEB_HOST_MULTIARCH).py \
896 > $(d)/$(scriptdir)/_sysconfigdata__$(PLAT)_$(DEB_HOST_MULTIARCH).py
897 sed $(sysconfig_substflags) \
898 $(buildd_shared)/$(shell cat $(buildd_shared)/pybuilddir.txt)/_sysconfig_vars__$(PLAT)_$(DEB_HOST_MULTIARCH).json \
899 > $(d)/$(scriptdir)/_sysconfig_vars__$(PLAT)_$(DEB_HOST_MULTIARCH).json
900 else
901 $(MAKE) -C $(buildd_shared) install DESTDIR=$(CURDIR)/$(d)
902 endif
903 mkdir -p $(d)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)
904 mv $(d)/usr/include/$(PVER)/pyconfig.h \
905 $(d)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)/.
906 rm -f $(d)/$(scriptdir)/lib-dynload/*.py
907 ls -l $(d)/$(scriptdir)/_sysconfigdata*
908 sed -i $(sysconfig_substflags) \
909 $(d)/$(scriptdir)/_sysconfigdata__$(PLAT)_$(DEB_HOST_MULTIARCH).py
910 sed -i $(sysconfig_substflags) \
911 $(d)/$(scriptdir)/_sysconfig_vars__$(PLAT)_$(DEB_HOST_MULTIARCH).json
912
913 : # fix /usr/local path in build-details_*.json
914 sed -i -e '/base_interpreter/s,/usr/local/,/usr/,' \
915 $(d)/$(scriptdir)/build-details..$(DEB_HOST_MULTIARCH).json
916
917 -find $(d)/usr/lib/python$(VER) -name '*_failed*.so'
918 find $(d)/usr/lib/python$(VER) -name '*_failed*.so' | xargs -r rm -f
919
920 for i in $(d)/$(scriptdir)/lib-dynload/*.so; do \
921 case "$$i" in *$(DEB_HOST_MULTIARCH)*) continue; esac; \
922 b=$$(basename $$i .cpython-$(EXT_VER)m.so); \
923 d=$${b}.cpython-$(EXT_VER)m-$(DEB_HOST_MULTIARCH).so; \
924 mv $$i $(d)/$(scriptdir)/lib-dynload/$$d; \
925 done
926
927 mkdir -p $(d)/usr/lib/python3
928 mv $(d)/usr/lib/python$(VER)/site-packages \
929 $(d)/usr/lib/python3/dist-packages
930 rm -f $(d)/usr/lib/python3/dist-packages/README*
931
932 : # remove files, which are not packaged
933 rm -rf $(d)/usr/lib/python$(VER)/ctypes/macholib
934 rm -f $(d)/usr/share/man/man1/python3.1
935
936 if [ -d $(d)/$(scriptdir)/ensurepip/_bundled ]; then \
937 echo "don't ship the prebuilt ensurepip/_bundled wheels."; \
938 rm -rf $(d)/$(scriptdir)/ensurepip/_bundled; \
939 fi
940
941 : # cannot build it, zlib maintainer won't provide a mingw build
942 find $(d) -name 'wininst*.exe' | xargs -r rm -f
943
944 mkdir -p $(d)/usr/share/man/man1
945 cp -p Misc/python.man $(d)/usr/share/man/man1/python$(VER).1
946 cp -p debian/pydoc.1 $(d)/usr/share/man/man1/pydoc$(VER).1
947
948 install -T -m755 debian/pdb $(d)/usr/bin/pdb$(VER)
949 cp -p debian/pdb.1 $(d)/usr/share/man/man1/pdb$(VER).1
950
951 : # versioned install only
952 rm -f $(d)/usr/bin/{idle3,pydoc3,python3,python3-config}
953 rm -f $(d)/usr/lib/*/pkgconfig/python3.pc
954 rm -f $(d)/usr/lib/*/pkgconfig/python3-embed.pc
955
956 dh_installdirs -p$(p_lib) \
957 usr/lib/$(DEB_HOST_MULTIARCH) \
958 $(scriptdir)/config-$(VER)m-$(DEB_HOST_MULTIARCH) \
959 usr/share/doc
960 : # install the shared library
961 cp -p $(buildd_shared)/libpython$(VER).so.1.0 \
962 $(d_lib)/usr/lib/$(DEB_HOST_MULTIARCH)/
963 dh_link -p$(p_lib) \
964 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so.1.0 \
965 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so.1 \
966 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so.1 \
967 /$(scriptdir)/config-$(VER)-$(DEB_HOST_MULTIARCH)/libpython$(VER).so \
968 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so.1 \
969 /$(scriptdir)/config-$(VER)-$(DEB_HOST_MULTIARCH)/libpython$(VER).so
970
971 ln -sf $(p_base) $(d_lib)/usr/share/doc/$(p_lib)
972
973 ln -sf libpython$(VER).so.1 $(d)/usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).so
974
975 ifeq ($(with_interp),shared)
976 : # install the statically linked runtime
977 install -m755 $(buildd_static)/python $(d)/usr/bin/python$(VER)-static
978 endif
979
980 cp -p Tools/i18n/pygettext.py $(d)/usr/bin/pygettext$(VER)
981 cp -p debian/pygettext.1 $(d)/usr/share/man/man1/pygettext$(VER).1
982
983 : # install the Makefile of the shared python build
984 sed $(sysconfig_substflags) \
985 $(buildd_shared)/Makefile \
986 > $(d)/$(scriptdir)/config-$(VER)-$(DEB_HOST_MULTIARCH)/Makefile
987
988 : # Move the minimal libraries into $(p_lmin).
989 dh_installdirs -p$(p_lmin) \
990 etc/$(PVER) \
991 usr/bin \
992 usr/share/man/man1 \
993 $(scriptdir)/lib-dynload
994 -cd $(d); for i in $(MIN_EXTS); do \
995 test -e $(scriptdir)/lib-dynload/$$i.*.so \
996 && echo $(scriptdir)/lib-dynload/$$i.*.so; \
997 done
998
999 $(dh_compat2) dh_movefiles -p$(p_lmin) --sourcedir=$(d) \
1000 $(foreach i,$(MIN_MODS),$(scriptdir)/$(i).py) \
1001 $(foreach i,$(MIN_PACKAGES),$(scriptdir)/$(i)) \
1002 $(foreach i,$(MIN_ENCODINGS),$(scriptdir)/$(i)) \
1003 $(scriptdir)/site.py \
1004 $(scriptdir)/_sysconfigdata__$(PLAT)_$(DEB_HOST_MULTIARCH).py \
1005 $(scriptdir)/build-details..$(DEB_HOST_MULTIARCH).json \
1006 `cd $(d); for i in $(MIN_EXTS); do \
1007 test -e $(scriptdir)/lib-dynload/$$i.*.so \
1008 && echo $(scriptdir)/lib-dynload/$$i.*.so; \
1009 done`
1010 -ls -l $(d_lmin)/$(scriptdir)/lib-dynload/*.so
1011
1012 : # Move the binary into $(p_min).
1013 dh_installdirs -p$(p_min) \
1014 usr/bin \
1015 usr/share/man/man1 \
1016 usr/local/lib/$(PVER)/dist-packages
1017 $(dh_compat2) dh_movefiles -p$(p_min) --sourcedir=$(d) \
1018 usr/bin/python$(VER) \
1019 usr/share/man/man1/python$(VER).1
1020 dh_usrlocal -p$(p_min)
1021
1022 rv=0; \
1023 for i in $(MIN_EXTS); do \
1024 if [ -f $(d)/$(scriptdir)/lib-dynload/$$i.so ]; then \
1025 echo >&2 "extension $$i not mentioned in Setup.dist"; \
1026 rv=1; \
1027 fi; \
1028 done; \
1029 exit $$rv;
1030
1031 : # Install sitecustomize.py
1032 cp -p debian/sitecustomize.py $(d_lmin)/etc/$(PVER)/
1033 dh_link -p$(p_lmin) \
1034 /etc/$(PVER)/sitecustomize.py /$(scriptdir)/sitecustomize.py
1035
1036 : # Move the static library and the header files into $(p_dev).
1037 # mv $(d)/usr/share/include/python$(VER)/* $(d)/usr/include/python$(VER)/.
1038 # rm -rf $(d)/usr/share/include
1039
1040 sed -i $(sysconfig_substflags) \
1041 $(d)/usr/bin/$(PVER)-config
1042 cp $(d)/usr/bin/$(PVER)-config $(d)/usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)-config
1043
1044 dh_installdirs -p$(p_ldev) \
1045 usr/bin \
1046 $(scriptdir) \
1047 usr/include \
1048 usr/share/man/man1
1049
1050 $(dh_compat2) dh_movefiles -p$(p_ldev) --sourcedir=$(d) \
1051 usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)*-config \
1052 usr/lib/python$(VER)/config-$(VER)-$(DEB_HOST_MULTIARCH) \
1053 usr/include \
1054 usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).{a,so} \
1055 usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)*.pc
1056
1057 sed 's/@subdir@/$(PVER)/;s/@header@/pyconfig.h/' \
1058 debian/multiarch.h.in > $(d_ldev)/usr/include/$(PVER)/pyconfig.h
1059
1060 sed -i \
1061 -e '/^Cflags:/s,$$, -I$${includedir}/$(DEB_HOST_MULTIARCH)/python$(VER),' \
1062 -e '/^libdir=/d;s/-L\$${libdir} *//' \
1063 $(d_ldev)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER).pc
1064
1065 dh_link -p$(p_ldev) \
1066 /usr/lib/$(PVER)/config-$(VER)-$(DEB_HOST_MULTIARCH)/libpython$(VER).a \
1067 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER).a
1068
1069 cp -p $(buildd_shared)/libpython$(VER)-pic.a \
1070 $(d_ldev)/usr/lib/python$(VER)/config-$(VER)-$(DEB_HOST_MULTIARCH)/
1071
1072 mkdir -p $(d_ldev)/usr/src/$(PVER)/{Grammar,Parser}
1073 cp -p Grammar/python.gram $(d_ldev)/usr/src/$(PVER)/Grammar/.
1074 cp -p Parser/Python.asdl $(d_ldev)/usr/src/$(PVER)/Parser/.
1075
1076 # FIXME
1077 # : # symlinks for the "old" include directory name
1078 # ln -sf python$(VER)m $(d_ldev)/usr/include/python$(VER)
1079
1080 dh_installdirs -p$(p_dev) \
1081 usr/share/doc/python$(VER) \
1082 usr/share/man/man1 \
1083 $(scriptdir) \
1084 $(scriptdir)/doc/html
1085 cp -p Misc/HISTORY Misc/README.valgrind \
1086 debian/README.maintainers \
1087 debian/test_results $(buildd_static)/pybench.log \
1088 $(d_dev)/usr/share/doc/python$(VER)/
1089
1090 $(dh_compat2) dh_movefiles -p$(p_dev) --sourcedir=$(d) \
1091 usr/bin/python$(VER)*-config
1092
1093 : # in $(p_ldev), prefix python-config with triplets
1094 cp -p debian/python3-config.1 \
1095 $(d_ldev)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-$(PVER)-config.1
1096 ifneq ($(DEB_HOST_MULTIARCH),$(DEB_HOST_GNU_TYPE))
1097 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config \
1098 $(d_ldev)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)-config
1099 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \
1100 $(d_ldev)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)-config.1.gz
1101 endif
1102
1103 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config $(d_dev)/usr/bin/$(PVER)-config
1104 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz $(d_dev)/usr/share/man/man1/$(PVER)-config.1.gz
1105
1106 ifeq ($(with_gdbm),yes)
1107 : # Move the gdbm extension file into $(p_gdbm).
1108 dh_installdirs -p$(p_gdbm) \
1109 $(scriptdir) \
1110 usr/lib/python$(VER)/lib-dynload
1111 $(dh_compat2) dh_movefiles -p$(p_gdbm) --sourcedir=$(d) \
1112 usr/lib/python$(VER)/lib-dynload/_gdbm*.so
1113 endif
1114
1115 ifeq ($(with_tk),yes)
1116 : # Move the Tkinter extension files into $(p_tk).
1117 dh_installdirs -p$(p_tk) \
1118 $(scriptdir) \
1119 usr/lib/python$(VER)/lib-dynload
1120 $(dh_compat2) dh_movefiles -p$(p_tk) --sourcedir=$(d) \
1121 usr/lib/python$(VER)/tkinter \
1122 usr/lib/python$(VER)/lib-dynload/_tkinter*.so
1123 endif
1124
1125 : # The test framework into $(p_lbase)
1126 $(dh_compat2) dh_movefiles -p$(p_lbase) --sourcedir=$(d) \
1127 $(scriptdir)/test/{libregrtest,support} \
1128 $(scriptdir)/test/typinganndata \
1129 $(scriptdir)/test/{regrtest,test_support,__init__,__main__}.py
1130
1131 : # The complete testsuite into $(p_ltst)
1132 $(dh_compat2) dh_movefiles -p$(p_ltst) --sourcedir=$(d) \
1133 $(scriptdir)/test
1134 rm -f $(d_ltst)/$(scriptdir)/test/test_ctypes/test_macholib.py
1135
1136 : # fixed upstream ...
1137 chmod -x $(d_ltst)/$(scriptdir)/test/{test_dbm_gnu,test_dbm_ndbm}.py
1138
1139 : # Move the demos and tools into $(p_exam)'s doc directory
1140 dh_installdirs -p$(p_exam) \
1141 usr/share/doc/python$(VER)/examples
1142 $(dh_compat2) dh_movefiles -p$(p_exam) --sourcedir=$(d) \
1143 $(scriptdir)/turtledemo
1144
1145 cp -rp Tools/* $(d_exam)/usr/share/doc/python$(VER)/examples/
1146 rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Tools/{buildbot,msi}
1147 : # XXX: We don't need rgb.txt, we'll use our own:
1148 rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Tools/pynche/X
1149
1150 : # IDLE
1151 mv $(d)/usr/bin/idle$(VER) $(d)/usr/bin/idle-python$(VER)
1152 rm -f $(d)/usr/lib/python$(VER)/idlelib/idle.bat
1153 dh_installdirs -p$(p_idle) \
1154 usr/bin \
1155 usr/share/man/man1
1156 $(dh_compat2) dh_movefiles -p$(p_idle) --sourcedir=$(d) \
1157 usr/bin/idle-python$(VER) \
1158 usr/lib/python$(VER)/idlelib
1159 cp -p debian/idle-$(PVER).1 $(d_idle)/usr/share/man/man1/
1160
1161 : # Move the docs into $(p_base)'s /usr/share/doc/$(PVER) directory,
1162 : # all other packages only have a copyright file.
1163 dh_installdocs -p$(p_base) \
1164 README.rst Misc/NEWS Misc/ACKS debian/README.venv
1165 ln -sf NEWS.gz $(d_base)/usr/share/doc/$(p_base)/changelog.gz
1166 dh_installdocs --all \
1167 -N$(p_base) -N$(p_dev) -N$(p_dbg) -N$(p_lib) \
1168 debian/README.Debian
1169
1170 : # IDLE has its own changelogs, docs...
1171 dh_installchangelogs -p$(p_idle) Lib/idlelib/ChangeLog
1172 dh_installdocs -p$(p_idle) Lib/idlelib/{NEWS2x,News3,README,TODO,extend}.txt
1173
1174 mkdir -p $(d_idle)/usr/share/applications
1175 cp -p debian/idle.desktop \
1176 $(d_idle)/usr/share/applications/idle-$(PVER).desktop
1177
1178 : # those packages have own README.Debian's
1179 install -m 644 -p debian/README.$(p_base) \
1180 $(d_base)/usr/share/doc/$(PVER)/README.Debian
1181 install -m 644 -p debian/README.$(p_idle) \
1182 $(d_idle)/usr/share/doc/$(p_idle)/README.Debian
1183 ifeq ($(with_tk),yes)
1184 mkdir -p $(d_tk)/usr/share/doc/$(p_base) $(d_tk)/usr/share/doc/$(p_tk)
1185 cp -p debian/README.Tk $(d_tk)/usr/share/doc/$(p_base)/
1186 ln -sf ../$(p_base)/README.Tk $(d_tk)/usr/share/doc/$(p_tk)/README.Tk
1187 endif
1188
1189 : # pyvenv and ensurepip files into $(p_venv)
1190 dh_installdirs -p$(p_venv) \
1191 usr/lib/python$(VER)
1192 dh_movefiles -p$(p_venv) \
1193 usr/lib/python$(VER)/ensurepip
1194
1195 : # library files into $(p_lbase)
1196 dh_installdirs -p$(p_lbase) \
1197 usr/lib
1198 dh_movefiles -p$(p_lbase) \
1199 usr/lib/python$(VER)
1200
1201 # Mark the interpreter as being PEP668 EXTERNALLY-MANAGED
1202 install -m 644 debian/EXTERNALLY-MANAGED \
1203 $(d_lbase)/$(scriptdir)
1204
1205 : # The rest goes into $(p_base)
1206 mkdir -p $(d)/usr/lib/python3/dist-packages
1207 (cd $(d) && tar cf - .) | (cd $(d_base) && tar xpf -)
1208 rm -f $(d_base)/usr/bin/python
1209
1210 : # Replace all '#!' calls to python with $(PY_INTERPRETER)
1211 : # and make them executable
1212 for p in $(shell dh_listpackages); do \
1213 [ -d debian/$$p ] || continue; \
1214 for i in `find debian/$$p -type f ! -name '*.so'`; do \
1215 sed '1s,#!.*python[^ ]*\(.*\),#! $(PY_INTERPRETER)\1,' \
1216 $$i > $$i.temp; \
1217 if cmp --quiet $$i $$i.temp; then \
1218 rm -f $$i.temp; \
1219 else \
1220 if [ ! -x $$i ]; then \
1221 echo "fixed x file permissions: $$i"; \
1222 fi; \
1223 mv -f $$i.temp $$i; \
1224 chmod 755 $$i; \
1225 echo "fixed interpreter: $$i"; \
1226 fi; \
1227 done; \
1228 done
1229
1230 : # Install menu icon
1231 dh_installdirs -p$(p_base) usr/share/pixmaps
1232 cp -p debian/pylogo.xpm $(d_base)/usr/share/pixmaps/$(PVER).xpm
1233
1234 : # generate binfmt file
1235 mkdir -p $(d_min)/usr/share/binfmts
1236 mkdir -p $(d_min)/usr/lib/binfmt.d
1237 ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
1238 $(buildd_static)/python debian/mkbinfmt.py $(PVER) \
1239 > $(d_min)/usr/share/binfmts/$(PVER)
1240 $(buildd_static)/python debian/mkbinfmtconf.py $(PVER) \
1241 > $(d_min)/usr/lib/binfmt.d/$(PVER).conf
1242 else
1243 $(PVER) debian/mkbinfmt.py $(PVER) > $(d_min)/usr/share/binfmts/$(PVER)
1244 $(PVER) debian/mkbinfmtconf.py $(PVER) > $(d_min)/usr/lib/binfmt.d/$(PVER).conf
1245 endif
1246
1247 : # desktop entry
1248 mkdir -p $(d_base)/usr/share/applications
1249 cp -p debian/$(PVER).desktop \
1250 $(d_base)/usr/share/applications/$(PVER).desktop
1251
1252 : # remove some things
1253 -find debian -name .cvsignore | xargs rm -f
1254 -find debian -name '*.py[co]' | xargs rm -f
1255
1256 : # remove empty directories, when all components are in place
1257 -find debian ! -name lib-dynload ! -name dist-packages -type d -empty -delete
1258
1259 : # install debug package
1260 rm -rf $(d)-dbg
1261 install -d $(d)-dbg/$(scriptdir)/lib-dynload
1262 $(MAKE) -C $(buildd_debug) install DESTDIR=$(CURDIR)/$(d)-dbg
1263 : # install the Makefile of the shared python debug build
1264 sed $(sysconfig_substflags) \
1265 $(buildd_shdebug)/Makefile \
1266 > $(d)-dbg/$(scriptdir)/config-$(VER)d-$(DEB_HOST_MULTIARCH)/Makefile
1267 sed $(sysconfig_substflags) \
1268 $(buildd_shdebug)/$(shell cat $(buildd_shdebug)/pybuilddir.txt)/_sysconfigdata_d_$(PLAT)_$(DEB_HOST_MULTIARCH).py \
1269 > $(d)-dbg/$(scriptdir)/_sysconfigdata_d_$(PLAT)_$(DEB_HOST_MULTIARCH).py
1270 sed -i $(sysconfig_substflags) \
1271 $(d)-dbg/$(scriptdir)/_sysconfigdata_d_$(PLAT)_$(DEB_HOST_MULTIARCH).py
1272 sed $(sysconfig_substflags) \
1273 $(buildd_shdebug)/$(shell cat $(buildd_shdebug)/pybuilddir.txt)/_sysconfig_vars_d_$(PLAT)_$(DEB_HOST_MULTIARCH).json \
1274 > $(d)-dbg/$(scriptdir)/_sysconfig_vars_d_$(PLAT)_$(DEB_HOST_MULTIARCH).json
1275 sed -i $(sysconfig_substflags) \
1276 $(d)-dbg/$(scriptdir)/_sysconfig_vars_d_$(PLAT)_$(DEB_HOST_MULTIARCH).json
1277
1278 : # fix /usr/local path in build-details.*.json
1279 sed -i -e '/base_interpreter/s,/usr/local/,/usr/,' \
1280 $(d)-dbg/$(scriptdir)/build-details.d.$(DEB_HOST_MULTIARCH).json
1281
1282 for i in $(d)-dbg/$(scriptdir)/lib-dynload/*.so; do \
1283 case "$$i" in *$(DEB_HOST_MULTIARCH)*) continue; esac; \
1284 b=$$(basename $$i .cpython-$(EXT_VER)d.so); \
1285 d=$${b}.cpython-$(EXT_VER)d-$(DEB_HOST_MULTIARCH).so; \
1286 mv $$i $(d)-dbg/$(scriptdir)/lib-dynload/$$d; \
1287 done
1288
1289 dh_installdirs -p$(p_ldbg) \
1290 usr/bin \
1291 usr/share/man/man1 \
1292 $(scriptdir)/lib-dynload \
1293 usr/include/$(PVER)d \
1294 usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)d \
1295 usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig
1296
1297 cp -p $(d)-dbg/$(scriptdir)/lib-dynload/*.so \
1298 $(d_ldbg)/$(scriptdir)/lib-dynload/
1299 cp -p $(d)-dbg/$(scriptdir)/_sysconfigdata_d_$(PLAT)_$(DEB_HOST_MULTIARCH).py \
1300 $(d)-dbg/$(scriptdir)/_sysconfig_vars_d_$(PLAT)_$(DEB_HOST_MULTIARCH).json \
1301 $(d)-dbg/$(scriptdir)/build-details.d.$(DEB_HOST_MULTIARCH).json \
1302 $(d_ldbg)/$(scriptdir)/
1303 cp -p $(buildd_shdebug)/libpython$(VER)d.so.1.0 \
1304 $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/
1305 dh_link -p$(p_ldbg) \
1306 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)d.so.1.0 \
1307 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)d.so.1 \
1308 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)d.so.1 \
1309 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)d.so
1310 cp $(d)-dbg/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)d.pc \
1311 $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/.
1312 ln -s python-$(VER)d.pc \
1313 $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)-dbg.pc
1314 cp $(d)-dbg/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)d-embed.pc \
1315 $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/.
1316 ln -s python-$(VER)d-embed.pc \
1317 $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)-dbg-embed.pc
1318
1319 dh_installdirs -p$(p_dbg) \
1320 usr/bin \
1321 usr/share/man/man1 \
1322 usr/share/doc/$(p_base)
1323 cp -p Misc/SpecialBuilds.txt $(d_dbg)/usr/share/doc/$(p_base)/
1324 cp -p debian/$(PVER)-dbg.README.Debian \
1325 $(d_dbg)/usr/share/doc/$(p_base)/README.debug
1326 cp -p $(buildd_debug)/python $(d_dbg)/usr/bin/$(PVER)d
1327 ln -sf python$(VER)d $(d_dbg)/usr/bin/$(PVER)-dbg
1328
1329 ifneq ($(with_dbmmodule),yes)
1330 rm -f $(d_lbase)/$(scriptdir)/lib-dynload/_dbm*.so
1331 rm -f $(d_ldbg)/$(scriptdir)/lib-dynload/_dbm*.so
1332 endif
1333
1334 cp -a $(d)-dbg/$(scriptdir)/config-$(VER)d-$(DEB_HOST_MULTIARCH) \
1335 $(d_ldbg)/$(scriptdir)/
1336 dh_link -p$(p_ldbg) \
1337 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)d.so \
1338 /$(scriptdir)/config-$(VER)d-$(DEB_HOST_MULTIARCH)/libpython$(VER)d.so \
1339 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)d.so \
1340 /$(scriptdir)/config-$(VER)d-$(DEB_HOST_MULTIARCH)/libpython$(VER).so \
1341 /$(scriptdir)/config-$(VER)d-$(DEB_HOST_MULTIARCH)/libpython$(VER)d.a \
1342 /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)d.a
1343
1344 for i in $(d_ldev)/usr/include/$(PVER)/*; do \
1345 i=$$(basename $$i); \
1346 case $$i in pyconfig.h) continue; esac; \
1347 ln -sf ../$(PVER)/$$i $(d_ldbg)/usr/include/$(PVER)d/$$i; \
1348 done
1349 cp -p $(buildd_debug)/pyconfig.h $(d_ldbg)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)d/
1350 sed 's/@subdir@/$(PVER)d/;s/@header@/pyconfig.h/' \
1351 debian/multiarch.h.in > $(d_ldbg)/usr/include/$(PVER)d/pyconfig.h
1352
1353 ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg.1.gz
1354
1355 : # in $(p_ldbg), prefix python-config with triplets
1356 sed -i $(sysconfig_substflags) \
1357 $(d)-dbg/usr/bin/$(PVER)d-config
1358 cp $(d)-dbg/usr/bin/$(PVER)d-config \
1359 $(d_ldbg)/usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)d-config
1360 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)d-config \
1361 $(d_ldbg)/usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config
1362 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \
1363 $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-$(PVER)d-config.1.gz
1364 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \
1365 $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config.1.gz
1366 ifneq ($(DEB_HOST_MULTIARCH),$(DEB_HOST_GNU_TYPE))
1367 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)d-config \
1368 $(d_ldbg)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)d-config
1369 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \
1370 $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)d-config.1.gz
1371 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)d-config \
1372 $(d_ldbg)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)-dbg-config
1373 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)d-config.1.gz \
1374 $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)-dbg-config.1.gz
1375 endif
1376 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)d-config $(d_dbg)/usr/bin/$(PVER)d-config
1377 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)d-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)d-config.1.gz
1378
1379 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config $(d_dbg)/usr/bin/$(PVER)-dbg-config
1380 ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg-config.1.gz
1381
1382 : # symlinks for the "old" include / config directory names
1383 ln -sf $(PVER)-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg-config.1.gz
1384 ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)d.1.gz
1385 ln -sf $(PVER)-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)d-config.1.gz
1386
1387 ifeq ($(with_udeb),yes)
1388 : # Copy the most important files from $(p_min) into $(p_udeb).
1389 dh_installdirs -p$(p_udeb) \
1390 etc/$(PVER) \
1391 usr/bin \
1392 usr/include/$(PVER)u \
1393 $(scriptdir)/lib-dynload \
1394 $(scriptdir)/config-$(VER)-$(DEB_HOST_MULTIARCH)
1395 cp -p $(d_min)/usr/bin/python$(VER) $(d_udeb)/usr/bin/
1396 ln -sf python$(VER)u $(d_udeb)/usr/bin/python$(VER)
1397 ln -sf python$(VER) $(d_udeb)/usr/bin/python3
1398 cp -p $(foreach i,$(MIN_MODS),$(d_min)/$(scriptdir)/$(i).py) \
1399 $(d_udeb)/$(scriptdir)/
1400 cp -a $(foreach i,$(MIN_PACKAGES),$(d_min)/$(scriptdir)/$(i)) \
1401 $(d_udeb)/$(scriptdir)/
1402 cp -p $(foreach i,$(MIN_ENCODINGS),$(d_min)/$(scriptdir)/$(i)) \
1403 $(d_udeb)/$(scriptdir)/
1404 cp -p $(d_min)/$(scriptdir)/config-$(VER)-$(DEB_HOST_MULTIARCH)/Makefile \
1405 $(d_udeb)/$(scriptdir)/config-$(VER)-$(DEB_HOST_MULTIARCH)/
1406 cp -p $(d_min)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)/pyconfig.h \
1407 $(d_udeb)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)/
1408 cp -p $(d_min)/$(scriptdir)/site.py $(d_udeb)/$(scriptdir)/
1409 cp -p debian/sitecustomize.py $(d_udeb)/etc/$(PVER)/
1410 dh_link -p$(p_udeb) /etc/$(PVER)/sitecustomize.py \
1411 /$(scriptdir)/sitecustomize.py
1412 endif
1413
1414 ifeq ($(with_nopie),yes)
1415 dh_installdirs -p$(p_npie) \
1416 usr/bin
1417 cp -p $(buildd_nopie)/python $(d_npie)/usr/bin/$(PVER)
1418 endif
1419
1420 # Compatibility with older python3.X builds carrying sysconfigdata-name.diff
1421 dh_link -p$(p_lmin) \
1422 /usr/lib/python$(VER)/_sysconfigdata__$(PLAT)_$(DEB_HOST_MULTIARCH).py \
1423 /usr/lib/python$(VER)/_sysconfigdata__$(DEB_HOST_MULTIARCH).py
1424 dh_link -p$(p_ldbg) \
1425 /usr/lib/python$(VER)/_sysconfigdata_d_$(PLAT)_$(DEB_HOST_MULTIARCH).py \
1426 /usr/lib/python$(VER)/_sysconfigdata_d_$(DEB_HOST_MULTIARCH).py
1427
1428 for i in debian/*.overrides; do \
1429 b=$$(basename $$i .overrides); \
1430 install -D -m 644 $$i debian/$$b/usr/share/lintian/overrides/$$b; \
1431 done
1432
1433 touch stamps/stamp-install
1434
1435 # Build architecture-independent files here.
1436 binary-indep: build-indep install stamps/stamp-control
1437 dh_testdir -i
1438 dh_testroot -i
1439
1440 : # $(p_doc) package
1441 dh_installdirs -p$(p_doc) \
1442 usr/share/doc/$(p_base) \
1443 usr/share/doc/$(p_doc)
1444 dh_installdocs -p$(p_doc)
1445 cp -a Doc/build/html $(d_doc)/usr/share/doc/$(p_base)/
1446 rm -f $(d_doc)/usr/share/doc/$(p_base)/html/_static/jquery.js
1447 dh_link -p$(p_doc) \
1448 /usr/share/doc/$(p_base)/html /usr/share/doc/$(p_doc)/html \
1449 /usr/share/javascript/jquery/jquery.js /usr/share/doc/$(p_base)/html/_static/jquery.js \
1450 /usr/share/javascript/underscore/underscore.js /usr/share/doc/$(p_base)/html/_static/underscore.js
1451 dh_installinfo -p$(p_doc)
1452 for f in $(d_doc)/usr/share/doc/$(p_base)/html/_images/*.png; do \
1453 b=$$(basename $$f); \
1454 dh_link -p$(p_doc) /usr/share/doc/$(p_base)/html/_images/$$b /usr/share/info/$(PVER)/$$b; \
1455 done
1456
1457 : # devhelp docs
1458 cd $(buildd_static) && ./python ../debian/pyhtml2devhelp.py \
1459 ../$(d_doc)/usr/share/doc/$(p_base)/html index.html $(VER) \
1460 > ../$(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp
1461 gzip -9nv $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp
1462 dh_link -p$(p_doc) \
1463 /usr/share/doc/$(p_base)/html /usr/share/devhelp/books/$(PVER)
1464
1465 : # regenerate idlelib/help.html, see idlelib.help.copy_strip
1466 sed 's/ *$$//' Doc/build/html/library/idle.html \
1467 > $(d_idle)/usr/lib/python$(VER)/idlelib/help.html
1468
1469 for i in $(p_ltst); do \
1470 rm -rf debian/$$i/usr/share/doc/$$i; \
1471 ln -s $(p_base) debian/$$i/usr/share/doc/$$i; \
1472 done
1473
1474 dh_installdebconf -i $(dh_args)
1475 dh_installexamples -i $(dh_args)
1476 -dh_icons -i $(dh_args) || dh_iconcache -i $(dh_args)
1477 dh_installchangelogs -i $(dh_args)
1478 dh_link -i $(dh_args)
1479 dh_compress -i $(dh_args) -X.py -X.cls -X.css -X.txt -X.json -X.js -Xobjects.inv
1480 dh_fixperms -i $(dh_args)
1481
1482 : # make python scripts starting with '#!' executable
1483 for i in `find debian -mindepth 3 -type f ! -perm 755`; do \
1484 if head -1 $$i | grep -q '^#!'; then \
1485 chmod 755 $$i; \
1486 echo "make executable: $$i"; \
1487 fi; \
1488 done
1489 -find $(d_doc) -name '*.txt' -perm 755 -exec chmod 644 {} \;
1490
1491 dh_installdeb -i $(dh_args)
1492 dh_gencontrol -i $(dh_args)
1493 dh_md5sums -i $(dh_args)
1494 dh_builddeb -i $(dh_args)
1495
1496 # Build architecture-dependent files here.
1497 binary-arch: build-arch install
1498 dh_testdir -a
1499 dh_testroot -a
1500 # dh_installdebconf -a
1501 dh_installexamples -a
1502 dh_installmenu -a
1503 -dh_icons -a || dh_iconcache -a
1504 # dh_installmime -a
1505 dh_installchangelogs -a
1506 for i in $(p_dev) $(p_dbg) $(p_venv) $(p_full); do \
1507 rm -rf debian/$$i/usr/share/doc/$$i; \
1508 ln -s $(p_base) debian/$$i/usr/share/doc/$$i; \
1509 done
1510 for i in $(p_lbase); do \
1511 rm -rf debian/$$i/usr/share/doc/$$i; \
1512 ln -s $(p_lmin) debian/$$i/usr/share/doc/$$i; \
1513 done
1514 for i in $(p_ldev) $(p_ldbg) $(p_lib); do \
1515 rm -rf debian/$$i/usr/share/doc/$$i; \
1516 ln -s $(p_lbase) debian/$$i/usr/share/doc/$$i; \
1517 done
1518 -find debian ! -perm -200 -print -exec chmod +w {} \;
1519 ifneq ($(with_tk),yes)
1520 rm -f $(d_lbase)/$(scriptdir)/tkinter
1521 rm -f $(d_lbase)/$(scriptdir)/lib-dynload/_tkinter*.so
1522 rm -f $(d_ldbg)/$(scriptdir)/lib-dynload/_tkinter*.so
1523 endif
1524 ifneq ($(with_gdbm),yes)
1525 rm -f $(d_lbase)/$(scriptdir)/lib-dynload/_gdbm*.so
1526 rm -f $(d_ldbg)/$(scriptdir)/lib-dynload/_gdbm*.so
1527 endif
1528
1529 find $(d_ldbg) $(d_ldev) -name '*.a' ! -type l \
1530 | xargs -n 1 $(DEB_HOST_GNU_TYPE)-objcopy -p --remove-section=.gnu.lto_.*
1531 dh_strip -a -N$(p_dbg) -N$(p_ldbg) -Xdebug -Xdbg --dbg-package=$(p_dbg)
1532 mkdir -p $(d_dbg)/usr/share/gdb/auto-load/usr/bin
1533 cp Tools/gdb/libpython.py $(d_dbg)/usr/share/gdb/auto-load/usr/bin/$(PVER)-gdb.py
1534 ln -sf $(PVER)-gdb.py $(d_dbg)/usr/share/gdb/auto-load/usr/bin/$(PVER)d-gdb.py
1535 ln -sf $(PVER)-gdb.py $(d_dbg)/usr/share/gdb/auto-load/usr/bin/$(PVER)-dbg-gdb.py
1536 mkdir -p $(d_dbg)/usr/share/gdb/auto-load/usr/lib/$(DEB_HOST_MULTIARCH)
1537 ln -sf ../../bin/$(PVER)-gdb.py \
1538 $(d_dbg)/usr/share/gdb/auto-load/usr/lib/$(DEB_HOST_MULTIARCH)/lib$(PVER).so.1.0-gdb.py
1539 ln -sf ../../bin/$(PVER)-gdb.py \
1540 $(d_dbg)/usr/share/gdb/auto-load/usr/lib/$(DEB_HOST_MULTIARCH)/lib$(PVER)d.so.1.0-gdb.py
1541 dh_link -a
1542 dh_compress -a -X.py
1543 dh_fixperms -a
1544 chmod 644 $(d_lmin)/$(scriptdir)/token.py
1545
1546 : # make python scripts starting with '#!' executable
1547 for i in `find debian -mindepth 3 -type f ! -perm 755`; do \
1548 if head -1 $$i | grep -q '^#!'; then \
1549 chmod 755 $$i; \
1550 echo "make executable: $$i"; \
1551 fi; \
1552 done
1553
1554 dh_makeshlibs -p$(p_lib) -V '$(p_lib)'
1555 dh_makeshlibs -p$(p_ldbg) -V '$(p_ldbg)'
1556 # don't include the following symbols, found in extensions
1557 # which either can be built as builtin or extension.
1558 sed -ri \
1559 -e '/^ (PyInit_|_add_one_to_index|asdl_)/d' \
1560 -e '/^ (PyExpat_XML_|PyExpat_Xml)/d' \
1561 -e '/^ (ffi_type_|_ctypes_)/d' \
1562 $(d_lib)/DEBIAN/symbols $(d_ldbg)/DEBIAN/symbols
1563 dh_installdeb -a
1564 dh_shlibdeps -a
1565 dep=`sed -n '/^shlibs:Depends/s/[^=]*=\(.*\)/\1/p' $(d_min).substvars | awk -v RS=', ' -v ORS=', ' '/^libc6/ { print }'`; \
1566 echo "shlibs:Pre-Depends=$$dep" >> $(d_min).substvars
1567 sed -i '/^shlibs:Depends/s/libc6[^,]*[, ]*//g' $(d_min).substvars
1568 dh_gencontrol -a -- $(arch_substvars)
1569 dh_md5sums -a
1570 dh_builddeb -a
1571
1572 # rules to patch the unpacked files in the source directory
1573 # ---------------------------------------------------------------------------
1574 # various rules to unpack addons and (un)apply patches.
1575 # - patch / apply-patches
1576 # - unpatch / reverse-patches
1577
1578 patchdir = debian/patches
1579
1580 patch: stamps/stamp-patch
1581 stamps/stamp-patch:
1582 dh_testdir
1583 uname -a
1584 @echo USER=$$USER, LOGNAME=$$LOGNAME
1585 @grep ^Mem /proc/meminfo
1586 @echo "DEB_BUILD_OPTIONS: $$DEB_BUILD_OPTIONS"
1587
1588 rm -rf autom4te.cache configure
1589 autoconf
1590 mkdir -p stamps
1591 echo ""; echo "Patches applied in this version:" > stamps/pxx
1592 for i in $$(cat $(patchdir)/series); do \
1593 case "$$i" in \#*) continue; esac; \
1594 echo ""; echo "$$i:"; \
1595 sed -n 's/^# *DP: */ /p' $(patchdir)/$$i; \
1596 done >> stamps/pxx
1597
1598 touch Parser/parser.c Parser/token.c
1599 touch Objects/obmalloc.c Python/dynamic_annotations.c \
1600 Python/mysnprintf.c Python/pyctype.c
1601
1602 ln -sf site-packages Lib/dist-packages
1603
1604 touch Lib/test/certdata/nullcert.pem
1605 touch Lib/test/libregrtest/__init__.py
1606 touch Lib/test/tokenizedata/__init__.py
1607
1608 # Check if patchlevel-noplus.diff is missing
1609 grep -Eq '^#define PY_VERSION +"[^+]+"$$' Include/patchlevel.h
1610
1611 mv stamps/pxx $@
1612
1613 reverse-patches: unpatch
1614 unpatch:
1615 rm -rf configure autom4te.cache
1616
1617 update-patches: $(patchdir)/series
1618 export QUILT_PATCHES=$(patchdir); \
1619 while quilt push; do quilt refresh -pab --no-timestamps --no-index; done
1620
1621 binary: binary-indep binary-arch
1622
1623 .NOTPARALLEL:
1624 .PHONY: control-file configure build clean binary-indep binary-arch binary install
1625
1626 # SVER is not updated once symbols are stable, so don't use it for checking all point releases
1627 SOURCE_VER = $(shell dpkg-parsechangelog -SVersion | cut -d- -f1)
1628 SOURCE_VER_FINAL = $(shell echo $(SOURCE_VER) | cut -d'~' -f1)
1629 SOURCE_VER_FN = $(subst ~,,$(SOURCE_VER))
1630 TAR_DIR := ./
1631
1632 $(TAR_DIR)python$(VER)_$(SOURCE_VER).orig.tar.xz.sigstore:
1633 wget https://www.python.org/ftp/python/$(SOURCE_VER_FINAL)/Python-$(SOURCE_VER_FN).tar.xz.sigstore -O $@
1634
1635 verify-signature: $(TAR_DIR)python$(VER)_$(SOURCE_VER).orig.tar.xz.sigstore $(TAR_DIR)python$(VER)_$(SOURCE_VER).orig.tar.xz
1636 sigstore verify identity \
1637 --cert-identity [email protected] \
1638 --cert-oidc-issuer https://github.com/login/oauth \
1639 --bundle $(TAR_DIR)python$(VER)_$(SOURCE_VER).orig.tar.xz.sigstore \
1640 $(TAR_DIR)python$(VER)_$(SOURCE_VER).orig.tar.xz
1641 .PHONY: verify-signature
1642
1643
1644 # Local Variables:
1645 # mode: makefile
1646 # end: