• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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@
39LINKCC=		@LINKCC@
40AR=		@AR@
41READELF=	@READELF@
42SOABI=		@SOABI@
43ABIFLAGS=	@ABIFLAGS@
44ABI_THREAD=	@ABI_THREAD@
45LDVERSION=	@LDVERSION@
46LIBPYTHON=@LIBPYTHON@
47GITVERSION=	@GITVERSION@
48GITTAG=		@GITTAG@
49GITBRANCH=	@GITBRANCH@
50PGO_PROF_GEN_FLAG=@PGO_PROF_GEN_FLAG@
51PGO_PROF_USE_FLAG=@PGO_PROF_USE_FLAG@
52LLVM_PROF_MERGER=@LLVM_PROF_MERGER@
53LLVM_PROF_FILE=@LLVM_PROF_FILE@
54LLVM_PROF_ERR=@LLVM_PROF_ERR@
55DTRACE=         @DTRACE@
56DFLAGS=         @DFLAGS@
57DTRACE_HEADERS= @DTRACE_HEADERS@
58DTRACE_OBJS=    @DTRACE_OBJS@
59DSYMUTIL=       @DSYMUTIL@
60DSYMUTIL_PATH=  @DSYMUTIL_PATH@
61
62GNULD=		@GNULD@
63
64# Shell used by make (some versions default to the login shell, which is bad)
65SHELL=		/bin/sh -e
66
67# Use this to make a link between python$(VERSION) and python in $(BINDIR)
68LN=		@LN@
69
70# Portable install script (configure doesn't always guess right)
71INSTALL=	@INSTALL@
72INSTALL_PROGRAM=@INSTALL_PROGRAM@
73INSTALL_SCRIPT= @INSTALL_SCRIPT@
74INSTALL_DATA=	@INSTALL_DATA@
75# Shared libraries must be installed with executable mode on some systems;
76# rather than figuring out exactly which, we always give them executable mode.
77INSTALL_SHARED= ${INSTALL} -m 755
78
79MKDIR_P=	@MKDIR_P@
80
81MAKESETUP=      $(srcdir)/Modules/makesetup
82
83# Compiler options
84OPT=		@OPT@
85BASECFLAGS=	@BASECFLAGS@
86BASECPPFLAGS=	@BASECPPFLAGS@
87CONFIGURE_CFLAGS=	@CFLAGS@
88# CFLAGS_NODIST is used for building the interpreter and stdlib C extensions.
89# Use it when a compiler flag should _not_ be part of the distutils CFLAGS
90# once Python is installed (Issue #21121).
91CONFIGURE_CFLAGS_NODIST=@CFLAGS_NODIST@
92# LDFLAGS_NODIST is used in the same manner as CFLAGS_NODIST.
93# Use it when a linker flag should _not_ be part of the distutils LDFLAGS
94# once Python is installed (bpo-35257)
95CONFIGURE_LDFLAGS_NODIST=@LDFLAGS_NODIST@
96# LDFLAGS_NOLTO is an extra flag to disable lto. It is used to speed up building
97# of _bootstrap_python and _freeze_module tools, which don't need LTO.
98CONFIGURE_LDFLAGS_NOLTO=@LDFLAGS_NOLTO@
99CONFIGURE_CPPFLAGS=	@CPPFLAGS@
100CONFIGURE_LDFLAGS=	@LDFLAGS@
101# Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the
102# command line to append to these values without stomping the pre-set
103# values.
104PY_CFLAGS=	$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
105PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal -I$(srcdir)/Include/internal/mimalloc
106# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
107# be able to build extension modules using the directories specified in the
108# environment variables
109PY_CPPFLAGS=	$(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
110PY_LDFLAGS=	$(CONFIGURE_LDFLAGS) $(LDFLAGS)
111PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)
112PY_LDFLAGS_NOLTO=$(PY_LDFLAGS) $(CONFIGURE_LDFLAGS_NOLTO) $(LDFLAGS_NODIST)
113NO_AS_NEEDED=	@NO_AS_NEEDED@
114CCSHARED=	@CCSHARED@
115# LINKFORSHARED are the flags passed to the $(CC) command that links
116# the python executable -- this is only needed for a few systems
117LINKFORSHARED=	@LINKFORSHARED@
118ARFLAGS=	@ARFLAGS@
119# Extra C flags added for building the interpreter object files.
120CFLAGSFORSHARED=@CFLAGSFORSHARED@
121# C flags used for building the interpreter object files
122PY_STDMODULE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)
123PY_BUILTIN_MODULE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN
124PY_CORE_CFLAGS=	$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
125# Linker flags used for building the interpreter object files
126PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST)
127# Strict or non-strict aliasing flags used to compile dtoa.c, see above
128CFLAGS_ALIASING=@CFLAGS_ALIASING@
129
130
131# Machine-dependent subdirectories
132MACHDEP=	@MACHDEP@
133
134# Multiarch directory (may be empty)
135MULTIARCH=	@MULTIARCH@
136MULTIARCH_CPPFLAGS = @MULTIARCH_CPPFLAGS@
137
138# Install prefix for architecture-independent files
139prefix=		@prefix@
140
141# Install prefix for architecture-dependent files
142exec_prefix=	@exec_prefix@
143
144# Install prefix for data files
145datarootdir=    @datarootdir@
146
147# Expanded directories
148BINDIR=		@bindir@
149LIBDIR=		@libdir@
150MANDIR=		@mandir@
151INCLUDEDIR=	@includedir@
152CONFINCLUDEDIR=	$(exec_prefix)/include
153PLATLIBDIR=	@PLATLIBDIR@
154SCRIPTDIR=	$(prefix)/$(PLATLIBDIR)
155# executable name for shebangs
156EXENAME=	$(BINDIR)/python$(LDVERSION)$(EXE)
157# Variable used by ensurepip
158WHEEL_PKG_DIR=	@WHEEL_PKG_DIR@
159
160# Detailed destination directories
161BINLIBDEST=	@BINLIBDEST@
162LIBDEST=	$(SCRIPTDIR)/python$(VERSION)$(ABI_THREAD)
163INCLUDEPY=	$(INCLUDEDIR)/python$(LDVERSION)
164CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(LDVERSION)
165
166# Symbols used for using shared libraries
167SHLIB_SUFFIX=	@SHLIB_SUFFIX@
168EXT_SUFFIX=	@EXT_SUFFIX@
169LDSHARED=	@LDSHARED@ $(PY_LDFLAGS)
170BLDSHARED=	@BLDSHARED@ $(PY_CORE_LDFLAGS)
171LDCXXSHARED=	@LDCXXSHARED@ $(PY_LDFLAGS)
172DESTSHARED=	$(BINLIBDEST)/lib-dynload
173
174# List of exported symbols for AIX
175EXPORTSYMS=	@EXPORTSYMS@
176EXPORTSFROM=	@EXPORTSFROM@
177
178# Executable suffix (.exe on Windows and Mac OS X)
179EXE=		@EXEEXT@
180BUILDEXE=	@BUILDEXEEXT@
181
182# Name of the patch file to apply for app store compliance
183APP_STORE_COMPLIANCE_PATCH=@APP_STORE_COMPLIANCE_PATCH@
184
185# Short name and location for Mac OS X Python framework
186UNIVERSALSDK=@UNIVERSALSDK@
187PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
188PYTHONFRAMEWORKDIR=	@PYTHONFRAMEWORKDIR@
189PYTHONFRAMEWORKPREFIX=	@PYTHONFRAMEWORKPREFIX@
190PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
191PYTHONFRAMEWORKINSTALLNAMEPREFIX= @PYTHONFRAMEWORKINSTALLNAMEPREFIX@
192RESSRCDIR= @RESSRCDIR@
193# macOS deployment target selected during configure, to be checked
194# by distutils. The export statement is needed to ensure that the
195# deployment target is active during build.
196MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
197@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
198
199# iOS Deployment target selected during configure. Unlike macOS, the iOS
200# deployment target is controlled using `-mios-version-min` arguments added to
201# CFLAGS and LDFLAGS by the configure script. This variable is not used during
202# the build, and is only listed here so it will be included in sysconfigdata.
203IPHONEOS_DEPLOYMENT_TARGET=@IPHONEOS_DEPLOYMENT_TARGET@
204
205# Option to install to strip binaries
206STRIPFLAG=-s
207
208# Flags to lipo to produce a 32-bit-only universal executable
209LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
210
211# Flags to lipo to produce an intel-64-only universal executable
212LIPO_INTEL64_FLAGS=@LIPO_INTEL64_FLAGS@
213
214# Environment to run shared python without installed libraries
215RUNSHARED=       @RUNSHARED@
216
217# ensurepip options
218ENSUREPIP=      @ENSUREPIP@
219
220# Internal static libraries
221LIBMPDEC_A= Modules/_decimal/libmpdec/libmpdec.a
222LIBEXPAT_A= Modules/expat/libexpat.a
223LIBHACL_SHA2_A= Modules/_hacl/libHacl_Hash_SHA2.a
224
225# Module state, compiler flags and linker flags
226# Empty CFLAGS and LDFLAGS are omitted.
227# states:
228#   * yes: module is available
229#   * missing: build dependency is missing
230#   * disabled: module is disabled
231#   * n/a: module is not available on the current platform
232# MODULE_EGG_STATE=yes  # yes, missing, disabled, n/a
233# MODULE_EGG_CFLAGS=
234# MODULE_EGG_LDFLAGS=
235@MODULE_BLOCK@
236
237# Default zoneinfo.TZPATH. Added here to expose it in sysconfig.get_config_var
238TZPATH=@TZPATH@
239
240# If to install mimalloc headers
241INSTALL_MIMALLOC=@INSTALL_MIMALLOC@
242
243# Modes for directories, executables and data files created by the
244# install process.  Default to user-only-writable for all file types.
245DIRMODE=	755
246EXEMODE=	755
247FILEMODE=	644
248
249# configure script arguments
250CONFIG_ARGS=	@CONFIG_ARGS@
251
252
253# Subdirectories with code
254SRCDIRS= 	@SRCDIRS@
255
256# Other subdirectories
257SUBDIRSTOO=	Include Lib Misc
258
259# assets for Emscripten browser builds
260WASM_ASSETS_DIR=.$(prefix)
261WASM_STDLIB=$(WASM_ASSETS_DIR)/lib/python$(VERSION)/os.py
262
263# Files and directories to be distributed
264CONFIGFILES=	configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
265DISTFILES=	README.rst ChangeLog $(CONFIGFILES)
266DISTDIRS=	$(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
267DIST=		$(DISTFILES) $(DISTDIRS)
268
269
270LIBRARY=	@LIBRARY@
271LDLIBRARY=      @LDLIBRARY@
272BLDLIBRARY=     @BLDLIBRARY@
273PY3LIBRARY=     @PY3LIBRARY@
274DLLLIBRARY=	@DLLLIBRARY@
275LDLIBRARYDIR=   @LDLIBRARYDIR@
276INSTSONAME=	@INSTSONAME@
277LIBRARY_DEPS=	@LIBRARY_DEPS@
278LINK_PYTHON_DEPS=@LINK_PYTHON_DEPS@
279PY_ENABLE_SHARED=	@PY_ENABLE_SHARED@
280STATIC_LIBPYTHON=	@STATIC_LIBPYTHON@
281
282
283LIBS=		@LIBS@
284LIBM=		@LIBM@
285LIBC=		@LIBC@
286SYSLIBS=	$(LIBM) $(LIBC)
287SHLIBS=		@SHLIBS@
288
289DLINCLDIR=	@DLINCLDIR@
290DYNLOADFILE=	@DYNLOADFILE@
291MACHDEP_OBJS=	@MACHDEP_OBJS@
292LIBOBJDIR=	Python/
293LIBOBJS=	@LIBOBJS@
294
295PYTHON=		python$(EXE)
296BUILDPYTHON=	python$(BUILDEXE)
297
298HOSTRUNNER= @HOSTRUNNER@
299
300PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@
301UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/update_file.py
302PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
303# Single-platform builds depend on $(BUILDPYTHON). Cross builds use an
304# external "build Python" and have an empty PYTHON_FOR_BUILD_DEPS.
305PYTHON_FOR_BUILD_DEPS=@PYTHON_FOR_BUILD_DEPS@
306
307# Single-platform builds use Programs/_freeze_module.c for bootstrapping and
308# ./_bootstrap_python Programs/_freeze_module.py for remaining modules
309# Cross builds use an external "build Python" for all modules.
310PYTHON_FOR_FREEZE=@PYTHON_FOR_FREEZE@
311FREEZE_MODULE_BOOTSTRAP=@FREEZE_MODULE_BOOTSTRAP@
312FREEZE_MODULE_BOOTSTRAP_DEPS=@FREEZE_MODULE_BOOTSTRAP_DEPS@
313FREEZE_MODULE=@FREEZE_MODULE@
314FREEZE_MODULE_DEPS=@FREEZE_MODULE_DEPS@
315
316_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
317BUILD_GNU_TYPE=	@build@
318HOST_GNU_TYPE=	@host@
319
320# The task to run while instrumented when building the profile-opt target.
321# To speed up profile generation, we don't run the full unit test suite
322# by default. The default is "-m test --pgo". To run more tests, use
323# PROFILE_TASK="-m test --pgo-extended"
324PROFILE_TASK=	@PROFILE_TASK@
325
326# report files for gcov / lcov coverage report
327COVERAGE_INFO=	$(abs_builddir)/coverage.info
328COVERAGE_REPORT=$(abs_builddir)/lcov-report
329COVERAGE_LCOV_OPTIONS=--rc lcov_branch_coverage=1
330COVERAGE_REPORT_OPTIONS=--rc lcov_branch_coverage=1 --branch-coverage --title "CPython $(VERSION) LCOV report [commit $(shell $(GITVERSION))]"
331
332
333# === Definitions added by makesetup ===
334
335
336##########################################################################
337# Modules
338MODULE_OBJS=	\
339		Modules/config.o \
340		Modules/main.o \
341		Modules/gcmodule.o
342
343IO_H=		Modules/_io/_iomodule.h
344
345IO_OBJS=	\
346		Modules/_io/_iomodule.o \
347		Modules/_io/iobase.o \
348		Modules/_io/fileio.o \
349		Modules/_io/bufferedio.o \
350		Modules/_io/textio.o \
351		Modules/_io/bytesio.o \
352		Modules/_io/stringio.o
353
354
355##########################################################################
356# mimalloc
357
358MIMALLOC_HEADERS= \
359	$(srcdir)/Include/internal/pycore_mimalloc.h \
360	$(srcdir)/Include/internal/mimalloc/mimalloc.h \
361	$(srcdir)/Include/internal/mimalloc/mimalloc/atomic.h \
362	$(srcdir)/Include/internal/mimalloc/mimalloc/internal.h \
363	$(srcdir)/Include/internal/mimalloc/mimalloc/prim.h \
364	$(srcdir)/Include/internal/mimalloc/mimalloc/track.h \
365	$(srcdir)/Include/internal/mimalloc/mimalloc/types.h
366
367
368##########################################################################
369# Parser
370
371PEGEN_OBJS=		\
372		Parser/pegen.o \
373		Parser/pegen_errors.o \
374		Parser/action_helpers.o \
375		Parser/parser.o \
376		Parser/string_parser.o \
377		Parser/peg_api.o
378
379TOKENIZER_OBJS=		\
380		Parser/lexer/buffer.o \
381		Parser/lexer/lexer.o \
382		Parser/lexer/state.o \
383		Parser/tokenizer/file_tokenizer.o \
384		Parser/tokenizer/readline_tokenizer.o \
385		Parser/tokenizer/string_tokenizer.o \
386		Parser/tokenizer/utf8_tokenizer.o \
387		Parser/tokenizer/helpers.o
388
389PEGEN_HEADERS= \
390		$(srcdir)/Include/internal/pycore_parser.h \
391		$(srcdir)/Parser/pegen.h \
392		$(srcdir)/Parser/string_parser.h
393
394TOKENIZER_HEADERS= \
395		Parser/lexer/buffer.h \
396		Parser/lexer/lexer.h \
397		Parser/lexer/state.h \
398		Parser/tokenizer/tokenizer.h \
399		Parser/tokenizer/helpers.h
400
401POBJS=		\
402		Parser/token.o \
403
404PARSER_OBJS=	$(POBJS) $(PEGEN_OBJS) $(TOKENIZER_OBJS) Parser/myreadline.o
405
406PARSER_HEADERS= \
407		$(PEGEN_HEADERS) \
408		$(TOKENIZER_HEADERS)
409
410##########################################################################
411# Python
412
413PYTHON_OBJS=	\
414		Python/_warnings.o \
415		Python/Python-ast.o \
416		Python/Python-tokenize.o \
417		Python/asdl.o \
418		Python/assemble.o \
419		Python/ast.o \
420		Python/ast_opt.o \
421		Python/ast_unparse.o \
422		Python/bltinmodule.o \
423		Python/brc.o \
424		Python/ceval.o \
425		Python/codecs.o \
426		Python/compile.o \
427		Python/context.o \
428		Python/critical_section.o \
429		Python/crossinterp.o \
430		Python/dynamic_annotations.o \
431		Python/errors.o \
432		Python/flowgraph.o \
433		Python/frame.o \
434		Python/frozenmain.o \
435		Python/future.o \
436		Python/gc.o \
437		Python/gc_free_threading.o \
438		Python/gc_gil.o \
439		Python/getargs.o \
440		Python/getcompiler.o \
441		Python/getcopyright.o \
442		Python/getplatform.o \
443		Python/getversion.o \
444		Python/ceval_gil.o \
445		Python/hamt.o \
446		Python/hashtable.o \
447		Python/import.o \
448		Python/importdl.o \
449		Python/initconfig.o \
450		Python/interpconfig.o \
451		Python/instrumentation.o \
452		Python/instruction_sequence.o \
453		Python/intrinsics.o \
454		Python/jit.o \
455		Python/legacy_tracing.o \
456		Python/lock.o \
457		Python/marshal.o \
458		Python/modsupport.o \
459		Python/mysnprintf.o \
460		Python/mystrtoul.o \
461		Python/object_stack.o \
462		Python/optimizer.o \
463		Python/optimizer_analysis.o \
464		Python/optimizer_symbols.o \
465		Python/parking_lot.o \
466		Python/pathconfig.o \
467		Python/preconfig.o \
468		Python/pyarena.o \
469		Python/pyctype.o \
470		Python/pyfpe.o \
471		Python/pyhash.o \
472		Python/pylifecycle.o \
473		Python/pymath.o \
474		Python/pystate.o \
475		Python/pythonrun.o \
476		Python/pytime.o \
477		Python/qsbr.o \
478		Python/bootstrap_hash.o \
479		Python/specialize.o \
480		Python/structmember.o \
481		Python/symtable.o \
482		Python/sysmodule.o \
483		Python/thread.o \
484		Python/traceback.o \
485		Python/tracemalloc.o \
486		Python/getopt.o \
487		Python/pystrcmp.o \
488		Python/pystrtod.o \
489		Python/pystrhex.o \
490		Python/dtoa.o \
491		Python/formatter_unicode.o \
492		Python/fileutils.o \
493		Python/suggestions.o \
494		Python/perf_trampoline.o \
495		Python/perf_jit_trampoline.o \
496		Python/$(DYNLOADFILE) \
497		$(LIBOBJS) \
498		$(MACHDEP_OBJS) \
499		$(DTRACE_OBJS) \
500		@PLATFORM_OBJS@
501
502
503##########################################################################
504# Objects
505OBJECT_OBJS=	\
506		Objects/abstract.o \
507		Objects/boolobject.o \
508		Objects/bytes_methods.o \
509		Objects/bytearrayobject.o \
510		Objects/bytesobject.o \
511		Objects/call.o \
512		Objects/capsule.o \
513		Objects/cellobject.o \
514		Objects/classobject.o \
515		Objects/codeobject.o \
516		Objects/complexobject.o \
517		Objects/descrobject.o \
518		Objects/enumobject.o \
519		Objects/exceptions.o \
520		Objects/genericaliasobject.o \
521		Objects/genobject.o \
522		Objects/fileobject.o \
523		Objects/floatobject.o \
524		Objects/frameobject.o \
525		Objects/funcobject.o \
526		Objects/iterobject.o \
527		Objects/listobject.o \
528		Objects/longobject.o \
529		Objects/dictobject.o \
530		Objects/odictobject.o \
531		Objects/memoryobject.o \
532		Objects/methodobject.o \
533		Objects/moduleobject.o \
534		Objects/namespaceobject.o \
535		Objects/object.o \
536		Objects/obmalloc.o \
537		Objects/picklebufobject.o \
538		Objects/rangeobject.o \
539		Objects/setobject.o \
540		Objects/sliceobject.o \
541		Objects/structseq.o \
542		Objects/tupleobject.o \
543		Objects/typeobject.o \
544		Objects/typevarobject.o \
545		Objects/unicodeobject.o \
546		Objects/unicodectype.o \
547		Objects/unionobject.o \
548		Objects/weakrefobject.o \
549		@PERF_TRAMPOLINE_OBJ@
550
551##########################################################################
552# objects that get linked into the Python library
553LIBRARY_OBJS_OMIT_FROZEN=	\
554		Modules/getbuildinfo.o \
555		$(PARSER_OBJS) \
556		$(OBJECT_OBJS) \
557		$(PYTHON_OBJS) \
558		$(MODULE_OBJS) \
559		$(MODOBJS)
560
561LIBRARY_OBJS=	\
562		$(LIBRARY_OBJS_OMIT_FROZEN) \
563		Modules/getpath.o \
564		Python/frozen.o
565
566LINK_PYTHON_OBJS=@LINK_PYTHON_OBJS@
567
568##########################################################################
569# DTrace
570
571# On some systems, object files that reference DTrace probes need to be modified
572# in-place by dtrace(1).
573DTRACE_DEPS = \
574	Python/ceval.o Python/gc.o Python/import.o Python/sysmodule.o
575
576##########################################################################
577# decimal's libmpdec
578
579LIBMPDEC_OBJS= \
580		Modules/_decimal/libmpdec/basearith.o \
581		Modules/_decimal/libmpdec/constants.o \
582		Modules/_decimal/libmpdec/context.o \
583		Modules/_decimal/libmpdec/convolute.o \
584		Modules/_decimal/libmpdec/crt.o \
585		Modules/_decimal/libmpdec/difradix2.o \
586		Modules/_decimal/libmpdec/fnt.o \
587		Modules/_decimal/libmpdec/fourstep.o \
588		Modules/_decimal/libmpdec/io.o \
589		Modules/_decimal/libmpdec/mpalloc.o \
590		Modules/_decimal/libmpdec/mpdecimal.o \
591		Modules/_decimal/libmpdec/numbertheory.o \
592		Modules/_decimal/libmpdec/sixstep.o \
593		Modules/_decimal/libmpdec/transpose.o
594		# _decimal does not use signaling API
595		# Modules/_decimal/libmpdec/mpsignal.o
596
597LIBMPDEC_HEADERS= \
598		$(srcdir)/Modules/_decimal/libmpdec/basearith.h \
599		$(srcdir)/Modules/_decimal/libmpdec/bits.h \
600		$(srcdir)/Modules/_decimal/libmpdec/constants.h \
601		$(srcdir)/Modules/_decimal/libmpdec/convolute.h \
602		$(srcdir)/Modules/_decimal/libmpdec/crt.h \
603		$(srcdir)/Modules/_decimal/libmpdec/difradix2.h \
604		$(srcdir)/Modules/_decimal/libmpdec/fnt.h \
605		$(srcdir)/Modules/_decimal/libmpdec/fourstep.h \
606		$(srcdir)/Modules/_decimal/libmpdec/io.h \
607		$(srcdir)/Modules/_decimal/libmpdec/mpalloc.h \
608		$(srcdir)/Modules/_decimal/libmpdec/mpdecimal.h \
609		$(srcdir)/Modules/_decimal/libmpdec/numbertheory.h \
610		$(srcdir)/Modules/_decimal/libmpdec/sixstep.h \
611		$(srcdir)/Modules/_decimal/libmpdec/transpose.h \
612		$(srcdir)/Modules/_decimal/libmpdec/typearith.h \
613		$(srcdir)/Modules/_decimal/libmpdec/umodarith.h
614
615##########################################################################
616# pyexpat's expat library
617
618LIBEXPAT_OBJS= \
619		Modules/expat/xmlparse.o \
620		Modules/expat/xmlrole.o \
621		Modules/expat/xmltok.o
622
623LIBEXPAT_HEADERS= \
624		Modules/expat/ascii.h \
625		Modules/expat/asciitab.h \
626		Modules/expat/expat.h \
627		Modules/expat/expat_config.h \
628		Modules/expat/expat_external.h \
629		Modules/expat/iasciitab.h \
630		Modules/expat/internal.h \
631		Modules/expat/latin1tab.h \
632		Modules/expat/nametab.h \
633		Modules/expat/pyexpatns.h \
634		Modules/expat/siphash.h \
635		Modules/expat/utf8tab.h \
636		Modules/expat/xmlrole.h \
637		Modules/expat/xmltok.h \
638		Modules/expat/xmltok_impl.h \
639		Modules/expat/xmltok_impl.c \
640		Modules/expat/xmltok_ns.c
641
642##########################################################################
643# hashlib's HACL* library
644
645LIBHACL_SHA2_OBJS= \
646                Modules/_hacl/Hacl_Hash_SHA2.o
647
648LIBHACL_HEADERS= \
649                Modules/_hacl/include/krml/FStar_UInt128_Verified.h \
650                Modules/_hacl/include/krml/FStar_UInt_8_16_32_64.h \
651                Modules/_hacl/include/krml/fstar_uint128_struct_endianness.h \
652                Modules/_hacl/include/krml/internal/target.h \
653                Modules/_hacl/include/krml/lowstar_endianness.h \
654                Modules/_hacl/include/krml/types.h \
655		Modules/_hacl/Hacl_Streaming_Types.h \
656                Modules/_hacl/python_hacl_namespaces.h
657
658LIBHACL_SHA2_HEADERS= \
659                Modules/_hacl/Hacl_Hash_SHA2.h \
660                Modules/_hacl/internal/Hacl_Hash_SHA2.h \
661		$(LIBHACL_HEADERS)
662
663#########################################################################
664# Rules
665
666# Default target
667all:		@DEF_MAKE_ALL_RULE@
668
669# First target in Makefile is implicit default. So .PHONY needs to come after
670# all.
671.PHONY: all
672
673# Provide quick help for common Makefile targets.
674.PHONY: help
675help:
676	@echo "Run 'make' to build the Python executable and extension modules"
677	@echo ""
678	@echo "or 'make <target>' where <target> is one of:"
679	@echo "  test         run the test suite"
680	@echo "  install      install built files"
681	@echo "  regen-all    regenerate a number of generated source files"
682	@echo "  clinic       run Argument Clinic over source files"
683	@echo ""
684	@echo "  clean        to remove build files"
685	@echo "  distclean    'clean' + remove other generated files (patch, exe, etc)"
686	@echo ""
687	@echo "  recheck      rerun configure with last cmdline options"
688	@echo "  reindent     reindent .py files in Lib directory"
689	@echo "  tags         build a tags file (useful for Emacs and other editors)"
690	@echo "  list-targets list all targets in the Makefile"
691
692# Display a full list of Makefile targets
693.PHONY: list-targets
694list-targets:
695	@grep -E '^[A-Za-z][-A-Za-z0-9]+:' Makefile | awk -F : '{print $$1}'
696
697.PHONY: build_all
698build_all:	check-clean-src check-app-store-compliance $(BUILDPYTHON) platform sharedmods \
699		gdbhooks Programs/_testembed scripts checksharedmods rundsymutil
700
701.PHONY: build_wasm
702build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \
703		python-config checksharedmods
704
705# Check that the source is clean when building out of source.
706.PHONY: check-clean-src
707check-clean-src:
708	@if test -n "$(VPATH)" -a \( \
709	    -f "$(srcdir)/$(BUILDPYTHON)" \
710	    -o -f "$(srcdir)/Programs/python.o" \
711	    -o -f "$(srcdir)/Python/frozen_modules/importlib._bootstrap.h" \
712	\); then \
713		echo "Error: The source directory ($(srcdir)) is not clean" ; \
714		echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \
715		echo "Build artifacts such as .o files, executables, and Python/frozen_modules/*.h must not exist within $(srcdir)." ; \
716		echo "Try to run:" ; \
717		echo "  (cd \"$(srcdir)\" && make clean || git clean -fdx -e Doc/venv)" ; \
718		exit 1; \
719	fi
720
721# Check that the app store compliance patch can be applied (if configured).
722# This is checked as a dry-run against the original library sources;
723# the patch will be actually applied during the install phase.
724.PHONY: check-app-store-compliance
725check-app-store-compliance:
726	@if [ "$(APP_STORE_COMPLIANCE_PATCH)" != "" ]; then \
727		patch --dry-run --quiet --force --strip 1 --directory "$(abs_srcdir)" --input "$(abs_srcdir)/$(APP_STORE_COMPLIANCE_PATCH)"; \
728		echo "App store compliance patch can be applied."; \
729	fi
730
731# Profile generation build must start from a clean tree.
732profile-clean-stamp:
733	$(MAKE) clean
734	touch $@
735
736# Compile with profile generation enabled.
737profile-gen-stamp: profile-clean-stamp
738	@if [ $(LLVM_PROF_ERR) = yes ]; then \
739		echo "Error: Cannot perform PGO build because llvm-profdata was not found in PATH" ;\
740		echo "Please add it to PATH and run ./configure again" ;\
741		exit 1;\
742	fi
743	@echo "Building with support for profile generation:"
744	$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)"
745	touch $@
746
747# Run task with profile generation build to create profile information.
748profile-run-stamp:
749	@echo "Running code to generate profile data (this can take a while):"
750	# First, we need to create a clean build with profile generation
751	# enabled.
752	$(MAKE) profile-gen-stamp
753	# Next, run the profile task to generate the profile information.
754	@ # FIXME: can't run for a cross build
755	$(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK)
756	$(LLVM_PROF_MERGER)
757	# Remove profile generation binary since we are done with it.
758	$(MAKE) clean-retain-profile
759	# This is an expensive target to build and it does not have proper
760	# makefile dependency information.  So, we create a "stamp" file
761	# to record its completion and avoid re-running it.
762	touch $@
763
764# Compile Python binary with profile guided optimization.
765# To force re-running of the profile task, remove the profile-run-stamp file.
766.PHONY: profile-opt
767profile-opt: profile-run-stamp
768	@echo "Rebuilding with profile guided optimizations:"
769	-rm -f profile-clean-stamp
770	$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_USE_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST)"
771
772# List of binaries that BOLT runs on.
773BOLT_BINARIES := @BOLT_BINARIES@
774
775BOLT_INSTRUMENT_FLAGS := @BOLT_INSTRUMENT_FLAGS@
776BOLT_APPLY_FLAGS := @BOLT_APPLY_FLAGS@
777
778.PHONY: clean-bolt
779clean-bolt:
780	# Profile data.
781	rm -f *.fdata
782	# Pristine binaries before BOLT optimization.
783	rm -f *.prebolt
784	# BOLT instrumented binaries.
785	rm -f *.bolt_inst
786
787profile-bolt-stamp: $(BUILDPYTHON)
788	# Ensure a pristine, pre-BOLT copy of the binary and no profile data from last run.
789	for bin in $(BOLT_BINARIES); do \
790	  prebolt="$${bin}.prebolt"; \
791	  if [ -e "$${prebolt}" ]; then \
792	    echo "Restoring pre-BOLT binary $${prebolt}"; \
793	    mv "$${bin}.prebolt" "$${bin}"; \
794	  fi; \
795	  cp "$${bin}" "$${prebolt}"; \
796	  rm -f $${bin}.bolt.*.fdata $${bin}.fdata; \
797	done
798	# Instrument each binary.
799	for bin in $(BOLT_BINARIES); do \
800	  @LLVM_BOLT@ "$${bin}" -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $${bin}.bolt) -o $${bin}.bolt_inst $(BOLT_INSTRUMENT_FLAGS); \
801	  mv "$${bin}.bolt_inst" "$${bin}"; \
802	done
803	# Run instrumented binaries to collect data.
804	$(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK)
805	# Merge all the data files together.
806	for bin in $(BOLT_BINARIES); do \
807	  @MERGE_FDATA@ $${bin}.*.fdata > "$${bin}.fdata"; \
808	  rm -f $${bin}.*.fdata; \
809	done
810	# Run bolt against the merged data to produce an optimized binary.
811	for bin in $(BOLT_BINARIES); do \
812	  @LLVM_BOLT@ "$${bin}.prebolt" -o "$${bin}.bolt" -data="$${bin}.fdata" $(BOLT_APPLY_FLAGS); \
813	  mv "$${bin}.bolt" "$${bin}"; \
814	done
815	touch $@
816
817.PHONY: bolt-opt
818bolt-opt:
819	$(MAKE) @PREBOLT_RULE@
820	$(MAKE) profile-bolt-stamp
821
822# Compile and run with gcov
823.PHONY: coverage
824coverage:
825	@echo "Building with support for coverage checking:"
826	$(MAKE) clean
827	$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) -O0 -pg --coverage" LDFLAGS="$(LDFLAGS) --coverage"
828
829.PHONY: coverage-lcov
830coverage-lcov:
831	@echo "Creating Coverage HTML report with LCOV:"
832	@rm -f $(COVERAGE_INFO)
833	@rm -rf $(COVERAGE_REPORT)
834	@lcov $(COVERAGE_LCOV_OPTIONS) --capture \
835	    --directory $(abs_builddir) \
836	    --base-directory $(realpath $(abs_builddir)) \
837	    --path $(realpath $(abs_srcdir)) \
838	    --output-file $(COVERAGE_INFO)
839	@ # remove 3rd party modules, system headers and internal files with
840	@ # debug, test or dummy functions.
841	@lcov $(COVERAGE_LCOV_OPTIONS) --remove $(COVERAGE_INFO) \
842	    '*/Modules/_blake2/impl/*' \
843	    '*/Modules/_ctypes/libffi*/*' \
844	    '*/Modules/_decimal/libmpdec/*' \
845	    '*/Modules/expat/*' \
846	    '*/Modules/xx*.c' \
847	    '*/Python/pyfpe.c' \
848	    '*/Python/pystrcmp.c' \
849	    '/usr/include/*' \
850	    '/usr/local/include/*' \
851	    '/usr/lib/gcc/*' \
852	    --output-file $(COVERAGE_INFO)
853	@genhtml $(COVERAGE_INFO) \
854	    --output-directory $(COVERAGE_REPORT) \
855	    $(COVERAGE_REPORT_OPTIONS)
856	@echo
857	@echo "lcov report at $(COVERAGE_REPORT)/index.html"
858	@echo
859
860# Force regeneration of parser and frozen modules
861.PHONY: coverage-report
862coverage-report: regen-token regen-frozen
863	@ # build with coverage info
864	$(MAKE) coverage
865	@ # run tests, ignore failures
866	$(TESTRUNNER) --fast-ci --timeout=$(TESTTIMEOUT) $(TESTOPTS) || true
867	@ # build lcov report
868	$(MAKE) coverage-lcov
869
870# Run "Argument Clinic" over all source files
871.PHONY: clinic
872clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
873	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --exclude Lib/test/clinic.test.c --srcdir $(srcdir)
874
875.PHONY: clinic-tests
876clinic-tests: check-clean-src $(srcdir)/Lib/test/clinic.test.c
877	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $(srcdir)/Lib/test/clinic.test.c
878
879# Build the interpreter
880$(BUILDPYTHON):	Programs/python.o $(LINK_PYTHON_DEPS)
881	$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
882
883platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt
884	$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
885
886# Create build directory and generate the sysconfig build-time data there.
887# pybuilddir.txt contains the name of the build dir and is used for
888# sys.path fixup -- see Modules/getpath.c.
889# Since this step runs before shared modules are built, try to avoid bootstrap
890# problems by creating a dummy pybuilddir.txt just to allow interpreter
891# initialization to succeed.  It will be overwritten by generate-posix-vars
892# or removed in case of failure.
893pybuilddir.txt: $(PYTHON_FOR_BUILD_DEPS)
894	@echo "none" > ./pybuilddir.txt
895	$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
896	if test $$? -ne 0 ; then \
897		echo "generate-posix-vars failed" ; \
898		rm -f ./pybuilddir.txt ; \
899		exit 1 ; \
900	fi
901
902# blake2s is auto-generated from blake2b
903$(srcdir)/Modules/_blake2/blake2s_impl.c: $(srcdir)/Modules/_blake2/blake2b_impl.c $(srcdir)/Modules/_blake2/blake2b2s.py
904	$(PYTHON_FOR_REGEN) $(srcdir)/Modules/_blake2/blake2b2s.py
905	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $@
906
907# Build static library
908$(LIBRARY): $(LIBRARY_OBJS)
909	-rm -f $@
910	$(AR) $(ARFLAGS) $@ $(LIBRARY_OBJS)
911
912libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS)
913	$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM)
914	if test $(INSTSONAME) != $@; then \
915		$(LN) -f $(INSTSONAME) $@; \
916	fi
917
918libpython3.so:	libpython$(LDVERSION).so
919	$(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
920
921libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
922	 $(CC) -dynamiclib $(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); \
923
924
925libpython$(VERSION).sl: $(LIBRARY_OBJS)
926	$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM)
927
928# List of exported symbols for AIX
929Modules/python.exp: $(LIBRARY)
930	$(srcdir)/Modules/makexp_aix $@ "$(EXPORTSFROM)" $?
931
932# Copy up the gdb python hooks into a position where they can be automatically
933# loaded by gdb during Lib/test/test_gdb.py
934#
935# Distributors are likely to want to install this somewhere else e.g. relative
936# to the stripped DWARF data for the shared library.
937.PHONY: gdbhooks
938gdbhooks: $(BUILDPYTHON)-gdb.py
939
940SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py
941$(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
942	$(INSTALL_DATA) $(SRC_GDB_HOOKS) $(BUILDPYTHON)-gdb.py
943
944# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
945# minimal framework (not including the Lib directory and such) in the current
946# directory.
947$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
948		$(LIBRARY) \
949		$(RESSRCDIR)/Info.plist
950	$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
951	$(CC) -o $(LDLIBRARY) $(PY_CORE_LDFLAGS) -dynamiclib \
952		-all_load $(LIBRARY) \
953		-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLNAMEPREFIX)/$(PYTHONFRAMEWORK) \
954		-compatibility_version $(VERSION) \
955		-current_version $(VERSION) \
956		-framework CoreFoundation $(LIBS);
957	$(INSTALL) -d -m $(DIRMODE)  \
958		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
959	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
960		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
961	$(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
962	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
963	$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
964
965# This rule is for iOS, which requires an annoyingly just slightly different
966# format for frameworks to macOS. It *doesn't* use a versioned framework, and
967# the Info.plist must be in the root of the framework.
968$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK): \
969		$(LIBRARY) \
970		$(RESSRCDIR)/Info.plist
971	$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)
972	$(CC) -o $(LDLIBRARY) $(PY_CORE_LDFLAGS) -dynamiclib \
973		-all_load $(LIBRARY) \
974		-install_name $(PYTHONFRAMEWORKINSTALLNAMEPREFIX)/$(PYTHONFRAMEWORK) \
975		-compatibility_version $(VERSION) \
976		-current_version $(VERSION) \
977		-framework CoreFoundation $(LIBS);
978	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist $(PYTHONFRAMEWORKDIR)/Info.plist
979
980# This rule builds the Cygwin Python DLL and import library if configured
981# for a shared core library; otherwise, this rule is a noop.
982$(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
983	if test -n "$(DLLLIBRARY)"; then \
984		$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
985			$(LIBS) $(MODLIBS) $(SYSLIBS); \
986	else true; \
987	fi
988
989# wasm32-emscripten browser build
990# wasm assets directory is relative to current build dir, e.g. "./usr/local".
991# --preload-file turns a relative asset path into an absolute path.
992
993.PHONY: wasm_stdlib
994wasm_stdlib: $(WASM_STDLIB)
995$(WASM_STDLIB): $(srcdir)/Lib/*.py $(srcdir)/Lib/*/*.py \
996	    $(srcdir)/Tools/wasm/wasm_assets.py \
997	    Makefile pybuilddir.txt Modules/Setup.local
998	$(PYTHON_FOR_BUILD) $(srcdir)/Tools/wasm/wasm_assets.py \
999	    --buildroot . --prefix $(prefix)
1000
1001python.html: $(srcdir)/Tools/wasm/python.html python.worker.js
1002	@cp $(srcdir)/Tools/wasm/python.html $@
1003
1004python.worker.js: $(srcdir)/Tools/wasm/python.worker.js
1005	@cp $(srcdir)/Tools/wasm/python.worker.js $@
1006
1007############################################################################
1008# Header files
1009
1010PYTHON_HEADERS= \
1011		$(srcdir)/Include/Python.h \
1012		$(srcdir)/Include/abstract.h \
1013		$(srcdir)/Include/bltinmodule.h \
1014		$(srcdir)/Include/boolobject.h \
1015		$(srcdir)/Include/bytearrayobject.h \
1016		$(srcdir)/Include/bytesobject.h \
1017		$(srcdir)/Include/ceval.h \
1018		$(srcdir)/Include/codecs.h \
1019		$(srcdir)/Include/compile.h \
1020		$(srcdir)/Include/complexobject.h \
1021		$(srcdir)/Include/critical_section.h \
1022		$(srcdir)/Include/descrobject.h \
1023		$(srcdir)/Include/dictobject.h \
1024		$(srcdir)/Include/dynamic_annotations.h \
1025		$(srcdir)/Include/enumobject.h \
1026		$(srcdir)/Include/errcode.h \
1027		$(srcdir)/Include/exports.h \
1028		$(srcdir)/Include/fileobject.h \
1029		$(srcdir)/Include/fileutils.h \
1030		$(srcdir)/Include/floatobject.h \
1031		$(srcdir)/Include/frameobject.h \
1032		$(srcdir)/Include/genericaliasobject.h \
1033		$(srcdir)/Include/import.h \
1034		$(srcdir)/Include/intrcheck.h \
1035		$(srcdir)/Include/iterobject.h \
1036		$(srcdir)/Include/listobject.h \
1037		$(srcdir)/Include/lock.h \
1038		$(srcdir)/Include/longobject.h \
1039		$(srcdir)/Include/marshal.h \
1040		$(srcdir)/Include/memoryobject.h \
1041		$(srcdir)/Include/methodobject.h \
1042		$(srcdir)/Include/modsupport.h \
1043		$(srcdir)/Include/moduleobject.h \
1044		$(srcdir)/Include/monitoring.h \
1045		$(srcdir)/Include/object.h \
1046		$(srcdir)/Include/objimpl.h \
1047		$(srcdir)/Include/opcode.h \
1048		$(srcdir)/Include/opcode_ids.h \
1049		$(srcdir)/Include/osdefs.h \
1050		$(srcdir)/Include/osmodule.h \
1051		$(srcdir)/Include/patchlevel.h \
1052		$(srcdir)/Include/pyatomic.h \
1053		$(srcdir)/Include/pybuffer.h \
1054		$(srcdir)/Include/pycapsule.h \
1055		$(srcdir)/Include/pydtrace.h \
1056		$(srcdir)/Include/pyerrors.h \
1057		$(srcdir)/Include/pyexpat.h \
1058		$(srcdir)/Include/pyframe.h \
1059		$(srcdir)/Include/pyhash.h \
1060		$(srcdir)/Include/pylifecycle.h \
1061		$(srcdir)/Include/pymacconfig.h \
1062		$(srcdir)/Include/pymacro.h \
1063		$(srcdir)/Include/pymath.h \
1064		$(srcdir)/Include/pymem.h \
1065		$(srcdir)/Include/pyport.h \
1066		$(srcdir)/Include/pystate.h \
1067		$(srcdir)/Include/pystats.h \
1068		$(srcdir)/Include/pystrcmp.h \
1069		$(srcdir)/Include/pystrtod.h \
1070		$(srcdir)/Include/pythonrun.h \
1071		$(srcdir)/Include/pythread.h \
1072		$(srcdir)/Include/pytypedefs.h \
1073		$(srcdir)/Include/rangeobject.h \
1074		$(srcdir)/Include/setobject.h \
1075		$(srcdir)/Include/sliceobject.h \
1076		$(srcdir)/Include/structmember.h \
1077		$(srcdir)/Include/structseq.h \
1078		$(srcdir)/Include/sysmodule.h \
1079		$(srcdir)/Include/traceback.h \
1080		$(srcdir)/Include/tupleobject.h \
1081		$(srcdir)/Include/typeslots.h \
1082		$(srcdir)/Include/unicodeobject.h \
1083		$(srcdir)/Include/warnings.h \
1084		$(srcdir)/Include/weakrefobject.h \
1085		\
1086		pyconfig.h \
1087		$(PARSER_HEADERS) \
1088		\
1089		$(srcdir)/Include/cpython/abstract.h \
1090		$(srcdir)/Include/cpython/bytearrayobject.h \
1091		$(srcdir)/Include/cpython/bytesobject.h \
1092		$(srcdir)/Include/cpython/cellobject.h \
1093		$(srcdir)/Include/cpython/ceval.h \
1094		$(srcdir)/Include/cpython/classobject.h \
1095		$(srcdir)/Include/cpython/code.h \
1096		$(srcdir)/Include/cpython/compile.h \
1097		$(srcdir)/Include/cpython/complexobject.h \
1098		$(srcdir)/Include/cpython/context.h \
1099		$(srcdir)/Include/cpython/critical_section.h \
1100		$(srcdir)/Include/cpython/descrobject.h \
1101		$(srcdir)/Include/cpython/dictobject.h \
1102		$(srcdir)/Include/cpython/fileobject.h \
1103		$(srcdir)/Include/cpython/fileutils.h \
1104		$(srcdir)/Include/cpython/floatobject.h \
1105		$(srcdir)/Include/cpython/frameobject.h \
1106		$(srcdir)/Include/cpython/funcobject.h \
1107		$(srcdir)/Include/cpython/genobject.h \
1108		$(srcdir)/Include/cpython/import.h \
1109		$(srcdir)/Include/cpython/initconfig.h \
1110		$(srcdir)/Include/cpython/listobject.h \
1111		$(srcdir)/Include/cpython/lock.h \
1112		$(srcdir)/Include/cpython/longintrepr.h \
1113		$(srcdir)/Include/cpython/longobject.h \
1114		$(srcdir)/Include/cpython/memoryobject.h \
1115		$(srcdir)/Include/cpython/methodobject.h \
1116		$(srcdir)/Include/cpython/modsupport.h \
1117		$(srcdir)/Include/cpython/monitoring.h \
1118		$(srcdir)/Include/cpython/object.h \
1119		$(srcdir)/Include/cpython/objimpl.h \
1120		$(srcdir)/Include/cpython/odictobject.h \
1121		$(srcdir)/Include/cpython/picklebufobject.h \
1122		$(srcdir)/Include/cpython/pthread_stubs.h \
1123		$(srcdir)/Include/cpython/pyatomic.h \
1124		$(srcdir)/Include/cpython/pyatomic_gcc.h \
1125		$(srcdir)/Include/cpython/pyatomic_std.h \
1126		$(srcdir)/Include/cpython/pyctype.h \
1127		$(srcdir)/Include/cpython/pydebug.h \
1128		$(srcdir)/Include/cpython/pyerrors.h \
1129		$(srcdir)/Include/cpython/pyfpe.h \
1130		$(srcdir)/Include/cpython/pyframe.h \
1131		$(srcdir)/Include/cpython/pyhash.h \
1132		$(srcdir)/Include/cpython/pylifecycle.h \
1133		$(srcdir)/Include/cpython/pymem.h \
1134		$(srcdir)/Include/cpython/pystate.h \
1135		$(srcdir)/Include/cpython/pystats.h \
1136		$(srcdir)/Include/cpython/pythonrun.h \
1137		$(srcdir)/Include/cpython/pythread.h \
1138		$(srcdir)/Include/cpython/setobject.h \
1139		$(srcdir)/Include/cpython/sysmodule.h \
1140		$(srcdir)/Include/cpython/traceback.h \
1141		$(srcdir)/Include/cpython/tracemalloc.h \
1142		$(srcdir)/Include/cpython/tupleobject.h \
1143		$(srcdir)/Include/cpython/unicodeobject.h \
1144		$(srcdir)/Include/cpython/warnings.h \
1145		$(srcdir)/Include/cpython/weakrefobject.h \
1146		\
1147		$(MIMALLOC_HEADERS) \
1148		\
1149		$(srcdir)/Include/internal/pycore_abstract.h \
1150		$(srcdir)/Include/internal/pycore_asdl.h \
1151		$(srcdir)/Include/internal/pycore_ast.h \
1152		$(srcdir)/Include/internal/pycore_ast_state.h \
1153		$(srcdir)/Include/internal/pycore_atexit.h \
1154		$(srcdir)/Include/internal/pycore_backoff.h \
1155		$(srcdir)/Include/internal/pycore_bitutils.h \
1156		$(srcdir)/Include/internal/pycore_blocks_output_buffer.h \
1157		$(srcdir)/Include/internal/pycore_brc.h \
1158		$(srcdir)/Include/internal/pycore_bytes_methods.h \
1159		$(srcdir)/Include/internal/pycore_bytesobject.h \
1160		$(srcdir)/Include/internal/pycore_call.h \
1161		$(srcdir)/Include/internal/pycore_capsule.h \
1162		$(srcdir)/Include/internal/pycore_cell.h \
1163		$(srcdir)/Include/internal/pycore_ceval.h \
1164		$(srcdir)/Include/internal/pycore_ceval_state.h \
1165		$(srcdir)/Include/internal/pycore_code.h \
1166		$(srcdir)/Include/internal/pycore_codecs.h \
1167		$(srcdir)/Include/internal/pycore_compile.h \
1168		$(srcdir)/Include/internal/pycore_complexobject.h \
1169		$(srcdir)/Include/internal/pycore_condvar.h \
1170		$(srcdir)/Include/internal/pycore_context.h \
1171		$(srcdir)/Include/internal/pycore_critical_section.h \
1172		$(srcdir)/Include/internal/pycore_crossinterp.h \
1173		$(srcdir)/Include/internal/pycore_descrobject.h \
1174		$(srcdir)/Include/internal/pycore_dict.h \
1175		$(srcdir)/Include/internal/pycore_dict_state.h \
1176		$(srcdir)/Include/internal/pycore_dtoa.h \
1177		$(srcdir)/Include/internal/pycore_exceptions.h \
1178		$(srcdir)/Include/internal/pycore_faulthandler.h \
1179		$(srcdir)/Include/internal/pycore_fileutils.h \
1180		$(srcdir)/Include/internal/pycore_floatobject.h \
1181		$(srcdir)/Include/internal/pycore_flowgraph.h \
1182		$(srcdir)/Include/internal/pycore_format.h \
1183		$(srcdir)/Include/internal/pycore_frame.h \
1184		$(srcdir)/Include/internal/pycore_freelist.h \
1185		$(srcdir)/Include/internal/pycore_function.h \
1186		$(srcdir)/Include/internal/pycore_gc.h \
1187		$(srcdir)/Include/internal/pycore_genobject.h \
1188		$(srcdir)/Include/internal/pycore_getopt.h \
1189		$(srcdir)/Include/internal/pycore_gil.h \
1190		$(srcdir)/Include/internal/pycore_global_objects.h \
1191		$(srcdir)/Include/internal/pycore_global_objects_fini_generated.h \
1192		$(srcdir)/Include/internal/pycore_global_strings.h \
1193		$(srcdir)/Include/internal/pycore_hamt.h \
1194		$(srcdir)/Include/internal/pycore_hashtable.h \
1195		$(srcdir)/Include/internal/pycore_identifier.h \
1196		$(srcdir)/Include/internal/pycore_import.h \
1197		$(srcdir)/Include/internal/pycore_importdl.h \
1198		$(srcdir)/Include/internal/pycore_initconfig.h \
1199		$(srcdir)/Include/internal/pycore_instruments.h \
1200		$(srcdir)/Include/internal/pycore_instruction_sequence.h \
1201		$(srcdir)/Include/internal/pycore_interp.h \
1202		$(srcdir)/Include/internal/pycore_intrinsics.h \
1203		$(srcdir)/Include/internal/pycore_jit.h \
1204		$(srcdir)/Include/internal/pycore_list.h \
1205		$(srcdir)/Include/internal/pycore_llist.h \
1206		$(srcdir)/Include/internal/pycore_lock.h \
1207		$(srcdir)/Include/internal/pycore_long.h \
1208		$(srcdir)/Include/internal/pycore_memoryobject.h \
1209		$(srcdir)/Include/internal/pycore_mimalloc.h \
1210		$(srcdir)/Include/internal/pycore_modsupport.h \
1211		$(srcdir)/Include/internal/pycore_moduleobject.h \
1212		$(srcdir)/Include/internal/pycore_namespace.h \
1213		$(srcdir)/Include/internal/pycore_object.h \
1214		$(srcdir)/Include/internal/pycore_object_alloc.h \
1215		$(srcdir)/Include/internal/pycore_object_stack.h \
1216		$(srcdir)/Include/internal/pycore_object_state.h \
1217		$(srcdir)/Include/internal/pycore_obmalloc.h \
1218		$(srcdir)/Include/internal/pycore_obmalloc_init.h \
1219		$(srcdir)/Include/internal/pycore_opcode_metadata.h \
1220		$(srcdir)/Include/internal/pycore_opcode_utils.h \
1221		$(srcdir)/Include/internal/pycore_optimizer.h \
1222		$(srcdir)/Include/internal/pycore_parking_lot.h \
1223		$(srcdir)/Include/internal/pycore_parser.h \
1224		$(srcdir)/Include/internal/pycore_pathconfig.h \
1225		$(srcdir)/Include/internal/pycore_pyarena.h \
1226		$(srcdir)/Include/internal/pycore_pyatomic_ft_wrappers.h \
1227		$(srcdir)/Include/internal/pycore_pybuffer.h \
1228		$(srcdir)/Include/internal/pycore_pyerrors.h \
1229		$(srcdir)/Include/internal/pycore_pyhash.h \
1230		$(srcdir)/Include/internal/pycore_pylifecycle.h \
1231		$(srcdir)/Include/internal/pycore_pymath.h \
1232		$(srcdir)/Include/internal/pycore_pymem.h \
1233		$(srcdir)/Include/internal/pycore_pymem_init.h \
1234		$(srcdir)/Include/internal/pycore_pystate.h \
1235		$(srcdir)/Include/internal/pycore_pystats.h \
1236		$(srcdir)/Include/internal/pycore_pythonrun.h \
1237		$(srcdir)/Include/internal/pycore_pythread.h \
1238		$(srcdir)/Include/internal/pycore_qsbr.h \
1239		$(srcdir)/Include/internal/pycore_range.h \
1240		$(srcdir)/Include/internal/pycore_runtime.h \
1241		$(srcdir)/Include/internal/pycore_runtime_init.h \
1242		$(srcdir)/Include/internal/pycore_runtime_init_generated.h \
1243		$(srcdir)/Include/internal/pycore_semaphore.h \
1244		$(srcdir)/Include/internal/pycore_setobject.h \
1245		$(srcdir)/Include/internal/pycore_signal.h \
1246		$(srcdir)/Include/internal/pycore_sliceobject.h \
1247		$(srcdir)/Include/internal/pycore_strhex.h \
1248		$(srcdir)/Include/internal/pycore_structseq.h \
1249		$(srcdir)/Include/internal/pycore_symtable.h \
1250		$(srcdir)/Include/internal/pycore_sysmodule.h \
1251		$(srcdir)/Include/internal/pycore_stackref.h \
1252		$(srcdir)/Include/internal/pycore_time.h \
1253		$(srcdir)/Include/internal/pycore_token.h \
1254		$(srcdir)/Include/internal/pycore_traceback.h \
1255		$(srcdir)/Include/internal/pycore_tracemalloc.h \
1256		$(srcdir)/Include/internal/pycore_tstate.h \
1257		$(srcdir)/Include/internal/pycore_tuple.h \
1258		$(srcdir)/Include/internal/pycore_typeobject.h \
1259		$(srcdir)/Include/internal/pycore_typevarobject.h \
1260		$(srcdir)/Include/internal/pycore_ucnhash.h \
1261		$(srcdir)/Include/internal/pycore_unicodeobject.h \
1262		$(srcdir)/Include/internal/pycore_unicodeobject_generated.h \
1263		$(srcdir)/Include/internal/pycore_unionobject.h \
1264		$(srcdir)/Include/internal/pycore_uop_ids.h \
1265		$(srcdir)/Include/internal/pycore_uop_metadata.h \
1266		$(srcdir)/Include/internal/pycore_warnings.h \
1267		$(srcdir)/Include/internal/pycore_weakref.h \
1268		$(DTRACE_HEADERS) \
1269		@PLATFORM_HEADERS@ \
1270		\
1271		$(srcdir)/Python/stdlib_module_names.h
1272
1273##########################################################################
1274# Build static libmpdec.a
1275LIBMPDEC_CFLAGS=@LIBMPDEC_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
1276
1277# "%.o: %c" is not portable
1278Modules/_decimal/libmpdec/basearith.o: $(srcdir)/Modules/_decimal/libmpdec/basearith.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1279	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/basearith.c
1280
1281Modules/_decimal/libmpdec/constants.o: $(srcdir)/Modules/_decimal/libmpdec/constants.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1282	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/constants.c
1283
1284Modules/_decimal/libmpdec/context.o: $(srcdir)/Modules/_decimal/libmpdec/context.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1285	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/context.c
1286
1287Modules/_decimal/libmpdec/convolute.o: $(srcdir)/Modules/_decimal/libmpdec/convolute.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1288	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/convolute.c
1289
1290Modules/_decimal/libmpdec/crt.o: $(srcdir)/Modules/_decimal/libmpdec/crt.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1291	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/crt.c
1292
1293Modules/_decimal/libmpdec/difradix2.o: $(srcdir)/Modules/_decimal/libmpdec/difradix2.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1294	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/difradix2.c
1295
1296Modules/_decimal/libmpdec/fnt.o: $(srcdir)/Modules/_decimal/libmpdec/fnt.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1297	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/fnt.c
1298
1299Modules/_decimal/libmpdec/fourstep.o: $(srcdir)/Modules/_decimal/libmpdec/fourstep.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1300	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/fourstep.c
1301
1302Modules/_decimal/libmpdec/io.o: $(srcdir)/Modules/_decimal/libmpdec/io.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1303	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/io.c
1304
1305Modules/_decimal/libmpdec/mpalloc.o: $(srcdir)/Modules/_decimal/libmpdec/mpalloc.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1306	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpalloc.c
1307
1308Modules/_decimal/libmpdec/mpdecimal.o: $(srcdir)/Modules/_decimal/libmpdec/mpdecimal.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1309	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpdecimal.c
1310
1311Modules/_decimal/libmpdec/mpsignal.o: $(srcdir)/Modules/_decimal/libmpdec/mpsignal.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1312	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpsignal.c
1313
1314Modules/_decimal/libmpdec/numbertheory.o: $(srcdir)/Modules/_decimal/libmpdec/numbertheory.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1315	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/numbertheory.c
1316
1317Modules/_decimal/libmpdec/sixstep.o: $(srcdir)/Modules/_decimal/libmpdec/sixstep.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1318	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/sixstep.c
1319
1320Modules/_decimal/libmpdec/transpose.o: $(srcdir)/Modules/_decimal/libmpdec/transpose.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
1321	$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/transpose.c
1322
1323$(LIBMPDEC_A): $(LIBMPDEC_OBJS)
1324	-rm -f $@
1325	$(AR) $(ARFLAGS) $@ $(LIBMPDEC_OBJS)
1326
1327##########################################################################
1328# Build static libexpat.a
1329LIBEXPAT_CFLAGS=@LIBEXPAT_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
1330
1331Modules/expat/xmlparse.o: $(srcdir)/Modules/expat/xmlparse.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
1332	$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmlparse.c
1333
1334Modules/expat/xmlrole.o: $(srcdir)/Modules/expat/xmlrole.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
1335	$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmlrole.c
1336
1337Modules/expat/xmltok.o: $(srcdir)/Modules/expat/xmltok.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
1338	$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmltok.c
1339
1340$(LIBEXPAT_A): $(LIBEXPAT_OBJS)
1341	-rm -f $@
1342	$(AR) $(ARFLAGS) $@ $(LIBEXPAT_OBJS)
1343
1344##########################################################################
1345# Build HACL* static libraries for hashlib: libHacl_Hash_SHA2.a
1346LIBHACL_CFLAGS=-I$(srcdir)/Modules/_hacl/include -D_BSD_SOURCE -D_DEFAULT_SOURCE $(PY_STDMODULE_CFLAGS) $(CCSHARED)
1347
1348Modules/_hacl/Hacl_Hash_SHA2.o: $(srcdir)/Modules/_hacl/Hacl_Hash_SHA2.c $(LIBHACL_SHA2_HEADERS)
1349	$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_SHA2.c
1350
1351$(LIBHACL_SHA2_A): $(LIBHACL_SHA2_OBJS)
1352	-rm -f $@
1353	$(AR) $(ARFLAGS) $@ $(LIBHACL_SHA2_OBJS)
1354
1355# create relative links from build/lib.platform/egg.so to Modules/egg.so
1356# pybuilddir.txt is created too late. We cannot use it in Makefile
1357# targets. ln --relative is not portable.
1358.PHONY: sharedmods
1359sharedmods: $(SHAREDMODS) pybuilddir.txt
1360	@target=`cat pybuilddir.txt`; \
1361	$(MKDIR_P) $$target; \
1362	for mod in X $(SHAREDMODS); do \
1363		if test $$mod != X; then \
1364			$(LN) -sf ../../$$mod $$target/`basename $$mod`; \
1365		fi; \
1366	done
1367
1368# dependency on BUILDPYTHON ensures that the target is run last
1369.PHONY: checksharedmods
1370checksharedmods: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON)
1371	@$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/check_extension_modules.py
1372
1373.PHONY: rundsymutil
1374rundsymutil: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON)
1375	@if [ ! -z $(DSYMUTIL) ] ; then \
1376		echo $(DSYMUTIL_PATH) $(BUILDPYTHON); \
1377		$(DSYMUTIL_PATH) $(BUILDPYTHON); \
1378		if test -f $(LDLIBRARY); then \
1379			echo $(DSYMUTIL_PATH) $(LDLIBRARY); \
1380			$(DSYMUTIL_PATH) $(LDLIBRARY); \
1381		fi; \
1382		for mod in X $(SHAREDMODS); do \
1383			if test $$mod != X; then \
1384				echo $(DSYMUTIL_PATH) $$mod; \
1385				$(DSYMUTIL_PATH) $$mod; \
1386			fi; \
1387		done \
1388	fi
1389
1390Modules/Setup.local:
1391	@# Create empty Setup.local when file was deleted by user
1392	echo "# Edit this file for local setup changes" > $@
1393
1394Modules/Setup.bootstrap: $(srcdir)/Modules/Setup.bootstrap.in config.status
1395	./config.status $@
1396
1397Modules/Setup.stdlib: $(srcdir)/Modules/Setup.stdlib.in config.status
1398	./config.status $@
1399
1400Makefile Modules/config.c: Makefile.pre \
1401				$(srcdir)/Modules/config.c.in \
1402				$(MAKESETUP) \
1403				$(srcdir)/Modules/Setup \
1404				Modules/Setup.local \
1405				Modules/Setup.bootstrap \
1406				Modules/Setup.stdlib
1407	$(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
1408				-s Modules \
1409				Modules/Setup.local \
1410				Modules/Setup.stdlib \
1411				Modules/Setup.bootstrap \
1412				$(srcdir)/Modules/Setup
1413	@mv config.c Modules
1414	@echo "The Makefile was updated, you may need to re-run make."
1415
1416.PHONY: regen-test-frozenmain
1417regen-test-frozenmain: $(BUILDPYTHON)
1418	# Regenerate Programs/test_frozenmain.h
1419	# from Programs/test_frozenmain.py
1420	# using Programs/freeze_test_frozenmain.py
1421	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Programs/freeze_test_frozenmain.py Programs/test_frozenmain.h
1422
1423.PHONY: regen-test-levenshtein
1424regen-test-levenshtein:
1425	# Regenerate Lib/test/levenshtein_examples.json
1426	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_levenshtein_examples.py $(srcdir)/Lib/test/levenshtein_examples.json
1427
1428.PHONY: regen-re
1429regen-re: $(BUILDPYTHON)
1430	# Regenerate Lib/re/_casefix.py
1431	# using Tools/build/generate_re_casefix.py
1432	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/generate_re_casefix.py $(srcdir)/Lib/re/_casefix.py
1433
1434Programs/_testembed: Programs/_testembed.o $(LINK_PYTHON_DEPS)
1435	$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
1436
1437############################################################################
1438# "Bootstrap Python" used to run Programs/_freeze_module.py
1439
1440BOOTSTRAP_HEADERS = \
1441	Python/frozen_modules/importlib._bootstrap.h \
1442	Python/frozen_modules/importlib._bootstrap_external.h \
1443	Python/frozen_modules/zipimport.h
1444
1445Programs/_bootstrap_python.o: Programs/_bootstrap_python.c $(BOOTSTRAP_HEADERS) $(PYTHON_HEADERS)
1446
1447_bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modules/getpath.o Modules/Setup.local
1448	$(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ $(LIBRARY_OBJS_OMIT_FROZEN) \
1449		Programs/_bootstrap_python.o Modules/getpath.o $(LIBS) $(MODLIBS) $(SYSLIBS)
1450
1451
1452############################################################################
1453# frozen modules (including importlib)
1454#
1455# Freezing is a multi step process. It works differently for standard builds
1456# and cross builds. Standard builds use Programs/_freeze_module and
1457# _bootstrap_python for freezing, so users can build Python
1458# without an existing Python installation. Cross builds cannot execute
1459# compiled binaries and therefore rely on an external build Python
1460# interpreter. The build interpreter must have same version and same bytecode
1461# as the host (target) binary.
1462#
1463# Standard build process:
1464# 1) compile minimal core objects for Py_Compile*() and PyMarshal_Write*().
1465# 2) build Programs/_freeze_module binary.
1466# 3) create frozen module headers for importlib and getpath.
1467# 4) build _bootstrap_python binary.
1468# 5) create remaining frozen module headers with
1469#    ``./_bootstrap_python Programs/_freeze_module.py``. The pure Python
1470#    script is used to test the cross compile code path.
1471#
1472# Cross compile process:
1473# 1) create all frozen module headers with external build Python and
1474#    Programs/_freeze_module.py script.
1475#
1476
1477# FROZEN_FILES_* are auto-generated by Tools/build/freeze_modules.py.
1478FROZEN_FILES_IN = \
1479		Lib/importlib/_bootstrap.py \
1480		Lib/importlib/_bootstrap_external.py \
1481		Lib/zipimport.py \
1482		Lib/abc.py \
1483		Lib/codecs.py \
1484		Lib/io.py \
1485		Lib/_collections_abc.py \
1486		Lib/_sitebuiltins.py \
1487		Lib/genericpath.py \
1488		Lib/ntpath.py \
1489		Lib/posixpath.py \
1490		Lib/os.py \
1491		Lib/site.py \
1492		Lib/stat.py \
1493		Lib/importlib/util.py \
1494		Lib/importlib/machinery.py \
1495		Lib/runpy.py \
1496		Lib/__hello__.py \
1497		Lib/__phello__/__init__.py \
1498		Lib/__phello__/ham/__init__.py \
1499		Lib/__phello__/ham/eggs.py \
1500		Lib/__phello__/spam.py \
1501		Tools/freeze/flag.py
1502# End FROZEN_FILES_IN
1503FROZEN_FILES_OUT = \
1504		Python/frozen_modules/importlib._bootstrap.h \
1505		Python/frozen_modules/importlib._bootstrap_external.h \
1506		Python/frozen_modules/zipimport.h \
1507		Python/frozen_modules/abc.h \
1508		Python/frozen_modules/codecs.h \
1509		Python/frozen_modules/io.h \
1510		Python/frozen_modules/_collections_abc.h \
1511		Python/frozen_modules/_sitebuiltins.h \
1512		Python/frozen_modules/genericpath.h \
1513		Python/frozen_modules/ntpath.h \
1514		Python/frozen_modules/posixpath.h \
1515		Python/frozen_modules/os.h \
1516		Python/frozen_modules/site.h \
1517		Python/frozen_modules/stat.h \
1518		Python/frozen_modules/importlib.util.h \
1519		Python/frozen_modules/importlib.machinery.h \
1520		Python/frozen_modules/runpy.h \
1521		Python/frozen_modules/__hello__.h \
1522		Python/frozen_modules/__phello__.h \
1523		Python/frozen_modules/__phello__.ham.h \
1524		Python/frozen_modules/__phello__.ham.eggs.h \
1525		Python/frozen_modules/__phello__.spam.h \
1526		Python/frozen_modules/frozen_only.h
1527# End FROZEN_FILES_OUT
1528
1529Programs/_freeze_module.o: Programs/_freeze_module.c Makefile
1530
1531Modules/getpath_noop.o: $(srcdir)/Modules/getpath_noop.c Makefile
1532
1533Programs/_freeze_module: Programs/_freeze_module.o Modules/getpath_noop.o $(LIBRARY_OBJS_OMIT_FROZEN)
1534	$(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_module.o Modules/getpath_noop.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS)
1535
1536# We manually freeze getpath.py rather than through freeze_modules
1537Python/frozen_modules/getpath.h: Modules/getpath.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1538	$(FREEZE_MODULE_BOOTSTRAP) getpath $(srcdir)/Modules/getpath.py Python/frozen_modules/getpath.h
1539
1540# BEGIN: freezing modules
1541
1542Python/frozen_modules/importlib._bootstrap.h: Lib/importlib/_bootstrap.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1543	$(FREEZE_MODULE_BOOTSTRAP) importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h
1544
1545Python/frozen_modules/importlib._bootstrap_external.h: Lib/importlib/_bootstrap_external.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1546	$(FREEZE_MODULE_BOOTSTRAP) importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
1547
1548Python/frozen_modules/zipimport.h: Lib/zipimport.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1549	$(FREEZE_MODULE_BOOTSTRAP) zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h
1550
1551Python/frozen_modules/abc.h: Lib/abc.py $(FREEZE_MODULE_DEPS)
1552	$(FREEZE_MODULE) abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h
1553
1554Python/frozen_modules/codecs.h: Lib/codecs.py $(FREEZE_MODULE_DEPS)
1555	$(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
1556
1557Python/frozen_modules/io.h: Lib/io.py $(FREEZE_MODULE_DEPS)
1558	$(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
1559
1560Python/frozen_modules/_collections_abc.h: Lib/_collections_abc.py $(FREEZE_MODULE_DEPS)
1561	$(FREEZE_MODULE) _collections_abc $(srcdir)/Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h
1562
1563Python/frozen_modules/_sitebuiltins.h: Lib/_sitebuiltins.py $(FREEZE_MODULE_DEPS)
1564	$(FREEZE_MODULE) _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h
1565
1566Python/frozen_modules/genericpath.h: Lib/genericpath.py $(FREEZE_MODULE_DEPS)
1567	$(FREEZE_MODULE) genericpath $(srcdir)/Lib/genericpath.py Python/frozen_modules/genericpath.h
1568
1569Python/frozen_modules/ntpath.h: Lib/ntpath.py $(FREEZE_MODULE_DEPS)
1570	$(FREEZE_MODULE) ntpath $(srcdir)/Lib/ntpath.py Python/frozen_modules/ntpath.h
1571
1572Python/frozen_modules/posixpath.h: Lib/posixpath.py $(FREEZE_MODULE_DEPS)
1573	$(FREEZE_MODULE) posixpath $(srcdir)/Lib/posixpath.py Python/frozen_modules/posixpath.h
1574
1575Python/frozen_modules/os.h: Lib/os.py $(FREEZE_MODULE_DEPS)
1576	$(FREEZE_MODULE) os $(srcdir)/Lib/os.py Python/frozen_modules/os.h
1577
1578Python/frozen_modules/site.h: Lib/site.py $(FREEZE_MODULE_DEPS)
1579	$(FREEZE_MODULE) site $(srcdir)/Lib/site.py Python/frozen_modules/site.h
1580
1581Python/frozen_modules/stat.h: Lib/stat.py $(FREEZE_MODULE_DEPS)
1582	$(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
1583
1584Python/frozen_modules/importlib.util.h: Lib/importlib/util.py $(FREEZE_MODULE_DEPS)
1585	$(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h
1586
1587Python/frozen_modules/importlib.machinery.h: Lib/importlib/machinery.py $(FREEZE_MODULE_DEPS)
1588	$(FREEZE_MODULE) importlib.machinery $(srcdir)/Lib/importlib/machinery.py Python/frozen_modules/importlib.machinery.h
1589
1590Python/frozen_modules/runpy.h: Lib/runpy.py $(FREEZE_MODULE_DEPS)
1591	$(FREEZE_MODULE) runpy $(srcdir)/Lib/runpy.py Python/frozen_modules/runpy.h
1592
1593Python/frozen_modules/__hello__.h: Lib/__hello__.py $(FREEZE_MODULE_DEPS)
1594	$(FREEZE_MODULE) __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h
1595
1596Python/frozen_modules/__phello__.h: Lib/__phello__/__init__.py $(FREEZE_MODULE_DEPS)
1597	$(FREEZE_MODULE) __phello__ $(srcdir)/Lib/__phello__/__init__.py Python/frozen_modules/__phello__.h
1598
1599Python/frozen_modules/__phello__.ham.h: Lib/__phello__/ham/__init__.py $(FREEZE_MODULE_DEPS)
1600	$(FREEZE_MODULE) __phello__.ham $(srcdir)/Lib/__phello__/ham/__init__.py Python/frozen_modules/__phello__.ham.h
1601
1602Python/frozen_modules/__phello__.ham.eggs.h: Lib/__phello__/ham/eggs.py $(FREEZE_MODULE_DEPS)
1603	$(FREEZE_MODULE) __phello__.ham.eggs $(srcdir)/Lib/__phello__/ham/eggs.py Python/frozen_modules/__phello__.ham.eggs.h
1604
1605Python/frozen_modules/__phello__.spam.h: Lib/__phello__/spam.py $(FREEZE_MODULE_DEPS)
1606	$(FREEZE_MODULE) __phello__.spam $(srcdir)/Lib/__phello__/spam.py Python/frozen_modules/__phello__.spam.h
1607
1608Python/frozen_modules/frozen_only.h: Tools/freeze/flag.py $(FREEZE_MODULE_DEPS)
1609	$(FREEZE_MODULE) frozen_only $(srcdir)/Tools/freeze/flag.py Python/frozen_modules/frozen_only.h
1610
1611# END: freezing modules
1612
1613Tools/build/freeze_modules.py: $(FREEZE_MODULE)
1614
1615.PHONY: regen-frozen
1616regen-frozen: Tools/build/freeze_modules.py $(FROZEN_FILES_IN)
1617	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/freeze_modules.py --frozen-modules
1618	@echo "The Makefile was updated, you may need to re-run make."
1619
1620# We keep this renamed target around for folks with muscle memory.
1621.PHONY: regen-importlib
1622regen-importlib: regen-frozen
1623
1624############################################################################
1625# Global objects
1626
1627# Dependencies which can add and/or remove _Py_ID() identifiers:
1628# - "make clinic"
1629.PHONY: regen-global-objects
1630regen-global-objects: $(srcdir)/Tools/build/generate_global_objects.py clinic
1631	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_global_objects.py
1632
1633############################################################################
1634# ABI
1635
1636.PHONY: regen-abidump
1637regen-abidump: all
1638	@$(MKDIR_P) $(srcdir)/Doc/data/
1639	abidw "libpython$(LDVERSION).so" --no-architecture --out-file $(srcdir)/Doc/data/python$(LDVERSION).abi.new
1640	@$(UPDATE_FILE) --create $(srcdir)/Doc/data/python$(LDVERSION).abi $(srcdir)/Doc/data/python$(LDVERSION).abi.new
1641
1642.PHONY: check-abidump
1643check-abidump: all
1644	abidiff $(srcdir)/Doc/data/python$(LDVERSION).abi "libpython$(LDVERSION).so" --drop-private-types --no-architecture --no-added-syms
1645
1646.PHONY: regen-limited-abi
1647regen-limited-abi: all
1648	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all $(srcdir)/Misc/stable_abi.toml
1649
1650############################################################################
1651# Regenerate Unicode Data
1652
1653.PHONY: regen-unicodedata
1654regen-unicodedata:
1655	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/unicode/makeunicodedata.py
1656
1657
1658############################################################################
1659# Regenerate all generated files
1660
1661# "clinic" is regenerated implicitly via "regen-global-objects".
1662.PHONY: regen-all
1663regen-all: regen-cases regen-typeslots \
1664	regen-token regen-ast regen-keyword regen-sre regen-frozen \
1665	regen-pegen-metaparser regen-pegen regen-test-frozenmain \
1666	regen-test-levenshtein regen-global-objects
1667	@echo
1668	@echo "Note: make regen-stdlib-module-names, make regen-limited-abi, "
1669	@echo "make regen-configure, make regen-sbom, and make regen-unicodedata should be run manually"
1670
1671############################################################################
1672# Special rules for object files
1673
1674Modules/getbuildinfo.o: $(PARSER_OBJS) \
1675		$(OBJECT_OBJS) \
1676		$(PYTHON_OBJS) \
1677		$(MODULE_OBJS) \
1678		$(MODOBJS) \
1679		$(DTRACE_OBJS) \
1680		$(srcdir)/Modules/getbuildinfo.c
1681	$(CC) -c $(PY_CORE_CFLAGS) \
1682	      -DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \
1683	      -DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \
1684	      -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \
1685	      -o $@ $(srcdir)/Modules/getbuildinfo.c
1686
1687Modules/getpath.o: $(srcdir)/Modules/getpath.c Python/frozen_modules/getpath.h Makefile $(PYTHON_HEADERS)
1688	$(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
1689		-DPREFIX='"$(prefix)"' \
1690		-DEXEC_PREFIX='"$(exec_prefix)"' \
1691		-DVERSION='"$(VERSION)"' \
1692		-DVPATH='"$(VPATH)"' \
1693		-DPLATLIBDIR='"$(PLATLIBDIR)"' \
1694		-DPYTHONFRAMEWORK='"$(PYTHONFRAMEWORK)"' \
1695		-o $@ $(srcdir)/Modules/getpath.c
1696
1697Programs/python.o: $(srcdir)/Programs/python.c
1698	$(CC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/python.c
1699
1700Programs/_testembed.o: $(srcdir)/Programs/_testembed.c Programs/test_frozenmain.h $(PYTHON_HEADERS)
1701	$(CC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/_testembed.c
1702
1703Modules/_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
1704
1705Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c $(srcdir)/Modules/posixmodule.h
1706
1707Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule.h
1708
1709Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h
1710
1711Modules/signalmodule.o: $(srcdir)/Modules/signalmodule.c $(srcdir)/Modules/posixmodule.h
1712
1713Modules/_interpretersmodule.o: $(srcdir)/Modules/_interpretersmodule.c $(srcdir)/Modules/_interpreters_common.h
1714
1715Modules/_interpqueuesmodule.o: $(srcdir)/Modules/_interpqueuesmodule.c $(srcdir)/Modules/_interpreters_common.h
1716
1717Modules/_interpchannelsmodule.o: $(srcdir)/Modules/_interpchannelsmodule.c $(srcdir)/Modules/_interpreters_common.h
1718
1719Python/crossinterp.o: $(srcdir)/Python/crossinterp.c $(srcdir)/Python/crossinterp_data_lookup.h $(srcdir)/Python/crossinterp_exceptions.h
1720
1721Python/initconfig.o: $(srcdir)/Python/initconfig.c $(srcdir)/Python/config_common.h
1722
1723Python/interpconfig.o: $(srcdir)/Python/interpconfig.c $(srcdir)/Python/config_common.h
1724
1725Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
1726	$(CC) -c $(PY_CORE_CFLAGS) \
1727		-DSOABI='"$(SOABI)"' \
1728		-o $@ $(srcdir)/Python/dynload_shlib.c
1729
1730Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
1731	$(CC) -c $(PY_CORE_CFLAGS) \
1732		-DSHLIB_EXT='"$(EXT_SUFFIX)"' \
1733		-o $@ $(srcdir)/Python/dynload_hpux.c
1734
1735Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydtrace.h
1736	$(CC) -c $(PY_CORE_CFLAGS) \
1737		-DABIFLAGS='"$(ABIFLAGS)"' \
1738		$(MULTIARCH_CPPFLAGS) \
1739		-o $@ $(srcdir)/Python/sysmodule.c
1740
1741$(IO_OBJS): $(IO_H)
1742
1743.PHONY: regen-pegen-metaparser
1744regen-pegen-metaparser:
1745	@$(MKDIR_P) $(srcdir)/Tools/peg_generator/pegen
1746	PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen -q python \
1747	$(srcdir)/Tools/peg_generator/pegen/metagrammar.gram \
1748	-o $(srcdir)/Tools/peg_generator/pegen/grammar_parser.py.new
1749	$(UPDATE_FILE) $(srcdir)/Tools/peg_generator/pegen/grammar_parser.py \
1750	$(srcdir)/Tools/peg_generator/pegen/grammar_parser.py.new
1751
1752.PHONY: regen-pegen
1753regen-pegen:
1754	@$(MKDIR_P) $(srcdir)/Parser
1755	@$(MKDIR_P) $(srcdir)/Parser/tokenizer
1756	@$(MKDIR_P) $(srcdir)/Parser/lexer
1757	PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen -q c \
1758		$(srcdir)/Grammar/python.gram \
1759		$(srcdir)/Grammar/Tokens \
1760		-o $(srcdir)/Parser/parser.c.new
1761	$(UPDATE_FILE) $(srcdir)/Parser/parser.c $(srcdir)/Parser/parser.c.new
1762
1763.PHONY: regen-ast
1764regen-ast:
1765	# Regenerate 3 files using using Parser/asdl_c.py:
1766	# - Include/internal/pycore_ast.h
1767	# - Include/internal/pycore_ast_state.h
1768	# - Python/Python-ast.c
1769	$(MKDIR_P) $(srcdir)/Include
1770	$(MKDIR_P) $(srcdir)/Python
1771	$(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
1772		$(srcdir)/Parser/Python.asdl \
1773		-H $(srcdir)/Include/internal/pycore_ast.h.new \
1774		-I $(srcdir)/Include/internal/pycore_ast_state.h.new \
1775		-C $(srcdir)/Python/Python-ast.c.new
1776
1777	$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_ast.h $(srcdir)/Include/internal/pycore_ast.h.new
1778	$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_ast_state.h $(srcdir)/Include/internal/pycore_ast_state.h.new
1779	$(UPDATE_FILE) $(srcdir)/Python/Python-ast.c $(srcdir)/Python/Python-ast.c.new
1780
1781.PHONY: regen-token
1782regen-token:
1783	# Regenerate Doc/library/token-list.inc from Grammar/Tokens
1784	# using Tools/build/generate_token.py
1785	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_token.py rst \
1786		$(srcdir)/Grammar/Tokens \
1787		$(srcdir)/Doc/library/token-list.inc
1788	# Regenerate Include/internal/pycore_token.h from Grammar/Tokens
1789	# using Tools/build/generate_token.py
1790	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_token.py h \
1791		$(srcdir)/Grammar/Tokens \
1792		$(srcdir)/Include/internal/pycore_token.h
1793	# Regenerate Parser/token.c from Grammar/Tokens
1794	# using Tools/build/generate_token.py
1795	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_token.py c \
1796		$(srcdir)/Grammar/Tokens \
1797		$(srcdir)/Parser/token.c
1798	# Regenerate Lib/token.py from Grammar/Tokens
1799	# using Tools/build/generate_token.py
1800	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_token.py py \
1801		$(srcdir)/Grammar/Tokens \
1802		$(srcdir)/Lib/token.py
1803
1804.PHONY: regen-keyword
1805regen-keyword:
1806	# Regenerate Lib/keyword.py from Grammar/python.gram and Grammar/Tokens
1807	# using Tools/peg_generator/pegen
1808	PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen.keywordgen \
1809		$(srcdir)/Grammar/python.gram \
1810		$(srcdir)/Grammar/Tokens \
1811		$(srcdir)/Lib/keyword.py.new
1812	$(UPDATE_FILE) $(srcdir)/Lib/keyword.py $(srcdir)/Lib/keyword.py.new
1813
1814.PHONY: regen-stdlib-module-names
1815regen-stdlib-module-names: all Programs/_testembed
1816	# Regenerate Python/stdlib_module_names.h
1817	# using Tools/build/generate_stdlib_module_names.py
1818	$(RUNSHARED) ./$(BUILDPYTHON) \
1819		$(srcdir)/Tools/build/generate_stdlib_module_names.py \
1820		> $(srcdir)/Python/stdlib_module_names.h.new
1821	$(UPDATE_FILE) $(srcdir)/Python/stdlib_module_names.h $(srcdir)/Python/stdlib_module_names.h.new
1822
1823.PHONY: regen-sre
1824regen-sre:
1825	# Regenerate Modules/_sre/sre_constants.h and Modules/_sre/sre_targets.h
1826	# from Lib/re/_constants.py using Tools/build/generate_sre_constants.py
1827	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_sre_constants.py \
1828		$(srcdir)/Lib/re/_constants.py \
1829		$(srcdir)/Modules/_sre/sre_constants.h \
1830		$(srcdir)/Modules/_sre/sre_targets.h
1831
1832Python/compile.o Python/symtable.o Python/ast_unparse.o Python/ast.o Python/future.o: $(srcdir)/Include/internal/pycore_ast.h $(srcdir)/Include/internal/pycore_ast.h
1833
1834Python/getplatform.o: $(srcdir)/Python/getplatform.c
1835		$(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
1836
1837Python/importdl.o: $(srcdir)/Python/importdl.c
1838		$(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
1839
1840Objects/unicodectype.o:	$(srcdir)/Objects/unicodectype.c \
1841				$(srcdir)/Objects/unicodetype_db.h
1842
1843BYTESTR_DEPS = \
1844		$(srcdir)/Objects/stringlib/count.h \
1845		$(srcdir)/Objects/stringlib/ctype.h \
1846		$(srcdir)/Objects/stringlib/fastsearch.h \
1847		$(srcdir)/Objects/stringlib/find.h \
1848		$(srcdir)/Objects/stringlib/join.h \
1849		$(srcdir)/Objects/stringlib/partition.h \
1850		$(srcdir)/Objects/stringlib/split.h \
1851		$(srcdir)/Objects/stringlib/stringdefs.h \
1852		$(srcdir)/Objects/stringlib/transmogrify.h
1853
1854UNICODE_DEPS = \
1855		$(srcdir)/Objects/stringlib/asciilib.h \
1856		$(srcdir)/Objects/stringlib/codecs.h \
1857		$(srcdir)/Objects/stringlib/count.h \
1858		$(srcdir)/Objects/stringlib/fastsearch.h \
1859		$(srcdir)/Objects/stringlib/find.h \
1860		$(srcdir)/Objects/stringlib/find_max_char.h \
1861		$(srcdir)/Objects/stringlib/localeutil.h \
1862		$(srcdir)/Objects/stringlib/partition.h \
1863		$(srcdir)/Objects/stringlib/replace.h \
1864		$(srcdir)/Objects/stringlib/split.h \
1865		$(srcdir)/Objects/stringlib/ucs1lib.h \
1866		$(srcdir)/Objects/stringlib/ucs2lib.h \
1867		$(srcdir)/Objects/stringlib/ucs4lib.h \
1868		$(srcdir)/Objects/stringlib/undef.h \
1869		$(srcdir)/Objects/stringlib/unicode_format.h
1870
1871Objects/bytes_methods.o: $(srcdir)/Objects/bytes_methods.c $(BYTESTR_DEPS)
1872Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS)
1873Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c $(BYTESTR_DEPS)
1874
1875Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS)
1876
1877Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h
1878Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
1879
1880Objects/obmalloc.o: $(srcdir)/Objects/mimalloc/alloc.c \
1881		$(srcdir)/Objects/mimalloc/alloc-aligned.c \
1882		$(srcdir)/Objects/mimalloc/alloc-posix.c \
1883		$(srcdir)/Objects/mimalloc/arena.c \
1884		$(srcdir)/Objects/mimalloc/bitmap.c \
1885		$(srcdir)/Objects/mimalloc/heap.c \
1886		$(srcdir)/Objects/mimalloc/init.c \
1887		$(srcdir)/Objects/mimalloc/options.c \
1888		$(srcdir)/Objects/mimalloc/os.c \
1889		$(srcdir)/Objects/mimalloc/page.c \
1890		$(srcdir)/Objects/mimalloc/random.c \
1891		$(srcdir)/Objects/mimalloc/segment.c \
1892		$(srcdir)/Objects/mimalloc/segment-map.c \
1893		$(srcdir)/Objects/mimalloc/stats.c \
1894		$(srcdir)/Objects/mimalloc/prim/prim.c \
1895		$(srcdir)/Objects/mimalloc/prim/osx/prim.c \
1896		$(srcdir)/Objects/mimalloc/prim/unix/prim.c \
1897		$(srcdir)/Objects/mimalloc/prim/wasi/prim.c
1898
1899Objects/mimalloc/page.o: $(srcdir)/Objects/mimalloc/page-queue.c
1900
1901
1902# Regenerate various files from Python/bytecodes.c
1903# Pass CASESFLAG=-l to insert #line directives in the output
1904
1905.PHONY: regen-cases
1906regen-cases: \
1907        regen-opcode-ids regen-opcode-targets regen-uop-ids regen-opcode-metadata-py \
1908		regen-generated-cases regen-executor-cases regen-optimizer-cases \
1909		regen-opcode-metadata regen-uop-metadata
1910
1911.PHONY: regen-opcode-ids
1912regen-opcode-ids:
1913	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/opcode_id_generator.py \
1914	    -o $(srcdir)/Include/opcode_ids.h.new $(srcdir)/Python/bytecodes.c
1915	$(UPDATE_FILE) $(srcdir)/Include/opcode_ids.h $(srcdir)/Include/opcode_ids.h.new
1916
1917.PHONY: regen-opcode-targets
1918regen-opcode-targets:
1919	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/target_generator.py \
1920	    -o $(srcdir)/Python/opcode_targets.h.new $(srcdir)/Python/bytecodes.c
1921	$(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new
1922
1923.PHONY: regen-uop-ids
1924regen-uop-ids:
1925	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/uop_id_generator.py \
1926	    -o $(srcdir)/Include/internal/pycore_uop_ids.h.new $(srcdir)/Python/bytecodes.c
1927	$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_uop_ids.h $(srcdir)/Include/internal/pycore_uop_ids.h.new
1928
1929.PHONY: regen-opcode-metadata-py
1930regen-opcode-metadata-py:
1931	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/py_metadata_generator.py \
1932	    -o $(srcdir)/Lib/_opcode_metadata.py.new $(srcdir)/Python/bytecodes.c
1933	$(UPDATE_FILE) $(srcdir)/Lib/_opcode_metadata.py $(srcdir)/Lib/_opcode_metadata.py.new
1934
1935.PHONY: regen-generated-cases
1936regen-generated-cases:
1937	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/tier1_generator.py \
1938	    -o $(srcdir)/Python/generated_cases.c.h.new $(srcdir)/Python/bytecodes.c
1939	$(UPDATE_FILE) $(srcdir)/Python/generated_cases.c.h $(srcdir)/Python/generated_cases.c.h.new
1940
1941.PHONY: regen-executor-cases
1942regen-executor-cases:
1943	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/tier2_generator.py \
1944	    -o $(srcdir)/Python/executor_cases.c.h.new $(srcdir)/Python/bytecodes.c
1945	$(UPDATE_FILE) $(srcdir)/Python/executor_cases.c.h $(srcdir)/Python/executor_cases.c.h.new
1946
1947.PHONY: regen-optimizer-cases
1948regen-optimizer-cases:
1949	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/optimizer_generator.py \
1950	    -o $(srcdir)/Python/optimizer_cases.c.h.new \
1951	    $(srcdir)/Python/optimizer_bytecodes.c \
1952	    $(srcdir)/Python/bytecodes.c
1953	$(UPDATE_FILE) $(srcdir)/Python/optimizer_cases.c.h $(srcdir)/Python/optimizer_cases.c.h.new
1954
1955.PHONY: regen-opcode-metadata
1956regen-opcode-metadata:
1957	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/opcode_metadata_generator.py \
1958	    -o $(srcdir)/Include/internal/pycore_opcode_metadata.h.new $(srcdir)/Python/bytecodes.c
1959	$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_opcode_metadata.h $(srcdir)/Include/internal/pycore_opcode_metadata.h.new
1960
1961.PHONY: regen-uop-metadata
1962regen-uop-metadata:
1963	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/cases_generator/uop_metadata_generator.py -o \
1964	    $(srcdir)/Include/internal/pycore_uop_metadata.h.new $(srcdir)/Python/bytecodes.c
1965	$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_uop_metadata.h $(srcdir)/Include/internal/pycore_uop_metadata.h.new
1966
1967Python/compile.o Python/assemble.o Python/flowgraph.o Python/instruction_sequence.o: \
1968                $(srcdir)/Include/internal/pycore_compile.h \
1969                $(srcdir)/Include/internal/pycore_flowgraph.h \
1970                $(srcdir)/Include/internal/pycore_instruction_sequence.h \
1971                $(srcdir)/Include/internal/pycore_opcode_metadata.h \
1972                $(srcdir)/Include/internal/pycore_opcode_utils.h
1973
1974Python/ceval.o: \
1975		$(srcdir)/Python/ceval_macros.h \
1976		$(srcdir)/Python/condvar.h \
1977		$(srcdir)/Python/generated_cases.c.h \
1978		$(srcdir)/Python/executor_cases.c.h \
1979		$(srcdir)/Python/opcode_targets.h
1980
1981Python/flowgraph.o: \
1982		$(srcdir)/Include/internal/pycore_opcode_metadata.h
1983
1984Python/optimizer.o: \
1985		$(srcdir)/Python/executor_cases.c.h \
1986		$(srcdir)/Include/internal/pycore_opcode_metadata.h \
1987		$(srcdir)/Include/internal/pycore_optimizer.h
1988
1989Python/optimizer_analysis.o: \
1990		$(srcdir)/Include/internal/pycore_opcode_metadata.h \
1991		$(srcdir)/Include/internal/pycore_optimizer.h \
1992		$(srcdir)/Python/optimizer_cases.c.h
1993
1994Python/frozen.o: $(FROZEN_FILES_OUT)
1995
1996# Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to
1997# follow our naming conventions. dtrace(1) uses the output filename to generate
1998# an include guard, so we can't use a pipeline to transform its output.
1999Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d
2000	$(MKDIR_P) Include
2001	$(DTRACE) $(DFLAGS) -o $@ -h -s $<
2002	: sed in-place edit with POSIX-only tools
2003	sed 's/PYTHON_/PyDTrace_/' $@ > $@.tmp
2004	mv $@.tmp $@
2005
2006Python/ceval.o: $(srcdir)/Include/pydtrace.h
2007Python/gc.o: $(srcdir)/Include/pydtrace.h
2008Python/import.o: $(srcdir)/Include/pydtrace.h
2009
2010Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
2011	$(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
2012
2013Objects/typeobject.o: Objects/typeslots.inc
2014
2015.PHONY: regen-typeslots
2016regen-typeslots:
2017	# Regenerate Objects/typeslots.inc from Include/typeslotsh
2018	# using Objects/typeslots.py
2019	$(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
2020		< $(srcdir)/Include/typeslots.h \
2021		$(srcdir)/Objects/typeslots.inc.new
2022	$(UPDATE_FILE) $(srcdir)/Objects/typeslots.inc $(srcdir)/Objects/typeslots.inc.new
2023
2024$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
2025
2026
2027######################################################################
2028
2029TESTOPTS=	$(EXTRATESTOPTS)
2030TESTPYTHON=	$(RUNSHARED) $(PYTHON_FOR_BUILD) $(TESTPYTHONOPTS)
2031TESTRUNNER=	$(TESTPYTHON) -m test
2032TESTTIMEOUT=
2033
2034# Remove "test_python_*" directories of previous failed test jobs.
2035# Pass TESTOPTS options because it can contain --tempdir option.
2036.PHONY: cleantest
2037cleantest: all
2038	$(TESTRUNNER) $(TESTOPTS) --cleanup
2039
2040# Run a basic set of regression tests.
2041# This excludes some tests that are particularly resource-intensive.
2042# Similar to buildbottest, but use --fast-ci option, instead of --slow-ci.
2043.PHONY: test
2044test: all
2045	$(TESTRUNNER) --fast-ci --timeout=$(TESTTIMEOUT) $(TESTOPTS)
2046
2047# Run the test suite for both architectures in a Universal build on OSX.
2048# Must be run on an Intel box.
2049.PHONY: testuniversal
2050testuniversal: all
2051	@if [ `arch` != 'i386' ]; then \
2052		echo "This can only be used on OSX/i386" ;\
2053		exit 1 ;\
2054	fi
2055	$(TESTRUNNER) --slow-ci --timeout=$(TESTTIMEOUT) $(TESTOPTS)
2056	$(RUNSHARED) /usr/libexec/oah/translate \
2057		./$(BUILDPYTHON) -E -m test -j 0 -u all $(TESTOPTS)
2058
2059# Run the test suite on the iOS simulator. Must be run on a macOS machine with
2060# a full Xcode install that has an iPhone SE (3rd edition) simulator available.
2061# This must be run *after* a `make install` has completed the build. The
2062# `--with-framework-name` argument *cannot* be used when configuring the build.
2063XCFOLDER:=iOSTestbed.$(MULTIARCH).$(shell date +%s)
2064XCRESULT=$(XCFOLDER)/$(MULTIARCH).xcresult
2065.PHONY: testios
2066testios:
2067	@if test "$(MACHDEP)" != "ios"; then \
2068		echo "Cannot run the iOS testbed for a non-iOS build."; \
2069		exit 1;\
2070	fi
2071	@if test "$(findstring -iphonesimulator,$(MULTIARCH))" != "-iphonesimulator"; then \
2072		echo "Cannot run the iOS testbed for non-simulator builds."; \
2073		exit 1;\
2074	fi
2075	@if test $(PYTHONFRAMEWORK) != "Python"; then \
2076		echo "Cannot run the iOS testbed with a non-default framework name."; \
2077		exit 1;\
2078	fi
2079	@if ! test -d $(PYTHONFRAMEWORKPREFIX); then \
2080		echo "Cannot find a finalized iOS Python.framework. Have you run 'make install' to finalize the framework build?"; \
2081		exit 1;\
2082	fi
2083	# Copy the testbed project into the build folder
2084	cp -r $(srcdir)/iOS/testbed $(XCFOLDER)
2085	# Copy the framework from the install location to the testbed project.
2086	cp -r $(PYTHONFRAMEWORKPREFIX)/* $(XCFOLDER)/Python.xcframework/ios-arm64_x86_64-simulator
2087
2088	# Run the test suite for the Xcode project, targeting the iOS simulator.
2089	# If the suite fails, touch a file in the test folder as a marker
2090	if ! xcodebuild test -project $(XCFOLDER)/iOSTestbed.xcodeproj -scheme "iOSTestbed" -destination "platform=iOS Simulator,name=iPhone SE (3rd Generation)" -resultBundlePath $(XCRESULT) -derivedDataPath $(XCFOLDER)/DerivedData ; then \
2091	 	touch $(XCFOLDER)/failed; \
2092	fi
2093
2094	# Regardless of success or failure, extract and print the test output
2095	xcrun xcresulttool get --path $(XCRESULT) \
2096		--id $$( \
2097			xcrun xcresulttool get --path $(XCRESULT) --format json | \
2098			$(PYTHON_FOR_BUILD) -c "import sys, json; result = json.load(sys.stdin); print(result['actions']['_values'][0]['actionResult']['logRef']['id']['_value'])" \
2099		) \
2100		--format json | \
2101		$(PYTHON_FOR_BUILD) -c "import sys, json; result = json.load(sys.stdin); print(result['subsections']['_values'][1]['subsections']['_values'][0]['emittedOutput']['_value'])"
2102
2103	@if test -e $(XCFOLDER)/failed ; then \
2104		exit 1; \
2105	fi
2106
2107# Like test, but using --slow-ci which enables all test resources and use
2108# longer timeout. Run an optional pybuildbot.identify script to include
2109# information about the build environment.
2110.PHONY: buildbottest
2111buildbottest: all
2112	-@if which pybuildbot.identify >/dev/null 2>&1; then \
2113		pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
2114	fi
2115	$(TESTRUNNER) --slow-ci --timeout=$(TESTTIMEOUT) $(TESTOPTS)
2116
2117.PHONY: pythoninfo
2118pythoninfo: all
2119		$(RUNSHARED) $(HOSTRUNNER) ./$(BUILDPYTHON) -m test.pythoninfo
2120
2121QUICKTESTOPTS=	-x test_subprocess test_io \
2122		test_multibytecodec test_urllib2_localnet test_itertools \
2123		test_multiprocessing_fork test_multiprocessing_spawn \
2124		test_multiprocessing_forkserver \
2125		test_mailbox test_socket test_poll \
2126		test_select test_zipfile test_concurrent_futures
2127
2128.PHONY: quicktest
2129quicktest: all
2130	$(TESTRUNNER) --fast-ci --timeout=$(TESTTIMEOUT) $(TESTOPTS) $(QUICKTESTOPTS)
2131
2132# SSL tests
2133.PHONY: multisslcompile
2134multisslcompile: all
2135	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/ssl/multissltests.py --steps=modules
2136
2137.PHONY: multissltest
2138multissltest: all
2139	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/ssl/multissltests.py
2140
2141# All install targets use the "all" target as synchronization point to
2142# prevent race conditions with PGO builds. PGO builds use recursive make,
2143# which can lead to two parallel `./python setup.py build` processes that
2144# step on each others toes.
2145.PHONY: install
2146install: @FRAMEWORKINSTALLFIRST@ @INSTALLTARGETS@ @FRAMEWORKINSTALLLAST@
2147	if test "x$(ENSUREPIP)" != "xno"  ; then \
2148		case $(ENSUREPIP) in \
2149			upgrade) ensurepip="--upgrade" ;; \
2150			install|*) ensurepip="" ;; \
2151		esac; \
2152		$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
2153			$$ensurepip --root=$(DESTDIR)/ ; \
2154	fi
2155
2156.PHONY: altinstall
2157altinstall: commoninstall
2158	if test "x$(ENSUREPIP)" != "xno"  ; then \
2159		case $(ENSUREPIP) in \
2160			upgrade) ensurepip="--altinstall --upgrade" ;; \
2161			install|*) ensurepip="--altinstall" ;; \
2162		esac; \
2163		$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
2164			$$ensurepip --root=$(DESTDIR)/ ; \
2165	fi
2166
2167.PHONY: commoninstall
2168commoninstall:  check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
2169		altbininstall libinstall inclinstall libainstall \
2170		sharedinstall altmaninstall @FRAMEWORKALTINSTALLLAST@
2171
2172# Install shared libraries enabled by Setup
2173DESTDIRS=	$(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
2174
2175.PHONY: sharedinstall
2176sharedinstall: all
2177		@for i in $(DESTDIRS); \
2178		do \
2179			if test ! -d $(DESTDIR)$$i; then \
2180				echo "Creating directory $$i"; \
2181				$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2182			else    true; \
2183			fi; \
2184		done
2185		@for i in X $(SHAREDMODS); do \
2186		  if test $$i != X; then \
2187		    echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
2188		    $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
2189			if test -d "$$i.dSYM"; then \
2190				echo $(DSYMUTIL_PATH) $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
2191				$(DSYMUTIL_PATH) $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
2192			fi; \
2193		  fi; \
2194		done
2195
2196# Install the interpreter with $(VERSION) affixed
2197# This goes into $(exec_prefix)
2198.PHONY: altbininstall
2199altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
2200	@for i in $(BINDIR) $(LIBDIR); \
2201	do \
2202		if test ! -d $(DESTDIR)$$i; then \
2203			echo "Creating directory $$i"; \
2204			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2205		else	true; \
2206		fi; \
2207	done
2208	if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
2209		$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
2210	else \
2211		$(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
2212	fi
2213	-if test "$(VERSION)" != "$(LDVERSION)"; then \
2214		if test -f $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE) -o -h $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
2215		then rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
2216		fi; \
2217		(cd $(DESTDIR)$(BINDIR); $(LN) python$(LDVERSION)$(EXE) python$(VERSION)$(EXE)); \
2218	fi
2219	@if test "$(PY_ENABLE_SHARED)" = 1 -o "$(STATIC_LIBPYTHON)" = 1; then \
2220		if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
2221			if test -n "$(DLLLIBRARY)" ; then \
2222				$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
2223			else \
2224				$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
2225				if test $(LDLIBRARY) != $(INSTSONAME); then \
2226					(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
2227				fi \
2228			fi; \
2229			if test -n "$(PY3LIBRARY)"; then \
2230				$(INSTALL_SHARED) $(PY3LIBRARY) $(DESTDIR)$(LIBDIR)/$(PY3LIBRARY); \
2231			fi; \
2232		else	true; \
2233		fi; \
2234	fi
2235	if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
2236		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-32$(EXE); \
2237		lipo $(LIPO_32BIT_FLAGS) \
2238			-output $(DESTDIR)$(BINDIR)/python$(VERSION)-32$(EXE) \
2239			$(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
2240	fi
2241	if test "x$(LIPO_INTEL64_FLAGS)" != "x" ; then \
2242		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-intel64$(EXE); \
2243		lipo $(LIPO_INTEL64_FLAGS) \
2244			-output $(DESTDIR)$(BINDIR)/python$(VERSION)-intel64$(EXE) \
2245			$(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
2246	fi
2247	# Install macOS debug information (if available)
2248	if test -d "$(BUILDPYTHON).dSYM"; then \
2249		echo $(DSYMUTIL_PATH) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
2250		$(DSYMUTIL_PATH) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
2251	fi
2252	if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
2253		if test -d "$(LDLIBRARY).dSYM"; then \
2254			echo $(DSYMUTIL_PATH) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
2255			$(DSYMUTIL_PATH) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
2256		fi \
2257	else \
2258		if test -d "$(LDLIBRARY).dSYM"; then \
2259			echo $(DSYMUTIL_PATH) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(INSTSONAME); \
2260      $(DSYMUTIL_PATH) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(INSTSONAME); \
2261		fi \
2262	fi
2263
2264.PHONY: bininstall
2265# We depend on commoninstall here to make sure the installation is already usable
2266# before we possibly overwrite the global 'python3' symlink to avoid causing
2267# problems for anything else trying to run 'python3' while we install, particularly
2268# if we're installing in parallel with -j.
2269bininstall: commoninstall altbininstall
2270	if test ! -d $(DESTDIR)$(LIBPC); then \
2271		echo "Creating directory $(LIBPC)"; \
2272		$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \
2273	fi
2274	-if test -f $(DESTDIR)$(BINDIR)/python3$(EXE) -o -h $(DESTDIR)$(BINDIR)/python3$(EXE); \
2275	then rm -f $(DESTDIR)$(BINDIR)/python3$(EXE); \
2276	else true; \
2277	fi
2278	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python3$(EXE))
2279	-if test "$(VERSION)" != "$(LDVERSION)"; then \
2280		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-config; \
2281		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(LDVERSION)-config python$(VERSION)-config); \
2282		rm -f $(DESTDIR)$(LIBPC)/python-$(VERSION).pc; \
2283		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(LDVERSION).pc python-$(VERSION).pc); \
2284		rm -f $(DESTDIR)$(LIBPC)/python-$(VERSION)-embed.pc; \
2285		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(LDVERSION)-embed.pc python-$(VERSION)-embed.pc); \
2286	fi
2287	-rm -f $(DESTDIR)$(BINDIR)/python3-config
2288	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
2289	-rm -f $(DESTDIR)$(LIBPC)/python3.pc
2290	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python3.pc)
2291	-rm -f $(DESTDIR)$(LIBPC)/python3-embed.pc
2292	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)-embed.pc python3-embed.pc)
2293	-rm -f $(DESTDIR)$(BINDIR)/idle3
2294	(cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3)
2295	-rm -f $(DESTDIR)$(BINDIR)/pydoc3
2296	(cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
2297	if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
2298		rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
2299		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
2300	fi
2301	if test "x$(LIPO_INTEL64_FLAGS)" != "x" ; then \
2302		rm -f $(DESTDIR)$(BINDIR)/python3-intel64$(EXE); \
2303		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-intel64$(EXE) python3-intel64$(EXE)) \
2304	fi
2305
2306# Install the versioned manual page
2307.PHONY: altmaninstall
2308altmaninstall:
2309	@for i in $(MANDIR) $(MANDIR)/man1; \
2310	do \
2311		if test ! -d $(DESTDIR)$$i; then \
2312			echo "Creating directory $$i"; \
2313			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2314		else	true; \
2315		fi; \
2316	done
2317	$(INSTALL_DATA) $(srcdir)/Misc/python.man \
2318		$(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
2319
2320# Install the unversioned manual page
2321.PHONY: maninstall
2322maninstall:	altmaninstall
2323	-rm -f $(DESTDIR)$(MANDIR)/man1/python3.1
2324	(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python3.1)
2325
2326# Install the library
2327XMLLIBSUBDIRS=  xml xml/dom xml/etree xml/parsers xml/sax
2328LIBSUBDIRS=	asyncio \
2329		collections \
2330		concurrent concurrent/futures \
2331		csv \
2332		ctypes ctypes/macholib \
2333		curses \
2334		dbm \
2335		email email/mime \
2336		encodings \
2337		ensurepip ensurepip/_bundled \
2338		html \
2339		http \
2340		idlelib idlelib/Icons \
2341		importlib importlib/resources importlib/metadata \
2342		json \
2343		logging \
2344		multiprocessing multiprocessing/dummy \
2345		pathlib \
2346		pydoc_data \
2347		re \
2348		site-packages \
2349		sqlite3 \
2350		sysconfig \
2351		tkinter \
2352		tomllib \
2353		turtledemo \
2354		unittest \
2355		urllib \
2356		venv venv/scripts venv/scripts/common venv/scripts/posix \
2357		wsgiref \
2358		$(XMLLIBSUBDIRS) \
2359		xmlrpc \
2360		zipfile zipfile/_path \
2361		zoneinfo \
2362		_pyrepl \
2363		__phello__
2364TESTSUBDIRS=	idlelib/idle_test \
2365		test \
2366		test/test_ast \
2367		test/archivetestdata \
2368		test/audiodata \
2369		test/certdata \
2370		test/certdata/capath \
2371		test/cjkencodings \
2372		test/configdata \
2373		test/crashers \
2374		test/data \
2375		test/decimaltestdata \
2376		test/dtracedata \
2377		test/encoded_modules \
2378		test/leakers \
2379		test/libregrtest \
2380		test/mathdata \
2381		test/regrtestdata \
2382		test/regrtestdata/import_from_tests \
2383		test/regrtestdata/import_from_tests/test_regrtest_b \
2384		test/subprocessdata \
2385		test/support \
2386		test/support/_hypothesis_stubs \
2387		test/support/interpreters \
2388		test/test_asyncio \
2389		test/test_capi \
2390		test/test_cext \
2391		test/test_concurrent_futures \
2392		test/test_cppext \
2393		test/test_ctypes \
2394		test/test_dataclasses \
2395		test/test_doctest \
2396		test/test_email \
2397		test/test_email/data \
2398		test/test_free_threading \
2399		test/test_future_stmt \
2400		test/test_gdb \
2401		test/test_import \
2402		test/test_import/data \
2403		test/test_import/data/circular_imports \
2404		test/test_import/data/circular_imports/subpkg \
2405		test/test_import/data/circular_imports/subpkg2 \
2406		test/test_import/data/circular_imports/subpkg2/parent \
2407		test/test_import/data/package \
2408		test/test_import/data/package2 \
2409		test/test_import/data/package3 \
2410		test/test_import/data/package4 \
2411		test/test_import/data/unwritable \
2412		test/test_importlib \
2413		test/test_importlib/builtin \
2414		test/test_importlib/extension \
2415		test/test_importlib/frozen \
2416		test/test_importlib/import_ \
2417		test/test_importlib/metadata \
2418		test/test_importlib/metadata/data \
2419		test/test_importlib/metadata/data/sources \
2420		test/test_importlib/metadata/data/sources/example \
2421		test/test_importlib/metadata/data/sources/example/example \
2422		test/test_importlib/metadata/data/sources/example2 \
2423		test/test_importlib/metadata/data/sources/example2/example2 \
2424		test/test_importlib/namespace_pkgs \
2425		test/test_importlib/namespace_pkgs/both_portions \
2426		test/test_importlib/namespace_pkgs/both_portions/foo \
2427		test/test_importlib/namespace_pkgs/module_and_namespace_package \
2428		test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test \
2429		test/test_importlib/namespace_pkgs/not_a_namespace_pkg \
2430		test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo \
2431		test/test_importlib/namespace_pkgs/portion1 \
2432		test/test_importlib/namespace_pkgs/portion1/foo \
2433		test/test_importlib/namespace_pkgs/portion2 \
2434		test/test_importlib/namespace_pkgs/portion2/foo \
2435		test/test_importlib/namespace_pkgs/project1 \
2436		test/test_importlib/namespace_pkgs/project1/parent \
2437		test/test_importlib/namespace_pkgs/project1/parent/child \
2438		test/test_importlib/namespace_pkgs/project2 \
2439		test/test_importlib/namespace_pkgs/project2/parent \
2440		test/test_importlib/namespace_pkgs/project2/parent/child \
2441		test/test_importlib/namespace_pkgs/project3 \
2442		test/test_importlib/namespace_pkgs/project3/parent \
2443		test/test_importlib/namespace_pkgs/project3/parent/child \
2444		test/test_importlib/partial \
2445		test/test_importlib/resources \
2446		test/test_importlib/source \
2447		test/test_inspect \
2448		test/test_interpreters \
2449		test/test_json \
2450		test/test_module \
2451		test/test_multiprocessing_fork \
2452		test/test_multiprocessing_forkserver \
2453		test/test_multiprocessing_spawn \
2454		test/test_pathlib \
2455		test/test_peg_generator \
2456		test/test_pydoc \
2457		test/test_pyrepl \
2458		test/test_sqlite3 \
2459		test/test_tkinter \
2460		test/test_tomllib \
2461		test/test_tomllib/data \
2462		test/test_tomllib/data/invalid \
2463		test/test_tomllib/data/invalid/array \
2464		test/test_tomllib/data/invalid/array-of-tables \
2465		test/test_tomllib/data/invalid/boolean \
2466		test/test_tomllib/data/invalid/dates-and-times \
2467		test/test_tomllib/data/invalid/dotted-keys \
2468		test/test_tomllib/data/invalid/inline-table \
2469		test/test_tomllib/data/invalid/keys-and-vals \
2470		test/test_tomllib/data/invalid/literal-str \
2471		test/test_tomllib/data/invalid/multiline-basic-str \
2472		test/test_tomllib/data/invalid/multiline-literal-str \
2473		test/test_tomllib/data/invalid/table \
2474		test/test_tomllib/data/valid \
2475		test/test_tomllib/data/valid/array \
2476		test/test_tomllib/data/valid/dates-and-times \
2477		test/test_tomllib/data/valid/multiline-basic-str \
2478		test/test_tools \
2479		test/test_tools/i18n_data \
2480		test/test_ttk \
2481		test/test_unittest \
2482		test/test_unittest/testmock \
2483		test/test_warnings \
2484		test/test_warnings/data \
2485		test/test_zipfile \
2486		test/test_zipfile/_path \
2487		test/test_zoneinfo \
2488		test/test_zoneinfo/data \
2489		test/tkinterdata \
2490		test/tokenizedata \
2491		test/tracedmodules \
2492		test/translationdata \
2493		test/translationdata/argparse \
2494		test/translationdata/getopt \
2495		test/translationdata/optparse \
2496		test/typinganndata \
2497		test/wheeldata \
2498		test/xmltestdata \
2499		test/xmltestdata/c14n-20 \
2500		test/zipimport_data
2501
2502COMPILEALL_OPTS=-j0
2503
2504TEST_MODULES=@TEST_MODULES@
2505
2506.PHONY: libinstall
2507libinstall:	all $(srcdir)/Modules/xxmodule.c
2508	@for i in $(SCRIPTDIR) $(LIBDEST); \
2509	do \
2510		if test ! -d $(DESTDIR)$$i; then \
2511			echo "Creating directory $$i"; \
2512			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2513		else	true; \
2514		fi; \
2515	done
2516	@if test "$(TEST_MODULES)" = yes; then \
2517		subdirs="$(LIBSUBDIRS) $(TESTSUBDIRS)"; \
2518	else \
2519		subdirs="$(LIBSUBDIRS)"; \
2520	fi; \
2521	for d in $$subdirs; \
2522	do \
2523		a=$(srcdir)/Lib/$$d; \
2524		if test ! -d $$a; then continue; else true; fi; \
2525		b=$(LIBDEST)/$$d; \
2526		if test ! -d $(DESTDIR)$$b; then \
2527			echo "Creating directory $$b"; \
2528			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
2529		else	true; \
2530		fi; \
2531	done
2532	@for i in $(srcdir)/Lib/*.py; \
2533	do \
2534		if test -x $$i; then \
2535			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
2536			echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
2537		else \
2538			$(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
2539			echo $(INSTALL_DATA) $$i $(LIBDEST); \
2540		fi; \
2541	done
2542	@if test "$(TEST_MODULES)" = yes; then \
2543		subdirs="$(LIBSUBDIRS) $(TESTSUBDIRS)"; \
2544	else \
2545		subdirs="$(LIBSUBDIRS)"; \
2546	fi; \
2547	for d in $$subdirs; \
2548	do \
2549		a=$(srcdir)/Lib/$$d; \
2550		if test ! -d $$a; then continue; else true; fi; \
2551		if test `ls $$a | wc -l` -lt 1; then continue; fi; \
2552		b=$(LIBDEST)/$$d; \
2553		for i in $$a/*; \
2554		do \
2555			case $$i in \
2556			*CVS) ;; \
2557			*.py[co]) ;; \
2558			*.orig) ;; \
2559			*~) ;; \
2560			*) \
2561				if test -d $$i; then continue; fi; \
2562				if test -x $$i; then \
2563				    echo $(INSTALL_SCRIPT) $$i $$b; \
2564				    $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
2565				else \
2566				    echo $(INSTALL_DATA) $$i $$b; \
2567				    $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
2568				fi;; \
2569			esac; \
2570		done; \
2571	done
2572	$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
2573		$(DESTDIR)$(LIBDEST); \
2574	$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
2575	@ # If app store compliance has been configured, apply the patch to the
2576	@ # installed library code. The patch has been previously validated against
2577	@ # the original source tree, so we can ignore any errors that are raised
2578	@ # due to files that are missing because of --disable-test-modules etc.
2579	@if [ "$(APP_STORE_COMPLIANCE_PATCH)" != "" ]; then \
2580		echo "Applying app store compliance patch"; \
2581		patch --force --reject-file "$(abs_builddir)/app-store-compliance.rej" --strip 2 --directory "$(DESTDIR)$(LIBDEST)" --input "$(abs_srcdir)/$(APP_STORE_COMPLIANCE_PATCH)" || true ; \
2582	fi
2583	@ # Build PYC files for the 3 optimization levels (0, 1, 2)
2584	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2585		$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
2586		-o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST) -f \
2587		-x 'bad_coding|badsyntax|site-packages' \
2588		$(DESTDIR)$(LIBDEST)
2589	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
2590		$(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
2591		-o 0 -o 1 -o 2 $(COMPILEALL_OPTS) -d $(LIBDEST)/site-packages -f \
2592		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
2593
2594# bpo-21536: Misc/python-config.sh is generated in the build directory
2595# from $(srcdir)Misc/python-config.sh.in.
2596python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
2597	@ # Substitution happens here, as the completely-expanded BINDIR
2598	@ # is not available in configure
2599	sed -e "s,@EXENAME@,$(EXENAME)," < $(srcdir)/Misc/python-config.in >python-config.py
2600	@ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
2601	LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config
2602	@ # On Darwin, always use the python version of the script, the shell
2603	@ # version doesn't use the compiler customizations that are provided
2604	@ # in python (_osx_support.py).
2605	@if test `uname -s` = Darwin; then \
2606		cp python-config.py python-config; \
2607	fi
2608
2609# macOS' make seems to ignore a dependency on a
2610# "$(BUILD_SCRIPTS_DIR): $(MKDIR_P) $@" rule.
2611BUILD_SCRIPTS_DIR=build/scripts-$(VERSION)
2612SCRIPT_IDLE=$(BUILD_SCRIPTS_DIR)/idle$(VERSION)
2613SCRIPT_PYDOC=$(BUILD_SCRIPTS_DIR)/pydoc$(VERSION)
2614
2615$(SCRIPT_IDLE): $(srcdir)/Tools/scripts/idle3
2616	@$(MKDIR_P) $(BUILD_SCRIPTS_DIR)
2617	sed -e "s,/usr/bin/env python3,$(EXENAME)," < $(srcdir)/Tools/scripts/idle3 > $@
2618	@chmod +x $@
2619
2620$(SCRIPT_PYDOC): $(srcdir)/Tools/scripts/pydoc3
2621	@$(MKDIR_P) $(BUILD_SCRIPTS_DIR)
2622	sed -e "s,/usr/bin/env python3,$(EXENAME)," < $(srcdir)/Tools/scripts/pydoc3 > $@
2623	@chmod +x $@
2624
2625.PHONY: scripts
2626scripts: $(SCRIPT_IDLE) $(SCRIPT_PYDOC) python-config
2627
2628# Install the include files
2629INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
2630
2631.PHONY: inclinstall
2632inclinstall:
2633	@for i in $(INCLDIRSTOMAKE); \
2634	do \
2635		if test ! -d $(DESTDIR)$$i; then \
2636			echo "Creating directory $$i"; \
2637			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2638		else	true; \
2639		fi; \
2640	done
2641	@if test ! -d $(DESTDIR)$(INCLUDEPY)/cpython; then \
2642		echo "Creating directory $(DESTDIR)$(INCLUDEPY)/cpython"; \
2643		$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/cpython; \
2644	else	true; \
2645	fi
2646	@if test ! -d $(DESTDIR)$(INCLUDEPY)/internal; then \
2647		echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal"; \
2648		$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal; \
2649	else	true; \
2650	fi
2651	@if test "$(INSTALL_MIMALLOC)" = "yes"; then \
2652		if test ! -d $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; then \
2653			echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc"; \
2654			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \
2655		fi; \
2656	fi
2657	@for i in $(srcdir)/Include/*.h; \
2658	do \
2659		echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
2660		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
2661	done
2662	@for i in $(srcdir)/Include/cpython/*.h; \
2663	do \
2664		echo $(INSTALL_DATA) $$i $(INCLUDEPY)/cpython; \
2665		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/cpython; \
2666	done
2667	@for i in $(srcdir)/Include/internal/*.h; \
2668	do \
2669		echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal; \
2670		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \
2671	done
2672	@if test "$(INSTALL_MIMALLOC)" = "yes"; then \
2673		echo $(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h; \
2674		$(INSTALL_DATA) $(srcdir)/Include/internal/mimalloc/mimalloc.h $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc.h; \
2675		for i in $(srcdir)/Include/internal/mimalloc/mimalloc/*.h; \
2676		do \
2677			echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal/mimalloc/mimalloc; \
2678			$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal/mimalloc/mimalloc; \
2679		done; \
2680	fi
2681	echo $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
2682	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
2683
2684# Install the library and miscellaneous stuff needed for extending/embedding
2685# This goes into $(exec_prefix)
2686LIBPL=		@LIBPL@
2687
2688# pkgconfig directory
2689LIBPC=		$(LIBDIR)/pkgconfig
2690
2691.PHONY: libainstall
2692libainstall: all scripts
2693	@for i in $(LIBDIR) $(LIBPL) $(LIBPC) $(BINDIR); \
2694	do \
2695		if test ! -d $(DESTDIR)$$i; then \
2696			echo "Creating directory $$i"; \
2697			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2698		else	true; \
2699		fi; \
2700	done
2701	@if test "$(STATIC_LIBPYTHON)" = 1; then \
2702		if test -d $(LIBRARY); then :; else \
2703			if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
2704				if test "$(SHLIB_SUFFIX)" = .dll; then \
2705					$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
2706				else \
2707					$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
2708				fi; \
2709			else \
2710				echo Skip install of $(LIBRARY) - use make frameworkinstall; \
2711			fi; \
2712		fi; \
2713		$(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o; \
2714	fi
2715	$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
2716	$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
2717	$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
2718	$(INSTALL_DATA) $(srcdir)/Modules/Setup $(DESTDIR)$(LIBPL)/Setup
2719	$(INSTALL_DATA) Modules/Setup.bootstrap $(DESTDIR)$(LIBPL)/Setup.bootstrap
2720	$(INSTALL_DATA) Modules/Setup.stdlib $(DESTDIR)$(LIBPL)/Setup.stdlib
2721	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
2722	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(LDVERSION).pc
2723	$(INSTALL_DATA) Misc/python-embed.pc $(DESTDIR)$(LIBPC)/python-$(LDVERSION)-embed.pc
2724	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
2725	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
2726	$(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
2727	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
2728	$(INSTALL_SCRIPT) $(SCRIPT_IDLE) $(DESTDIR)$(BINDIR)/idle$(VERSION)
2729	$(INSTALL_SCRIPT) $(SCRIPT_PYDOC) $(DESTDIR)$(BINDIR)/pydoc$(VERSION)
2730	@if [ -s Modules/python.exp -a \
2731		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
2732		echo; echo "Installing support files for building shared extension modules on AIX:"; \
2733		$(INSTALL_DATA) Modules/python.exp		\
2734				$(DESTDIR)$(LIBPL)/python.exp;		\
2735		echo; echo "$(LIBPL)/python.exp";		\
2736		$(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix	\
2737				$(DESTDIR)$(LIBPL)/makexp_aix;		\
2738		echo "$(LIBPL)/makexp_aix";			\
2739		$(INSTALL_SCRIPT) Modules/ld_so_aix	\
2740				$(DESTDIR)$(LIBPL)/ld_so_aix;		\
2741		echo "$(LIBPL)/ld_so_aix";			\
2742		echo; echo "See Misc/README.AIX for details.";	\
2743	else true; \
2744	fi
2745
2746# Here are a couple of targets for MacOSX again, to install a full
2747# framework-based Python. frameworkinstall installs everything, the
2748# subtargets install specific parts. Much of the actual work is offloaded to
2749# the Makefile in Mac
2750#
2751#
2752# This target is here for backward compatibility, previous versions of Python
2753# hadn't integrated framework installation in the normal install process.
2754.PHONY: frameworkinstall
2755frameworkinstall: install
2756
2757# On install, we re-make the framework
2758# structure in the install location, /Library/Frameworks/ or the argument to
2759# --enable-framework. If --enable-framework has been specified then we have
2760# automatically set prefix to the location deep down in the framework, so we
2761# only have to cater for the structural bits of the framework.
2762
2763.PHONY: frameworkinstallframework
2764frameworkinstallframework: @FRAMEWORKINSTALLFIRST@ install frameworkinstallmaclib
2765
2766# macOS uses a versioned frameworks structure that includes a full install
2767.PHONY: frameworkinstallversionedstructure
2768frameworkinstallversionedstructure:	$(LDLIBRARY)
2769	@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
2770		echo Not configured with --enable-framework; \
2771		exit 1; \
2772	else true; \
2773	fi
2774	@for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
2775		if test ! -d $(DESTDIR)$$i; then \
2776			echo "Creating directory $(DESTDIR)$$i"; \
2777			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
2778		else	true; \
2779		fi; \
2780	done
2781	$(LN) -fsn include/python$(LDVERSION) $(DESTDIR)$(prefix)/Headers
2782	sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
2783	$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
2784	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
2785	$(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
2786	$(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
2787	$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
2788
2789# iOS/tvOS/watchOS uses a non-versioned framework with Info.plist in the
2790# framework root, no .lproj data, and only stub compilation assistance binaries
2791.PHONY: frameworkinstallunversionedstructure
2792frameworkinstallunversionedstructure:	$(LDLIBRARY)
2793	@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
2794		echo Not configured with --enable-framework; \
2795		exit 1; \
2796	else true; \
2797	fi
2798	if test -d $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/include; then \
2799		echo "Clearing stale header symlink directory"; \
2800		rm -rf $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/include; \
2801	fi
2802	$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)
2803	sed 's/%VERSION%/'"`$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Info.plist
2804	$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
2805	$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(BINDIR)
2806	for file in $(srcdir)/$(RESSRCDIR)/bin/* ; do \
2807		$(INSTALL) -m $(EXEMODE) $$file $(DESTDIR)$(BINDIR); \
2808	done
2809
2810# This installs Mac/Lib into the framework
2811# Install a number of symlinks to keep software that expects a normal unix
2812# install (which includes python-config) happy.
2813.PHONY: frameworkinstallmaclib
2814frameworkinstallmaclib:
2815	$(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).a"
2816	$(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).dylib"
2817	$(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).a"
2818	$(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).dylib"
2819	$(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(LDVERSION).dylib"
2820	$(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
2821
2822# This installs the IDE, the Launcher and other apps into /Applications
2823.PHONY: frameworkinstallapps
2824frameworkinstallapps:
2825	cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
2826
2827# Build the bootstrap executable that will spawn the interpreter inside
2828# an app bundle within the framework.  This allows the interpreter to
2829# run OS X GUI APIs.
2830.PHONY: frameworkpythonw
2831frameworkpythonw:
2832	cd Mac && $(MAKE) pythonw
2833
2834# This installs the python* and other bin symlinks in $prefix/bin or in
2835# a bin directory relative to the framework root
2836.PHONY: frameworkinstallunixtools
2837frameworkinstallunixtools:
2838	cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
2839
2840.PHONY: frameworkaltinstallunixtools
2841frameworkaltinstallunixtools:
2842	cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
2843
2844# This installs the Tools into the applications directory.
2845# It is not part of a normal frameworkinstall
2846.PHONY: frameworkinstallextras
2847frameworkinstallextras:
2848	cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
2849
2850# On iOS, bin/lib can't live inside the framework; include needs to be called
2851# "Headers", but *must* be in the framework, and *not* include the `python3.X`
2852# subdirectory. The install has put these folders in the same folder as
2853# Python.framework; Move the headers to their final framework-compatible home.
2854.PHONY: frameworkinstallmobileheaders
2855frameworkinstallmobileheaders: frameworkinstallunversionedstructure inclinstall
2856	if test -d $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; then \
2857		echo "Removing old framework headers"; \
2858		rm -rf $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; \
2859	fi
2860	mv "$(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/include/python$(LDVERSION)" "$(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers"
2861	$(LN) -fs "../$(PYTHONFRAMEWORKDIR)/Headers" "$(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/include/python$(LDVERSION)"
2862
2863# Build the toplevel Makefile
2864Makefile.pre: $(srcdir)/Makefile.pre.in config.status
2865	CONFIG_FILES=Makefile.pre CONFIG_HEADERS= ./config.status
2866	$(MAKE) -f Makefile.pre Makefile
2867
2868# Run the configure script.
2869config.status:	$(srcdir)/configure
2870	$(srcdir)/configure $(CONFIG_ARGS)
2871
2872.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
2873
2874Python/asm_trampoline.o: $(srcdir)/Python/asm_trampoline.S
2875	$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
2876
2877
2878JIT_DEPS = \
2879		$(srcdir)/Tools/jit/*.c \
2880		$(srcdir)/Tools/jit/*.py \
2881		$(srcdir)/Python/executor_cases.c.h \
2882		pyconfig.h
2883
2884jit_stencils.h: $(JIT_DEPS)
2885	@REGEN_JIT_COMMAND@
2886
2887Python/jit.o: $(srcdir)/Python/jit.c @JIT_STENCILS_H@
2888	$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
2889
2890.PHONY: regen-jit
2891regen-jit:
2892	@REGEN_JIT_COMMAND@
2893
2894# Some make's put the object file in the current directory
2895.c.o:
2896	$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
2897
2898# bpo-30104: dtoa.c uses union to cast double to unsigned long[2]. clang 4.0
2899# with -O2 or higher and strict aliasing miscompiles the ratio() function
2900# causing rounding issues. Compile dtoa.c using -fno-strict-aliasing on clang.
2901# https://bugs.llvm.org//show_bug.cgi?id=31928
2902Python/dtoa.o: Python/dtoa.c
2903	$(CC) -c $(PY_CORE_CFLAGS) $(CFLAGS_ALIASING) -o $@ $<
2904
2905# Run reindent on the library
2906.PHONY: reindent
2907reindent:
2908	./$(BUILDPYTHON) $(srcdir)/Tools/patchcheck/reindent.py -r $(srcdir)/Lib
2909
2910# Rerun configure with the same options as it was run last time,
2911# provided the config.status script exists
2912.PHONY: recheck
2913recheck:
2914	./config.status --recheck
2915	./config.status
2916
2917# Regenerate configure and pyconfig.h.in
2918.PHONY: autoconf
2919autoconf:
2920	(cd $(srcdir); autoreconf -ivf -Werror)
2921
2922.PHONY: regen-configure
2923regen-configure:
2924	$(srcdir)/Tools/build/regen-configure.sh
2925
2926.PHONY: regen-sbom
2927regen-sbom:
2928	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_sbom.py
2929
2930# Create a tags file for vi
2931tags::
2932	ctags -w $(srcdir)/Include/*.h $(srcdir)/Include/cpython/*.h $(srcdir)/Include/internal/*.h
2933	for i in $(SRCDIRS); do ctags -f tags -w -a $(srcdir)/$$i/*.[ch]; done
2934	ctags -f tags -w -a $(srcdir)/Modules/_ctypes/*.[ch]
2935	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 -
2936	LC_ALL=C sort -o tags tags
2937
2938# Create a tags file for GNU Emacs
2939TAGS::
2940	cd $(srcdir); \
2941	etags Include/*.h Include/cpython/*.h Include/internal/*.h; \
2942	for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
2943	etags -a $(srcdir)/Modules/_ctypes/*.[ch]
2944	find $(srcdir)/Lib -type f -name "*.py" -not -name "test_*.py" -not -path "*/test/*" -not -path "*/tests/*" -not -path "*/*_test/*" | etags - -a
2945
2946# Sanitation targets -- clean leaves libraries, executables and tags
2947# files, which clobber removes as well
2948.PHONY: pycremoval
2949pycremoval:
2950	-find $(srcdir) -depth -name '__pycache__' -exec rm -rf {} ';'
2951	-find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
2952
2953.PHONY: rmtestturds
2954rmtestturds:
2955	-rm -f *BAD *GOOD *SKIPPED
2956	-rm -rf OUT
2957	-rm -f *.TXT
2958	-rm -f *.txt
2959	-rm -f gb-18030-2000.xml
2960
2961.PHONY: docclean
2962docclean:
2963	$(MAKE) -C $(srcdir)/Doc clean
2964
2965# like the 'clean' target but retain the profile guided optimization (PGO)
2966# data.  The PGO data is only valid if source code remains unchanged.
2967.PHONY: clean-retain-profile
2968clean-retain-profile: pycremoval
2969	find . -name '*.[oa]' -exec rm -f {} ';'
2970	find . -name '*.s[ol]' -exec rm -f {} ';'
2971	find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
2972	find . -name '*.lto' -exec rm -f {} ';'
2973	find . -name '*.wasm' -exec rm -f {} ';'
2974	find . -name '*.lst' -exec rm -f {} ';'
2975	find build -name 'fficonfig.h' -exec rm -f {} ';' || true
2976	find build -name '*.py' -exec rm -f {} ';' || true
2977	find build -name '*.py[co]' -exec rm -f {} ';' || true
2978	-rm -f pybuilddir.txt
2979	-rm -f _bootstrap_python
2980	-rm -f python.html python*.js python.data python*.symbols python*.map
2981	-rm -f $(WASM_STDLIB)
2982	-rm -f Programs/_testembed Programs/_freeze_module
2983	-rm -rf Python/deepfreeze
2984	-rm -f Python/frozen_modules/*.h
2985	-rm -f Python/frozen_modules/MANIFEST
2986	-rm -f jit_stencils.h
2987	-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
2988	-rm -f Include/pydtrace_probes.h
2989	-rm -f profile-gen-stamp
2990	-rm -rf iOS/testbed/Python.xcframework/ios-*/bin
2991	-rm -rf iOS/testbed/Python.xcframework/ios-*/lib
2992	-rm -rf iOS/testbed/Python.xcframework/ios-*/include
2993	-rm -rf iOS/testbed/Python.xcframework/ios-*/Python.framework
2994
2995.PHONY: profile-removal
2996profile-removal:
2997	find . -name '*.gc??' -exec rm -f {} ';'
2998	find . -name '*.profclang?' -exec rm -f {} ';'
2999	find . -name '*.dyn' -exec rm -f {} ';'
3000	rm -f $(COVERAGE_INFO)
3001	rm -rf $(COVERAGE_REPORT)
3002	rm -f profile-run-stamp
3003	rm -f profile-bolt-stamp
3004
3005.PHONY: clean
3006clean: clean-retain-profile clean-bolt
3007	@if test @DEF_MAKE_ALL_RULE@ = profile-opt -o @DEF_MAKE_ALL_RULE@ = bolt-opt; then \
3008		rm -f profile-gen-stamp profile-clean-stamp; \
3009		$(MAKE) profile-removal; \
3010	fi
3011
3012.PHONY: clobber
3013clobber: clean
3014	-rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
3015		tags TAGS \
3016		config.cache config.log pyconfig.h Modules/config.c
3017	-rm -rf build platform
3018	-rm -rf $(PYTHONFRAMEWORKDIR)
3019	-rm -rf iOS/Frameworks
3020	-rm -rf iOSTestbed.*
3021	-rm -f python-config.py python-config
3022	-rm -rf cross-build
3023
3024# Make things extra clean, before making a distribution:
3025# remove all generated files, even Makefile[.pre]
3026# Keep configure and Python-ast.[ch], it's possible they can't be generated
3027.PHONY: distclean
3028distclean: clobber docclean
3029	for file in $(srcdir)/Lib/test/data/* ; do \
3030	    if test "$$file" != "$(srcdir)/Lib/test/data/README"; then rm "$$file"; fi; \
3031	done
3032	-rm -f core Makefile Makefile.pre config.status Modules/Setup.local \
3033	    Modules/Setup.bootstrap Modules/Setup.stdlib \
3034		Modules/ld_so_aix Modules/python.exp Misc/python.pc \
3035		Misc/python-embed.pc Misc/python-config.sh
3036	-rm -f python*-gdb.py
3037	# Issue #28258: set LC_ALL to avoid issues with Estonian locale.
3038	# Expansion is performed here by shell (spawned by make) itself before
3039	# arguments are passed to find. So LC_ALL=C must be set as a separate
3040	# command.
3041	LC_ALL=C; find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \
3042				     -o -name '[@,#]*' -o -name '*.old' \
3043				     -o -name '*.orig' -o -name '*.rej' \
3044				     -o -name '*.bak' ')' \
3045				     -exec rm -f {} ';'
3046
3047# Check that all symbols exported by libpython start with "Py" or "_Py"
3048.PHONY: smelly
3049smelly: all
3050	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/smelly.py
3051
3052# Check if any unsupported C global variables have been added.
3053.PHONY: check-c-globals
3054check-c-globals:
3055	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/c-analyzer/check-c-globals.py \
3056		--format summary \
3057		--traceback
3058
3059# Find files with funny names
3060.PHONY: funny
3061funny:
3062	find $(SUBDIRS) $(SUBDIRSTOO) \
3063		-type d \
3064		-o -name '*.[chs]' \
3065		-o -name '*.py' \
3066		-o -name '*.pyw' \
3067		-o -name '*.dat' \
3068		-o -name '*.el' \
3069		-o -name '*.fd' \
3070		-o -name '*.in' \
3071		-o -name '*.gif' \
3072		-o -name '*.txt' \
3073		-o -name '*.xml' \
3074		-o -name '*.xbm' \
3075		-o -name '*.xpm' \
3076		-o -name '*.uue' \
3077		-o -name '*.decTest' \
3078		-o -name '*.tmCommand' \
3079		-o -name '*.tmSnippet' \
3080		-o -name 'Setup' \
3081		-o -name 'Setup.*' \
3082		-o -name README \
3083		-o -name NEWS \
3084		-o -name HISTORY \
3085		-o -name Makefile \
3086		-o -name ChangeLog \
3087		-o -name .hgignore \
3088		-o -name MANIFEST \
3089		-o -print
3090
3091# Perform some verification checks on any modified files.
3092.PHONY: patchcheck
3093patchcheck: all
3094	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/patchcheck/patchcheck.py
3095
3096.PHONY: check-limited-abi
3097check-limited-abi: all
3098	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --all $(srcdir)/Misc/stable_abi.toml
3099
3100.PHONY: update-config
3101update-config:
3102	curl -sL -o config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
3103	curl -sL -o config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
3104	chmod +x config.guess config.sub
3105
3106# Dependencies
3107
3108Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
3109
3110##########################################################################
3111# Module dependencies and platform-specific files
3112
3113# force rebuild when header file or module build flavor (static/shared) is changed
3114MODULE_DEPS_STATIC=Modules/config.c
3115MODULE_DEPS_SHARED=@MODULE_DEPS_SHARED@
3116
3117MODULE__CURSES_DEPS=$(srcdir)/Include/py_curses.h
3118MODULE__CURSES_PANEL_DEPS=$(srcdir)/Include/py_curses.h
3119MODULE__DATETIME_DEPS=$(srcdir)/Include/datetime.h
3120MODULE_CMATH_DEPS=$(srcdir)/Modules/_math.h
3121MODULE_MATH_DEPS=$(srcdir)/Modules/_math.h
3122MODULE_PYEXPAT_DEPS=@LIBEXPAT_INTERNAL@
3123MODULE_UNICODEDATA_DEPS=$(srcdir)/Modules/unicodedata_db.h $(srcdir)/Modules/unicodename_db.h
3124MODULE__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
3125MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h
3126MODULE__CTYPES_MALLOC_CLOSURE=@MODULE__CTYPES_MALLOC_CLOSURE@
3127MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
3128MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
3129MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
3130MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
3131MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HEADERS) Modules/_hacl/Hacl_Hash_MD5.h Modules/_hacl/Hacl_Hash_MD5.c
3132MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HEADERS) Modules/_hacl/Hacl_Hash_SHA1.h Modules/_hacl/Hacl_Hash_SHA1.c
3133MODULE__SHA2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_A)
3134MODULE__SHA3_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HEADERS) Modules/_hacl/Hacl_Hash_SHA3.h Modules/_hacl/Hacl_Hash_SHA3.c
3135MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c
3136MODULE__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_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h
3137MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/_testcapi/parts.h $(srcdir)/Modules/_testcapi/util.h
3138MODULE__TESTLIMITEDCAPI_DEPS=$(srcdir)/Modules/_testlimitedcapi/testcapi_long.h $(srcdir)/Modules/_testlimitedcapi/parts.h $(srcdir)/Modules/_testlimitedcapi/util.h
3139MODULE__TESTINTERNALCAPI_DEPS=$(srcdir)/Modules/_testinternalcapi/parts.h
3140MODULE__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
3141
3142CODECS_COMMON_HEADERS=$(srcdir)/Modules/cjkcodecs/multibytecodec.h $(srcdir)/Modules/cjkcodecs/cjkcodecs.h
3143MODULE__CODECS_CN_DEPS=$(srcdir)/Modules/cjkcodecs/mappings_cn.h $(CODECS_COMMON_HEADERS)
3144MODULE__CODECS_HK_DEPS=$(srcdir)/Modules/cjkcodecs/mappings_hk.h  $(CODECS_COMMON_HEADERS)
3145MODULE__CODECS_ISO2022_DEPS=$(srcdir)/Modules/cjkcodecs/mappings_jisx0213_pair.h $(srcdir)/Modules/cjkcodecs/alg_jisx0201.h $(srcdir)/Modules/cjkcodecs/emu_jisx0213_2000.h $(CODECS_COMMON_HEADERS)
3146MODULE__CODECS_JP_DEPS=$(srcdir)/Modules/cjkcodecs/mappings_jisx0213_pair.h $(srcdir)/Modules/cjkcodecs/alg_jisx0201.h $(srcdir)/Modules/cjkcodecs/emu_jisx0213_2000.h $(srcdir)/Modules/cjkcodecs/mappings_jp.h $(CODECS_COMMON_HEADERS)
3147MODULE__CODECS_KR_DEPS=$(srcdir)/Modules/cjkcodecs/mappings_kr.h $(CODECS_COMMON_HEADERS)
3148MODULE__CODECS_TW_DEPS=$(srcdir)/Modules/cjkcodecs/mappings_tw.h $(CODECS_COMMON_HEADERS)
3149MODULE__MULTIBYTECODEC_DEPS=$(srcdir)/Modules/cjkcodecs/multibytecodec.h
3150
3151# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
3152# Local Variables:
3153# mode: makefile
3154# End:
3155