• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Top-level Makefile for Python
2#
3# As distributed, this file is called Makefile.pre.in; it is processed
4# into the real Makefile by running the script ./configure, which
5# replaces things like @spam@ with values appropriate for your system.
6# This means that if you edit Makefile, your changes get lost the next
7# time you run the configure script.  Ideally, you can do:
8#
9#	./configure
10#	make
11#	make test
12#	make install
13#
14# If you have a previous version of Python installed that you don't
15# want to overwrite, you can use "make altinstall" instead of "make
16# install".  Refer to the "Installing" section in the README file for
17# additional details.
18#
19# See also the section "Build instructions" in the README file.
20
21# === Variables set by makesetup ===
22
23MODOBJS=        _MODOBJS_
24MODLIBS=        _MODLIBS_
25
26# === Variables set by configure
27VERSION=	@VERSION@
28srcdir=		@srcdir@
29VPATH=		@srcdir@
30abs_srcdir=	@abs_srcdir@
31abs_builddir=	@abs_builddir@
32build=		@build@
33host=		@host@
34
35CC=		@CC@
36CXX=		@CXX@
37MAINCC=		@MAINCC@
38LINKCC=		@LINKCC@
39AR=		@AR@
40RANLIB=		@RANLIB@
41GITVERSION=	@GITVERSION@
42GITTAG=		@GITTAG@
43GITBRANCH=	@GITBRANCH@
44PGO_PROF_GEN_FLAG=@PGO_PROF_GEN_FLAG@
45PGO_PROF_USE_FLAG=@PGO_PROF_USE_FLAG@
46LLVM_PROF_MERGER=@LLVM_PROF_MERGER@
47LLVM_PROF_FILE=@LLVM_PROF_FILE@
48LLVM_PROF_ERR=@LLVM_PROF_ERR@
49
50GNULD=          @GNULD@
51
52# Shell used by make (some versions default to the login shell, which is bad)
53SHELL=		/bin/sh
54
55# Use this to make a link between python$(VERSION) and python in $(BINDIR)
56LN=		@LN@
57
58# Portable install script (configure doesn't always guess right)
59INSTALL=	@INSTALL@
60INSTALL_PROGRAM=@INSTALL_PROGRAM@
61INSTALL_SCRIPT= @INSTALL_SCRIPT@
62INSTALL_DATA=	@INSTALL_DATA@
63# Shared libraries must be installed with executable mode on some systems;
64# rather than figuring out exactly which, we always give them executable mode.
65# Also, making them read-only seems to be a good idea...
66INSTALL_SHARED= ${INSTALL} -m 555
67
68MKDIR_P=	@MKDIR_P@
69
70MAKESETUP=      $(srcdir)/Modules/makesetup
71
72# Compiler options
73OPT=		@OPT@
74BASECFLAGS=	@BASECFLAGS@
75CFLAGS=		$(BASECFLAGS) @CFLAGS@ $(OPT) $(EXTRA_CFLAGS)
76# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
77# be able to build extension modules using the directories specified in the
78# environment variables
79CPPFLAGS=	-I. -IInclude -I$(srcdir)/Include @CPPFLAGS@
80LDFLAGS=	@LDFLAGS@
81LDLAST=		@LDLAST@
82SGI_ABI=	@SGI_ABI@
83CCSHARED=	@CCSHARED@
84LINKFORSHARED=	@LINKFORSHARED@
85ARFLAGS=	@ARFLAGS@
86# Extra C flags added for building the interpreter object files.
87CFLAGSFORSHARED=@CFLAGSFORSHARED@
88# C flags used for building the interpreter object files
89PY_CFLAGS=	$(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
90
91
92# Machine-dependent subdirectories
93MACHDEP=	@MACHDEP@
94
95# Multiarch directory (may be empty)
96MULTIARCH=	@MULTIARCH@
97
98# Install prefix for architecture-independent files
99prefix=		@prefix@
100
101# Install prefix for architecture-dependent files
102exec_prefix=	@exec_prefix@
103
104# Install prefix for data files
105datarootdir=    @datarootdir@
106
107# Expanded directories
108BINDIR=		@bindir@
109LIBDIR=		@libdir@
110MANDIR=		@mandir@
111INCLUDEDIR=	@includedir@
112CONFINCLUDEDIR=	$(exec_prefix)/include
113SCRIPTDIR=	$(prefix)/lib
114
115# Detailed destination directories
116BINLIBDEST=	$(LIBDIR)/python$(VERSION)
117LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
118INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)
119CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)
120LIBP=		$(LIBDIR)/python$(VERSION)
121
122# Symbols used for using shared libraries
123SO=		@SO@
124LDSHARED=	@LDSHARED@ $(LDFLAGS)
125BLDSHARED=	@BLDSHARED@ $(LDFLAGS)
126LDCXXSHARED=	@LDCXXSHARED@
127DESTSHARED=	$(BINLIBDEST)/lib-dynload
128
129# Executable suffix (.exe on Windows and Mac OS X)
130EXE=		@EXEEXT@
131BUILDEXE=	@BUILDEXEEXT@
132
133# Short name and location for Mac OS X Python framework
134UNIVERSALSDK=@UNIVERSALSDK@
135PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
136PYTHONFRAMEWORKDIR=	@PYTHONFRAMEWORKDIR@
137PYTHONFRAMEWORKPREFIX=	@PYTHONFRAMEWORKPREFIX@
138PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
139# Deployment target selected during configure, to be checked
140# by distutils. The export statement is needed to ensure that the
141# deployment target is active during build.
142MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
143@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
144
145# Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
146OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@
147
148# Environment to run shared python without installed libraries
149RUNSHARED=       @RUNSHARED@
150
151# ensurepip options
152ENSUREPIP=      @ENSUREPIP@
153
154# Modes for directories, executables and data files created by the
155# install process.  Default to user-only-writable for all file types.
156DIRMODE=	755
157EXEMODE=	755
158FILEMODE=	644
159
160# configure script arguments
161CONFIG_ARGS=	@CONFIG_ARGS@
162
163
164# Subdirectories with code
165SRCDIRS= 	@SRCDIRS@
166
167# Other subdirectories
168SUBDIRSTOO=	Include Lib Misc Demo
169
170# Files and directories to be distributed
171CONFIGFILES=	configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
172DISTFILES=	README ChangeLog $(CONFIGFILES)
173DISTDIRS=	$(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
174DIST=		$(DISTFILES) $(DISTDIRS)
175
176
177LIBRARY=	@LIBRARY@
178LDLIBRARY=      @LDLIBRARY@
179BLDLIBRARY=     @BLDLIBRARY@
180DLLLIBRARY=	@DLLLIBRARY@
181LDLIBRARYDIR=   @LDLIBRARYDIR@
182INSTSONAME=	@INSTSONAME@
183
184
185LIBS=		@LIBS@
186LIBM=		@LIBM@
187LIBC=		@LIBC@
188SYSLIBS=	$(LIBM) $(LIBC)
189SHLIBS=		@SHLIBS@
190
191THREADOBJ=	@THREADOBJ@
192DLINCLDIR=	@DLINCLDIR@
193DYNLOADFILE=	@DYNLOADFILE@
194MACHDEP_OBJS=	@MACHDEP_OBJS@
195LIBOBJDIR=	Python/
196LIBOBJS=	@LIBOBJS@
197UNICODE_OBJS=   @UNICODE_OBJS@
198
199PYTHON=		python$(EXE)
200BUILDPYTHON=	python$(BUILDEXE)
201
202PYTHON_FOR_REGEN=@PYTHON_FOR_REGEN@
203PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
204_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
205HOST_GNU_TYPE=  @host@
206
207# Tcl and Tk config info from --with-tcltk-includes and -libs options
208TCLTK_INCLUDES=	@TCLTK_INCLUDES@
209TCLTK_LIBS=	@TCLTK_LIBS@
210
211# The task to run while instrument when building the profile-opt target
212# We exclude unittests with -x that take a rediculious amount of time to
213# run in the instrumented training build or do not provide much value.
214PROFILE_TASK=-m test.regrtest --pgo -x test_asyncore test_gdb test_multiprocessing test_subprocess
215
216# report files for gcov / lcov coverage report
217COVERAGE_INFO=	$(abs_builddir)/coverage.info
218COVERAGE_REPORT=$(abs_builddir)/lcov-report
219COVERAGE_REPORT_OPTIONS=--no-branch-coverage --title "CPython lcov report"
220
221# === Definitions added by makesetup ===
222
223
224##########################################################################
225# Modules
226MODULE_OBJS=	\
227		Modules/config.o \
228		Modules/getpath.o \
229		Modules/main.o \
230		Modules/gcmodule.o
231
232# Used of signalmodule.o is not available
233SIGNAL_OBJS=	@SIGNAL_OBJS@
234
235
236##########################################################################
237
238LIBFFI_INCLUDEDIR=	@LIBFFI_INCLUDEDIR@
239
240##########################################################################
241# Parser
242PGEN=		Parser/pgen$(EXE)
243
244PSRCS=		\
245		Parser/acceler.c \
246		Parser/grammar1.c \
247		Parser/listnode.c \
248		Parser/node.c \
249		Parser/parser.c \
250		Parser/parsetok.c \
251		Parser/bitset.c \
252		Parser/metagrammar.c \
253		Parser/firstsets.c \
254		Parser/grammar.c \
255		Parser/pgen.c
256
257POBJS=		\
258		Parser/acceler.o \
259		Parser/grammar1.o \
260		Parser/listnode.o \
261		Parser/node.o \
262		Parser/parser.o \
263		Parser/parsetok.o \
264		Parser/bitset.o \
265		Parser/metagrammar.o \
266		Parser/firstsets.o \
267		Parser/grammar.o \
268		Parser/pgen.o
269
270PARSER_OBJS=	$(POBJS) Parser/myreadline.o Parser/tokenizer.o
271
272PGSRCS=		\
273		Objects/obmalloc.c \
274		Python/mysnprintf.c \
275		Python/pyctype.c \
276		Parser/tokenizer_pgen.c \
277		Parser/printgrammar.c \
278		Parser/pgenmain.c
279
280PGOBJS=		\
281		Objects/obmalloc.o \
282		Python/mysnprintf.o \
283		Python/pyctype.o \
284		Parser/tokenizer_pgen.o \
285		Parser/printgrammar.o \
286		Parser/pgenmain.o
287
288PARSER_HEADERS= \
289		Parser/parser.h \
290		Parser/tokenizer.h
291
292PGENSRCS=	$(PSRCS) $(PGSRCS)
293PGENOBJS=	$(POBJS) $(PGOBJS)
294
295##########################################################################
296PYTHON_OBJS=	\
297		Python/_warnings.o \
298		Python/Python-ast.o \
299		Python/asdl.o \
300		Python/ast.o \
301		Python/bltinmodule.o \
302		Python/ceval.o \
303		Python/compile.o \
304		Python/codecs.o \
305		Python/errors.o \
306		Python/frozen.o \
307		Python/frozenmain.o \
308		Python/future.o \
309		Python/getargs.o \
310		Python/getcompiler.o \
311		Python/getcopyright.o \
312		Python/getplatform.o \
313		Python/getversion.o \
314		Python/graminit.o \
315		Python/import.o \
316		Python/importdl.o \
317		Python/marshal.o \
318		Python/modsupport.o \
319		Python/mystrtoul.o \
320		Python/mysnprintf.o \
321		Python/peephole.o \
322		Python/pyarena.o \
323		Python/pyctype.o \
324		Python/pyfpe.o \
325		Python/pymath.o \
326		Python/pystate.o \
327		Python/pythonrun.o \
328                Python/random.o \
329		Python/structmember.o \
330		Python/symtable.o \
331		Python/sysmodule.o \
332		Python/traceback.o \
333		Python/getopt.o \
334		Python/pystrcmp.o \
335		Python/pystrtod.o \
336		Python/dtoa.o \
337		Python/formatter_unicode.o \
338		Python/formatter_string.o \
339		Python/$(DYNLOADFILE) \
340		$(LIBOBJS) \
341		$(MACHDEP_OBJS) \
342		$(THREADOBJ)
343
344
345##########################################################################
346# Objects
347OBJECT_OBJS=	\
348		Objects/abstract.o \
349		Objects/boolobject.o \
350		Objects/bufferobject.o \
351		Objects/bytes_methods.o \
352		Objects/bytearrayobject.o \
353		Objects/capsule.o \
354		Objects/cellobject.o \
355		Objects/classobject.o \
356		Objects/cobject.o \
357		Objects/codeobject.o \
358		Objects/complexobject.o \
359		Objects/descrobject.o \
360		Objects/enumobject.o \
361		Objects/exceptions.o \
362		Objects/genobject.o \
363		Objects/fileobject.o \
364		Objects/floatobject.o \
365		Objects/frameobject.o \
366		Objects/funcobject.o \
367		Objects/intobject.o \
368		Objects/iterobject.o \
369		Objects/listobject.o \
370		Objects/longobject.o \
371		Objects/dictobject.o \
372		Objects/memoryobject.o \
373		Objects/methodobject.o \
374		Objects/moduleobject.o \
375		Objects/object.o \
376		Objects/obmalloc.o \
377		Objects/rangeobject.o \
378		Objects/setobject.o \
379		Objects/sliceobject.o \
380		Objects/stringobject.o \
381		Objects/structseq.o \
382		Objects/tupleobject.o \
383		Objects/typeobject.o \
384		Objects/weakrefobject.o \
385		$(UNICODE_OBJS)
386
387
388##########################################################################
389# objects that get linked into the Python library
390LIBRARY_OBJS=	\
391		Modules/getbuildinfo.o \
392		$(PARSER_OBJS) \
393		$(OBJECT_OBJS) \
394		$(PYTHON_OBJS) \
395		$(MODULE_OBJS) \
396		$(SIGNAL_OBJS) \
397		$(MODOBJS)
398
399#########################################################################
400# Rules
401
402# Default target
403all:		@DEF_MAKE_ALL_RULE@
404build_all:	check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
405
406# Check that the source is clean when building out of source.
407check-clean-src:
408	@if test -n "$(VPATH)" -a -f "$(srcdir)/Modules/python.o"; then \
409		echo "Error: The source directory ($(srcdir)) is not clean" ; \
410		echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \
411		echo "Try to run: make -C \"$(srcdir)\" clean" ; \
412		exit 1; \
413	fi
414
415# Compile a binary with profile guided optimization.
416profile-opt:
417	@if [ $(LLVM_PROF_ERR) = yes ]; then \
418		echo "Error: Cannot perform PGO build because llvm-profdata was not found in PATH" ;\
419		echo "Please add it to PATH and run ./configure again" ;\
420		exit 1;\
421	fi
422	@echo "Building with support for profile generation:"
423	$(MAKE) clean
424	$(MAKE) profile-removal
425	$(MAKE) build_all_generate_profile
426	$(MAKE) profile-removal
427	@echo "Running code to generate profile data (this can take a while):"
428	$(MAKE) run_profile_task
429	$(MAKE) build_all_merge_profile
430	@echo "Rebuilding with profile guided optimizations:"
431	$(MAKE) clean
432	$(MAKE) build_all_use_profile
433	$(MAKE) profile-removal
434
435build_all_generate_profile:
436	$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG) @LTOFLAGS@" LIBS="$(LIBS)"
437
438run_profile_task:
439	: # FIXME: can't run for a cross build
440	$(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true
441
442build_all_merge_profile:
443	$(LLVM_PROF_MERGER)
444
445build_all_use_profile:
446	$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) $(PGO_PROF_USE_FLAG) @LTOFLAGS@" LDFLAGS="$(LDFLAGS) @LTOFLAGS@"
447
448# Compile and run with gcov
449.PHONY=coverage coverage-lcov coverage-report
450coverage:
451	@echo "Building with support for coverage checking:"
452	$(MAKE) clean profile-removal
453	$(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
454
455coverage-lcov:
456	@echo "Creating Coverage HTML report with LCOV:"
457	@rm -f $(COVERAGE_INFO)
458	@rm -rf $(COVERAGE_REPORT)
459	@lcov --capture --directory $(abs_builddir) \
460	    --base-directory $(realpath $(abs_builddir)) \
461	    --path $(realpath $(abs_srcdir)) \
462	    --output-file $(COVERAGE_INFO)
463	: # remove 3rd party modules and system headers
464	@lcov --remove $(COVERAGE_INFO) \
465	    '*/Modules/_ctypes/libffi*/*' \
466	    '*/Modules/expat/*' \
467	    '*/Modules/zlib/*' \
468	    '*/Include/*' \
469	    '/usr/include/*' \
470	    '/usr/local/include/*' \
471	    --output-file $(COVERAGE_INFO)
472	@genhtml $(COVERAGE_INFO) --output-directory $(COVERAGE_REPORT) \
473	    $(COVERAGE_REPORT_OPTIONS)
474	@echo
475	@echo "lcov report at $(COVERAGE_REPORT)/index.html"
476	@echo
477
478# Force regeneration of parser
479coverage-report: regen-grammar
480	: # build with coverage info
481	$(MAKE) coverage
482	: # run tests, ignore failures
483	$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) || true
484	: # build lcov report
485	$(MAKE) coverage-lcov
486
487
488# Build the interpreter
489$(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY)
490		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
491			Modules/python.o \
492			$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
493
494platform: $(BUILDPYTHON) pybuilddir.txt
495	$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
496
497# Create build directory and generate the sysconfig build-time data there.
498# pybuilddir.txt contains the name of the build dir and is used for
499# sys.path fixup -- see Modules/getpath.c.
500# Since this step runs before shared modules are built, try to avoid bootstrap
501# problems by creating a dummy pybuilddir.txt just to allow interpreter
502# initialization to succeed.  It will be overwritten by generate-posix-vars
503# or removed in case of failure.
504pybuilddir.txt: $(BUILDPYTHON)
505	@echo "none" > ./pybuilddir.txt
506	$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
507	if test $$? -ne 0 ; then \
508		echo "generate-posix-vars failed" ; \
509		rm -f ./pybuilddir.txt ; \
510		exit 1 ; \
511	fi
512
513# This is shared by the math and cmath modules
514Modules/_math.o: Modules/_math.c Modules/_math.h
515	$(CC) -c $(CCSHARED) $(PY_CFLAGS) -o $@ $<
516
517# Build the shared modules
518# Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
519# -s, --silent or --quiet is always the first char.
520# Under BSD make, MAKEFLAGS might be " -s -v x=y".
521sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
522	@case "$$MAKEFLAGS" in \
523	    *\ -s*|s*) quiet="-q";; \
524	    *) quiet="";; \
525	esac; \
526	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
527		_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
528		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
529
530# Build static library
531# avoid long command lines, same as LIBRARY_OBJS
532$(LIBRARY): $(LIBRARY_OBJS)
533	-rm -f $@
534	$(AR) $(ARFLAGS) $@ Modules/getbuildinfo.o
535	$(AR) $(ARFLAGS) $@ $(PARSER_OBJS)
536	$(AR) $(ARFLAGS) $@ $(OBJECT_OBJS)
537	$(AR) $(ARFLAGS) $@ $(PYTHON_OBJS)
538	$(AR) $(ARFLAGS) $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
539	$(AR) $(ARFLAGS) $@ $(MODOBJS)
540	$(RANLIB) $@
541
542libpython$(VERSION).so: $(LIBRARY_OBJS)
543	if test $(INSTSONAME) != $(LDLIBRARY); then \
544		$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
545		$(LN) -f $(INSTSONAME) $@; \
546	else \
547		$(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
548	fi
549
550libpython$(VERSION).dylib: $(LIBRARY_OBJS)
551	 $(CC) -dynamiclib -Wl,-single_module $(LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
552
553
554libpython$(VERSION).sl: $(LIBRARY_OBJS)
555	$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST)
556
557# Copy up the gdb python hooks into a position where they can be automatically
558# loaded by gdb during Lib/test/test_gdb.py
559#
560# Distributors are likely to want to install this somewhere else e.g. relative
561# to the stripped DWARF data for the shared library.
562gdbhooks: $(BUILDPYTHON)-gdb.py
563
564SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py
565$(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
566	$(INSTALL_DATA) $(SRC_GDB_HOOKS) $(BUILDPYTHON)-gdb.py
567
568# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
569# minimal framework (not including the Lib directory and such) in the current
570# directory.
571RESSRCDIR=Mac/Resources/framework
572$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
573		$(LIBRARY) \
574		$(RESSRCDIR)/Info.plist
575	$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
576	$(CC) -o $(LDLIBRARY) $(LDFLAGS)  -dynamiclib \
577		-all_load $(LIBRARY) -Wl,-single_module \
578		-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
579		-compatibility_version $(VERSION) \
580		-current_version $(VERSION);
581	$(INSTALL) -d -m $(DIRMODE)  \
582		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
583	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
584		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
585	$(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
586	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
587	$(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
588	$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
589
590# This rule builds the Cygwin Python DLL and import library if configured
591# for a shared core library; otherwise, this rule is a noop.
592$(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
593	if test -n "$(DLLLIBRARY)"; then \
594		$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
595			$(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
596	else true; \
597	fi
598
599
600oldsharedmods: $(SHAREDMODS)
601
602
603Makefile Modules/config.c: Makefile.pre \
604				$(srcdir)/Modules/config.c.in \
605				$(MAKESETUP) \
606				Modules/Setup.config \
607				Modules/Setup \
608				Modules/Setup.local
609	$(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
610				-s Modules \
611				Modules/Setup.config \
612				Modules/Setup.local \
613				Modules/Setup
614	@mv config.c Modules
615	@echo "The Makefile was updated, you may need to re-run make."
616
617
618Modules/Setup: $(srcdir)/Modules/Setup.dist
619	@if test -f Modules/Setup; then \
620		echo "-----------------------------------------------"; \
621		echo "Modules/Setup.dist is newer than Modules/Setup;"; \
622		echo "check to make sure you have all the updates you"; \
623		echo "need in your Modules/Setup file."; \
624		echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
625		echo "-----------------------------------------------"; \
626	fi
627
628
629############################################################################
630# Regenerate all generated files
631
632regen-all: regen-opcode-targets regen-grammar regen-ast
633
634############################################################################
635# Special rules for object files
636
637Modules/getbuildinfo.o: $(PARSER_OBJS) \
638		$(OBJECT_OBJS) \
639		$(PYTHON_OBJS) \
640		$(MODULE_OBJS) \
641		$(SIGNAL_OBJS) \
642		$(MODOBJS) \
643		$(srcdir)/Modules/getbuildinfo.c
644	$(CC) -c $(PY_CFLAGS) \
645	      -DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \
646	      -DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \
647	      -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \
648	      -o $@ $(srcdir)/Modules/getbuildinfo.c
649
650Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
651	$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
652		-DPREFIX='"$(prefix)"' \
653		-DEXEC_PREFIX='"$(exec_prefix)"' \
654		-DVERSION='"$(VERSION)"' \
655		-DVPATH='"$(VPATH)"' \
656		-o $@ $(srcdir)/Modules/getpath.c
657
658Modules/python.o: $(srcdir)/Modules/python.c
659	$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
660
661Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c $(srcdir)/Modules/posixmodule.h
662
663Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule.h
664
665Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h
666
667$(PGEN):	$(PGENOBJS)
668		$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
669
670.PHONY: regen-grammar
671regen-grammar: $(PGEN)
672	# Regenerate Include/graminit.h and Python/graminit.c
673	# from Grammar/Grammar using pgen
674	@$(MKDIR_P) Include
675	$(PGEN) $(srcdir)/Grammar/Grammar \
676		$(srcdir)/Include/graminit.h \
677		$(srcdir)/Python/graminit.c
678
679Parser/grammar.o:	$(srcdir)/Parser/grammar.c \
680				$(srcdir)/Include/token.h \
681				$(srcdir)/Include/grammar.h
682Parser/metagrammar.o:	$(srcdir)/Parser/metagrammar.c
683
684Parser/tokenizer_pgen.o:	$(srcdir)/Parser/tokenizer.c
685
686Parser/pgenmain.o:	$(srcdir)/Include/parsetok.h
687
688.PHONY=regen-ast
689regen-ast:
690	# Regenerate Include/Python-ast.h using Parser/asdl_c.py -h
691	$(MKDIR_P) $(srcdir)/Include
692	$(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
693		-h $(srcdir)/Include \
694		$(srcdir)/Parser/Python.asdl
695	# Regenerate Python/Python-ast.c using Parser/asdl_c.py -c
696	$(MKDIR_P) $(srcdir)/Python
697	$(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
698		-c $(srcdir)/Python \
699		$(srcdir)/Parser/Python.asdl
700
701Python/compile.o Python/symtable.o Python/ast.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
702
703Python/getplatform.o: $(srcdir)/Python/getplatform.c
704		$(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
705
706Python/importdl.o: $(srcdir)/Python/importdl.c
707		$(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
708
709Objects/unicodectype.o:	$(srcdir)/Objects/unicodectype.c \
710				$(srcdir)/Objects/unicodetype_db.h
711
712STRINGLIB_HEADERS= \
713		$(srcdir)/Include/bytes_methods.h \
714		$(srcdir)/Objects/stringlib/count.h \
715		$(srcdir)/Objects/stringlib/ctype.h \
716		$(srcdir)/Objects/stringlib/fastsearch.h \
717		$(srcdir)/Objects/stringlib/find.h \
718		$(srcdir)/Objects/stringlib/formatter.h \
719		$(srcdir)/Objects/stringlib/partition.h \
720		$(srcdir)/Objects/stringlib/split.h \
721		$(srcdir)/Objects/stringlib/stringdefs.h \
722		$(srcdir)/Objects/stringlib/string_format.h \
723		$(srcdir)/Objects/stringlib/transmogrify.h \
724		$(srcdir)/Objects/stringlib/unicodedefs.h \
725		$(srcdir)/Objects/stringlib/localeutil.h
726
727Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
728				$(STRINGLIB_HEADERS)
729
730Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c \
731				$(STRINGLIB_HEADERS)
732
733Objects/stringobject.o: $(srcdir)/Objects/stringobject.c \
734				$(STRINGLIB_HEADERS)
735
736.PHONY: regen-opcode-targets
737regen-opcode-targets:
738	# Regenerate Python/opcode_targets.h from Lib/opcode.py
739	# using Python/makeopcodetargets.py
740	$(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
741		$(srcdir)/Python/opcode_targets.h
742
743Python/ceval.o: $(srcdir)/Python/opcode_targets.h
744
745Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
746				$(STRINGLIB_HEADERS)
747
748Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
749				$(STRINGLIB_HEADERS)
750
751############################################################################
752# Header files
753
754PYTHON_HEADERS= \
755		Include/Python-ast.h \
756		Include/Python.h \
757		Include/abstract.h \
758		Include/asdl.h \
759		Include/ast.h \
760		Include/bitset.h \
761		Include/boolobject.h \
762		Include/bytearrayobject.h \
763		Include/bytes_methods.h \
764		Include/bytesobject.h \
765		Include/bufferobject.h \
766		Include/cellobject.h \
767		Include/ceval.h \
768		Include/classobject.h \
769		Include/cobject.h \
770		Include/code.h \
771		Include/codecs.h \
772		Include/compile.h \
773		Include/complexobject.h \
774		Include/descrobject.h \
775		Include/dictobject.h \
776		Include/dtoa.h \
777		Include/enumobject.h \
778		Include/errcode.h \
779		Include/eval.h \
780		Include/fileobject.h \
781		Include/floatobject.h \
782		Include/frameobject.h \
783		Include/funcobject.h \
784		Include/genobject.h \
785		Include/import.h \
786		Include/intobject.h \
787		Include/intrcheck.h \
788		Include/iterobject.h \
789		Include/listobject.h \
790		Include/longintrepr.h \
791		Include/longobject.h \
792		Include/marshal.h \
793		Include/memoryobject.h \
794		Include/metagrammar.h \
795		Include/methodobject.h \
796		Include/modsupport.h \
797		Include/moduleobject.h \
798		Include/node.h \
799		Include/object.h \
800		Include/objimpl.h \
801		Include/opcode.h \
802		Include/osdefs.h \
803		Include/parsetok.h \
804		Include/patchlevel.h \
805		Include/pgen.h \
806		Include/pgenheaders.h \
807		Include/pyarena.h \
808		Include/pycapsule.h \
809		Include/pyctype.h \
810		Include/pydebug.h \
811		Include/pyerrors.h \
812		Include/pyfpe.h \
813		Include/pymath.h \
814		Include/pygetopt.h \
815		Include/pymem.h \
816		Include/pyport.h \
817		Include/pystate.h \
818		Include/pystrcmp.h \
819		Include/pystrtod.h \
820		Include/pythonrun.h \
821		Include/pythread.h \
822		Include/rangeobject.h \
823		Include/setobject.h \
824		Include/sliceobject.h \
825		Include/stringobject.h \
826		Include/structmember.h \
827		Include/structseq.h \
828		Include/symtable.h \
829		Include/sysmodule.h \
830		Include/traceback.h \
831		Include/tupleobject.h \
832		Include/ucnhash.h \
833		Include/unicodeobject.h \
834		Include/warnings.h \
835		Include/weakrefobject.h \
836		pyconfig.h \
837		$(PARSER_HEADERS) \
838		$(srcdir)/Include/Python-ast.h
839
840$(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
841
842
843######################################################################
844
845# Test the interpreter (twice, once without .pyc files, once with)
846# In the past, we've had problems where bugs in the marshalling or
847# elsewhere caused bytecode read from .pyc files to behave differently
848# than bytecode generated directly from a .py source file.  Sometimes
849# the bytecode read from a .pyc file had the bug, sometimes the directly
850# generated bytecode.  This is sometimes a very shy bug needing a lot of
851# sample data.
852
853.PHONY: test testall testuniversal buildbottest pythoninfo
854
855TESTOPTS=	-l $(EXTRATESTOPTS)
856TESTPROG=	$(srcdir)/Lib/test/regrtest.py
857TESTPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS)
858test:		@DEF_MAKE_RULE@ platform
859		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
860		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
861		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
862
863testall:	@DEF_MAKE_RULE@ platform
864		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
865		$(TESTPYTHON) $(srcdir)/Lib/compileall.py
866		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
867		-$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
868		$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
869
870#  Run the unitests for both architectures in a Universal build on OSX
871#  Must be run on an Intel box.
872testuniversal:	@DEF_MAKE_RULE@ platform
873		if [ `arch` != 'i386' ];then \
874			echo "This can only be used on OSX/i386" ;\
875			exit 1 ;\
876		fi
877		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
878		-$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
879		$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
880		$(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) -uall $(TESTOPTS)
881
882
883# Like testall, but with a single pass only
884# run an optional script to include some information about the build environment
885buildbottest:	build_all platform
886		-@if which pybuildbot.identify >/dev/null 2>&1; then \
887			pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
888		fi
889		$(TESTPYTHON) -R $(TESTPROG) -uall --slowest -rwW $(TESTOPTS)
890
891pythoninfo: build_all
892		$(RUNSHARED) ./$(BUILDPYTHON) -m test.pythoninfo
893
894QUICKTESTOPTS=	$(TESTOPTS) -x test_subprocess test_io test_lib2to3 \
895		test_multibytecodec test_urllib2_localnet test_itertools \
896		test_multiprocessing test_mailbox test_socket test_poll \
897		test_select test_zipfile
898quicktest:	@DEF_MAKE_RULE@ platform
899		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
900		-$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
901		$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
902
903MEMTESTOPTS=    $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
904		test_longexp
905memtest:	@DEF_MAKE_RULE@ platform
906		-rm -f $(srcdir)/Lib/test/*.py[co]
907		-$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
908		$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
909
910# SSL tests
911.PHONY: multisslcompile multissltest
912multisslcompile: build_all
913	$(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py --compile-only
914
915multissltest: build_all
916	$(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py
917
918# Install everything
919install:	@FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@
920	if test "x$(ENSUREPIP)" != "xno"  ; then \
921		case $(ENSUREPIP) in \
922			upgrade) ensurepip="--upgrade" ;; \
923			install|*) ensurepip="" ;; \
924		esac; \
925		$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
926			$$ensurepip --root=$(DESTDIR)/ ; \
927	fi
928
929# Install almost everything without disturbing previous versions
930altinstall:	commoninstall
931	if test "x$(ENSUREPIP)" != "xno"  ; then \
932		case $(ENSUREPIP) in \
933			upgrade) ensurepip="--altinstall --upgrade --no-default-pip" ;; \
934			install|*) ensurepip="--altinstall --no-default-pip" ;; \
935		esac; \
936		$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
937			$$ensurepip --root=$(DESTDIR)/ ; \
938	fi
939
940commoninstall:	check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
941		altbininstall libinstall inclinstall libainstall \
942		sharedinstall oldsharedinstall altmaninstall \
943		@FRAMEWORKALTINSTALLLAST@
944
945# Install shared libraries enabled by Setup
946DESTDIRS=	$(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
947
948oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
949		@for i in X $(SHAREDMODS); do \
950		  if test $$i != X; then \
951		    echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
952		    $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
953		  fi; \
954		done
955
956$(DESTSHARED):
957		@for i in $(DESTDIRS); \
958		do \
959			if test ! -d $(DESTDIR)$$i; then \
960				echo "Creating directory $$i"; \
961				$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
962			else    true; \
963			fi; \
964		done
965
966
967# Install the interpreter by creating a symlink chain:
968#  $(PYTHON) -> python2 -> python$(VERSION))
969# Also create equivalent chains for other installed files
970bininstall:	altbininstall
971	if test ! -d $(DESTDIR)$(LIBPC); then \
972		echo "Creating directory $(LIBPC)"; \
973		$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \
974	fi
975	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
976	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
977	else true; \
978	fi
979	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(EXE) $(PYTHON))
980	-rm -f $(DESTDIR)$(BINDIR)/python2$(EXE)
981	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python2$(EXE))
982	-rm -f $(DESTDIR)$(BINDIR)/python2-config
983	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python2-config)
984	-rm -f $(DESTDIR)$(BINDIR)/python-config
985	(cd $(DESTDIR)$(BINDIR); $(LN) -s python2-config python-config)
986	-test -d $(DESTDIR)$(LIBPC) || $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC)
987	-rm -f $(DESTDIR)$(LIBPC)/python2.pc
988	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python2.pc)
989	-rm -f $(DESTDIR)$(LIBPC)/python.pc
990	(cd $(DESTDIR)$(LIBPC); $(LN) -s python2.pc python.pc)
991
992# Install the interpreter with $(VERSION) affixed
993# This goes into $(exec_prefix)
994altbininstall:	$(BUILDPYTHON)
995	@for i in $(BINDIR) $(LIBDIR); \
996	do \
997		if test ! -d $(DESTDIR)$$i; then \
998			echo "Creating directory $$i"; \
999			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1000		else	true; \
1001		fi; \
1002	done
1003	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
1004	if test -f $(LDLIBRARY); then \
1005		if test -n "$(DLLLIBRARY)" ; then \
1006			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
1007		else \
1008			$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
1009			if test $(LDLIBRARY) != $(INSTSONAME); then \
1010				(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
1011			fi \
1012		fi; \
1013	else	true; \
1014	fi
1015
1016# Install the versioned manual page
1017altmaninstall:
1018	@for i in $(MANDIR) $(MANDIR)/man1; \
1019	do \
1020		if test ! -d $(DESTDIR)$$i; then \
1021			echo "Creating directory $$i"; \
1022			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1023		else	true; \
1024		fi; \
1025	done
1026	$(INSTALL_DATA) $(srcdir)/Misc/python.man \
1027		$(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
1028
1029# Install the unversioned manual pages
1030maninstall:	altmaninstall
1031	-rm -f $(DESTDIR)$(MANDIR)/man1/python2.1
1032	(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python2.1)
1033	-rm -f $(DESTDIR)$(MANDIR)/man1/python.1
1034	(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python2.1 python.1)
1035
1036# Install the library
1037PLATDIR=	@PLATDIR@
1038EXTRAPLATDIR= @EXTRAPLATDIR@
1039EXTRAMACHDEPPATH=@EXTRAMACHDEPPATH@
1040MACHDEPS=	$(PLATDIR) $(EXTRAPLATDIR)
1041XMLLIBSUBDIRS=  xml xml/dom xml/etree xml/parsers xml/sax
1042PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
1043	plat-mac/lib-scriptpackages/_builtinSuites \
1044	plat-mac/lib-scriptpackages/CodeWarrior \
1045	plat-mac/lib-scriptpackages/Explorer \
1046	plat-mac/lib-scriptpackages/Finder \
1047	plat-mac/lib-scriptpackages/Netscape \
1048	plat-mac/lib-scriptpackages/StdSuites \
1049	plat-mac/lib-scriptpackages/SystemEvents \
1050	plat-mac/lib-scriptpackages/Terminal
1051PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
1052LIBSUBDIRS=	lib-tk lib-tk/test lib-tk/test/test_tkinter \
1053		lib-tk/test/test_ttk site-packages test test/audiodata test/capath \
1054		test/data test/cjkencodings test/decimaltestdata test/xmltestdata \
1055		test/imghdrdata \
1056		test/subprocessdata \
1057		test/support \
1058		test/tracedmodules \
1059		encodings compiler hotshot \
1060		email email/mime email/test email/test/data \
1061		ensurepip ensurepip/_bundled \
1062		json json/tests \
1063		sqlite3 sqlite3/test \
1064		logging bsddb bsddb/test csv importlib wsgiref \
1065		lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
1066		lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
1067		ctypes ctypes/test ctypes/macholib \
1068		idlelib idlelib/Icons idlelib/idle_test \
1069		distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
1070		multiprocessing multiprocessing/dummy \
1071		unittest unittest/test \
1072		lib-old \
1073		curses pydoc_data $(MACHDEPS)
1074libinstall:	build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
1075	@for i in $(SCRIPTDIR) $(LIBDEST); \
1076	do \
1077		if test ! -d $(DESTDIR)$$i; then \
1078			echo "Creating directory $$i"; \
1079			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1080		else	true; \
1081		fi; \
1082	done
1083	@for d in $(LIBSUBDIRS); \
1084	do \
1085		a=$(srcdir)/Lib/$$d; \
1086		if test ! -d $$a; then continue; else true; fi; \
1087		b=$(LIBDEST)/$$d; \
1088		if test ! -d $(DESTDIR)$$b; then \
1089			echo "Creating directory $$b"; \
1090			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
1091		else	true; \
1092		fi; \
1093	done
1094	@for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
1095	do \
1096		if test -x $$i; then \
1097			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
1098			echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
1099		else \
1100			$(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
1101			echo $(INSTALL_DATA) $$i $(LIBDEST); \
1102		fi; \
1103	done
1104	@for d in $(LIBSUBDIRS); \
1105	do \
1106		a=$(srcdir)/Lib/$$d; \
1107		if test ! -d $$a; then continue; else true; fi; \
1108		if test `ls $$a | wc -l` -lt 1; then continue; fi; \
1109		b=$(LIBDEST)/$$d; \
1110		for i in $$a/*; \
1111		do \
1112			case $$i in \
1113			*CVS) ;; \
1114			*.py[co]) ;; \
1115			*.orig) ;; \
1116			*~) ;; \
1117			*) \
1118				if test -d $$i; then continue; fi; \
1119				if test -x $$i; then \
1120				    echo $(INSTALL_SCRIPT) $$i $$b; \
1121				    $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
1122				else \
1123				    echo $(INSTALL_DATA) $$i $$b; \
1124				    $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
1125				fi;; \
1126			esac; \
1127		done; \
1128	done
1129	$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
1130	if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
1131		$(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
1132			$(DESTDIR)$(LIBDEST)/distutils/tests ; \
1133	fi
1134	PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
1135		$(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
1136		-d $(LIBDEST) -f \
1137		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
1138		$(DESTDIR)$(LIBDEST)
1139	PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1140		$(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
1141		-d $(LIBDEST) -f \
1142		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
1143		$(DESTDIR)$(LIBDEST)
1144	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
1145		$(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
1146		-d $(LIBDEST)/site-packages -f \
1147		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
1148	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1149		$(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
1150		-d $(LIBDEST)/site-packages -f \
1151		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
1152	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1153		$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
1154	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1155		$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
1156
1157# Create the PLATDIR source directory, if one wasn't distributed..
1158$(srcdir)/Lib/$(PLATDIR):
1159	mkdir $(srcdir)/Lib/$(PLATDIR)
1160	cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
1161	export PATH; PATH="`pwd`:$$PATH"; \
1162	export PYTHONPATH; PYTHONPATH="$(srcdir)/Lib:$(abs_builddir)/`cat pybuilddir.txt`"; \
1163	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
1164	export EXE; EXE="$(BUILDEXE)"; \
1165	if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \
1166	export PYTHON_FOR_BUILD; \
1167	if [ "$(build)" = "$(host)" ]; then \
1168	  PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \
1169	else \
1170	  PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \
1171	fi; \
1172	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
1173
1174python-config: $(srcdir)/Misc/python-config.in
1175	# Substitution happens here, as the completely-expanded BINDIR
1176	# is not available in configure
1177	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
1178
1179# Install the include files
1180INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
1181inclinstall:
1182	@for i in $(INCLDIRSTOMAKE); \
1183	do \
1184		if test ! -d $(DESTDIR)$$i; then \
1185			echo "Creating directory $$i"; \
1186			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1187		else	true; \
1188		fi; \
1189	done
1190	@for i in $(srcdir)/Include/*.h; \
1191	do \
1192		echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
1193		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
1194	done
1195	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
1196
1197# Install the library and miscellaneous stuff needed for extending/embedding
1198# This goes into $(exec_prefix)
1199LIBPL=		$(LIBP)/config
1200
1201# pkgconfig directory
1202LIBPC=		$(LIBDIR)/pkgconfig
1203
1204libainstall:	@DEF_MAKE_RULE@ python-config
1205	@for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
1206	do \
1207		if test ! -d $(DESTDIR)$$i; then \
1208			echo "Creating directory $$i"; \
1209			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1210		else	true; \
1211		fi; \
1212	done
1213	@if test -d $(LIBRARY); then :; else \
1214		if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1215			if test "$(SO)" = .dll; then \
1216				$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
1217			else \
1218				$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
1219				$(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
1220			fi; \
1221		else \
1222			echo Skip install of $(LIBRARY) - use make frameworkinstall; \
1223		fi; \
1224	fi
1225	$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
1226	$(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
1227	$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
1228	$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
1229	$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
1230	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
1231	$(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
1232	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
1233	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
1234	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
1235	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
1236	rm python-config
1237	@if [ -s Modules/python.exp -a \
1238		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
1239		echo; echo "Installing support files for building shared extension modules on AIX:"; \
1240		$(INSTALL_DATA) Modules/python.exp		\
1241				$(DESTDIR)$(LIBPL)/python.exp;		\
1242		echo; echo "$(LIBPL)/python.exp";		\
1243		$(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix	\
1244				$(DESTDIR)$(LIBPL)/makexp_aix;		\
1245		echo "$(LIBPL)/makexp_aix";			\
1246		$(INSTALL_SCRIPT) Modules/ld_so_aix	\
1247				$(DESTDIR)$(LIBPL)/ld_so_aix;		\
1248		echo "$(LIBPL)/ld_so_aix";			\
1249		echo; echo "See Misc/AIX-NOTES for details.";	\
1250	else true; \
1251	fi
1252	@case "$(MACHDEP)" in beos*) \
1253		echo; echo "Installing support files for building shared extension modules on BeOS:"; \
1254		$(INSTALL_DATA) Misc/BeOS-NOTES $(DESTDIR)$(LIBPL)/README;	\
1255		echo; echo "$(LIBPL)/README";			\
1256		$(INSTALL_SCRIPT) Modules/ar_beos $(DESTDIR)$(LIBPL)/ar_beos; \
1257		echo "$(LIBPL)/ar_beos";			\
1258		$(INSTALL_SCRIPT) Modules/ld_so_beos $(DESTDIR)$(LIBPL)/ld_so_beos; \
1259		echo "$(LIBPL)/ld_so_beos";			\
1260		echo; echo "See Misc/BeOS-NOTES for details.";	\
1261		;; \
1262	esac
1263
1264# Install the dynamically loadable modules
1265# This goes into $(exec_prefix)
1266sharedinstall: sharedmods
1267	$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
1268	   	--prefix=$(prefix) \
1269		--install-scripts=$(BINDIR) \
1270		--install-platlib=$(DESTSHARED) \
1271		--root=$(DESTDIR)/
1272	-rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata.py*
1273
1274# Here are a couple of targets for MacOSX again, to install a full
1275# framework-based Python. frameworkinstall installs everything, the
1276# subtargets install specific parts. Much of the actual work is offloaded to
1277# the Makefile in Mac
1278#
1279#
1280# This target is here for backward compatibility, previous versions of Python
1281# hadn't integrated framework installation in the normal install process.
1282frameworkinstall: install
1283
1284# On install, we re-make the framework
1285# structure in the install location, /Library/Frameworks/ or the argument to
1286# --enable-framework. If --enable-framework has been specified then we have
1287# automatically set prefix to the location deep down in the framework, so we
1288# only have to cater for the structural bits of the framework.
1289
1290frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
1291
1292frameworkinstallstructure:	$(LDLIBRARY)
1293	@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1294		echo Not configured with --enable-framework; \
1295		exit 1; \
1296	else true; \
1297	fi
1298	@for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1299		if test ! -d $(DESTDIR)$$i; then \
1300			echo "Creating directory $(DESTDIR)$$i"; \
1301			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1302		else	true; \
1303		fi; \
1304	done
1305	$(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
1306	sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1307	$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
1308	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1309	$(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
1310	$(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1311	$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1312
1313# This installs Mac/Lib into the framework
1314# Install a number of symlinks to keep software that expects a normal unix
1315# install (which includes python-config) happy.
1316frameworkinstallmaclib:
1317	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1318	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).dylib"
1319	ln -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
1320	cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
1321
1322# This installs the IDE, the Launcher and other apps into /Applications
1323frameworkinstallapps:
1324	cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
1325
1326# This install the unix python and pythonw tools in /usr/local/bin
1327frameworkinstallunixtools:
1328	cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
1329
1330frameworkaltinstallunixtools:
1331	cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1332
1333# This installs the Demos and Tools into the applications directory.
1334# It is not part of a normal frameworkinstall
1335frameworkinstallextras:
1336	cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
1337
1338# This installs a few of the useful scripts in Tools/scripts
1339scriptsinstall:
1340	SRCDIR=$(srcdir) $(RUNSHARED) \
1341	$(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
1342	--prefix=$(prefix) \
1343	--install-scripts=$(BINDIR) \
1344	--root=$(DESTDIR)/
1345
1346# Build the toplevel Makefile
1347Makefile.pre: Makefile.pre.in config.status
1348	CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
1349	$(MAKE) -f Makefile.pre Makefile
1350
1351# Run the configure script.
1352config.status:	$(srcdir)/configure
1353	$(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1354
1355.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1356
1357# Some make's put the object file in the current directory
1358.c.o:
1359	$(CC) -c $(PY_CFLAGS) -o $@ $<
1360
1361# Run reindent on the library
1362reindent:
1363	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
1364
1365# Rerun configure with the same options as it was run last time,
1366# provided the config.status script exists
1367recheck:
1368	$(SHELL) config.status --recheck
1369	$(SHELL) config.status
1370
1371# Regenerate configure and pyconfig.h.in
1372.PHONY: autoconf
1373autoconf:
1374	# Regenerate the configure script from configure.ac using autoconf
1375	(cd $(srcdir); autoconf)
1376	# Regenerate pyconfig.h.in from configure.ac using autoheader
1377	(cd $(srcdir); autoheader)
1378
1379# Create a tags file for vi
1380tags::
1381	ctags -w $(srcdir)/Include/*.h
1382	for i in $(SRCDIRS); do ctags -f tags -w -a $(srcdir)/$$i/*.[ch]; done
1383	ctags -f tags -w -a $(srcdir)/Modules/_ctypes/*.[ch]
1384	LC_ALL=C sort -o tags tags
1385
1386# Create a tags file for GNU Emacs
1387TAGS::
1388	cd $(srcdir); \
1389	etags Include/*.h; \
1390	for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
1391
1392# Sanitation targets -- clean leaves libraries, executables and tags
1393# files, which clobber removes as well
1394pycremoval:
1395	find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1396
1397clean: pycremoval
1398	find . -name '*.[oa]' -exec rm -f {} ';'
1399	find . -name '*.s[ol]' -exec rm -f {} ';'
1400	find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
1401	find build -name 'fficonfig.h' -exec rm -f {} ';' || true
1402	find build -name 'fficonfig.py' -exec rm -f {} ';' || true
1403	-rm -f Lib/lib2to3/*Grammar*.pickle
1404	-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
1405
1406profile-removal:
1407	find . -name '*.gc??' -exec rm -f {} ';'
1408	find . -name '*.profclang?' -exec rm -f {} ';'
1409	find . -name '*.dyn' -exec rm -f {} ';'
1410
1411clobber: clean profile-removal
1412	-rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1413		tags TAGS \
1414		config.cache config.log pyconfig.h Modules/config.c
1415	-rm -rf build platform
1416	-rm -rf $(PYTHONFRAMEWORKDIR)
1417
1418# Make things extra clean, before making a distribution:
1419# remove all generated files, even Makefile[.pre]
1420# Keep configure and Python-ast.[ch], it's possible they can't be generated
1421distclean: clobber
1422	for file in Lib/test/data/* ; do \
1423	    if test "$$file" != "Lib/test/data/README"; then rm "$$file"; fi; \
1424	done
1425	-rm -f core Makefile Makefile.pre config.status \
1426		Modules/Setup Modules/Setup.local Modules/Setup.config \
1427		Modules/ld_so_aix Modules/python.exp Misc/python.pc
1428	-rm -f python*-gdb.py
1429	-rm -f pybuilddir.txt
1430	# Issue #28258: set LC_ALL to avoid issues with Estonian locale.
1431	# Expansion is performed here by shell (spawned by make) itself before
1432	# arguments are passed to find. So LC_ALL=C must be set as a separate
1433	# command.
1434	LC_ALL=C; find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \
1435				     -o -name '[@,#]*' -o -name '*.old' \
1436				     -o -name '*.orig' -o -name '*.rej' \
1437				     -o -name '*.bak' ')' \
1438				     -exec rm -f {} ';'
1439
1440# Check for smelly exported symbols (not starting with Py/_Py)
1441smelly: @DEF_MAKE_RULE@
1442	nm -p $(LIBRARY) | \
1443		sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
1444
1445# Find files with funny names
1446funny:
1447	find $(SUBDIRS) $(SUBDIRSTOO) -type d \
1448		-o -name '*.[chs]' \
1449		-o -name '*.py' \
1450		-o -name '*.doc' \
1451		-o -name '*.sty' \
1452		-o -name '*.bib' \
1453		-o -name '*.dat' \
1454		-o -name '*.el' \
1455		-o -name '*.fd' \
1456		-o -name '*.in' \
1457		-o -name '*.tex' \
1458		-o -name '*,[vpt]' \
1459		-o -name 'Setup' \
1460		-o -name 'Setup.*' \
1461		-o -name README \
1462		-o -name Makefile \
1463		-o -name ChangeLog \
1464		-o -name Repository \
1465		-o -name Root \
1466		-o -name Entries \
1467		-o -name Tag \
1468		-o -name tags \
1469		-o -name TAGS \
1470		-o -name .cvsignore \
1471		-o -name MANIFEST \
1472		-o -print
1473
1474# Perform some verification checks on any modified files.
1475patchcheck:
1476	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1477
1478# Dependencies
1479
1480Python/thread.o: @THREADHEADERS@
1481
1482# Declare targets that aren't real files
1483.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest memtest
1484.PHONY: install altinstall oldsharedinstall bininstall altbininstall
1485.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1486.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
1487.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1488.PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
1489.PHONY: smelly funny patchcheck altmaninstall commoninstall
1490.PHONY: gdbhooks
1491
1492# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
1493