80
80
with_interp := static
81
81
#with_interp := shared
83
build_target := build-all
84
install_target := install
86
83
PY_INTERPRETER = /usr/bin/python$(VER)
88
85
ifeq ($(DEFAULT_VERSION),yes)
101
DPKG_CFLAGS := $(shell dpkg-buildflags --get CFLAGS)
102
DPKG_LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
103
OPT_CFLAGS := $(filter-out -O%,$(DPKG_CFLAGS)) # default is -O3
104
DEBUG_CFLAGS := $(patsubst -O%,-O0,$(DPKG_CFLAGS))
104
106
# on alpha, use -O2 only, use -mieee
105
107
ifeq ($(DEB_HOST_ARCH),alpha)
106
OPTSETTINGS = OPT="-g -O2 -fwrapv -mieee -Wall -Wstrict-prototypes"
107
OPTDEBUGSETTINGS = OPT="-g -O0 -fwrapv -mieee -Wall -Wstrict-prototypes"
109
DEBUG_CFLAGS += -mieee
110
EXTRA_OPT_FLAGS += -O2
109
112
# issues with ia64 and m68k with -O3
110
ifneq (,$(filter $(DEB_HOST_ARCH),ia64 m68k))
111
OPTSETTINGS = OPT="-fwrapv -g -O2 -Wall -Wstrict-prototypes"
113
ifeq ($(DEB_HOST_ARCH),m68k)
114
EXTRA_OPT_FLAGS += -O2
117
ifeq ($(DEB_HOST_ARCH_OS),linux)
118
ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel armhf i386 powerpc ppc64))
123
ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel armhf i386))
127
ifneq (,$(findstring noopt, $(DEB_BUILD_OPTIONS)))
128
OPT_CFLAGS := $(filter-out -O%, $(OPT_CFLAGS))
129
EXTRA_OPT_CFLAGS = -O0
134
ifeq ($(with_lto),yes)
135
EXTRA_OPT_CFLAGS += -g1 -flto -fuse-linker-plugin
138
make_build_target = $(if $(with_pgo),profile-opt)
115
140
buildd_static := $(CURDIR)/build-static
116
141
buildd_shared := $(CURDIR)/build-shared
117
142
buildd_debug := $(CURDIR)/build-debug
145
170
d_doc := debian/$(p_doc)
146
171
d_dbg := debian/$(p_dbg)
148
# profiled build fails on some architectures ...
149
ifneq (,$(filter $(DEB_HOST_ARCH), hppa ia64 m68k sparc hurd-i386))
152
make_build_target = profile-opt
155
build: $(build_target)
156
build-all: stamps/stamp-build
157
stamps/stamp-build: stamps/stamp-build-static stamps/stamp-build-shared stamps/stamp-build-debug stamps/stamp-build-shared-debug stamps/stamp-mincheck stamps/stamp-check stamps/stamp-pystone stamps/stamp-pybench
158
touch stamps/stamp-build
173
build-arch: stamps/stamp-build
174
build-indep: stamps/stamp-build-doc
176
stamps/stamp-build: stamps/stamp-build-static stamps/stamp-mincheck \
177
stamps/stamp-build-shared stamps/stamp-build-debug \
178
stamps/stamp-build-shared-debug \
179
stamps/stamp-check stamps/stamp-pystone stamps/stamp-pybench
160
182
PROFILE_EXCLUDES = test_compiler test_distutils test_platform test_subprocess \
161
183
test_multiprocessing test_cprofile \
177
199
stamps/stamp-build-static: stamps/stamp-configure-static
179
201
$(MAKE) $(NJOBS) -C $(buildd_static) \
202
EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" \
180
203
PROFILE_TASK='$(PROFILE_TASK)' $(make_build_target)
181
204
touch stamps/stamp-build-static
183
206
stamps/stamp-build-shared: stamps/stamp-configure-shared
185
$(MAKE) $(NJOBS) -C $(buildd_shared)
208
$(MAKE) $(NJOBS) -C $(buildd_shared) \
209
EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)"
186
210
# : # build the shared library
187
211
# $(MAKE) $(NJOBS) -C $(buildd_shared) \
188
212
# libpython$(VER).so
189
213
: # build a static library with PIC objects
190
214
$(MAKE) $(NJOBS) -C $(buildd_shared) \
215
EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" \
191
216
LIBRARY=libpython$(VER)-pic.a libpython$(VER)-pic.a
192
217
touch stamps/stamp-build-shared
194
219
stamps/stamp-build-debug: stamps/stamp-configure-debug
196
221
$(MAKE) $(NJOBS) -C $(buildd_debug)
222
EXTRA_CFLAGS="$(DEBUG_CFLAGS)"
197
223
touch stamps/stamp-build-debug
199
225
stamps/stamp-build-shared-debug: stamps/stamp-configure-shared-debug
225
251
rm -rf $(buildd_shared)
226
252
mkdir -p $(buildd_shared)
227
253
cd $(buildd_shared) && \
228
CC="$(CC)" $(OPTSETTINGS) \
230
256
--enable-shared \
231
257
$(common_configure_args)
233
"^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
235
| sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \
236
>> $(buildd_shared)/Modules/Setup.local
237
cd $(buildd_shared) && \
238
../Modules/makesetup -c ../Modules/config.c.in -s Modules \
239
Modules/Setup.config Modules/Setup.local Modules/Setup
240
mv $(buildd_shared)/config.c $(buildd_shared)/Modules/
259
$(call __post_configure,$(buildd_shared))
242
261
touch stamps/stamp-configure-shared
245
264
rm -rf $(buildd_static)
246
265
mkdir -p $(buildd_static)
247
266
cd $(buildd_static) && \
248
CC="$(CC)" $(OPTSETTINGS) \
250
269
$(common_configure_args)
252
"^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
253
Modules/Setup.dist | sed 's/^#//' \
254
>> $(buildd_static)/Modules/Setup.local
255
cd $(buildd_static) && \
256
../Modules/makesetup -c ../Modules/config.c.in -s Modules \
257
Modules/Setup.config Modules/Setup.local Modules/Setup
259
: # apply workaround for missing os.fsync
260
sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(buildd_static)/pyconfig.h \
261
> $(buildd_static)/pyconfig.h.new
262
touch -r $(buildd_static)/pyconfig.h $(buildd_static)/pyconfig.h.new
263
mv -f $(buildd_static)/pyconfig.h.new $(buildd_static)/pyconfig.h
264
mv $(buildd_static)/config.c $(buildd_static)/Modules/
271
$(call __post_configure,$(buildd_static))
266
273
touch stamps/stamp-configure-static
269
276
rm -rf $(buildd_debug)
270
277
mkdir -p $(buildd_debug)
271
278
cd $(buildd_debug) && \
272
CC="$(CC)" $(OPTDEBUGSETTINGS) CFLAGS="" CXXFLAGS="" \
274
281
$(common_configure_args) \
277
"^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
278
Modules/Setup.dist | sed 's/^#//' \
279
>> $(buildd_debug)/Modules/Setup.local
280
cd $(buildd_debug) && \
281
../Modules/makesetup -c ../Modules/config.c.in -s Modules \
282
Modules/Setup.config Modules/Setup.local Modules/Setup
283
mv $(buildd_debug)/config.c $(buildd_debug)/Modules/
285
: # apply workaround for missing os.fsync
286
sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(buildd_debug)/pyconfig.h \
287
> $(buildd_debug)/pyconfig.h.new
288
touch -r $(buildd_debug)/pyconfig.h $(buildd_debug)/pyconfig.h.new
289
mv -f $(buildd_debug)/pyconfig.h.new $(buildd_debug)/pyconfig.h
284
$(call __post_configure,$(buildd_debug))
291
286
touch stamps/stamp-configure-debug
294
289
rm -rf $(buildd_shdebug)
295
290
mkdir -p $(buildd_shdebug)
296
291
cd $(buildd_shdebug) && \
297
CC="$(CC)" $(OPTDEBUGSETTINGS) CFLAGS="" CXXFLAGS="" \
299
294
$(common_configure_args) \
300
295
--enable-shared \
298
$(call __post_configure,$(buildd_shdebug))
300
touch stamps/stamp-configure-shared-debug
302
define __post_configure
303
"^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
304
"^#($$(awk -v ORS='|' '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in)XX)" \
304
305
Modules/Setup.dist \
305
306
| sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \
306
>> $(buildd_shdebug)/Modules/Setup.local
307
cd $(buildd_shdebug) && \
307
>> $(1)/Modules/Setup.local
309
: # unconditionally run makesetup
308
311
../Modules/makesetup -c ../Modules/config.c.in -s Modules \
309
312
Modules/Setup.config Modules/Setup.local Modules/Setup
310
mv $(buildd_shdebug)/config.c $(buildd_shdebug)/Modules/
313
mv $(1)/config.c $(1)/Modules/
315
: # and fix the timestamps
316
$(MAKE) -C $(1) Makefile Modules/config.c
312
318
: # apply workaround for missing os.fsync
313
sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(buildd_shdebug)/pyconfig.h \
314
> $(buildd_shdebug)/pyconfig.h.new
315
touch -r $(buildd_shdebug)/pyconfig.h $(buildd_shdebug)/pyconfig.h.new
316
mv -f $(buildd_shdebug)/pyconfig.h.new $(buildd_shdebug)/pyconfig.h
318
touch stamps/stamp-configure-shared-debug
319
sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(1)/pyconfig.h \
320
> $(1)/pyconfig.h.new
321
touch -r $(1)/pyconfig.h $(1)/pyconfig.h.new
322
mv -f $(1)/pyconfig.h.new $(1)/pyconfig.h
320
325
stamps/stamp-mincheck: stamps/stamp-build-static debian/PVER-minimal.README.Debian.in
321
326
for m in $(MIN_MODS) $(MIN_PACKAGES) $(MIN_EXTS) $(MIN_BUILTINS); do \
343
348
TEST_EXCLUDES += test_tcl test_codecmaps_cn test_codecmaps_hk \
344
349
test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw \
345
350
test_normalization test_ossaudiodev
346
ifneq (,$(filter $(DEB_HOST_ARCH), powerpc kfreebsd-i386))
351
ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel powerpc kfreebsd-i386))
347
352
TEST_EXCLUDES += test_threading
359
364
ifneq (,$(filter $(DEB_HOST_ARCH), arm avr32))
360
365
TEST_EXCLUDES += test_ctypes
362
ifneq (,$(filter $(DEB_HOST_ARCH), m68k avr32 kfreebsd-amd64 kfreebsd-i386))
367
#ifneq (,$(filter $(DEB_HOST_ARCH), m68k avr32 kfreebsd-amd64 kfreebsd-i386))
368
ifneq (,$(filter $(DEB_HOST_ARCH), m68k avr32))
363
369
TEST_EXCLUDES += test_bsddb3
365
371
ifneq (,$(filter $(DEB_HOST_ARCH), arm armel avr32 m68k))
367
373
TEST_EXCLUDES += test_compiler
376
#ifneq (,$(filter $(DEB_HOST_ARCH), kfreebsd-amd64 kfreebsd-i386))
377
# TEST_EXCLUDES += test_io
370
379
ifneq (,$(filter $(DEB_HOST_ARCH), hurd-i386))
371
380
TEST_EXCLUDES += test_io test_random test_signal test_socketserver test_ssl test_threading
396
405
@echo "BEGIN test static"
399
$(MAKE) -C $(buildd_static) test \
400
TESTOPTS="$(TESTOPTS)" 2>&1 \
408
xvfb-run -a -e xvfb-run.log \
409
$(MAKE) -C $(buildd_static) test \
410
EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" \
411
TESTOPTS="$(TESTOPTS)" 2>&1 \
401
412
| tee $(buildd_static)/test_results
402
413
@echo "END test static"
403
414
@echo "BEGIN test shared"
406
$(MAKE) -C $(buildd_shared) test \
407
TESTOPTS="$(TESTOPTS)" 2>&1 \
417
xvfb-run -a -e xvfb-run.log \
418
$(MAKE) -C $(buildd_shared) test \
419
EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" \
420
TESTOPTS="$(TESTOPTS)" 2>&1 \
408
421
| tee $(buildd_shared)/test_results
409
422
@echo "END test shared"
411
423
ifeq (,$(findstring $(DEB_HOST_ARCH), alpha))
412
424
@echo "BEGIN test debug"
415
$(MAKE) -C $(buildd_debug) test \
416
TESTOPTS="$(TESTOPTS)" 2>&1 \
427
xvfb-run -a -e xvfb-run.log \
428
$(MAKE) -C $(buildd_debug) test \
429
TESTOPTS="$(TESTOPTS)" 2>&1 \
417
430
| tee $(buildd_debug)/test_results
418
431
@echo "END test debug"
422
434
cp -p $(buildd_static)/test_results debian/
423
435
touch stamps/stamp-check
572
584
help2man --no-info --version-string=$(VER) --no-discard-stderr \
585
--name 'Python2 to Python3 converter' \
573
586
2to3-$(VER) > debian/2to3-$(VER).1
575
install: $(build_target) stamps/stamp-install
588
install: build-arch stamps/stamp-install
576
589
stamps/stamp-install: stamps/stamp-build control-file stamps/stamp-control
895
908
cp -p $(buildd_debug)/pyconfig.h $(d_dbg)/usr/include/$(PVER)_d/
896
909
ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg.1.gz
910
ln -sf $(PVER)-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg-config.1.gz
898
912
for i in debian/*.overrides; do \
899
913
b=$$(basename $$i .overrides); \
903
917
touch stamps/stamp-install
905
919
# Build architecture-independent files here.
906
binary-indep: $(install_target) $(build_target) stamps/stamp-build-doc stamps/stamp-control
920
binary-indep: build-indep install stamps/stamp-control