1 # Top-level Makefile for Python
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:
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
19 # See also the section "Build instructions" in the README file.
21 # === Variables set by makesetup ===
26 # === Variables set by configure
37 SVNVERSION= @SVNVERSION@
41 # Shell used by make (some versions default to the login shell, which is bad)
44 # Use this to make a link between python$(VERSION) and python in $(BINDIR)
47 # Portable install script (configure doesn't always guess right)
49 INSTALL_PROGRAM=@INSTALL_PROGRAM@
50 INSTALL_SCRIPT= @INSTALL_SCRIPT@
51 INSTALL_DATA= @INSTALL_DATA@
52 # Shared libraries must be installed with executable mode on some systems;
53 # rather than figuring out exactly which, we always give them executable mode.
54 # Also, making them read-only seems to be a good idea...
55 INSTALL_SHARED= ${INSTALL} -m 555
57 MAKESETUP= $(srcdir)/Modules/makesetup
61 BASECFLAGS= @BASECFLAGS@
62 CFLAGS= $(BASECFLAGS) @CFLAGS@ $(OPT) $(EXTRA_CFLAGS)
63 # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
64 # be able to build extension modules using the directories specified in the
65 # environment variables
66 CPPFLAGS= -I. -IInclude -I$(srcdir)/Include @CPPFLAGS@
71 LINKFORSHARED= @LINKFORSHARED@
73 # Extra C flags added for building the interpreter object files.
74 CFLAGSFORSHARED=@CFLAGSFORSHARED@
75 # C flags used for building the interpreter object files
76 PY_CFLAGS= $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
79 # Machine-dependent subdirectories
82 # Install prefix for architecture-independent files
85 # Install prefix for architecture-dependent files
86 exec_prefix= @exec_prefix@
88 # Install prefix for data files
89 datarootdir= @datarootdir@
91 # Expanded directories
95 INCLUDEDIR= @includedir@
96 CONFINCLUDEDIR= $(exec_prefix)/include
97 SCRIPTDIR= $(prefix)/lib
99 # Detailed destination directories
100 BINLIBDEST= $(LIBDIR)/python$(VERSION)
101 LIBDEST= $(SCRIPTDIR)/python$(VERSION)
102 INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
103 CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(VERSION)
104 LIBP= $(LIBDIR)/python$(VERSION)
106 # Symbols used for using shared libraries
109 BLDSHARED= @BLDSHARED@
110 DESTSHARED= $(BINLIBDEST)/lib-dynload
112 # Executable suffix (.exe on Windows and Mac OS X)
114 BUILDEXE= @BUILDEXEEXT@
116 # Short name and location for Mac OS X Python framework
117 UNIVERSALSDK=@UNIVERSALSDK@
118 PYTHONFRAMEWORK= @PYTHONFRAMEWORK@
119 PYTHONFRAMEWORKDIR= @PYTHONFRAMEWORKDIR@
120 PYTHONFRAMEWORKPREFIX= @PYTHONFRAMEWORKPREFIX@
121 PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
122 # Deployment target selected during configure, to be checked
123 # by distutils. The export statement is needed to ensure that the
124 # deployment target is active during build.
125 MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
126 @EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
128 # Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
129 OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@
131 # Environment to run shared python without installed libraries
132 RUNSHARED= @RUNSHARED@
134 # Modes for directories, executables and data files created by the
135 # install process. Default to user-only-writable for all file types.
140 # configure script arguments
141 CONFIG_ARGS= @CONFIG_ARGS@
144 # Subdirectories with code
147 # Other subdirectories
148 SUBDIRSTOO= Include Lib Misc Demo
150 # Files and directories to be distributed
151 CONFIGFILES= configure configure.in acconfig.h pyconfig.h.in Makefile.pre.in
152 DISTFILES= README ChangeLog $(CONFIGFILES)
153 DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
154 DIST= $(DISTFILES) $(DISTDIRS)
158 LDLIBRARY= @LDLIBRARY@
159 BLDLIBRARY= @BLDLIBRARY@
160 DLLLIBRARY= @DLLLIBRARY@
161 LDLIBRARYDIR= @LDLIBRARYDIR@
162 INSTSONAME= @INSTSONAME@
168 SYSLIBS= $(LIBM) $(LIBC)
171 THREADOBJ= @THREADOBJ@
172 DLINCLDIR= @DLINCLDIR@
173 DYNLOADFILE= @DYNLOADFILE@
174 MACHDEP_OBJS= @MACHDEP_OBJS@
179 BUILDPYTHON= python$(BUILDEXE)
181 # The task to run while instrument when building the profile-opt target
182 PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
183 #PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py
185 # === Definitions added by makesetup ===
188 ##########################################################################
196 # Used of signalmodule.o is not available
197 SIGNAL_OBJS= @SIGNAL_OBJS@
199 IO_H= Modules/_io/_iomodule.h
202 Modules/_io/_iomodule.o \
203 Modules/_io/iobase.o \
204 Modules/_io/fileio.o \
205 Modules/_io/bufferedio.o \
206 Modules/_io/textio.o \
207 Modules/_io/bytesio.o \
208 Modules/_io/stringio.o
210 ##########################################################################
212 GRAMMAR_H= $(srcdir)/Include/graminit.h
213 GRAMMAR_C= $(srcdir)/Python/graminit.c
214 GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
217 ##########################################################################
219 PGEN= Parser/pgen$(EXE)
229 Parser/metagrammar.o \
234 PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/tokenizer.o
238 Python/mysnprintf.o \
239 Parser/tokenizer_pgen.o \
240 Parser/printgrammar.o \
247 PGENOBJS= $(PGENMAIN) $(POBJS) $(PGOBJS)
249 ##########################################################################
251 AST_H_DIR= $(srcdir)/Include
252 AST_H= $(AST_H_DIR)/Python-ast.h
253 AST_C_DIR= $(srcdir)/Python
254 AST_C= $(AST_C_DIR)/Python-ast.c
255 AST_ASDL= $(srcdir)/Parser/Python.asdl
257 ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
258 # XXX Note that a build now requires Python exist before the build starts
259 ASDLGEN= $(srcdir)/Parser/asdl_c.py
261 ##########################################################################
265 $(srcdir)/Python/opcode_targets.h
268 $(srcdir)/Python/makeopcodetargets.py
270 OPCODETARGETGEN_FILES= \
271 $(OPCODETARGETGEN) $(srcdir)/Lib/opcode.py
275 Python/Python-ast.o \
278 Python/bltinmodule.o \
284 Python/frozenmain.o \
287 Python/getcompiler.o \
288 Python/getcopyright.o \
289 Python/getplatform.o \
290 Python/getversion.o \
295 Python/modsupport.o \
297 Python/mysnprintf.o \
305 Python/structmember.o \
313 Python/formatter_unicode.o \
314 Python/$(DYNLOADFILE) \
320 ##########################################################################
324 Objects/boolobject.o \
325 Objects/bytes_methods.o \
326 Objects/bytearrayobject.o \
327 Objects/bytesobject.o \
328 Objects/cellobject.o \
329 Objects/classobject.o \
331 Objects/codeobject.o \
332 Objects/complexobject.o \
333 Objects/descrobject.o \
334 Objects/enumobject.o \
335 Objects/exceptions.o \
336 Objects/genobject.o \
337 Objects/fileobject.o \
338 Objects/floatobject.o \
339 Objects/frameobject.o \
340 Objects/funcobject.o \
341 Objects/iterobject.o \
342 Objects/listobject.o \
343 Objects/longobject.o \
344 Objects/dictobject.o \
345 Objects/memoryobject.o \
346 Objects/methodobject.o \
347 Objects/moduleobject.o \
351 Objects/rangeobject.o \
352 Objects/setobject.o \
353 Objects/sliceobject.o \
354 Objects/structseq.o \
355 Objects/tupleobject.o \
356 Objects/typeobject.o \
357 Objects/unicodeobject.o \
358 Objects/unicodectype.o \
359 Objects/weakrefobject.o
362 ##########################################################################
363 # objects that get linked into the Python library
365 Modules/getbuildinfo.o \
373 #########################################################################
378 build_all: $(BUILDPYTHON) oldsharedmods sharedmods
380 # Compile a binary with gcc profile guided optimization.
382 @echo "Building with support for profile generation:"
384 $(MAKE) build_all_generate_profile
385 @echo "Running benchmark to generate profile data:"
386 $(MAKE) profile-removal
387 $(MAKE) run_profile_task
388 @echo "Rebuilding with profile guided optimizations:"
390 $(MAKE) build_all_use_profile
392 build_all_generate_profile:
393 $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"
396 ./$(BUILDPYTHON) $(PROFILE_TASK)
398 build_all_use_profile:
399 $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"
402 @echo "Building with support for coverage checking:"
404 $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
407 # Build the interpreter
408 $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
409 $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
411 $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
413 platform: $(BUILDPYTHON)
414 $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform
417 # Build the shared modules
418 sharedmods: $(BUILDPYTHON)
419 @case $$MAKEFLAGS in \
420 *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
421 *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(LDFLAGS)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
424 # Build static library
425 # avoid long command lines, same as LIBRARY_OBJS
426 $(LIBRARY): $(LIBRARY_OBJS)
428 $(AR) $(ARFLAGS) $@ Modules/getbuildinfo.o
429 $(AR) $(ARFLAGS) $@ $(PARSER_OBJS)
430 $(AR) $(ARFLAGS) $@ $(OBJECT_OBJS)
431 $(AR) $(ARFLAGS) $@ $(PYTHON_OBJS)
432 $(AR) $(ARFLAGS) $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
433 $(AR) $(ARFLAGS) $@ $(MODOBJS)
436 libpython$(VERSION).so: $(LIBRARY_OBJS)
437 if test $(INSTSONAME) != $(LDLIBRARY); then \
438 $(LDSHARED) $(LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
439 $(LN) -f $(INSTSONAME) $@; \
441 $(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
444 libpython$(VERSION).dylib: $(LIBRARY_OBJS)
445 $(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); \
448 libpython$(VERSION).sl: $(LIBRARY_OBJS)
449 $(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST)
451 # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
452 # minimal framework (not including the Lib directory and such) in the current
454 RESSRCDIR=Mac/Resources/framework
455 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
457 $(RESSRCDIR)/Info.plist
458 $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
459 if test "${UNIVERSALSDK}"; then \
460 $(CC) -o $(LDLIBRARY) @UNIVERSAL_ARCH_FLAGS@ -dynamiclib \
461 -isysroot "${UNIVERSALSDK}" \
462 -all_load $(LIBRARY) -Wl,-single_module \
463 -install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
464 -compatibility_version $(VERSION) \
465 -current_version $(VERSION) \
466 -framework CoreFoundation $(LIBS); \
468 /usr/bin/libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
469 @LIBTOOL_CRUFT@ -framework CoreFoundation $(LIBS);\
471 $(INSTALL) -d -m $(DIRMODE) \
472 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
473 $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
474 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
475 $(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
476 $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
477 $(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
478 $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
480 # This rule builds the Cygwin Python DLL and import library if configured
481 # for a shared core library; otherwise, this rule is a noop.
482 $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
483 if test -n "$(DLLLIBRARY)"; then \
484 $(LDSHARED) $(LDFLAGS) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
485 $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
490 oldsharedmods: $(SHAREDMODS)
493 Makefile Modules/config.c: Makefile.pre \
494 $(srcdir)/Modules/config.c.in \
496 Modules/Setup.config \
499 $(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
501 Modules/Setup.config \
502 Modules/Setup.local \
505 @echo "The Makefile was updated, you may need to re-run make."
508 Modules/Setup: $(srcdir)/Modules/Setup.dist
509 @if test -f Modules/Setup; then \
510 echo "-----------------------------------------------"; \
511 echo "Modules/Setup.dist is newer than Modules/Setup;"; \
512 echo "check to make sure you have all the updates you"; \
513 echo "need in your Modules/Setup file."; \
514 echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
515 echo "-----------------------------------------------"; \
518 ############################################################################
519 # Special rules for object files
521 Modules/getbuildinfo.o: $(PARSER_OBJS) \
527 $(srcdir)/Modules/getbuildinfo.c
528 $(CC) -c $(PY_CFLAGS) -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" -o $@ $(srcdir)/Modules/getbuildinfo.c
530 Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
531 $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
532 -DPREFIX='"$(prefix)"' \
533 -DEXEC_PREFIX='"$(exec_prefix)"' \
534 -DVERSION='"$(VERSION)"' \
535 -DVPATH='"$(VPATH)"' \
536 -o $@ $(srcdir)/Modules/getpath.c
538 Modules/python.o: $(srcdir)/Modules/python.c
539 $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
543 $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
544 -@$(INSTALL) -d Include
545 -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
548 $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
550 Parser/grammar.o: $(srcdir)/Parser/grammar.c \
551 $(srcdir)/Include/token.h \
552 $(srcdir)/Include/grammar.h
553 Parser/metagrammar.o: $(srcdir)/Parser/metagrammar.c
555 Parser/tokenizer_pgen.o: $(srcdir)/Parser/tokenizer.c
557 Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
559 $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
560 $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
562 $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
563 $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
565 Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
567 Python/getplatform.o: $(srcdir)/Python/getplatform.c
568 $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
570 Python/importdl.o: $(srcdir)/Python/importdl.c
571 $(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
573 Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \
574 $(srcdir)/Objects/unicodetype_db.h
577 $(srcdir)/Include/bytes_methods.h \
578 $(srcdir)/Objects/stringlib/count.h \
579 $(srcdir)/Objects/stringlib/ctype.h \
580 $(srcdir)/Objects/stringlib/eq.h \
581 $(srcdir)/Objects/stringlib/fastsearch.h \
582 $(srcdir)/Objects/stringlib/find.h \
583 $(srcdir)/Objects/stringlib/partition.h \
584 $(srcdir)/Objects/stringlib/stringdefs.h \
585 $(srcdir)/Objects/stringlib/string_format.h \
586 $(srcdir)/Objects/stringlib/transmogrify.h \
587 $(srcdir)/Objects/stringlib/unicodedefs.h \
588 $(srcdir)/Objects/stringlib/localeutil.h
590 Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS)
592 Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c $(BYTESTR_DEPS)
594 Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
597 $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
598 $(OPCODETARGETGEN) $(OPCODETARGETS_H)
600 Python/ceval.o: $(OPCODETARGETS_H)
602 Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
604 $(srcdir)/Objects/stringlib/formatter.h
607 ############################################################################
611 Include/Python-ast.h \
616 Include/bltinmodule.h \
618 Include/boolobject.h \
619 Include/bytes_methods.h \
620 Include/bytearrayobject.h \
621 Include/bytesobject.h \
622 Include/cellobject.h \
624 Include/classobject.h \
629 Include/complexobject.h \
630 Include/descrobject.h \
631 Include/dictobject.h \
633 Include/enumobject.h \
636 Include/fileobject.h \
637 Include/floatobject.h \
638 Include/frameobject.h \
639 Include/funcobject.h \
640 Include/genobject.h \
642 Include/intrcheck.h \
643 Include/iterobject.h \
644 Include/listobject.h \
645 Include/longintrepr.h \
646 Include/longobject.h \
648 Include/memoryobject.h \
649 Include/metagrammar.h \
650 Include/methodobject.h \
651 Include/modsupport.h \
652 Include/moduleobject.h \
659 Include/patchlevel.h \
661 Include/pgenheaders.h \
663 Include/pycapsule.h \
675 Include/pythonrun.h \
677 Include/rangeobject.h \
678 Include/setobject.h \
679 Include/sliceobject.h \
680 Include/structmember.h \
681 Include/structseq.h \
683 Include/sysmodule.h \
684 Include/traceback.h \
685 Include/tupleobject.h \
687 Include/unicodeobject.h \
689 Include/weakrefobject.h \
693 $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
696 ######################################################################
698 # Test the interpreter (twice, once without .pyc files, once with)
699 # In the past, we've had problems where bugs in the marshalling or
700 # elsewhere caused bytecode read from .pyc files to behave differently
701 # than bytecode generated directly from a .py source file. Sometimes
702 # the bytecode read from a .pyc file had the bug, somtimes the directly
703 # generated bytecode. This is sometimes a very shy bug needing a lot of
706 TESTOPTS= -l $(EXTRATESTOPTS)
707 TESTPROG= $(srcdir)/Lib/test/regrtest.py
708 TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -bb
710 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
711 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
712 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
714 testall: all platform
715 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
716 $(TESTPYTHON) $(srcdir)/Lib/compileall.py
717 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
718 -$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
719 $(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
721 # Run the unitests for both architectures in a Universal build on OSX
722 # Must be run on an Intel box.
723 testuniversal: all platform
724 if [ `arch` != 'i386' ];then \
725 echo "This can only be used on OSX/i386" ;\
728 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
729 -$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
730 $(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
731 $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E $(TESTPROG) -uall $(TESTOPTS)
734 # Like testall, but with a single pass only
735 # run an optional script to include some information about the build environment
736 buildbottest: all platform
737 -@if which pybuildbot.identify >/dev/null 2>&1; then \
738 pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
740 $(TESTPYTHON) $(TESTPROG) -uall -rw $(TESTOPTS)
742 QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \
743 test_multibytecodec test_urllib2_localnet test_itertools \
744 test_multiprocessing test_mailbox test_socket test_poll \
745 test_select test_zipfile
746 quicktest: all platform
747 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
748 -$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
749 $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
751 MEMTESTOPTS= $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
753 memtest: all platform
754 -rm -f $(srcdir)/Lib/test/*.py[co]
755 -$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
756 $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
758 install: altinstall bininstall
760 altinstall: @FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \
761 sharedinstall oldsharedinstall maninstall @FRAMEWORKALTINSTALLLAST@
763 # Install shared libraries enabled by Setup
764 DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
766 oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
767 @for i in X $(SHAREDMODS); do \
768 if test $$i != X; then \
769 echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
770 $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
775 @for i in $(DESTDIRS); \
777 if test ! -d $(DESTDIR)$$i; then \
778 echo "Creating directory $$i"; \
779 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
784 # Install the interpreter with $(VERSION) affixed
785 # This goes into $(exec_prefix)
786 altbininstall: $(BUILDPYTHON)
787 @for i in $(BINDIR) $(LIBDIR); \
789 if test ! -d $(DESTDIR)$$i; then \
790 echo "Creating directory $$i"; \
791 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
795 $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
796 if test -f $(LDLIBRARY); then \
797 if test -n "$(DLLLIBRARY)" ; then \
798 $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
800 $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
801 if test $(LDLIBRARY) != $(INSTSONAME); then \
802 (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
808 bininstall: altbininstall
809 -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE); \
810 then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON)3$(EXE); \
813 (cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON)3$(EXE))
814 -rm -f $(DESTDIR)$(BINDIR)/python3-config
815 (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
816 -rm -f $(DESTDIR)$(LIBPC)/python3.pc
817 (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python3.pc)
819 # Install the manual page
821 @for i in $(MANDIR) $(MANDIR)/man1; \
823 if test ! -d $(DESTDIR)$$i; then \
824 echo "Creating directory $$i"; \
825 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
829 $(INSTALL_DATA) $(srcdir)/Misc/python.man \
830 $(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
832 # Install the library
833 PLATDIR= plat-$(MACHDEP)
834 EXTRAPLATDIR= @EXTRAPLATDIR@
835 MACHDEPS= $(PLATDIR) $(EXTRAPLATDIR)
836 XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
837 LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \
838 tkinter/test/test_ttk site-packages test test/data \
839 test/decimaltestdata \
841 email email/mime email/test email/test/data \
842 html json json/tests http dbm xmlrpc \
843 sqlite3 sqlite3/test \
844 logging csv wsgiref urllib \
845 lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
846 lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
847 ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
848 distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
849 importlib importlib/test importlib/test/builtin \
850 importlib/test/extension importlib/test/frozen \
851 importlib/test/import_ importlib/test/source \
852 setuptools setuptools/command setuptools/tests setuptools.egg-info \
853 multiprocessing multiprocessing/dummy \
854 curses pydoc_data $(MACHDEPS)
855 libinstall: build_all $(srcdir)/Lib/$(PLATDIR)
856 @for i in $(SCRIPTDIR) $(LIBDEST); \
858 if test ! -d $(DESTDIR)$$i; then \
859 echo "Creating directory $$i"; \
860 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
864 @for d in $(LIBSUBDIRS); \
866 a=$(srcdir)/Lib/$$d; \
867 if test ! -d $$a; then continue; else true; fi; \
869 if test ! -d $(DESTDIR)$$b; then \
870 echo "Creating directory $$b"; \
871 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
875 @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
877 if test -x $$i; then \
878 $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
879 echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
881 $(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
882 echo $(INSTALL_DATA) $$i $(LIBDEST); \
885 @for d in $(LIBSUBDIRS); \
887 a=$(srcdir)/Lib/$$d; \
888 if test ! -d $$a; then continue; else true; fi; \
889 if test `ls $$a | wc -l` -lt 1; then continue; fi; \
899 if test -d $$i; then continue; fi; \
900 if test -x $$i; then \
901 echo $(INSTALL_SCRIPT) $$i $$b; \
902 $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
904 echo $(INSTALL_DATA) $$i $$b; \
905 $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
910 $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
911 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
912 ./$(BUILDPYTHON) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
914 -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
916 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
917 ./$(BUILDPYTHON) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
919 -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
921 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
922 ./$(BUILDPYTHON) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
923 -d $(LIBDEST)/site-packages -f \
924 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
925 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
926 ./$(BUILDPYTHON) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
927 -d $(LIBDEST)/site-packages -f \
928 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
929 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
930 ./$(BUILDPYTHON) -Wi -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
932 # Create the PLATDIR source directory, if one wasn't distributed..
933 $(srcdir)/Lib/$(PLATDIR):
934 mkdir $(srcdir)/Lib/$(PLATDIR)
935 cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
936 export PATH; PATH="`pwd`:$$PATH"; \
937 export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
938 export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
939 export EXE; EXE="$(BUILDEXE)"; \
940 cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
942 # Install the include files
943 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
945 @for i in $(INCLDIRSTOMAKE); \
947 if test ! -d $(DESTDIR)$$i; then \
948 echo "Creating directory $$i"; \
949 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
953 @for i in $(srcdir)/Include/*.h; \
955 echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
956 $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
958 $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
960 # Install the library and miscellaneous stuff needed for extending/embedding
961 # This goes into $(exec_prefix)
962 LIBPL= $(LIBP)/config
964 # pkgconfig directory
965 LIBPC= $(LIBDIR)/pkgconfig
968 @for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
970 if test ! -d $(DESTDIR)$$i; then \
971 echo "Creating directory $$i"; \
972 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
976 @if test -d $(LIBRARY); then :; else \
977 if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
978 if test "$(SO)" = .dll; then \
979 $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
981 $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
982 $(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
985 echo Skip install of $(LIBRARY) - use make frameworkinstall; \
988 $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
989 $(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
990 $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
991 $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
992 $(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
993 $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
994 $(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
995 $(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
996 $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
997 $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
998 # Substitution happens here, as the completely-expanded BINDIR
999 # is not available in configure
1000 sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
1001 $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
1003 @if [ -s Modules/python.exp -a \
1004 "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
1005 echo; echo "Installing support files for building shared extension modules on AIX:"; \
1006 $(INSTALL_DATA) Modules/python.exp \
1007 $(DESTDIR)$(LIBPL)/python.exp; \
1008 echo; echo "$(LIBPL)/python.exp"; \
1009 $(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix \
1010 $(DESTDIR)$(LIBPL)/makexp_aix; \
1011 echo "$(LIBPL)/makexp_aix"; \
1012 $(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix \
1013 $(DESTDIR)$(LIBPL)/ld_so_aix; \
1014 echo "$(LIBPL)/ld_so_aix"; \
1015 echo; echo "See Misc/AIX-NOTES for details."; \
1019 # Install the dynamically loadable modules
1020 # This goes into $(exec_prefix)
1022 $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
1023 --prefix=$(prefix) \
1024 --install-scripts=$(BINDIR) \
1025 --install-platlib=$(DESTSHARED) \
1028 # Here are a couple of targets for MacOSX again, to install a full
1029 # framework-based Python. frameworkinstall installs everything, the
1030 # subtargets install specific parts. Much of the actual work is offloaded to
1031 # the Makefile in Mac
1034 # This target is here for backward compatiblity, previous versions of Python
1035 # hadn't integrated framework installation in the normal install process.
1036 frameworkinstall: install
1038 # On install, we re-make the framework
1039 # structure in the install location, /Library/Frameworks/ or the argument to
1040 # --enable-framework. If --enable-framework has been specified then we have
1041 # automatically set prefix to the location deep down in the framework, so we
1042 # only have to cater for the structural bits of the framework.
1044 frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
1046 frameworkinstallstructure: $(LDLIBRARY)
1047 @if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1048 echo Not configured with --enable-framework; \
1052 @for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1053 if test ! -d $(DESTDIR)$$i; then \
1054 echo "Creating directory $(DESTDIR)$$i"; \
1055 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1059 $(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
1060 sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1061 $(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
1062 $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1063 $(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
1064 $(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1065 $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1067 # This installs Mac/Lib into the framework
1068 # Install a number of symlinks to keep software that expects a normal unix
1069 # install (which includes python-config) happy.
1070 frameworkinstallmaclib:
1071 ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1072 ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).dylib"
1073 ln -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
1075 # This installs the IDE, the Launcher and other apps into /Applications
1076 frameworkinstallapps:
1077 cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
1079 frameworkinstallapps4way:
1080 cd Mac && $(MAKE) installapps4way DESTDIR="$(DESTDIR)"
1082 # This install the unix python and pythonw tools in /usr/local/bin
1083 frameworkinstallunixtools:
1084 cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
1086 frameworkinstallunixtools4way:
1087 cd Mac && $(MAKE) installunixtools4way DESTDIR="$(DESTDIR)"
1089 frameworkaltinstallunixtools:
1090 cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1092 frameworkaltinstallunixtools4way:
1093 cd Mac && $(MAKE) altinstallunixtools4way DESTDIR="$(DESTDIR)"
1095 # This installs the Demos and Tools into the applications directory.
1096 # It is not part of a normal frameworkinstall
1097 frameworkinstallextras:
1098 cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
1100 # This installs a few of the useful scripts in Tools/scripts
1102 SRCDIR=$(srcdir) $(RUNSHARED) \
1103 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
1104 --prefix=$(prefix) \
1105 --install-scripts=$(BINDIR) \
1108 # Build the toplevel Makefile
1109 Makefile.pre: Makefile.pre.in config.status
1110 CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
1111 $(MAKE) -f Makefile.pre Makefile
1113 # Run the configure script.
1114 config.status: $(srcdir)/configure
1115 $(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1117 .PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1119 # Some make's put the object file in the current directory
1121 $(CC) -c $(PY_CFLAGS) -o $@ $<
1123 # Run reindent on the library
1125 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
1127 # Rerun configure with the same options as it was run last time,
1128 # provided the config.status script exists
1130 $(SHELL) config.status --recheck
1131 $(SHELL) config.status
1133 # Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
1135 (cd $(srcdir); autoconf)
1136 (cd $(srcdir); autoheader)
1138 # Create a tags file for vi
1141 ctags -w -t Include/*.h; \
1142 for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \
1146 # Create a tags file for GNU Emacs
1149 etags Include/*.h; \
1150 for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
1152 # Sanitation targets -- clean leaves libraries, executables and tags
1153 # files, which clobber removes as well
1155 find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1158 -rm -f *BAD *GOOD *SKIPPED
1162 -rm -f gb-18030-2000.xml
1166 -rm -rf Doc/tools/sphinx Doc/tools/pygments Doc/tools/docutils
1169 find . -name '*.o' -exec rm -f {} ';'
1170 find . -name '*.s[ol]' -exec rm -f {} ';'
1171 find build -name 'fficonfig.h' -exec rm -f {} ';' || true
1172 find build -name 'fficonfig.py' -exec rm -f {} ';' || true
1173 -rm -f Lib/lib2to3/*Grammar*.pickle
1176 find . -name '*.gc??' -exec rm -f {} ';'
1178 clobber: clean profile-removal
1179 -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1181 config.cache config.log pyconfig.h Modules/config.c
1182 -rm -rf build platform
1183 -rm -rf $(PYTHONFRAMEWORKDIR)
1185 # Make things extra clean, before making a distribution:
1186 # remove all generated files, even Makefile[.pre]
1187 # Keep configure and Python-ast.[ch], it's possible they can't be generated
1189 -rm -f core Makefile Makefile.pre config.status \
1190 Modules/Setup Modules/Setup.local Modules/Setup.config \
1192 find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
1193 -o -name '[@,#]*' -o -name '*.old' \
1194 -o -name '*.orig' -o -name '*.rej' \
1195 -o -name '*.bak' ')' \
1198 # Check for smelly exported symbols (not starting with Py/_Py)
1200 nm -p $(LIBRARY) | \
1201 sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
1203 # Find files with funny names
1208 -o -name '*.[chs]' \
1221 -o -name '*.decTest' \
1222 -o -name '*,[vpt]' \
1224 -o -name 'Setup.*' \
1228 -o -name ChangeLog \
1229 -o -name Repository \
1235 -o -name .cvsignore \
1239 # Perform some verification checks on any modified files.
1241 $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1245 Python/thread.o: @THREADHEADERS@
1247 # Declare targets that aren't real files
1248 .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1249 .PHONY: install altinstall oldsharedinstall bininstall altbininstall
1250 .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1251 .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
1252 .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1253 .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1254 .PHONY: smelly funny patchcheck
1256 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY