1# Top-level Makefile for Python
2#
3# As distributed, this file is called Makefile.pre.in; it is processed
4# into the real Makefile by running the script ./configure, which
5# replaces things like @spam@ with values appropriate for your system.
6# This means that if you edit Makefile, your changes get lost the next
7# time you run the configure script.  Ideally, you can do:
8#
9#	./configure
10#	make
11#	make test
12#	make install
13#
14# If you have a previous version of Python installed that you don't
15# want to overwrite, you can use "make altinstall" instead of "make
16# install".  Refer to the "Installing" section in the README file for
17# additional details.
18#
19# See also the section "Build instructions" in the README file.
20
21# === Variables set by makesetup ===
22
23MODBUILT_NAMES=    _MODBUILT_NAMES_
24MODSHARED_NAMES=   _MODSHARED_NAMES_
25MODDISABLED_NAMES= _MODDISABLED_NAMES_
26MODOBJS=           _MODOBJS_
27MODLIBS=           _MODLIBS_
28
29# === Variables set by configure
30VERSION=	@VERSION@
31srcdir=		@srcdir@
32VPATH=		@srcdir@
33abs_srcdir=	@abs_srcdir@
34abs_builddir=	@abs_builddir@
35
36
37CC=		@CC@
38CXX=		@CXX@
39MAINCC=		@MAINCC@
40LINKCC=		@LINKCC@
41AR=		@AR@
42READELF=	@READELF@
43SOABI=		@SOABI@
44LDVERSION=	@LDVERSION@
45LIBPYTHON=	@LIBPYTHON@
46GITVERSION=	@GITVERSION@
47GITTAG=		@GITTAG@
48GITBRANCH=	@GITBRANCH@
49PGO_PROF_GEN_FLAG=@PGO_PROF_GEN_FLAG@
50PGO_PROF_USE_FLAG=@PGO_PROF_USE_FLAG@
51LLVM_PROF_MERGER=@LLVM_PROF_MERGER@
52LLVM_PROF_FILE=@LLVM_PROF_FILE@
53LLVM_PROF_ERR=@LLVM_PROF_ERR@
54DTRACE=         @DTRACE@
55DFLAGS=         @DFLAGS@
56DTRACE_HEADERS= @DTRACE_HEADERS@
57DTRACE_OBJS=    @DTRACE_OBJS@
58
59GNULD=		@GNULD@
60
61# Shell used by make (some versions default to the login shell, which is bad)
62SHELL=		/bin/sh
63
64# Use this to make a link between python$(VERSION) and python in $(BINDIR)
65LN=		@LN@
66
67# Portable install script (configure doesn't always guess right)
68INSTALL=	@INSTALL@
69INSTALL_PROGRAM=@INSTALL_PROGRAM@
70INSTALL_SCRIPT= @INSTALL_SCRIPT@
71INSTALL_DATA=	@INSTALL_DATA@
72# Shared libraries must be installed with executable mode on some systems;
73# rather than figuring out exactly which, we always give them executable mode.
74INSTALL_SHARED= ${INSTALL} -m 755
75
76MKDIR_P=	@MKDIR_P@
77
78MAKESETUP=      $(srcdir)/Modules/makesetup
79
80# Compiler options
81OPT=		@OPT@
82BASECFLAGS=	@BASECFLAGS@
83BASECPPFLAGS=	@BASECPPFLAGS@
84CONFIGURE_CFLAGS=	@CFLAGS@
85# CFLAGS_NODIST is used for building the interpreter and stdlib C extensions.
86# Use it when a compiler flag should _not_ be part of the distutils CFLAGS
87# once Python is installed (Issue #21121).
88CONFIGURE_CFLAGS_NODIST=@CFLAGS_NODIST@
89# LDFLAGS_NODIST is used in the same manner as CFLAGS_NODIST.
90# Use it when a linker flag should _not_ be part of the distutils LDFLAGS
91# once Python is installed (bpo-35257)
92CONFIGURE_LDFLAGS_NODIST=@LDFLAGS_NODIST@
93# LDFLAGS_NOLTO is an extra flag to disable lto. It is used to speed up building
94# of _bootstrap_python and _freeze_module tools, which don't need LTO.
95CONFIGURE_LDFLAGS_NOLTO=@LDFLAGS_NOLTO@
96CONFIGURE_CPPFLAGS=	@CPPFLAGS@
97CONFIGURE_LDFLAGS=	@LDFLAGS@
98# Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the
99# command line to append to these values without stomping the pre-set
100# values.
101PY_CFLAGS=	$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
102PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal
103# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
104# be able to build extension modules using the directories specified in the
105# environment variables
106PY_CPPFLAGS=	$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
107PY_LDFLAGS=	$(CONFIGURE_LDFLAGS) $(LDFLAGS)
108PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)
109PY_LDFLAGS_NOLTO=$(PY_LDFLAGS) $(CONFIGURE_LDFLAGS_NOLTO) $(LDFLAGS_NODIST)
110NO_AS_NEEDED=	@NO_AS_NEEDED@
111CCSHARED=	@CCSHARED@
112# LINKFORSHARED are the flags passed to the $(CC) command that links
113# the python executable -- this is only needed for a few systems
114LINKFORSHARED=	@LINKFORSHARED@
115ARFLAGS=	@ARFLAGS@
116# Extra C flags added for building the interpreter object files.
117CFLAGSFORSHARED=@CFLAGSFORSHARED@
118# C flags used for building the interpreter object files
119PY_STDMODULE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)
120PY_BUILTIN_MODULE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN
121PY_CORE_CFLAGS=	$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
122# Linker flags used for building the interpreter object files
123PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST)
124# Strict or non-strict aliasing flags used to compile dtoa.c, see above
125CFLAGS_ALIASING=@CFLAGS_ALIASING@
126
127
128# Machine-dependent subdirectories
129MACHDEP=	@MACHDEP@
130
131# Multiarch directory (may be empty)
132MULTIARCH=	@MULTIARCH@
133MULTIARCH_CPPFLAGS = @MULTIARCH_CPPFLAGS@
134
135# Install prefix for architecture-independent files
136prefix=		@prefix@
137
138# Install prefix for architecture-dependent files
139exec_prefix=	@exec_prefix@
140
141# Install prefix for data files
142datarootdir=    @datarootdir@
143
144# Expanded directories
145BINDIR=		@bindir@
146LIBDIR=		@libdir@
147MANDIR=		@mandir@
148INCLUDEDIR=	@includedir@
149CONFINCLUDEDIR=	$(exec_prefix)/include
150PLATLIBDIR=	@PLATLIBDIR@
151SCRIPTDIR=	$(prefix)/$(PLATLIBDIR)
152ABIFLAGS=	@ABIFLAGS@
153# Variable used by ensurepip
154WHEEL_PKG_DIR=	@WHEEL_PKG_DIR@
155
156# Detailed destination directories
157BINLIBDEST=	@BINLIBDEST@
158LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
159INCLUDEPY=	$(INCLUDEDIR)/python$(LDVERSION)
160CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(LDVERSION)
161
162# Symbols used for using shared libraries
163SHLIB_SUFFIX=	@SHLIB_SUFFIX@
164EXT_SUFFIX=	@EXT_SUFFIX@
165LDSHARED=	@LDSHARED@ $(PY_LDFLAGS)
166BLDSHARED=	@BLDSHARED@ $(PY_CORE_LDFLAGS)
167LDCXXSHARED=	@LDCXXSHARED@
168DESTSHARED=	$(BINLIBDEST)/lib-dynload
169
170# List of exported symbols for AIX
171EXPORTSYMS=	@EXPORTSYMS@
172EXPORTSFROM=	@EXPORTSFROM@
173
174# Executable suffix (.exe on Windows and Mac OS X)
175EXE=		@EXEEXT@
176BUILDEXE=	@BUILDEXEEXT@
177
178# Short name and location for Mac OS X Python framework
179UNIVERSALSDK=@UNIVERSALSDK@
180PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
181PYTHONFRAMEWORKDIR=	@PYTHONFRAMEWORKDIR@
182PYTHONFRAMEWORKPREFIX=	@PYTHONFRAMEWORKPREFIX@
183PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
184# Deployment target selected during configure, to be checked
185# by distutils. The export statement is needed to ensure that the
186# deployment target is active during build.
187MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
188@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
189
190# Option to install to strip binaries
191STRIPFLAG=-s
192
193# Flags to lipo to produce a 32-bit-only universal executable
194LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
195
196# Flags to lipo to produce an intel-64-only universal executable
197LIPO_INTEL64_FLAGS=@LIPO_INTEL64_FLAGS@
198
199# Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
200OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@
201
202# Environment to run shared python without installed libraries
203RUNSHARED=       @RUNSHARED@
204
205# ensurepip options
206ENSUREPIP=      @ENSUREPIP@
207
208# Internal static libraries
209LIBMPDEC_A= Modules/_decimal/libmpdec/libmpdec.a
210LIBEXPAT_A= Modules/expat/libexpat.a
211
212# OpenSSL options for setup.py so sysconfig can pick up AC_SUBST() vars.
213OPENSSL_INCLUDES=@OPENSSL_INCLUDES@
214OPENSSL_LIBS=@OPENSSL_LIBS@
215OPENSSL_LDFLAGS=@OPENSSL_LDFLAGS@
216OPENSSL_RPATH=@OPENSSL_RPATH@
217
218# Module state, compiler flags and linker flags
219# Empty CFLAGS and LDFLAGS are omitted.
220# states:
221#   * yes: module is available
222#   * missing: build dependency is missing
223#   * disabled: module is disabled
224#   * n/a: module is not available on the current platform
225# MODULE_EGG_STATE=yes  # yes, missing, disabled, n/a
226# MODULE_EGG_CFLAGS=
227# MODULE_EGG_LDFLAGS=
228@MODULE_BLOCK@
229
230# Default zoneinfo.TZPATH. Added here to expose it in sysconfig.get_config_var
231TZPATH=@TZPATH@
232
233# Modes for directories, executables and data files created by the
234# install process.  Default to user-only-writable for all file types.
235DIRMODE=	755
236EXEMODE=	755
237FILEMODE=	644
238
239# configure script arguments
240CONFIG_ARGS=	@CONFIG_ARGS@
241
242
243# Subdirectories with code
244SRCDIRS= 	@SRCDIRS@
245
246# Other subdirectories
247SUBDIRSTOO=	Include Lib Misc
248
249# assets for Emscripten browser builds
250WASM_ASSETS_DIR=.$(prefix)
251WASM_STDLIB=$(WASM_ASSETS_DIR)/lib/python$(VERSION)/os.py
252
253# Files and directories to be distributed
254CONFIGFILES=	configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
255DISTFILES=	README.rst ChangeLog $(CONFIGFILES)
256DISTDIRS=	$(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
257DIST=		$(DISTFILES) $(DISTDIRS)
258
259
260LIBRARY=	@LIBRARY@
261LDLIBRARY=      @LDLIBRARY@
262BLDLIBRARY=     @BLDLIBRARY@
263PY3LIBRARY=     @PY3LIBRARY@
264DLLLIBRARY=	@DLLLIBRARY@
265LDLIBRARYDIR=   @LDLIBRARYDIR@
266INSTSONAME=	@INSTSONAME@
267LIBRARY_DEPS=	@LIBRARY_DEPS@
268LINK_PYTHON_DEPS=@LINK_PYTHON_DEPS@
269PY_ENABLE_SHARED=	@PY_ENABLE_SHARED@
270STATIC_LIBPYTHON=	@STATIC_LIBPYTHON@
271
272
273LIBS=		@LIBS@
274LIBM=		@LIBM@
275LIBC=		@LIBC@
276SYSLIBS=	$(LIBM) $(LIBC)
277SHLIBS=		@SHLIBS@
278
279DLINCLDIR=	@DLINCLDIR@
280DYNLOADFILE=	@DYNLOADFILE@
281MACHDEP_OBJS=	@MACHDEP_OBJS@
282LIBOBJDIR=	Python/
283LIBOBJS=	@LIBOBJS@
284
285PYTHON=		python$(EXE)
286BUILDPYTHON=	python$(BUILDEXE)
287
288HOSTRUNNER= @HOSTRUNNER@
289
290PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@
291UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py
292PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
293# Single-platform builds depend on $(BUILDPYTHON). Cross builds use an
294# external "build Python" and have an empty PYTHON_FOR_BUILD_DEPS.
295PYTHON_FOR_BUILD_DEPS=@PYTHON_FOR_BUILD_DEPS@
296
297# Single-platform builds use Programs/_freeze_module.c for bootstrapping and
298# ./_bootstrap_python Programs/_freeze_module.py for remaining modules
299# Cross builds use an external "build Python" for all modules.
300PYTHON_FOR_FREEZE=@PYTHON_FOR_FREEZE@
301FREEZE_MODULE_BOOTSTRAP=@FREEZE_MODULE_BOOTSTRAP@
302FREEZE_MODULE_BOOTSTRAP_DEPS=@FREEZE_MODULE_BOOTSTRAP_DEPS@
303FREEZE_MODULE=@FREEZE_MODULE@
304FREEZE_MODULE_DEPS=@FREEZE_MODULE_DEPS@
305
306_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
307BUILD_GNU_TYPE=	@build@
308HOST_GNU_TYPE=	@host@
309
310# The task to run while instrumented when building the profile-opt target.
311# To speed up profile generation, we don't run the full unit test suite
312# by default. The default is "-m test --pgo". To run more tests, use
313# PROFILE_TASK="-m test --pgo-extended"
314PROFILE_TASK=	@PROFILE_TASK@
315
316# report files for gcov / lcov coverage report
317COVERAGE_INFO=	$(abs_builddir)/coverage.info
318COVERAGE_REPORT=$(abs_builddir)/lcov-report
319COVERAGE_LCOV_OPTIONS=--rc lcov_branch_coverage=1
320COVERAGE_REPORT_OPTIONS=--rc lcov_branch_coverage=1 --branch-coverage --title "CPython $(VERSION) LCOV report [commit $(shell $(GITVERSION))]"
321
322
323# === Definitions added by makesetup ===
324
325
326##########################################################################
327# Modules
328MODULE_OBJS=	\
329		Modules/config.o \
330		Modules/main.o \
331		Modules/gcmodule.o
332
333IO_H=		Modules/_io/_iomodule.h
334
335IO_OBJS=	\
336		Modules/_io/_iomodule.o \
337		Modules/_io/iobase.o \
338		Modules/_io/fileio.o \
339		Modules/_io/bufferedio.o \
340		Modules/_io/textio.o \
341		Modules/_io/bytesio.o \
342		Modules/_io/stringio.o
343
344##########################################################################
345
346LIBFFI_INCLUDEDIR=	@LIBFFI_INCLUDEDIR@
347
348##########################################################################
349# Parser
350
351PEGEN_OBJS=		\
352		Parser/pegen.o \
353		Parser/pegen_errors.o \
354		Parser/action_helpers.o \
355		Parser/parser.o \
356		Parser/string_parser.o \
357		Parser/peg_api.o
358
359
360PEGEN_HEADERS= \
361		$(srcdir)/Include/internal/pycore_parser.h \
362		$(srcdir)/Parser/pegen.h \
363		$(srcdir)/Parser/string_parser.h
364
365POBJS=		\
366		Parser/token.o \
367
368PARSER_OBJS=	$(POBJS) $(PEGEN_OBJS) Parser/myreadline.o Parser/tokenizer.o
369
370PARSER_HEADERS= \
371		$(PEGEN_HEADERS) \
372		$(srcdir)/Parser/tokenizer.h
373
374##########################################################################
375# Python
376
377PYTHON_OBJS=	\
378		Python/_warnings.o \
379		Python/Python-ast.o \
380		Python/Python-tokenize.o \
381		Python/asdl.o \
382		Python/ast.o \
383		Python/ast_opt.o \
384		Python/ast_unparse.o \
385		Python/bltinmodule.o \
386		Python/ceval.o \
387		Python/codecs.o \
388		Python/compile.o \
389		Python/context.o \
390		Python/dynamic_annotations.o \
391		Python/errors.o \
392		Python/frame.o \
393		Python/frozenmain.o \
394		Python/future.o \
395		Python/getargs.o \
396		Python/getcompiler.o \
397		Python/getcopyright.o \
398		Python/getplatform.o \
399		Python/getversion.o \
400		Python/hamt.o \
401		Python/hashtable.o \
402		Python/import.o \
403		Python/importdl.o \
404		Python/initconfig.o \
405		Python/marshal.o \
406		Python/modsupport.o \
407		Python/mysnprintf.o \
408		Python/mystrtoul.o \
409		Python/pathconfig.o \
410		Python/preconfig.o \
411		Python/pyarena.o \
412		Python/pyctype.o \
413		Python/pyfpe.o \
414		Python/pyhash.o \
415		Python/pylifecycle.o \
416		Python/pymath.o \
417		Python/pystate.o \
418		Python/pythonrun.o \
419		Python/pytime.o \
420		Python/bootstrap_hash.o \
421		Python/specialize.o \
422		Python/structmember.o \
423		Python/symtable.o \
424		Python/sysmodule.o \
425		Python/thread.o \
426		Python/traceback.o \
427		Python/getopt.o \
428		Python/pystrcmp.o \
429		Python/pystrtod.o \
430		Python/pystrhex.o \
431		Python/dtoa.o \
432		Python/formatter_unicode.o \
433		Python/fileutils.o \
434		Python/suggestions.o \
435		Python/$(DYNLOADFILE) \
436		$(LIBOBJS) \
437		$(MACHDEP_OBJS) \
438		$(DTRACE_OBJS) \
439		@PLATFORM_OBJS@
440
441
442##########################################################################
443# Objects
444OBJECT_OBJS=	\
445		Objects/abstract.o \
446		Objects/accu.o \
447		Objects/boolobject.o \
448		Objects/bytes_methods.o \
449		Objects/bytearrayobject.o \
450		Objects/bytesobject.o \
451		Objects/call.o \
452		Objects/capsule.o \
453		Objects/cellobject.o \
454		Objects/classobject.o \
455		Objects/codeobject.o \
456		Objects/complexobject.o \
457		Objects/descrobject.o \
458		Objects/enumobject.o \
459		Objects/exceptions.o \
460		Objects/genericaliasobject.o \
461		Objects/genobject.o \
462		Objects/fileobject.o \
463		Objects/floatobject.o \
464		Objects/frameobject.o \
465		Objects/funcobject.o \
466		Objects/interpreteridobject.o \
467		Objects/iterobject.o \
468		Objects/listobject.o \
469		Objects/longobject.o \
470		Objects/dictobject.o \
471		Objects/odictobject.o \
472		Objects/memoryobject.o \
473		Objects/methodobject.o \
474		Objects/moduleobject.o \
475		Objects/namespaceobject.o \
476		Objects/object.o \
477		Objects/obmalloc.o \
478		Objects/picklebufobject.o \
479		Objects/rangeobject.o \
480		Objects/setobject.o \
481		Objects/sliceobject.o \
482		Objects/structseq.o \
483		Objects/tupleobject.o \
484		Objects/typeobject.o \
485		Objects/unicodeobject.o \
486		Objects/unicodectype.o \
487		Objects/unionobject.o \
488		Objects/weakrefobject.o
489
490DEEPFREEZE_OBJS = Python/deepfreeze/deepfreeze.o
491
492##########################################################################
493# objects that get linked into the Python library
494LIBRARY_OBJS_OMIT_FROZEN=	\
495		Modules/getbuildinfo.o \
496		$(PARSER_OBJS) \
497		$(OBJECT_OBJS) \
498		$(PYTHON_OBJS) \
499		$(MODULE_OBJS) \
500		$(MODOBJS)
501
502LIBRARY_OBJS=	\
503		$(LIBRARY_OBJS_OMIT_FROZEN) \
504		$(DEEPFREEZE_OBJS) \
505		Modules/getpath.o \
506		Python/frozen.o
507
508LINK_PYTHON_OBJS=@LINK_PYTHON_OBJS@
509
510##########################################################################
511# DTrace
512
513# On some systems, object files that reference DTrace probes need to be modified
514# in-place by dtrace(1).
515DTRACE_DEPS = \
516	Python/ceval.o Python/import.o Python/sysmodule.o Modules/gcmodule.o
517
518##########################################################################
519# decimal's libmpdec
520
521LIBMPDEC_OBJS= \
522		Modules/_decimal/libmpdec/basearith.o \
523		Modules/_decimal/libmpdec/constants.o \
524		Modules/_decimal/libmpdec/context.o \
525		Modules/_decimal/libmpdec/convolute.o \
526		Modules/_decimal/libmpdec/crt.o \
527		Modules/_decimal/libmpdec/difradix2.o \
528		Modules/_decimal/libmpdec/fnt.o \
529		Modules/_decimal/libmpdec/fourstep.o \
530		Modules/_decimal/libmpdec/io.o \
531		Modules/_decimal/libmpdec/mpalloc.o \
532		Modules/_decimal/libmpdec/mpdecimal.o \
533		Modules/_decimal/libmpdec/numbertheory.o \
534		Modules/_decimal/libmpdec/sixstep.o \
535		Modules/_decimal/libmpdec/transpose.o
536		# _decimal does not use signaling API
537		# Modules/_decimal/libmpdec/mpsignal.o
538
539LIBMPDEC_HEADERS= \
540		$(srcdir)/Modules/_decimal/libmpdec/basearith.h \
541		$(srcdir)/Modules/_decimal/libmpdec/bits.h \
542		$(srcdir)/Modules/_decimal/libmpdec/constants.h \
543		$(srcdir)/Modules/_decimal/libmpdec/convolute.h \
544		$(srcdir)/Modules/_decimal/libmpdec/crt.h \
545		$(srcdir)/Modules/_decimal/libmpdec/difradix2.h \
546		$(srcdir)/Modules/_decimal/libmpdec/fnt.h \
547		$(srcdir)/Modules/_decimal/libmpdec/fourstep.h \
548		$(srcdir)/Modules/_decimal/libmpdec/io.h \
549		$(srcdir)/Modules/_decimal/libmpdec/mpalloc.h \
550		$(srcdir)/Modules/_decimal/libmpdec/mpdecimal.h \
551		$(srcdir)/Modules/_decimal/libmpdec/numbertheory.h \
552		$(srcdir)/Modules/_decimal/libmpdec/sixstep.h \
553		$(srcdir)/Modules/_decimal/libmpdec/transpose.h \
554		$(srcdir)/Modules/_decimal/libmpdec/typearith.h \
555		$(srcdir)/Modules/_decimal/libmpdec/umodarith.h
556
557##########################################################################
558# pyexpat's expat library
559
560LIBEXPAT_OBJS= \
561		Modules/expat/xmlparse.o \
562		Modules/expat/xmlrole.o \
563		Modules/expat/xmltok.o
564
565LIBEXPAT_HEADERS= \
566		Modules/expat/ascii.h \
567		Modules/expat/asciitab.h \
568		Modules/expat/expat.h \
569		Modules/expat/expat_config.h \
570		Modules/expat/expat_external.h \
571		Modules/expat/iasciitab.h \
572		Modules/expat/internal.h \
573		Modules/expat/latin1tab.h \
574		Modules/expat/nametab.h \
575		Modules/expat/pyexpatns.h \
576		Modules/expat/siphash.h \
577		Modules/expat/utf8tab.h \
578		Modules/expat/xmlrole.h \
579		Modules/expat/xmltok.h \
580		Modules/expat/xmltok_impl.h
581
582#########################################################################
583# Rules
584
585# Default target
586all:		@DEF_MAKE_ALL_RULE@
587build_all:	check-clean-src $(BUILDPYTHON) platform oldsharedmods sharedmods \
588		gdbhooks Programs/_testembed python-config
589build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config
590
591# Check that the source is clean when building out of source.
592check-clean-src:
593	@if test -n "$(VPATH)" -a \( \
594	    -f "$(srcdir)/Programs/python.o" \
595	    -o -f "$(srcdir)\Python/frozen_modules/importlib._bootstrap.h" \
596	\); then \
597		echo "Error: The source directory ($(srcdir)) is not clean" ; \
598		echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \
599		echo "Try to run: make -C \"$(srcdir)\" clean" ; \
600		exit 1; \
601	fi
602
603# Profile generation build must start from a clean tree.
604profile-clean-stamp:
605	$(MAKE) clean
606	touch $@
607
608# Compile with profile generation enabled.
609profile-gen-stamp: profile-clean-stamp
610	@if [ $(LLVM_PROF_ERR) = yes ]; then \
611		echo "Error: Cannot perform PGO build because llvm-profdata was not found in PATH" ;\
612		echo "Please add it to PATH and run ./configure again" ;\
613		exit 1;\
614	fi
615	@echo "Building with support for profile generation:"
616	$(MAKE) build_all_generate_profile
617	touch $@
618
619# Run task with profile generation build to create profile information.
620profile-run-stamp:
621	@echo "Running code to generate profile data (this can take a while):"
622	# First, we need to create a clean build with profile generation
623	# enabled.
624	$(MAKE) profile-gen-stamp
625	# Next, run the profile task to generate the profile information.
626	$(MAKE) run_profile_task
627	$(MAKE) build_all_merge_profile
628	# Remove profile generation binary since we are done with it.
629	$(MAKE) clean-retain-profile
630	# This is an expensive target to build and it does not have proper
631	# makefile dependency information.  So, we create a "stamp" file
632	# to record its completion and avoid re-running it.
633	touch $@
634
635build_all_generate_profile:
636	$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)"
637
638run_profile_task:
639	@ # FIXME: can't run for a cross build
640	$(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true
641
642build_all_merge_profile:
643	$(LLVM_PROF_MERGER)
644
645# Compile Python binary with profile guided optimization.
646# To force re-running of the profile task, remove the profile-run-stamp file.
647profile-opt: profile-run-stamp
648	@echo "Rebuilding with profile guided optimizations:"
649	-rm -f profile-clean-stamp
650	$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_USE_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST)"
651
652# Compile and run with gcov
653.PHONY=coverage coverage-lcov coverage-report
654coverage:
655	@echo "Building with support for coverage checking:"
656	$(MAKE) clean
657	$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) -O0 -pg --coverage" LDFLAGS="$(LDFLAGS) --coverage"
658
659coverage-lcov:
660	@echo "Creating Coverage HTML report with LCOV:"
661	@rm -f $(COVERAGE_INFO)
662	@rm -rf $(COVERAGE_REPORT)
663	@lcov $(COVERAGE_LCOV_OPTIONS) --capture \
664	    --directory $(abs_builddir) \
665	    --base-directory $(realpath $(abs_builddir)) \
666	    --path $(realpath $(abs_srcdir)) \
667	    --output-file $(COVERAGE_INFO)
668	@ # remove 3rd party modules, system headers and internal files with
669	@ # debug, test or dummy functions.
670	@lcov $(COVERAGE_LCOV_OPTIONS) --remove $(COVERAGE_INFO) \
671	    '*/Modules/_blake2/impl/*' \
672	    '*/Modules/_ctypes/libffi*/*' \
673	    '*/Modules/_decimal/libmpdec/*' \
674	    '*/Modules/expat/*' \
675	    '*/Modules/xx*.c' \
676	    '*/Python/pyfpe.c' \
677	    '*/Python/pystrcmp.c' \
678	    '/usr/include/*' \
679	    '/usr/local/include/*' \
680	    '/usr/lib/gcc/*' \
681	    --output-file $(COVERAGE_INFO)
682	@genhtml $(COVERAGE_INFO) \
683	    --output-directory $(COVERAGE_REPORT) \
684	    $(COVERAGE_REPORT_OPTIONS)
685	@echo
686	@echo "lcov report at $(COVERAGE_REPORT)/index.html"
687	@echo
688
689# Force regeneration of parser and frozen modules
690coverage-report: regen-token regen-frozen
691	@ # build with coverage info
692	$(MAKE) coverage
693	@ # run tests, ignore failures
694	$(TESTRUNNER) $(TESTOPTS) || true
695	@ # build lcov report
696	$(MAKE) coverage-lcov
697
698# Run "Argument Clinic" over all source files
699.PHONY=clinic
700clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
701	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
702
703# Build the interpreter
704$(BUILDPYTHON):	Programs/python.o $(LINK_PYTHON_DEPS)
705	$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
706
707platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt
708	$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
709
710# Create build directory and generate the sysconfig build-time data there.
711# pybuilddir.txt contains the name of the build dir and is used for
712# sys.path fixup -- see Modules/getpath.c.
713# Since this step runs before shared modules are built, try to avoid bootstrap
714# problems by creating a dummy pybuilddir.txt just to allow interpreter
715# initialization to succeed.  It will be overwritten by generate-posix-vars
716# or removed in case of failure.
717pybuilddir.txt: $(PYTHON_FOR_BUILD_DEPS)
718	@echo "none" > ./pybuilddir.txt
719	$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
720	if test $$? -ne 0 ; then \
721		echo "generate-posix-vars failed" ; \
722		rm -f ./pybuilddir.txt ; \
723		exit 1 ; \
724	fi
725
726# blake2s is auto-generated from blake2b
727$(srcdir)/Modules/_blake2/blake2s_impl.c: $(srcdir)/Modules/_blake2/blake2b_impl.c $(srcdir)/Modules/_blake2/blake2b2s.py
728	$(PYTHON_FOR_REGEN) $(srcdir)/Modules/_blake2/blake2b2s.py
729	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $@
730
731# Build the shared modules
732# Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
733# -s, --silent or --quiet is always the first char.
734# Under BSD make, MAKEFLAGS might be " -s -v x=y".
735# Ignore macros passed by GNU make, passed after --
736sharedmods: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt @LIBMPDEC_INTERNAL@ @LIBEXPAT_INTERNAL@
737	@case "`echo X $$MAKEFLAGS | sed 's/^X //;s/ -- .*//'`" in \
738	    *\ -s*|s*) quiet="-q";; \
739	    *) quiet="";; \
740	esac; \
741	echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
742		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \
743	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
744		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
745
746
747# Build static library
748$(LIBRARY): $(LIBRARY_OBJS)
749	-rm -f $@
750	$(AR) $(ARFLAGS) $@ $(LIBRARY_OBJS)
751
752libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS)
753	if test $(INSTSONAME) != $(LDLIBRARY); then \
754		$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
755		$(LN) -f $(INSTSONAME) $@; \
756	else \
757		$(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
758	fi
759
760libpython3.so:	libpython$(LDVERSION).so
761	$(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
762
763libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
764	 $(CC) -dynamiclib -Wl,-single_module $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
765
766
767libpython$(VERSION).sl: $(LIBRARY_OBJS)
768	$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM)
769
770# List of exported symbols for AIX
771Modules/python.exp: $(LIBRARY)
772	$(srcdir)/Modules/makexp_aix $@ "$(EXPORTSFROM)" $?
773
774# Copy up the gdb python hooks into a position where they can be automatically
775# loaded by gdb during Lib/test/test_gdb.py
776#
777# Distributors are likely to want to install this somewhere else e.g. relative
778# to the stripped DWARF data for the shared library.
779gdbhooks: $(BUILDPYTHON)-gdb.py
780
781SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py
782$(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
783	$(INSTALL_DATA) $(SRC_GDB_HOOKS) $(BUILDPYTHON)-gdb.py
784
785# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
786# minimal framework (not including the Lib directory and such) in the current
787# directory.
788RESSRCDIR=Mac/Resources/framework
789$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
790		$(LIBRARY) \
791		$(RESSRCDIR)/Info.plist
792	$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
793	$(CC) -o $(LDLIBRARY) $(PY_CORE_LDFLAGS) -dynamiclib \
794		-all_load $(LIBRARY) -Wl,-single_module \
795		-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
796		-compatibility_version $(VERSION) \
797		-current_version $(VERSION) \
798		-framework CoreFoundation $(LIBS);
799	$(INSTALL) -d -m $(DIRMODE)  \
800		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
801	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
802		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
803	$(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
804	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
805	$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
806
807# This rule builds the Cygwin Python DLL and import library if configured
808# for a shared core library; otherwise, this rule is a noop.
809$(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
810	if test -n "$(DLLLIBRARY)"; then \
811		$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
812			$(LIBS) $(MODLIBS) $(SYSLIBS); \
813	else true; \
814	fi
815
816# wasm32-emscripten browser build
817# wasm assets directory is relative to current build dir, e.g. "./usr/local".
818# --preload-file turns a relative asset path into an absolute path.
819
820.PHONY: wasm_stdlib
821wasm_stdlib: $(WASM_STDLIB)
822$(WASM_STDLIB): $(srcdir)/Lib/*.py $(srcdir)/Lib/*/*.py \
823	    $(srcdir)/Tools/wasm/wasm_assets.py \
824	    Makefile pybuilddir.txt Modules/Setup.local
825	$(PYTHON_FOR_BUILD) $(srcdir)/Tools/wasm/wasm_assets.py \
826	    --buildroot . --prefix $(prefix)
827
828python.html: $(srcdir)/Tools/wasm/python.html python.worker.js
829	@cp $(srcdir)/Tools/wasm/python.html $@
830
831python.worker.js: $(srcdir)/Tools/wasm/python.worker.js
832	@cp $(srcdir)/Tools/wasm/python.worker.js $@
833
834##########################################################################
835# Build static libmpdec.a
836LIBMPDEC_CFLAGS=@LIBMPDEC_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
837
838# for setup.py
839DECIMAL_CFLAGS=@LIBMPDEC_CFLAGS@
840DECIMAL_LDFLAGS=@LIBMPDEC_LDFLAGS@
841
842# "%.o: %c" is not portable
843Modules/_decimal/libmpdec/basearith.o: $(srcdir)/Modules/_decimal/libmpdec/basearith.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
844	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/basearith.c
845
846Modules/_decimal/libmpdec/constants.o: $(srcdir)/Modules/_decimal/libmpdec/constants.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
847	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/constants.c
848
849Modules/_decimal/libmpdec/context.o: $(srcdir)/Modules/_decimal/libmpdec/context.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
850	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/context.c
851
852Modules/_decimal/libmpdec/convolute.o: $(srcdir)/Modules/_decimal/libmpdec/convolute.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
853	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/convolute.c
854
855Modules/_decimal/libmpdec/crt.o: $(srcdir)/Modules/_decimal/libmpdec/crt.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
856	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/crt.c
857
858Modules/_decimal/libmpdec/difradix2.o: $(srcdir)/Modules/_decimal/libmpdec/difradix2.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
859	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/difradix2.c
860
861Modules/_decimal/libmpdec/fnt.o: $(srcdir)/Modules/_decimal/libmpdec/fnt.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
862	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/fnt.c
863
864Modules/_decimal/libmpdec/fourstep.o: $(srcdir)/Modules/_decimal/libmpdec/fourstep.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
865	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/fourstep.c
866
867Modules/_decimal/libmpdec/io.o: $(srcdir)/Modules/_decimal/libmpdec/io.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
868	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/io.c
869
870Modules/_decimal/libmpdec/mpalloc.o: $(srcdir)/Modules/_decimal/libmpdec/mpalloc.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
871	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpalloc.c
872
873Modules/_decimal/libmpdec/mpdecimal.o: $(srcdir)/Modules/_decimal/libmpdec/mpdecimal.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
874	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpdecimal.c
875
876Modules/_decimal/libmpdec/mpsignal.o: $(srcdir)/Modules/_decimal/libmpdec/mpsignal.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
877	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpsignal.c
878
879Modules/_decimal/libmpdec/numbertheory.o: $(srcdir)/Modules/_decimal/libmpdec/numbertheory.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
880	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/numbertheory.c
881
882Modules/_decimal/libmpdec/sixstep.o: $(srcdir)/Modules/_decimal/libmpdec/sixstep.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
883	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/sixstep.c
884
885Modules/_decimal/libmpdec/transpose.o: $(srcdir)/Modules/_decimal/libmpdec/transpose.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
886	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/transpose.c
887
888$(LIBMPDEC_A): $(LIBMPDEC_OBJS)
889	-rm -f $@
890	$(AR) $(ARFLAGS) $@ $(LIBMPDEC_OBJS)
891
892##########################################################################
893# Build static libexpat.a
894LIBEXPAT_CFLAGS=@LIBEXPAT_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
895
896# for setup.py
897EXPAT_CFLAGS=@LIBEXPAT_CFLAGS@
898EXPAT_LDFLAGS=@LIBEXPAT_LDFLAGS@
899
900Modules/expat/xmlparse.o: $(srcdir)/Modules/expat/xmlparse.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
901	$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmlparse.c
902
903Modules/expat/xmlrole.o: $(srcdir)/Modules/expat/xmlrole.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
904	$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmlrole.c
905
906Modules/expat/xmltok.o: $(srcdir)/Modules/expat/xmltok.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
907	$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmltok.c
908
909$(LIBEXPAT_A): $(LIBEXPAT_OBJS)
910	-rm -f $@
911	$(AR) $(ARFLAGS) $@ $(LIBEXPAT_OBJS)
912
913# create relative links from build/lib.platform/egg.so to Modules/egg.so
914# pybuilddir.txt is created too late. We cannot use it in Makefile
915# targets. ln --relative is not portable.
916oldsharedmods: $(SHAREDMODS) pybuilddir.txt
917	@target=`cat pybuilddir.txt`; \
918	$(MKDIR_P) $$target; \
919	for mod in X $(SHAREDMODS); do \
920		if test $$mod != X; then \
921			$(LN) -sf ../../$$mod $$target/`basename $$mod`; \
922		fi; \
923	done
924
925Modules/Setup.local:
926	@# Create empty Setup.local when file was deleted by user
927	echo "# Edit this file for local setup changes" > $@
928
929Modules/Setup.bootstrap: $(srcdir)/Modules/Setup.bootstrap.in config.status
930	./config.status $@
931
932Modules/Setup.stdlib: $(srcdir)/Modules/Setup.stdlib.in config.status
933	./config.status $@
934
935Makefile Modules/config.c: Makefile.pre \
936				$(srcdir)/Modules/config.c.in \
937				$(MAKESETUP) \
938				$(srcdir)/Modules/Setup \
939				Modules/Setup.local \
940				Modules/Setup.bootstrap \
941				Modules/Setup.stdlib
942	$(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
943				-s Modules \
944				Modules/Setup.local \
945				@MODULES_SETUP_STDLIB@ \
946				Modules/Setup.bootstrap \
947				$(srcdir)/Modules/Setup
948	@mv config.c Modules
949	@echo "The Makefile was updated, you may need to re-run make."
950
951.PHONY: regen-test-frozenmain
952regen-test-frozenmain: $(BUILDPYTHON)
953	# Regenerate Programs/test_frozenmain.h
954	# from Programs/test_frozenmain.py
955	# using Programs/freeze_test_frozenmain.py
956	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Programs/freeze_test_frozenmain.py Programs/test_frozenmain.h
957
958.PHONY: regen-re
959regen-re: $(BUILDPYTHON)
960	# Regenerate Lib/re/_casefix.py
961	# using Tools/scripts/generate_re_casefix.py
962	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/generate_re_casefix.py $(srcdir)/Lib/re/_casefix.py
963
964Programs/_testembed: Programs/_testembed.o $(LINK_PYTHON_DEPS)
965	$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
966
967############################################################################
968# "Bootstrap Python" used to run deepfreeze.py
969
970BOOTSTRAP_HEADERS = \
971	Python/frozen_modules/importlib._bootstrap.h \
972	Python/frozen_modules/importlib._bootstrap_external.h
973
974Programs/_bootstrap_python.o: Programs/_bootstrap_python.c $(BOOTSTRAP_HEADERS) $(PYTHON_HEADERS)
975
976_bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modules/getpath.o Modules/Setup.local
977	$(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ $(LIBRARY_OBJS_OMIT_FROZEN) \
978		Programs/_bootstrap_python.o Modules/getpath.o $(LIBS) $(MODLIBS) $(SYSLIBS)
979
980
981############################################################################
982# frozen modules (including importlib)
983#
984# Freezing is a multi step process. It works differently for standard builds
985# and cross builds. Standard builds use Programs/_freeze_module and
986# _bootstrap_python for freezing and deepfreezing, so users can build Python
987# without an existing Python installation. Cross builds cannot execute
988# compiled binaries and therefore rely on an external build Python
989# interpreter. The build interpreter must have same version and same bytecode
990# as the host (target) binary.
991#
992# Standard build process:
993# 1) compile minimal core objects for Py_Compile*() and PyMarshal_Write*().
994# 2) build Programs/_freeze_module binary.
995# 3) create frozen module headers for importlib and getpath.
996# 4) build _bootstrap_python binary.
997# 5) create remaining frozen module headers with
998#    ``./_bootstrap_python Programs/_freeze_module.py``. The pure Python
999#    script is used to test the cross compile code path.
1000# 6) deepfreeze modules with _bootstrap_python
1001#
1002# Cross compile process:
1003# 1) create all frozen module headers with external build Python and
1004#    Programs/_freeze_module.py script.
1005# 2) deepfreeze modules with external build Python.
1006#
1007
1008# FROZEN_FILES_* are auto-generated by Tools/scripts/freeze_modules.py.
1009FROZEN_FILES_IN = \
1010		Lib/importlib/_bootstrap.py \
1011		Lib/importlib/_bootstrap_external.py \
1012		Lib/zipimport.py \
1013		Lib/abc.py \
1014		Lib/codecs.py \
1015		Lib/io.py \
1016		Lib/_collections_abc.py \
1017		Lib/_sitebuiltins.py \
1018		Lib/genericpath.py \
1019		Lib/ntpath.py \
1020		Lib/posixpath.py \
1021		Lib/os.py \
1022		Lib/site.py \
1023		Lib/stat.py \
1024		Lib/importlib/util.py \
1025		Lib/importlib/machinery.py \
1026		Lib/runpy.py \
1027		Lib/__hello__.py \
1028		Lib/__phello__/__init__.py \
1029		Lib/__phello__/ham/__init__.py \
1030		Lib/__phello__/ham/eggs.py \
1031		Lib/__phello__/spam.py \
1032		Tools/freeze/flag.py
1033# End FROZEN_FILES_IN
1034FROZEN_FILES_OUT = \
1035		Python/frozen_modules/importlib._bootstrap.h \
1036		Python/frozen_modules/importlib._bootstrap_external.h \
1037		Python/frozen_modules/zipimport.h \
1038		Python/frozen_modules/abc.h \
1039		Python/frozen_modules/codecs.h \
1040		Python/frozen_modules/io.h \
1041		Python/frozen_modules/_collections_abc.h \
1042		Python/frozen_modules/_sitebuiltins.h \
1043		Python/frozen_modules/genericpath.h \
1044		Python/frozen_modules/ntpath.h \
1045		Python/frozen_modules/posixpath.h \
1046		Python/frozen_modules/os.h \
1047		Python/frozen_modules/site.h \
1048		Python/frozen_modules/stat.h \
1049		Python/frozen_modules/importlib.util.h \
1050		Python/frozen_modules/importlib.machinery.h \
1051		Python/frozen_modules/runpy.h \
1052		Python/frozen_modules/__hello__.h \
1053		Python/frozen_modules/__phello__.h \
1054		Python/frozen_modules/__phello__.ham.h \
1055		Python/frozen_modules/__phello__.ham.eggs.h \
1056		Python/frozen_modules/__phello__.spam.h \
1057		Python/frozen_modules/frozen_only.h
1058# End FROZEN_FILES_OUT
1059
1060Programs/_freeze_module.o: Programs/_freeze_module.c Makefile
1061
1062Modules/getpath_noop.o: $(srcdir)/Modules/getpath_noop.c Makefile
1063
1064Programs/_freeze_module: Programs/_freeze_module.o Modules/getpath_noop.o $(LIBRARY_OBJS_OMIT_FROZEN)
1065	$(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_module.o Modules/getpath_noop.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS)
1066
1067# We manually freeze getpath.py rather than through freeze_modules
1068Python/frozen_modules/getpath.h: Modules/getpath.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1069	$(FREEZE_MODULE_BOOTSTRAP) getpath $(srcdir)/Modules/getpath.py Python/frozen_modules/getpath.h
1070
1071# BEGIN: freezing modules
1072
1073Python/frozen_modules/importlib._bootstrap.h: Lib/importlib/_bootstrap.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1074	$(FREEZE_MODULE_BOOTSTRAP) importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h
1075
1076Python/frozen_modules/importlib._bootstrap_external.h: Lib/importlib/_bootstrap_external.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1077	$(FREEZE_MODULE_BOOTSTRAP) importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
1078
1079Python/frozen_modules/zipimport.h: Lib/zipimport.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1080	$(FREEZE_MODULE_BOOTSTRAP) zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h
1081
1082Python/frozen_modules/abc.h: Lib/abc.py $(FREEZE_MODULE_DEPS)
1083	$(FREEZE_MODULE) abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h
1084
1085Python/frozen_modules/codecs.h: Lib/codecs.py $(FREEZE_MODULE_DEPS)
1086	$(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
1087
1088Python/frozen_modules/io.h: Lib/io.py $(FREEZE_MODULE_DEPS)
1089	$(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
1090
1091Python/frozen_modules/_collections_abc.h: Lib/_collections_abc.py $(FREEZE_MODULE_DEPS)
1092	$(FREEZE_MODULE) _collections_abc $(srcdir)/Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h
1093
1094Python/frozen_modules/_sitebuiltins.h: Lib/_sitebuiltins.py $(FREEZE_MODULE_DEPS)
1095	$(FREEZE_MODULE) _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h
1096
1097Python/frozen_modules/genericpath.h: Lib/genericpath.py $(FREEZE_MODULE_DEPS)
1098	$(FREEZE_MODULE) genericpath $(srcdir)/Lib/genericpath.py Python/frozen_modules/genericpath.h
1099
1100Python/frozen_modules/ntpath.h: Lib/ntpath.py $(FREEZE_MODULE_DEPS)
1101	$(FREEZE_MODULE) ntpath $(srcdir)/Lib/ntpath.py Python/frozen_modules/ntpath.h
1102
1103Python/frozen_modules/posixpath.h: Lib/posixpath.py $(FREEZE_MODULE_DEPS)
1104	$(FREEZE_MODULE) posixpath $(srcdir)/Lib/posixpath.py Python/frozen_modules/posixpath.h
1105
1106Python/frozen_modules/os.h: Lib/os.py $(FREEZE_MODULE_DEPS)
1107	$(FREEZE_MODULE) os $(srcdir)/Lib/os.py Python/frozen_modules/os.h
1108
1109Python/frozen_modules/site.h: Lib/site.py $(FREEZE_MODULE_DEPS)
1110	$(FREEZE_MODULE) site $(srcdir)/Lib/site.py Python/frozen_modules/site.h
1111
1112Python/frozen_modules/stat.h: Lib/stat.py $(FREEZE_MODULE_DEPS)
1113	$(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
1114
1115Python/frozen_modules/importlib.util.h: Lib/importlib/util.py $(FREEZE_MODULE_DEPS)
1116	$(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h
1117
1118Python/frozen_modules/importlib.machinery.h: Lib/importlib/machinery.py $(FREEZE_MODULE_DEPS)
1119	$(FREEZE_MODULE) importlib.machinery $(srcdir)/Lib/importlib/machinery.py Python/frozen_modules/importlib.machinery.h
1120
1121Python/frozen_modules/runpy.h: Lib/runpy.py $(FREEZE_MODULE_DEPS)
1122	$(FREEZE_MODULE) runpy $(srcdir)/Lib/runpy.py Python/frozen_modules/runpy.h
1123
1124Python/frozen_modules/__hello__.h: Lib/__hello__.py $(FREEZE_MODULE_DEPS)
1125	$(FREEZE_MODULE) __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h
1126
1127Python/frozen_modules/__phello__.h: Lib/__phello__/__init__.py $(FREEZE_MODULE_DEPS)
1128	$(FREEZE_MODULE) __phello__ $(srcdir)/Lib/__phello__/__init__.py Python/frozen_modules/__phello__.h
1129
1130Python/frozen_modules/__phello__.ham.h: Lib/__phello__/ham/__init__.py $(FREEZE_MODULE_DEPS)
1131	$(FREEZE_MODULE) __phello__.ham $(srcdir)/Lib/__phello__/ham/__init__.py Python/frozen_modules/__phello__.ham.h
1132
1133Python/frozen_modules/__phello__.ham.eggs.h: Lib/__phello__/ham/eggs.py $(FREEZE_MODULE_DEPS)
1134	$(FREEZE_MODULE) __phello__.ham.eggs $(srcdir)/Lib/__phello__/ham/eggs.py Python/frozen_modules/__phello__.ham.eggs.h
1135
1136Python/frozen_modules/__phello__.spam.h: Lib/__phello__/spam.py $(FREEZE_MODULE_DEPS)
1137	$(FREEZE_MODULE) __phello__.spam $(srcdir)/Lib/__phello__/spam.py Python/frozen_modules/__phello__.spam.h
1138
1139Python/frozen_modules/frozen_only.h: Tools/freeze/flag.py $(FREEZE_MODULE_DEPS)
1140	$(FREEZE_MODULE) frozen_only $(srcdir)/Tools/freeze/flag.py Python/frozen_modules/frozen_only.h
1141
1142# END: freezing modules
1143
1144Tools/scripts/freeze_modules.py: $(FREEZE_MODULE)
1145
1146.PHONY: regen-frozen
1147regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN)
1148	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/freeze_modules.py
1149	@echo "The Makefile was updated, you may need to re-run make."
1150
1151############################################################################
1152# Deepfreeze targets
1153
1154.PHONY: regen-deepfreeze
1155regen-deepfreeze: $(DEEPFREEZE_OBJS)
1156
1157DEEPFREEZE_DEPS=$(srcdir)/Tools/scripts/deepfreeze.py $(FREEZE_MODULE_DEPS) $(FROZEN_FILES_OUT)
1158
1159# BEGIN: deepfreeze modules
1160Python/deepfreeze/deepfreeze.c: $(DEEPFREEZE_DEPS)
1161	$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py \
1162	Python/frozen_modules/importlib._bootstrap.h:importlib._bootstrap \
1163	Python/frozen_modules/importlib._bootstrap_external.h:importlib._bootstrap_external \
1164	Python/frozen_modules/zipimport.h:zipimport \
1165	Python/frozen_modules/abc.h:abc \
1166	Python/frozen_modules/codecs.h:codecs \
1167	Python/frozen_modules/io.h:io \
1168	Python/frozen_modules/_collections_abc.h:_collections_abc \
1169	Python/frozen_modules/_sitebuiltins.h:_sitebuiltins \
1170	Python/frozen_modules/genericpath.h:genericpath \
1171	Python/frozen_modules/ntpath.h:ntpath \
1172	Python/frozen_modules/posixpath.h:posixpath \
1173	Python/frozen_modules/os.h:os \
1174	Python/frozen_modules/site.h:site \
1175	Python/frozen_modules/stat.h:stat \
1176	Python/frozen_modules/importlib.util.h:importlib.util \
1177	Python/frozen_modules/importlib.machinery.h:importlib.machinery \
1178	Python/frozen_modules/runpy.h:runpy \
1179	Python/frozen_modules/__hello__.h:__hello__ \
1180	Python/frozen_modules/__phello__.h:__phello__ \
1181	Python/frozen_modules/__phello__.ham.h:__phello__.ham \
1182	Python/frozen_modules/__phello__.ham.eggs.h:__phello__.ham.eggs \
1183	Python/frozen_modules/__phello__.spam.h:__phello__.spam \
1184	Python/frozen_modules/frozen_only.h:frozen_only \
1185	-o Python/deepfreeze/deepfreeze.c
1186# END: deepfreeze modules
1187	@echo "Note: Deepfreeze may have added some global objects,"
1188	@echo "      so run 'make regen-global-objects' if necessary."
1189
1190# We keep this renamed target around for folks with muscle memory.
1191.PHONY: regen-importlib
1192regen-importlib: regen-frozen
1193
1194############################################################################
1195# Global objects
1196
1197.PHONY: regen-global-objects
1198regen-global-objects: $(srcdir)/Tools/scripts/generate_global_objects.py
1199	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_global_objects.py
1200	@echo "Note: Global objects can be added or removed by other tools (e.g. deepfreeze), "
1201	@echo "      so be sure to re-run regen-global-objects after those tools."
1202
1203############################################################################
1204# ABI
1205
1206regen-abidump: all
1207	@$(MKDIR_P) $(srcdir)/Doc/data/
1208	abidw "libpython$(LDVERSION).so" --no-architecture --out-file $(srcdir)/Doc/data/python$(LDVERSION).abi.new
1209	@$(UPDATE_FILE) $(srcdir)/Doc/data/python$(LDVERSION).abi $(srcdir)/Doc/data/python$(LDVERSION).abi.new
1210
1211check-abidump: all
1212		abidiff $(srcdir)/Doc/data/python$(LDVERSION).abi "libpython$(LDVERSION).so" --drop-private-types --no-architecture --no-added-syms
1213
1214regen-limited-abi: all
1215	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/stable_abi.py --generate-all $(srcdir)/Misc/stable_abi.toml
1216
1217############################################################################
1218# Regenerate all generated files
1219
1220regen-all: regen-opcode regen-opcode-targets regen-typeslots \
1221	regen-token regen-ast regen-keyword regen-sre regen-frozen clinic \
1222	regen-pegen-metaparser regen-pegen regen-test-frozenmain \
1223	regen-global-objects
1224	@echo
1225	@echo "Note: make regen-stdlib-module-names and make regen-configure should be run manually"
1226
1227############################################################################
1228# Special rules for object files
1229
1230Modules/getbuildinfo.o: $(PARSER_OBJS) \
1231		$(OBJECT_OBJS) \
1232		$(PYTHON_OBJS) \
1233		$(MODULE_OBJS) \
1234		$(MODOBJS) \
1235		$(DTRACE_OBJS) \
1236		$(srcdir)/Modules/getbuildinfo.c
1237	$(CC) -c $(PY_CORE_CFLAGS) \
1238	      -DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \
1239	      -DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \
1240	      -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \
1241	      -o $@ $(srcdir)/Modules/getbuildinfo.c
1242
1243Modules/getpath.o: $(srcdir)/Modules/getpath.c Python/frozen_modules/getpath.h Makefile $(PYTHON_HEADERS)
1244	$(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
1245		-DPREFIX='"$(prefix)"' \
1246		-DEXEC_PREFIX='"$(exec_prefix)"' \
1247		-DVERSION='"$(VERSION)"' \
1248		-DVPATH='"$(VPATH)"' \
1249		-DPLATLIBDIR='"$(PLATLIBDIR)"' \
1250		-DPYTHONFRAMEWORK='"$(PYTHONFRAMEWORK)"' \
1251		-o $@ $(srcdir)/Modules/getpath.c
1252
1253Programs/python.o: $(srcdir)/Programs/python.c
1254	$(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/python.c
1255
1256Programs/_testembed.o: $(srcdir)/Programs/_testembed.c Programs/test_frozenmain.h
1257	$(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/_testembed.c
1258
1259Modules/_sre/sre.o: $(srcdir)/Modules/_sre/sre.c $(srcdir)/Modules/_sre/sre.h $(srcdir)/Modules/_sre/sre_constants.h $(srcdir)/Modules/_sre/sre_lib.h
1260
1261Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c $(srcdir)/Modules/posixmodule.h
1262
1263Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule.h
1264
1265Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h
1266
1267Modules/signalmodule.o: $(srcdir)/Modules/signalmodule.c $(srcdir)/Modules/posixmodule.h
1268
1269Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
1270	$(CC) -c $(PY_CORE_CFLAGS) \
1271		-DSOABI='"$(SOABI)"' \
1272		-o $@ $(srcdir)/Python/dynload_shlib.c
1273
1274Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
1275	$(CC) -c $(PY_CORE_CFLAGS) \
1276		-DSHLIB_EXT='"$(EXT_SUFFIX)"' \
1277		-o $@ $(srcdir)/Python/dynload_hpux.c
1278
1279Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydtrace.h
1280	$(CC) -c $(PY_CORE_CFLAGS) \
1281		-DABIFLAGS='"$(ABIFLAGS)"' \
1282		$(MULTIARCH_CPPFLAGS) \
1283		-o $@ $(srcdir)/Python/sysmodule.c
1284
1285$(IO_OBJS): $(IO_H)
1286
1287.PHONY: regen-pegen-metaparser
1288regen-pegen-metaparser:
1289	@$(MKDIR_P) $(srcdir)/Tools/peg_generator/pegen
1290	PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen -q python \
1291	$(srcdir)/Tools/peg_generator/pegen/metagrammar.gram \
1292	-o $(srcdir)/Tools/peg_generator/pegen/grammar_parser.py.new
1293	$(UPDATE_FILE) $(srcdir)/Tools/peg_generator/pegen/grammar_parser.py \
1294	$(srcdir)/Tools/peg_generator/pegen/grammar_parser.py.new
1295
1296.PHONY: regen-pegen
1297regen-pegen:
1298	@$(MKDIR_P) $(srcdir)/Parser
1299	PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen -q c \
1300		$(srcdir)/Grammar/python.gram \
1301		$(srcdir)/Grammar/Tokens \
1302		-o $(srcdir)/Parser/parser.new.c
1303	$(UPDATE_FILE) $(srcdir)/Parser/parser.c $(srcdir)/Parser/parser.new.c
1304
1305.PHONY=regen-ast
1306regen-ast:
1307	# Regenerate 3 files using using Parser/asdl_c.py:
1308	# - Include/internal/pycore_ast.h
1309	# - Include/internal/pycore_ast_state.h
1310	# - Python/Python-ast.c
1311	$(MKDIR_P) $(srcdir)/Include
1312	$(MKDIR_P) $(srcdir)/Python
1313	$(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
1314		$(srcdir)/Parser/Python.asdl \
1315		-H $(srcdir)/Include/internal/pycore_ast.h.new \
1316		-I $(srcdir)/Include/internal/pycore_ast_state.h.new \
1317		-C $(srcdir)/Python/Python-ast.c.new
1318
1319	$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_ast.h $(srcdir)/Include/internal/pycore_ast.h.new
1320	$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_ast_state.h $(srcdir)/Include/internal/pycore_ast_state.h.new
1321	$(UPDATE_FILE) $(srcdir)/Python/Python-ast.c $(srcdir)/Python/Python-ast.c.new
1322
1323.PHONY: regen-opcode
1324regen-opcode:
1325	# Regenerate Include/opcode.h from Lib/opcode.py
1326	# using Tools/scripts/generate_opcode_h.py
1327	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \
1328		$(srcdir)/Lib/opcode.py \
1329		$(srcdir)/Include/opcode.h.new \
1330		$(srcdir)/Include/internal/pycore_opcode.h.new
1331	$(UPDATE_FILE) $(srcdir)/Include/opcode.h $(srcdir)/Include/opcode.h.new
1332	$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_opcode.h $(srcdir)/Include/internal/pycore_opcode.h.new
1333
1334.PHONY: regen-token
1335regen-token:
1336	# Regenerate Doc/library/token-list.inc from Grammar/Tokens
1337	# using Tools/scripts/generate_token.py
1338	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py rst \
1339		$(srcdir)/Grammar/Tokens \
1340		$(srcdir)/Doc/library/token-list.inc
1341	# Regenerate Include/token.h from Grammar/Tokens
1342	# using Tools/scripts/generate_token.py
1343	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py h \
1344		$(srcdir)/Grammar/Tokens \
1345		$(srcdir)/Include/token.h
1346	# Regenerate Parser/token.c from Grammar/Tokens
1347	# using Tools/scripts/generate_token.py
1348	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py c \
1349		$(srcdir)/Grammar/Tokens \
1350		$(srcdir)/Parser/token.c
1351	# Regenerate Lib/token.py from Grammar/Tokens
1352	# using Tools/scripts/generate_token.py
1353	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py py \
1354		$(srcdir)/Grammar/Tokens \
1355		$(srcdir)/Lib/token.py
1356
1357.PHONY: regen-keyword
1358regen-keyword:
1359	# Regenerate Lib/keyword.py from Grammar/python.gram and Grammar/Tokens
1360	# using Tools/peg_generator/pegen
1361	PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen.keywordgen \
1362		$(srcdir)/Grammar/python.gram \
1363		$(srcdir)/Grammar/Tokens \
1364		$(srcdir)/Lib/keyword.py.new
1365	$(UPDATE_FILE) $(srcdir)/Lib/keyword.py $(srcdir)/Lib/keyword.py.new
1366
1367.PHONY: regen-stdlib-module-names
1368regen-stdlib-module-names: all Programs/_testembed
1369	# Regenerate Python/stdlib_module_names.h
1370	# using Tools/scripts/generate_stdlib_module_names.py
1371	$(RUNSHARED) ./$(BUILDPYTHON) \
1372		$(srcdir)/Tools/scripts/generate_stdlib_module_names.py \
1373		> $(srcdir)/Python/stdlib_module_names.h.new
1374	$(UPDATE_FILE) $(srcdir)/Python/stdlib_module_names.h $(srcdir)/Python/stdlib_module_names.h.new
1375
1376regen-sre:
1377	# Regenerate Modules/_sre/sre_constants.h and Modules/_sre/sre_targets.h
1378	# from Lib/re/_constants.py using Tools/scripts/generate_sre_constants.py
1379	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_sre_constants.py \
1380		$(srcdir)/Lib/re/_constants.py \
1381		$(srcdir)/Modules/_sre/sre_constants.h \
1382		$(srcdir)/Modules/_sre/sre_targets.h
1383
1384Python/compile.o Python/symtable.o Python/ast_unparse.o Python/ast.o Python/future.o: $(srcdir)/Include/internal/pycore_ast.h
1385
1386Python/getplatform.o: $(srcdir)/Python/getplatform.c
1387		$(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
1388
1389Python/importdl.o: $(srcdir)/Python/importdl.c
1390		$(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
1391
1392Objects/unicodectype.o:	$(srcdir)/Objects/unicodectype.c \
1393				$(srcdir)/Objects/unicodetype_db.h
1394
1395BYTESTR_DEPS = \
1396		$(srcdir)/Objects/stringlib/count.h \
1397		$(srcdir)/Objects/stringlib/ctype.h \
1398		$(srcdir)/Objects/stringlib/fastsearch.h \
1399		$(srcdir)/Objects/stringlib/find.h \
1400		$(srcdir)/Objects/stringlib/join.h \
1401		$(srcdir)/Objects/stringlib/partition.h \
1402		$(srcdir)/Objects/stringlib/split.h \
1403		$(srcdir)/Objects/stringlib/stringdefs.h \
1404		$(srcdir)/Objects/stringlib/transmogrify.h
1405
1406UNICODE_DEPS = \
1407		$(srcdir)/Objects/stringlib/asciilib.h \
1408		$(srcdir)/Objects/stringlib/codecs.h \
1409		$(srcdir)/Objects/stringlib/count.h \
1410		$(srcdir)/Objects/stringlib/fastsearch.h \
1411		$(srcdir)/Objects/stringlib/find.h \
1412		$(srcdir)/Objects/stringlib/find_max_char.h \
1413		$(srcdir)/Objects/stringlib/localeutil.h \
1414		$(srcdir)/Objects/stringlib/partition.h \
1415		$(srcdir)/Objects/stringlib/replace.h \
1416		$(srcdir)/Objects/stringlib/split.h \
1417		$(srcdir)/Objects/stringlib/ucs1lib.h \
1418		$(srcdir)/Objects/stringlib/ucs2lib.h \
1419		$(srcdir)/Objects/stringlib/ucs4lib.h \
1420		$(srcdir)/Objects/stringlib/undef.h \
1421		$(srcdir)/Objects/stringlib/unicode_format.h \
1422		$(srcdir)/Objects/stringlib/unicodedefs.h
1423
1424Objects/bytes_methods.o: $(srcdir)/Objects/bytes_methods.c $(BYTESTR_DEPS)
1425Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS)
1426Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c $(BYTESTR_DEPS)
1427
1428Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS)
1429
1430Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h
1431Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
1432
1433.PHONY: regen-opcode-targets
1434regen-opcode-targets:
1435	# Regenerate Python/opcode_targets.h from Lib/opcode.py
1436	# using Python/makeopcodetargets.py
1437	$(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
1438		$(srcdir)/Python/opcode_targets.h.new
1439	$(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new
1440
1441Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h \
1442		$(srcdir)/Python/condvar.h
1443
1444Python/frozen.o: $(FROZEN_FILES_OUT)
1445
1446# Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to
1447# follow our naming conventions. dtrace(1) uses the output filename to generate
1448# an include guard, so we can't use a pipeline to transform its output.
1449Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d
1450	$(MKDIR_P) Include
1451	$(DTRACE) $(DFLAGS) -o $@ -h -s $<
1452	: sed in-place edit with POSIX-only tools
1453	sed 's/PYTHON_/PyDTrace_/' $@ > [email protected]
1454	mv [email protected] $@
1455
1456Python/ceval.o: $(srcdir)/Include/pydtrace.h
1457Python/import.o: $(srcdir)/Include/pydtrace.h
1458Modules/gcmodule.o: $(srcdir)/Include/pydtrace.h
1459
1460Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
1461	$(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
1462
1463Objects/typeobject.o: Objects/typeslots.inc
1464
1465.PHONY: regen-typeslots
1466regen-typeslots:
1467	# Regenerate Objects/typeslots.inc from Include/typeslotsh
1468	# using Objects/typeslots.py
1469	$(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
1470		< $(srcdir)/Include/typeslots.h \
1471		$(srcdir)/Objects/typeslots.inc.new
1472	$(UPDATE_FILE) $(srcdir)/Objects/typeslots.inc $(srcdir)/Objects/typeslots.inc.new
1473
1474############################################################################
1475# Header files
1476
1477PYTHON_HEADERS= \
1478		$(srcdir)/Include/Python.h \
1479		$(srcdir)/Include/abstract.h \
1480		$(srcdir)/Include/bltinmodule.h \
1481		$(srcdir)/Include/boolobject.h \
1482		$(srcdir)/Include/bytearrayobject.h \
1483		$(srcdir)/Include/bytesobject.h \
1484		$(srcdir)/Include/ceval.h \
1485		$(srcdir)/Include/codecs.h \
1486		$(srcdir)/Include/compile.h \
1487		$(srcdir)/Include/complexobject.h \
1488		$(srcdir)/Include/descrobject.h \
1489		$(srcdir)/Include/dictobject.h \
1490		$(srcdir)/Include/dynamic_annotations.h \
1491		$(srcdir)/Include/enumobject.h \
1492		$(srcdir)/Include/errcode.h \
1493		$(srcdir)/Include/fileobject.h \
1494		$(srcdir)/Include/fileutils.h \
1495		$(srcdir)/Include/floatobject.h \
1496		$(srcdir)/Include/frameobject.h \
1497		$(srcdir)/Include/import.h \
1498		$(srcdir)/Include/intrcheck.h \
1499		$(srcdir)/Include/iterobject.h \
1500		$(srcdir)/Include/listobject.h \
1501		$(srcdir)/Include/longobject.h \
1502		$(srcdir)/Include/marshal.h \
1503		$(srcdir)/Include/memoryobject.h \
1504		$(srcdir)/Include/methodobject.h \
1505		$(srcdir)/Include/modsupport.h \
1506		$(srcdir)/Include/moduleobject.h \
1507		$(srcdir)/Include/object.h \
1508		$(srcdir)/Include/objimpl.h \
1509		$(srcdir)/Include/opcode.h \
1510		$(srcdir)/Include/osdefs.h \
1511		$(srcdir)/Include/osmodule.h \
1512		$(srcdir)/Include/patchlevel.h \
1513		$(srcdir)/Include/pybuffer.h \
1514		$(srcdir)/Include/pycapsule.h \
1515		$(srcdir)/Include/pydtrace.h \
1516		$(srcdir)/Include/pyerrors.h \
1517		$(srcdir)/Include/pyframe.h \
1518		$(srcdir)/Include/pyhash.h \
1519		$(srcdir)/Include/pylifecycle.h \
1520		$(srcdir)/Include/pymacconfig.h \
1521		$(srcdir)/Include/pymacro.h \
1522		$(srcdir)/Include/pymath.h \
1523		$(srcdir)/Include/pymem.h \
1524		$(srcdir)/Include/pyport.h \
1525		$(srcdir)/Include/pystate.h \
1526		$(srcdir)/Include/pystrcmp.h \
1527		$(srcdir)/Include/pystrtod.h \
1528		$(srcdir)/Include/pythonrun.h \
1529		$(srcdir)/Include/pythread.h \
1530		$(srcdir)/Include/pytypedefs.h \
1531		$(srcdir)/Include/rangeobject.h \
1532		$(srcdir)/Include/setobject.h \
1533		$(srcdir)/Include/sliceobject.h \
1534		$(srcdir)/Include/structmember.h \
1535		$(srcdir)/Include/structseq.h \
1536		$(srcdir)/Include/sysmodule.h \
1537		$(srcdir)/Include/token.h \
1538		$(srcdir)/Include/traceback.h \
1539		$(srcdir)/Include/tracemalloc.h \
1540		$(srcdir)/Include/tupleobject.h \
1541		$(srcdir)/Include/unicodeobject.h \
1542		$(srcdir)/Include/warnings.h \
1543		$(srcdir)/Include/weakrefobject.h \
1544		\
1545		pyconfig.h \
1546		$(PARSER_HEADERS) \
1547		\
1548		$(srcdir)/Include/cpython/abstract.h \
1549		$(srcdir)/Include/cpython/bytearrayobject.h \
1550		$(srcdir)/Include/cpython/bytesobject.h \
1551		$(srcdir)/Include/cpython/cellobject.h \
1552		$(srcdir)/Include/cpython/ceval.h \
1553		$(srcdir)/Include/cpython/classobject.h \
1554		$(srcdir)/Include/cpython/code.h \
1555		$(srcdir)/Include/cpython/compile.h \
1556		$(srcdir)/Include/cpython/complexobject.h \
1557		$(srcdir)/Include/cpython/context.h \
1558		$(srcdir)/Include/cpython/descrobject.h \
1559		$(srcdir)/Include/cpython/dictobject.h \
1560		$(srcdir)/Include/cpython/fileobject.h \
1561		$(srcdir)/Include/cpython/fileutils.h \
1562		$(srcdir)/Include/cpython/floatobject.h \
1563		$(srcdir)/Include/cpython/frameobject.h \
1564		$(srcdir)/Include/cpython/funcobject.h \
1565		$(srcdir)/Include/cpython/genobject.h \
1566		$(srcdir)/Include/cpython/import.h \
1567		$(srcdir)/Include/cpython/initconfig.h \
1568		$(srcdir)/Include/cpython/listobject.h \
1569		$(srcdir)/Include/cpython/longintrepr.h \
1570		$(srcdir)/Include/cpython/longobject.h \
1571		$(srcdir)/Include/cpython/methodobject.h \
1572		$(srcdir)/Include/cpython/modsupport.h \
1573		$(srcdir)/Include/cpython/object.h \
1574		$(srcdir)/Include/cpython/objimpl.h \
1575		$(srcdir)/Include/cpython/odictobject.h \
1576		$(srcdir)/Include/cpython/picklebufobject.h \
1577		$(srcdir)/Include/cpython/pthread_stubs.h \
1578		$(srcdir)/Include/cpython/pyctype.h \
1579		$(srcdir)/Include/cpython/pydebug.h \
1580		$(srcdir)/Include/cpython/pyerrors.h \
1581		$(srcdir)/Include/cpython/pyfpe.h \
1582		$(srcdir)/Include/cpython/pyframe.h \
1583		$(srcdir)/Include/cpython/pylifecycle.h \
1584		$(srcdir)/Include/cpython/pymem.h \
1585		$(srcdir)/Include/cpython/pystate.h \
1586		$(srcdir)/Include/cpython/pythonrun.h \
1587		$(srcdir)/Include/cpython/pythread.h \
1588		$(srcdir)/Include/cpython/pytime.h \
1589		$(srcdir)/Include/cpython/setobject.h \
1590		$(srcdir)/Include/cpython/sysmodule.h \
1591		$(srcdir)/Include/cpython/traceback.h \
1592		$(srcdir)/Include/cpython/tupleobject.h \
1593		$(srcdir)/Include/cpython/unicodeobject.h \
1594		$(srcdir)/Include/cpython/warnings.h \
1595		$(srcdir)/Include/cpython/weakrefobject.h \
1596		\
1597		$(srcdir)/Include/internal/pycore_abstract.h \
1598		$(srcdir)/Include/internal/pycore_accu.h \
1599		$(srcdir)/Include/internal/pycore_asdl.h \
1600		$(srcdir)/Include/internal/pycore_ast.h \
1601		$(srcdir)/Include/internal/pycore_ast_state.h \
1602		$(srcdir)/Include/internal/pycore_atomic.h \
1603		$(srcdir)/Include/internal/pycore_atomic_funcs.h \
1604		$(srcdir)/Include/internal/pycore_bitutils.h \
1605		$(srcdir)/Include/internal/pycore_bytes_methods.h \
1606		$(srcdir)/Include/internal/pycore_bytesobject.h \
1607		$(srcdir)/Include/internal/pycore_call.h \
1608		$(srcdir)/Include/internal/pycore_ceval.h \
1609		$(srcdir)/Include/internal/pycore_code.h \
1610		$(srcdir)/Include/internal/pycore_compile.h \
1611		$(srcdir)/Include/internal/pycore_condvar.h \
1612		$(srcdir)/Include/internal/pycore_context.h \
1613		$(srcdir)/Include/internal/pycore_dict.h \
1614		$(srcdir)/Include/internal/pycore_dtoa.h \
1615		$(srcdir)/Include/internal/pycore_exceptions.h \
1616		$(srcdir)/Include/internal/pycore_fileutils.h \
1617		$(srcdir)/Include/internal/pycore_floatobject.h \
1618		$(srcdir)/Include/internal/pycore_format.h \
1619		$(srcdir)/Include/internal/pycore_function.h \
1620		$(srcdir)/Include/internal/pycore_genobject.h \
1621		$(srcdir)/Include/internal/pycore_getopt.h \
1622		$(srcdir)/Include/internal/pycore_gil.h \
1623		$(srcdir)/Include/internal/pycore_global_objects.h \
1624		$(srcdir)/Include/internal/pycore_hamt.h \
1625		$(srcdir)/Include/internal/pycore_hashtable.h \
1626		$(srcdir)/Include/internal/pycore_import.h \
1627		$(srcdir)/Include/internal/pycore_initconfig.h \
1628		$(srcdir)/Include/internal/pycore_interp.h \
1629		$(srcdir)/Include/internal/pycore_interpreteridobject.h \
1630		$(srcdir)/Include/internal/pycore_list.h \
1631		$(srcdir)/Include/internal/pycore_long.h \
1632		$(srcdir)/Include/internal/pycore_moduleobject.h \
1633		$(srcdir)/Include/internal/pycore_namespace.h \
1634		$(srcdir)/Include/internal/pycore_object.h \
1635		$(srcdir)/Include/internal/pycore_pathconfig.h \
1636		$(srcdir)/Include/internal/pycore_pyarena.h \
1637		$(srcdir)/Include/internal/pycore_pyerrors.h \
1638		$(srcdir)/Include/internal/pycore_pyhash.h \
1639		$(srcdir)/Include/internal/pycore_pylifecycle.h \
1640		$(srcdir)/Include/internal/pycore_pymem.h \
1641		$(srcdir)/Include/internal/pycore_pystate.h \
1642		$(srcdir)/Include/internal/pycore_runtime.h \
1643		$(srcdir)/Include/internal/pycore_runtime_init.h \
1644		$(srcdir)/Include/internal/pycore_signal.h \
1645		$(srcdir)/Include/internal/pycore_sliceobject.h \
1646		$(srcdir)/Include/internal/pycore_strhex.h \
1647		$(srcdir)/Include/internal/pycore_structseq.h \
1648		$(srcdir)/Include/internal/pycore_symtable.h \
1649		$(srcdir)/Include/internal/pycore_sysmodule.h \
1650		$(srcdir)/Include/internal/pycore_traceback.h \
1651		$(srcdir)/Include/internal/pycore_tuple.h \
1652		$(srcdir)/Include/internal/pycore_typeobject.h \
1653		$(srcdir)/Include/internal/pycore_ucnhash.h \
1654		$(srcdir)/Include/internal/pycore_unionobject.h \
1655		$(srcdir)/Include/internal/pycore_unicodeobject.h \
1656		$(srcdir)/Include/internal/pycore_warnings.h \
1657		$(DTRACE_HEADERS) \
1658		@PLATFORM_HEADERS@ \
1659		\
1660		$(srcdir)/Python/stdlib_module_names.h
1661
1662$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
1663
1664
1665######################################################################
1666
1667TESTOPTS=	$(EXTRATESTOPTS)
1668TESTPYTHON=	$(RUNSHARED) $(PYTHON_FOR_BUILD) $(TESTPYTHONOPTS)
1669TESTRUNNER=	$(TESTPYTHON) $(srcdir)/Tools/scripts/run_tests.py
1670TESTTIMEOUT=	1200
1671
1672.PHONY: test testall testuniversal buildbottest pythoninfo
1673
1674# Remove "test_python_*" directories of previous failed test jobs.
1675# Pass TESTOPTS options because it can contain --tempdir option.
1676cleantest: all
1677	$(TESTRUNNER) $(TESTOPTS) --cleanup
1678
1679# Run a basic set of regression tests.
1680# This excludes some tests that are particularly resource-intensive.
1681test: all
1682		$(TESTRUNNER) $(TESTOPTS)
1683
1684# Run the full test suite twice - once without .pyc files, and once with.
1685# In the past, we've had problems where bugs in the marshalling or
1686# elsewhere caused bytecode read from .pyc files to behave differently
1687# than bytecode generated directly from a .py source file.  Sometimes
1688# the bytecode read from a .pyc file had the bug, sometimes the directly
1689# generated bytecode.  This is sometimes a very shy bug needing a lot of
1690# sample data.
1691testall: all
1692		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
1693		$(TESTPYTHON) -E $(srcdir)/Lib/compileall.py
1694		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
1695		-$(TESTRUNNER) -u all $(TESTOPTS)
1696		$(TESTRUNNER) -u all $(TESTOPTS)
1697
1698# Run the test suite for both architectures in a Universal build on OSX.
1699# Must be run on an Intel box.
1700testuniversal: all
1701		@if [ `arch` != 'i386' ]; then \
1702			echo "This can only be used on OSX/i386" ;\
1703			exit 1 ;\
1704		fi
1705		$(TESTRUNNER) -u all $(TESTOPTS)
1706		$(RUNSHARED) /usr/libexec/oah/translate \
1707			./$(BUILDPYTHON) -E -m test -j 0 -u all $(TESTOPTS)
1708
1709# Like testall, but with only one pass and without multiple processes.
1710# Run an optional script to include information about the build environment.
1711buildbottest: all
1712		-@if which pybuildbot.identify >/dev/null 2>&1; then \
1713			pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
1714		fi
1715		$(TESTRUNNER) -j 1 -u all -W --slowest --fail-env-changed --timeout=$(TESTTIMEOUT) $(TESTOPTS)
1716
1717# Like testall, but run Python tests with HOSTRUNNER directly.
1718hostrunnertest: all
1719	$(RUNSHARED) $(HOSTRUNNER) ./$(BUILDPYTHON) -m test -u all $(TESTOPTS)
1720
1721pythoninfo: all
1722		$(RUNSHARED) $(HOSTRUNNER) ./$(BUILDPYTHON) -m test.pythoninfo
1723
1724QUICKTESTOPTS=	$(TESTOPTS) -x test_subprocess test_io test_lib2to3 \
1725		test_multibytecodec test_urllib2_localnet test_itertools \
1726		test_multiprocessing_fork test_multiprocessing_spawn \
1727		test_multiprocessing_forkserver \
1728		test_mailbox test_nntplib test_socket test_poll \
1729		test_select test_zipfile test_concurrent_futures
1730quicktest: all
1731		$(TESTRUNNER) $(QUICKTESTOPTS)
1732
1733# SSL tests
1734.PHONY: multisslcompile multissltest
1735multisslcompile: all
1736	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/ssl/multissltests.py --steps=modules
1737
1738multissltest: all
1739	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/ssl/multissltests.py
1740
1741# All install targets use the "all" target as synchronization point to
1742# prevent race conditions with PGO builds. PGO builds use recursive make,
1743# which can lead to two parallel `./python setup.py build` processes that
1744# step on each others toes.
1745install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@
1746	if test "x$(ENSUREPIP)" != "xno"  ; then \
1747		case $(ENSUREPIP) in \
1748			upgrade) ensurepip="--upgrade" ;; \
1749			install|*) ensurepip="" ;; \
1750		esac; \
1751		$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
1752			$$ensurepip --root=$(DESTDIR)/ ; \
1753	fi
1754
1755altinstall: commoninstall
1756	if test "x$(ENSUREPIP)" != "xno"  ; then \
1757		case $(ENSUREPIP) in \
1758			upgrade) ensurepip="--altinstall --upgrade" ;; \
1759			install|*) ensurepip="--altinstall" ;; \
1760		esac; \
1761		$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
1762			$$ensurepip --root=$(DESTDIR)/ ; \
1763	fi
1764
1765commoninstall:  check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
1766		altbininstall libinstall inclinstall libainstall \
1767		sharedinstall oldsharedinstall altmaninstall \
1768		@FRAMEWORKALTINSTALLLAST@
1769
1770# Install shared libraries enabled by Setup
1771DESTDIRS=	$(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
1772
1773oldsharedinstall: $(DESTSHARED) all
1774		@for i in X $(SHAREDMODS); do \
1775		  if test $$i != X; then \
1776		    echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
1777		    $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
1778		  fi; \
1779		done
1780
1781$(DESTSHARED):
1782		@for i in $(DESTDIRS); \
1783		do \
1784			if test ! -d $(DESTDIR)$$i; then \
1785				echo "Creating directory $$i"; \
1786				$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1787			else    true; \
1788			fi; \
1789		done
1790
1791# Install the interpreter with $(VERSION) affixed
1792# This goes into $(exec_prefix)
1793altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
1794	@for i in $(BINDIR) $(LIBDIR); \
1795	do \
1796		if test ! -d $(DESTDIR)$$i; then \
1797			echo "Creating directory $$i"; \
1798			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1799		else	true; \
1800		fi; \
1801	done
1802	if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
1803		$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
1804	else \
1805		$(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
1806	fi
1807	-if test "$(VERSION)" != "$(LDVERSION)"; then \
1808		if test -f $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE) -o -h $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
1809		then rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
1810		fi; \
1811		(cd $(DESTDIR)$(BINDIR); $(LN) python$(LDVERSION)$(EXE) python$(VERSION)$(EXE)); \
1812	fi
1813	@if test "$(PY_ENABLE_SHARED)" = 1 -o "$(STATIC_LIBPYTHON)" = 1; then \
1814		if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
1815			if test -n "$(DLLLIBRARY)" ; then \
1816				$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
1817			else \
1818				$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
1819				if test $(LDLIBRARY) != $(INSTSONAME); then \
1820					(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
1821				fi \
1822			fi; \
1823			if test -n "$(PY3LIBRARY)"; then \
1824				$(INSTALL_SHARED) $(PY3LIBRARY) $(DESTDIR)$(LIBDIR)/$(PY3LIBRARY); \
1825			fi; \
1826		else	true; \
1827		fi; \
1828	fi
1829	if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
1830		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-32$(EXE); \
1831		lipo $(LIPO_32BIT_FLAGS) \
1832			-output $(DESTDIR)$(BINDIR)/python$(VERSION)-32$(EXE) \
1833			$(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
1834	fi
1835	if test "x$(LIPO_INTEL64_FLAGS)" != "x" ; then \
1836		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-intel64$(EXE); \
1837		lipo $(LIPO_INTEL64_FLAGS) \
1838			-output $(DESTDIR)$(BINDIR)/python$(VERSION)-intel64$(EXE) \
1839			$(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
1840	fi
1841
1842bininstall: altbininstall
1843	if test ! -d $(DESTDIR)$(LIBPC); then \
1844		echo "Creating directory $(LIBPC)"; \
1845		$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \
1846	fi
1847	-if test -f $(DESTDIR)$(BINDIR)/python3$(EXE) -o -h $(DESTDIR)$(BINDIR)/python3$(EXE); \
1848	then rm -f $(DESTDIR)$(BINDIR)/python3$(EXE); \
1849	else true; \
1850	fi
1851	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python3$(EXE))
1852	-if test "$(VERSION)" != "$(LDVERSION)"; then \
1853		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-config; \
1854		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(LDVERSION)-config python$(VERSION)-config); \
1855		rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION).pc; \
1856		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python-$(LDVERSION).pc); \
1857		rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION)-embed.pc; \
1858		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)-embed.pc python-$(LDVERSION)-embed.pc); \
1859	fi
1860	-rm -f $(DESTDIR)$(BINDIR)/python3-config
1861	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
1862	-rm -f $(DESTDIR)$(LIBPC)/python3.pc
1863	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python3.pc)
1864	-rm -f $(DESTDIR)$(LIBPC)/python3-embed.pc
1865	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)-embed.pc python3-embed.pc)
1866	-rm -f $(DESTDIR)$(BINDIR)/idle3
1867	(cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3)
1868	-rm -f $(DESTDIR)$(BINDIR)/pydoc3
1869	(cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
1870	-rm -f $(DESTDIR)$(BINDIR)/2to3
1871	(cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
1872	if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
1873		rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
1874		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
1875	fi
1876	if test "x$(LIPO_INTEL64_FLAGS)" != "x" ; then \
1877		rm -f $(DESTDIR)$(BINDIR)/python3-intel64$(EXE); \
1878		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-intel64$(EXE) python3-intel64$(EXE)) \
1879	fi
1880
1881# Install the versioned manual page
1882altmaninstall:
1883	@for i in $(MANDIR) $(MANDIR)/man1; \
1884	do \
1885		if test ! -d $(DESTDIR)$$i; then \
1886			echo "Creating directory $$i"; \
1887			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1888		else	true; \
1889		fi; \
1890	done
1891	$(INSTALL_DATA) $(srcdir)/Misc/python.man \
1892		$(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
1893
1894# Install the unversioned manual page
1895maninstall:	altmaninstall
1896	-rm -f $(DESTDIR)$(MANDIR)/man1/python3.1
1897	(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python3.1)
1898
1899# Install the library
1900XMLLIBSUBDIRS=  xml xml/dom xml/etree xml/parsers xml/sax
1901LIBSUBDIRS=	asyncio \
1902		collections \
1903		concurrent concurrent/futures \
1904		csv \
1905		ctypes ctypes/macholib \
1906		curses \
1907		dbm \
1908		distutils distutils/command \
1909		email email/mime \
1910		encodings \
1911		ensurepip ensurepip/_bundled \
1912		html \
1913		http \
1914		idlelib idlelib/Icons \
1915		importlib importlib/resources importlib/metadata \
1916		json \
1917		lib2to3 lib2to3/fixes lib2to3/pgen2 \
1918		logging \
1919		multiprocessing multiprocessing/dummy \
1920		pydoc_data \
1921		re \
1922		site-packages \
1923		sqlite3 \
1924		tkinter \
1925		tomllib \
1926		turtledemo \
1927		unittest \
1928		urllib \
1929		venv venv/scripts venv/scripts/common venv/scripts/posix \
1930		wsgiref \
1931		$(XMLLIBSUBDIRS) \
1932		xmlrpc \
1933		zoneinfo \
1934		__phello__
1935TESTSUBDIRS=	ctypes/test \
1936		distutils/tests \
1937		idlelib/idle_test \
1938		lib2to3/tests \
1939		lib2to3/tests/data \
1940		lib2to3/tests/data/fixers \
1941		lib2to3/tests/data/fixers/myfixes \
1942		test \
1943		test/audiodata \
1944		test/capath \
1945		test/cjkencodings \
1946		test/crashers \
1947		test/data \
1948		test/decimaltestdata \
1949		test/dtracedata \
1950		test/encoded_modules \
1951		test/imghdrdata \
1952		test/leakers \
1953		test/libregrtest \
1954		test/sndhdrdata \
1955		test/subprocessdata \
1956		test/support \
1957		test/test_asyncio \
1958		test/test_capi \
1959		test/test_email \
1960		test/test_email/data \
1961		test/test_import \
1962		test/test_import/data \
1963		test/test_import/data/circular_imports \
1964		test/test_import/data/circular_imports/subpkg \
1965		test/test_import/data/circular_imports/subpkg2 \
1966		test/test_import/data/circular_imports/subpkg2/parent \
1967		test/test_import/data/package \
1968		test/test_import/data/package2 \
1969		test/test_import/data/unwritable \
1970		test/test_importlib \
1971		test/test_importlib/builtin \
1972		test/test_importlib/data \
1973		test/test_importlib/data01 \
1974		test/test_importlib/data01/subdirectory \
1975		test/test_importlib/data02 \
1976		test/test_importlib/data02/one \
1977		test/test_importlib/data02/two \
1978		test/test_importlib/data03 \
1979		test/test_importlib/data03/namespace \
1980		test/test_importlib/data03/namespace/portion1 \
1981		test/test_importlib/data03/namespace/portion2 \
1982		test/test_importlib/extension \
1983		test/test_importlib/frozen \
1984		test/test_importlib/import_ \
1985		test/test_importlib/namespace_pkgs \
1986		test/test_importlib/namespace_pkgs/both_portions \
1987		test/test_importlib/namespace_pkgs/both_portions/foo \
1988		test/test_importlib/namespace_pkgs/module_and_namespace_package \
1989		test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test \
1990		test/test_importlib/namespace_pkgs/not_a_namespace_pkg \
1991		test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo \
1992		test/test_importlib/namespace_pkgs/portion1 \
1993		test/test_importlib/namespace_pkgs/portion1/foo \
1994		test/test_importlib/namespace_pkgs/portion2 \
1995		test/test_importlib/namespace_pkgs/portion2/foo \
1996		test/test_importlib/namespace_pkgs/project1 \
1997		test/test_importlib/namespace_pkgs/project1/parent \
1998		test/test_importlib/namespace_pkgs/project1/parent/child \
1999		test/test_importlib/namespace_pkgs/project2 \
2000		test/test_importlib/namespace_pkgs/project2/parent \
2001		test/test_importlib/namespace_pkgs/project2/parent/child \
2002		test/test_importlib/namespace_pkgs/project3 \
2003		test/test_importlib/namespace_pkgs/project3/parent \
2004		test/test_importlib/namespace_pkgs/project3/parent/child \
2005		test/test_importlib/namespacedata01 \
2006		test/test_importlib/partial \
2007		test/test_importlib/resources \
2008		test/test_importlib/source \
2009		test/test_importlib/zipdata01 \
2010		test/test_importlib/zipdata02 \
2011		test/test_json \
2012		test/test_peg_generator \
2013		test/test_sqlite3 \
2014		test/test_tomllib \
2015		test/test_tomllib/data \
2016		test/test_tomllib/data/invalid \
2017		test/test_tomllib/data/invalid/array \
2018		test/test_tomllib/data/invalid/array-of-tables \
2019		test/test_tomllib/data/invalid/boolean \
2020		test/test_tomllib/data/invalid/dates-and-times \
2021		test/test_tomllib/data/invalid/dotted-keys \
2022		test/test_tomllib/data/invalid/inline-table \
2023		test/test_tomllib/data/invalid/keys-and-vals \
2024		test/test_tomllib/data/invalid/literal-str \
2025		test/test_tomllib/data/invalid/multiline-basic-str \
2026		test/test_tomllib/data/invalid/multiline-literal-str \
2027		test/test_tomllib/data/invalid/table \
2028		test/test_tomllib/data/valid \
2029		test/test_tomllib/data/valid/array \
2030		test/test_tomllib/data/valid/dates-and-times \
2031		test/test_tomllib/data/valid/multiline-basic-str \
2032		test/test_tools \
2033		test/test_warnings \
2034		test/test_warnings/data \
2035		test/test_zoneinfo \
2036		test/test_zoneinfo/data \
2037		test/tracedmodules \
2038		test/typinganndata \
2039		test/xmltestdata \
2040		test/xmltestdata/c14n-20 \
2041		test/ziptestdata \
2042		tkinter/test \
2043		tkinter/test/test_tkinter \
2044		tkinter/test/test_ttk \
2045		unittest/test \
2046		unittest/test/testmock
2047
2048TEST_MODULES=@TEST_MODULES@
2049libinstall:	all $(srcdir)/Modules/xxmodule.c
2050	@for i in $(SCRIPTDIR) $(LIBDEST); \
2051	do \
2052		if test ! -d $(DESTDIR)$$i; then \
2053			echo "Creating directory $$i"; \
2054			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2055		else	true; \
2056		fi; \
2057	done
2058	@if test "$(TEST_MODULES)" = yes; then \
2059		subdirs="$(LIBSUBDIRS) $(TESTSUBDIRS)"; \
2060	else \
2061		subdirs="$(LIBSUBDIRS)"; \
2062	fi; \
2063	for d in $$subdirs; \
2064	do \
2065		a=$(srcdir)/Lib/$$d; \
2066		if test ! -d $$a; then continue; else true; fi; \
2067		b=$(LIBDEST)/$$d; \
2068		if test ! -d $(DESTDIR)$$b; then \
2069			echo "Creating directory $$b"; \
2070			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
2071		else	true; \
2072		fi; \
2073	done
2074	@for i in $(srcdir)/Lib/*.py; \
2075	do \
2076		if test -x $$i; then \
2077			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
2078			echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
2079		else \
2080			$(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
2081			echo $(INSTALL_DATA) $$i $(LIBDEST); \
2082		fi; \
2083	done
2084	@if test "$(TEST_MODULES)" = yes; then \
2085		subdirs="$(LIBSUBDIRS) $(TESTSUBDIRS)"; \
2086	else \
2087		subdirs="$(LIBSUBDIRS)"; \
2088	fi; \
2089	for d in $$subdirs; \
2090	do \
2091		a=$(srcdir)/Lib/$$d; \
2092		if test ! -d $$a; then continue; else true; fi; \
2093		if test `ls $$a | wc -l` -lt 1; then continue; fi; \
2094		b=$(LIBDEST)/$$d; \
2095		for i in $$a/*; \
2096		do \
2097			case $$i in \
2098			*CVS) ;; \
2099			*.py[co]) ;; \
2100			*.orig) ;; \
2101			*~) ;; \
2102			*) \
2103				if test -d $$i; then continue; fi; \
2104				if test -x $$i; then \
2105				    echo $(INSTALL_SCRIPT) $$i $$b; \
2106				    $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
2107				else \
2108				    echo $(INSTALL_DATA) $$i $$b; \
2109				    $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
2110				fi;; \
2111			esac; \
2112		done; \
2113	done
2114	$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
2115		$(DESTDIR)$(LIBDEST); \
2116	$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
2117	if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
2118		$(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
2119			$(DESTDIR)$(LIBDEST)/distutils/tests ; \
2120	fi
2121	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
2122		$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
2123		-j0 -d $(LIBDEST) -f \
2124		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
2125		$(DESTDIR)$(LIBDEST)
2126	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2127		$(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
2128		-j0 -d $(LIBDEST) -f \
2129		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
2130		$(DESTDIR)$(LIBDEST)
2131	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2132		$(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
2133		-j0 -d $(LIBDEST) -f \
2134		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
2135		$(DESTDIR)$(LIBDEST)
2136	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2137		$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
2138		-j0 -d $(LIBDEST)/site-packages -f \
2139		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
2140	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2141		$(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
2142		-j0 -d $(LIBDEST)/site-packages -f \
2143		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
2144	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2145		$(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
2146		-j0 -d $(LIBDEST)/site-packages -f \
2147		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
2148	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2149		$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
2150	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2151		$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
2152
2153# bpo-21536: Misc/python-config.sh is generated in the build directory
2154# from $(srcdir)Misc/python-config.sh.in.
2155python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
2156	@ # Substitution happens here, as the completely-expanded BINDIR
2157	@ # is not available in configure
2158	sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
2159	@ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
2160	LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config
2161	@ # On Darwin, always use the python version of the script, the shell
2162	@ # version doesn't use the compiler customizations that are provided
2163	@ # in python (_osx_support.py).
2164	@if test `uname -s` = Darwin; then \
2165		cp python-config.py python-config; \
2166	fi
2167
2168
2169# Install the include files
2170INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
2171inclinstall:
2172	@for i in $(INCLDIRSTOMAKE); \
2173	do \
2174		if test ! -d $(DESTDIR)$$i; then \
2175			echo "Creating directory $$i"; \
2176			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2177		else	true; \
2178		fi; \
2179	done
2180	@if test ! -d $(DESTDIR)$(INCLUDEPY)/cpython; then \
2181		echo "Creating directory $(DESTDIR)$(INCLUDEPY)/cpython"; \
2182		$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/cpython; \
2183	else	true; \
2184	fi
2185	@if test ! -d $(DESTDIR)$(INCLUDEPY)/internal; then \
2186		echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal"; \
2187		$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal; \
2188	else	true; \
2189	fi
2190	@for i in $(srcdir)/Include/*.h; \
2191	do \
2192		echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
2193		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
2194	done
2195	@for i in $(srcdir)/Include/cpython/*.h; \
2196	do \
2197		echo $(INSTALL_DATA) $$i $(INCLUDEPY)/cpython; \
2198		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/cpython; \
2199	done
2200	@for i in $(srcdir)/Include/internal/*.h; \
2201	do \
2202		echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal; \
2203		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \
2204	done
2205	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
2206
2207# Install the library and miscellaneous stuff needed for extending/embedding
2208# This goes into $(exec_prefix)
2209LIBPL=		@LIBPL@
2210
2211# pkgconfig directory
2212LIBPC=		$(LIBDIR)/pkgconfig
2213
2214libainstall: all python-config
2215	@for i in $(LIBDIR) $(LIBPL) $(LIBPC) $(BINDIR); \
2216	do \
2217		if test ! -d $(DESTDIR)$$i; then \
2218			echo "Creating directory $$i"; \
2219			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2220		else	true; \
2221		fi; \
2222	done
2223	@if test "$(STATIC_LIBPYTHON)" = 1; then \
2224		if test -d $(LIBRARY); then :; else \
2225			if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
2226				if test "$(SHLIB_SUFFIX)" = .dll; then \
2227					$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
2228				else \
2229					$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
2230				fi; \
2231			else \
2232				echo Skip install of $(LIBRARY) - use make frameworkinstall; \
2233			fi; \
2234		fi; \
2235		$(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o; \
2236	fi
2237	$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
2238	$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
2239	$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
2240	$(INSTALL_DATA) $(srcdir)/Modules/Setup $(DESTDIR)$(LIBPL)/Setup
2241	$(INSTALL_DATA) Modules/Setup.bootstrap $(DESTDIR)$(LIBPL)/Setup.bootstrap
2242	$(INSTALL_DATA) Modules/Setup.stdlib $(DESTDIR)$(LIBPL)/Setup.stdlib
2243	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
2244	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
2245	$(INSTALL_DATA) Misc/python-embed.pc $(DESTDIR)$(LIBPC)/python-$(VERSION)-embed.pc
2246	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
2247	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
2248	$(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
2249	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
2250	@if [ -s Modules/python.exp -a \
2251		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
2252		echo; echo "Installing support files for building shared extension modules on AIX:"; \
2253		$(INSTALL_DATA) Modules/python.exp		\
2254				$(DESTDIR)$(LIBPL)/python.exp;		\
2255		echo; echo "$(LIBPL)/python.exp";		\
2256		$(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix	\
2257				$(DESTDIR)$(LIBPL)/makexp_aix;		\
2258		echo "$(LIBPL)/makexp_aix";			\
2259		$(INSTALL_SCRIPT) Modules/ld_so_aix	\
2260				$(DESTDIR)$(LIBPL)/ld_so_aix;		\
2261		echo "$(LIBPL)/ld_so_aix";			\
2262		echo; echo "See Misc/README.AIX for details.";	\
2263	else true; \
2264	fi
2265
2266# Install the dynamically loadable modules
2267# This goes into $(exec_prefix)
2268sharedinstall: all
2269	$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
2270	   	--prefix=$(prefix) \
2271		--install-scripts=$(BINDIR) \
2272		--install-platlib=$(DESTSHARED) \
2273		--root=$(DESTDIR)/
2274	-rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py
2275	-rm -r $(DESTDIR)$(DESTSHARED)/__pycache__
2276
2277# Here are a couple of targets for MacOSX again, to install a full
2278# framework-based Python. frameworkinstall installs everything, the
2279# subtargets install specific parts. Much of the actual work is offloaded to
2280# the Makefile in Mac
2281#
2282#
2283# This target is here for backward compatibility, previous versions of Python
2284# hadn't integrated framework installation in the normal install process.
2285frameworkinstall: install
2286
2287# On install, we re-make the framework
2288# structure in the install location, /Library/Frameworks/ or the argument to
2289# --enable-framework. If --enable-framework has been specified then we have
2290# automatically set prefix to the location deep down in the framework, so we
2291# only have to cater for the structural bits of the framework.
2292
2293frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
2294
2295frameworkinstallstructure:	$(LDLIBRARY)
2296	@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
2297		echo Not configured with --enable-framework; \
2298		exit 1; \
2299	else true; \
2300	fi
2301	@for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
2302		if test ! -d $(DESTDIR)$$i; then \
2303			echo "Creating directory $(DESTDIR)$$i"; \
2304			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2305		else	true; \
2306		fi; \
2307	done
2308	$(LN) -fsn include/python$(LDVERSION) $(DESTDIR)$(prefix)/Headers
2309	sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
2310	$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
2311	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
2312	$(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
2313	$(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
2314	$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
2315
2316# This installs Mac/Lib into the framework
2317# Install a number of symlinks to keep software that expects a normal unix
2318# install (which includes python-config) happy.
2319frameworkinstallmaclib:
2320	$(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).a"
2321	$(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).dylib"
2322	$(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).a"
2323	$(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).dylib"
2324	$(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(LDVERSION).dylib"
2325	$(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
2326
2327# This installs the IDE, the Launcher and other apps into /Applications
2328frameworkinstallapps:
2329	cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
2330
2331# Build the bootstrap executable that will spawn the interpreter inside
2332# an app bundle within the framework.  This allows the interpreter to
2333# run OS X GUI APIs.
2334frameworkpythonw:
2335	cd Mac && $(MAKE) pythonw
2336
2337# This installs the python* and other bin symlinks in $prefix/bin or in
2338# a bin directory relative to the framework root
2339frameworkinstallunixtools:
2340	cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
2341
2342frameworkaltinstallunixtools:
2343	cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
2344
2345# This installs the Tools into the applications directory.
2346# It is not part of a normal frameworkinstall
2347frameworkinstallextras:
2348	cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
2349
2350# Build the toplevel Makefile
2351Makefile.pre: $(srcdir)/Makefile.pre.in config.status
2352	CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
2353	$(MAKE) -f Makefile.pre Makefile
2354
2355# Run the configure script.
2356config.status:	$(srcdir)/configure
2357	$(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
2358
2359.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
2360
2361# Some make's put the object file in the current directory
2362.c.o:
2363	$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
2364
2365# bpo-30104: dtoa.c uses union to cast double to unsigned long[2]. clang 4.0
2366# with -O2 or higher and strict aliasing miscompiles the ratio() function
2367# causing rounding issues. Compile dtoa.c using -fno-strict-aliasing on clang.
2368# https://bugs.llvm.org//show_bug.cgi?id=31928
2369Python/dtoa.o: Python/dtoa.c
2370	$(CC) -c $(PY_CORE_CFLAGS) $(CFLAGS_ALIASING) -o $@ $<
2371
2372# Run reindent on the library
2373reindent:
2374	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
2375
2376# Rerun configure with the same options as it was run last time,
2377# provided the config.status script exists
2378recheck:
2379	$(SHELL) config.status --recheck
2380	$(SHELL) config.status
2381
2382# Regenerate configure and pyconfig.h.in
2383.PHONY: autoconf
2384autoconf:
2385	(cd $(srcdir); autoreconf -ivf -Werror)
2386
2387.PHONY: regen-configure
2388regen-configure:
2389	@if command -v podman >/dev/null; then RUNTIME="podman"; else RUNTIME="docker"; fi; \
2390	if ! command -v $$RUNTIME; then echo "$@ needs either Podman or Docker container runtime." >&2; exit 1; fi; \
2391	if command -v selinuxenabled >/dev/null && selinuxenabled; then OPT=":Z"; fi; \
2392	CMD="$$RUNTIME run --rm --pull=always -v $(abs_srcdir):/src$$OPT quay.io/tiran/cpython_autoconf:269"; \
2393	echo $$CMD; \
2394	$$CMD || exit $?
2395
2396# Create a tags file for vi
2397tags::
2398	ctags -w $(srcdir)/Include/*.h $(srcdir)/Include/cpython/*.h $(srcdir)/Include/internal/*.h
2399	for i in $(SRCDIRS); do ctags -f tags -w -a $(srcdir)/$$i/*.[ch]; done
2400	ctags -f tags -w -a $(srcdir)/Modules/_ctypes/*.[ch]
2401	find $(srcdir)/Lib -type f -name "*.py" -not -name "test_*.py" -not -path "*/test/*" -not -path "*/tests/*" -not -path "*/*_test/*" | ctags -f tags -w -a -L -
2402	LC_ALL=C sort -o tags tags
2403
2404# Create a tags file for GNU Emacs
2405TAGS::
2406	cd $(srcdir); \
2407	etags Include/*.h Include/cpython/*.h Include/internal/*.h; \
2408	for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
2409	etags -a $(srcdir)/Modules/_ctypes/*.[ch]
2410	find $(srcdir)/Lib -type f -name "*.py" -not -name "test_*.py" -not -path "*/test/*" -not -path "*/tests/*" -not -path "*/*_test/*" | etags - -a
2411
2412# Sanitation targets -- clean leaves libraries, executables and tags
2413# files, which clobber removes as well
2414pycremoval:
2415	-find $(srcdir) -depth -name '__pycache__' -exec rm -rf {} ';'
2416	-find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
2417
2418rmtestturds:
2419	-rm -f *BAD *GOOD *SKIPPED
2420	-rm -rf OUT
2421	-rm -f *.TXT
2422	-rm -f *.txt
2423	-rm -f gb-18030-2000.xml
2424
2425docclean:
2426	$(MAKE) -C $(srcdir)/Doc clean
2427
2428# like the 'clean' target but retain the profile guided optimization (PGO)
2429# data.  The PGO data is only valid if source code remains unchanged.
2430clean-retain-profile: pycremoval
2431	find . -name '*.[oa]' -exec rm -f {} ';'
2432	find . -name '*.s[ol]' -exec rm -f {} ';'
2433	find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
2434	find . -name '*.wasm' -exec rm -f {} ';'
2435	find . -name '*.lst' -exec rm -f {} ';'
2436	find build -name 'fficonfig.h' -exec rm -f {} ';' || true
2437	find build -name '*.py' -exec rm -f {} ';' || true
2438	find build -name '*.py[co]' -exec rm -f {} ';' || true
2439	-rm -f pybuilddir.txt
2440	-rm -f Lib/lib2to3/*Grammar*.pickle
2441	-rm -f _bootstrap_python
2442	-rm -f python.html python*.js python.data python*.symbols python*.map
2443	-rm -f $(WASM_STDLIB)
2444	-rm -f Programs/_testembed Programs/_freeze_module
2445	-rm -f Python/deepfreeze/*.[co]
2446	-rm -f Python/frozen_modules/*.h
2447	-rm -f Python/frozen_modules/MANIFEST
2448	-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
2449	-rm -f Include/pydtrace_probes.h
2450	-rm -f profile-gen-stamp
2451
2452profile-removal:
2453	find . -name '*.gc??' -exec rm -f {} ';'
2454	find . -name '*.profclang?' -exec rm -f {} ';'
2455	find . -name '*.dyn' -exec rm -f {} ';'
2456	rm -f $(COVERAGE_INFO)
2457	rm -rf $(COVERAGE_REPORT)
2458	rm -f profile-run-stamp
2459
2460clean: clean-retain-profile
2461	@if test @DEF_MAKE_ALL_RULE@ = profile-opt; then \
2462		rm -f profile-gen-stamp profile-clean-stamp; \
2463		$(MAKE) profile-removal; \
2464	fi
2465
2466clobber: clean
2467	-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
2468		tags TAGS \
2469		config.cache config.log pyconfig.h Modules/config.c
2470	-rm -rf build platform
2471	-rm -rf $(PYTHONFRAMEWORKDIR)
2472	-rm -f python-config.py python-config
2473
2474# Make things extra clean, before making a distribution:
2475# remove all generated files, even Makefile[.pre]
2476# Keep configure and Python-ast.[ch], it's possible they can't be generated
2477distclean: clobber docclean
2478	for file in $(srcdir)/Lib/test/data/* ; do \
2479	    if test "$$file" != "$(srcdir)/Lib/test/data/README"; then rm "$$file"; fi; \
2480	done
2481	-rm -f core Makefile Makefile.pre config.status Modules/Setup.local \
2482	    Modules/Setup.bootstrap Modules/Setup.stdlib \
2483		Modules/ld_so_aix Modules/python.exp Misc/python.pc \
2484		Misc/python-embed.pc Misc/python-config.sh
2485	-rm -f python*-gdb.py
2486	# Issue #28258: set LC_ALL to avoid issues with Estonian locale.
2487	# Expansion is performed here by shell (spawned by make) itself before
2488	# arguments are passed to find. So LC_ALL=C must be set as a separate
2489	# command.
2490	LC_ALL=C; find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \
2491				     -o -name '[@,#]*' -o -name '*.old' \
2492				     -o -name '*.orig' -o -name '*.rej' \
2493				     -o -name '*.bak' ')' \
2494				     -exec rm -f {} ';'
2495
2496# Check that all symbols exported by libpython start with "Py" or "_Py"
2497smelly: all
2498	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/smelly.py
2499
2500# Find files with funny names
2501funny:
2502	find $(SUBDIRS) $(SUBDIRSTOO) \
2503		-type d \
2504		-o -name '*.[chs]' \
2505		-o -name '*.py' \
2506		-o -name '*.pyw' \
2507		-o -name '*.dat' \
2508		-o -name '*.el' \
2509		-o -name '*.fd' \
2510		-o -name '*.in' \
2511		-o -name '*.gif' \
2512		-o -name '*.txt' \
2513		-o -name '*.xml' \
2514		-o -name '*.xbm' \
2515		-o -name '*.xpm' \
2516		-o -name '*.uue' \
2517		-o -name '*.decTest' \
2518		-o -name '*.tmCommand' \
2519		-o -name '*.tmSnippet' \
2520		-o -name 'Setup' \
2521		-o -name 'Setup.*' \
2522		-o -name README \
2523		-o -name NEWS \
2524		-o -name HISTORY \
2525		-o -name Makefile \
2526		-o -name ChangeLog \
2527		-o -name .hgignore \
2528		-o -name MANIFEST \
2529		-o -print
2530
2531# Perform some verification checks on any modified files.
2532patchcheck: all
2533	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
2534
2535check-limited-abi: all
2536	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/stable_abi.py --all $(srcdir)/Misc/stable_abi.toml
2537
2538.PHONY: update-config
2539update-config:
2540	curl -sL -o config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
2541	curl -sL -o config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
2542	chmod +x config.guess config.sub
2543
2544# Dependencies
2545
2546Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
2547
2548# Declare targets that aren't real files
2549.PHONY: all build_all build_wasm sharedmods check-clean-src oldsharedmods test quicktest
2550.PHONY: install altinstall oldsharedinstall bininstall altbininstall
2551.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
2552.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
2553.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
2554.PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
2555.PHONY: smelly funny patchcheck touch altmaninstall commoninstall
2556.PHONY: clean-retain-profile profile-removal run_profile_task
2557.PHONY: build_all_generate_profile build_all_merge_profile
2558.PHONY: gdbhooks
2559
2560##########################################################################
2561# Module dependencies
2562
2563MODULE_CMATH_DEPS=$(srcdir)/Modules/_math.h
2564MODULE_MATH_DEPS=$(srcdir)/Modules/_math.h
2565MODULE_PYEXPAT_DEPS=@LIBEXPAT_INTERNAL@
2566MODULE_UNICODEDATA_DEPS=$(srcdir)/Modules/unicodedata_db.h $(srcdir)/Modules/unicodename_db.h
2567MODULE__BLAKE2_DEPS=$(srcdir)/Modules/_blake2/impl/blake2-config.h $(srcdir)/Modules/_blake2/impl/blake2-impl.h $(srcdir)/Modules/_blake2/impl/blake2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2b-ref.c $(srcdir)/Modules/_blake2/impl/blake2b-round.h $(srcdir)/Modules/_blake2/impl/blake2b.c $(srcdir)/Modules/_blake2/impl/blake2s-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2s-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2s-load-xop.h $(srcdir)/Modules/_blake2/impl/blake2s-ref.c $(srcdir)/Modules/_blake2/impl/blake2s-round.h $(srcdir)/Modules/_blake2/impl/blake2s.c $(srcdir)/Modules/_blake2/blake2module.h $(srcdir)/Modules/hashlib.h
2568MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h
2569MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
2570MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
2571MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
2572MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
2573MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h
2574MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h
2575MODULE__SHA256_DEPS=$(srcdir)/Modules/hashlib.h
2576MODULE__SHA3_DEPS=$(srcdir)/Modules/_sha3/sha3.c $(srcdir)/Modules/_sha3/sha3.h $(srcdir)/Modules/hashlib.h
2577MODULE__SHA512_DEPS=$(srcdir)/Modules/hashlib.h
2578MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c
2579MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data.h $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h
2580MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/testcapi_long.h
2581MODULE__SQLITE3_DEPS=$(srcdir)/Modules/_sqlite/connection.h $(srcdir)/Modules/_sqlite/cursor.h $(srcdir)/Modules/_sqlite/microprotocols.h $(srcdir)/Modules/_sqlite/module.h $(srcdir)/Modules/_sqlite/prepare_protocol.h $(srcdir)/Modules/_sqlite/row.h $(srcdir)/Modules/_sqlite/util.h
2582
2583# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
2584# Local Variables:
2585# mode: makefile
2586# End:
2587