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