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) $(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
92 BINDIR= $(exec_prefix)/bin
93 LIBDIR= $(exec_prefix)/lib
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@
177 UNICODE_OBJS= @UNICODE_OBJS@
180 BUILDPYTHON= python$(BUILDEXE)
182 # The task to run while instrument when building the profile-opt target
183 PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
184 #PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py
186 # === Definitions added by makesetup ===
189 ##########################################################################
197 # Used of signalmodule.o is not available
198 SIGNAL_OBJS= @SIGNAL_OBJS@
201 ##########################################################################
203 GRAMMAR_H= $(srcdir)/Include/graminit.h
204 GRAMMAR_C= $(srcdir)/Python/graminit.c
205 GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
208 ##########################################################################
210 PGEN= Parser/pgen$(EXE)
220 Parser/metagrammar.o \
225 PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/tokenizer.o
229 Python/mysnprintf.o \
230 Parser/tokenizer_pgen.o \
231 Parser/printgrammar.o \
238 PGENOBJS= $(PGENMAIN) $(POBJS) $(PGOBJS)
240 ##########################################################################
242 AST_H_DIR= $(srcdir)/Include
243 AST_H= $(AST_H_DIR)/Python-ast.h
244 AST_C_DIR= $(srcdir)/Python
245 AST_C= $(AST_C_DIR)/Python-ast.c
246 AST_ASDL= $(srcdir)/Parser/Python.asdl
248 ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
249 # XXX Note that a build now requires Python exist before the build starts
250 ASDLGEN= $(srcdir)/Parser/asdl_c.py
252 ##########################################################################
256 Python/Python-ast.o \
259 Python/bltinmodule.o \
265 Python/frozenmain.o \
268 Python/getcompiler.o \
269 Python/getcopyright.o \
270 Python/getplatform.o \
271 Python/getversion.o \
276 Python/modsupport.o \
278 Python/mysnprintf.o \
286 Python/structmember.o \
293 Python/formatter_unicode.o \
294 Python/formatter_string.o \
295 Python/$(DYNLOADFILE) \
301 ##########################################################################
305 Objects/boolobject.o \
306 Objects/bufferobject.o \
307 Objects/bytes_methods.o \
308 Objects/bytearrayobject.o \
309 Objects/cellobject.o \
310 Objects/classobject.o \
312 Objects/codeobject.o \
313 Objects/complexobject.o \
314 Objects/descrobject.o \
315 Objects/enumobject.o \
316 Objects/exceptions.o \
317 Objects/genobject.o \
318 Objects/fileobject.o \
319 Objects/floatobject.o \
320 Objects/frameobject.o \
321 Objects/funcobject.o \
322 Objects/intobject.o \
323 Objects/iterobject.o \
324 Objects/listobject.o \
325 Objects/longobject.o \
326 Objects/dictobject.o \
327 Objects/memoryobject.o \
328 Objects/methodobject.o \
329 Objects/moduleobject.o \
332 Objects/rangeobject.o \
333 Objects/setobject.o \
334 Objects/sliceobject.o \
335 Objects/stringobject.o \
336 Objects/structseq.o \
337 Objects/tupleobject.o \
338 Objects/typeobject.o \
339 Objects/weakrefobject.o \
343 ##########################################################################
344 # objects that get linked into the Python library
346 Modules/getbuildinfo.o \
354 #########################################################################
359 build_all: $(BUILDPYTHON) oldsharedmods sharedmods
361 # Compile a binary with gcc profile guided optimization.
363 @echo "Building with support for profile generation:"
365 $(MAKE) build_all_generate_profile
366 @echo "Running benchmark to generate profile data:"
367 $(MAKE) profile-removal
368 $(MAKE) run_profile_task
369 @echo "Rebuilding with profile guided optimizations:"
371 $(MAKE) build_all_use_profile
373 build_all_generate_profile:
374 $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"
377 ./$(BUILDPYTHON) $(PROFILE_TASK)
379 build_all_use_profile:
380 $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"
383 @echo "Building with support for coverage checking:"
385 $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
388 # Build the interpreter
389 $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
390 $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
392 $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
394 platform: $(BUILDPYTHON)
395 $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
398 # Build the shared modules
399 sharedmods: $(BUILDPYTHON)
400 @case $$MAKEFLAGS in \
401 *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
402 *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
405 # Build static library
406 # avoid long command lines, same as LIBRARY_OBJS
407 $(LIBRARY): $(LIBRARY_OBJS)
409 $(AR) $(ARFLAGS) $@ Modules/getbuildinfo.o
410 $(AR) $(ARFLAGS) $@ $(PARSER_OBJS)
411 $(AR) $(ARFLAGS) $@ $(OBJECT_OBJS)
412 $(AR) $(ARFLAGS) $@ $(PYTHON_OBJS)
413 $(AR) $(ARFLAGS) $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
414 $(AR) $(ARFLAGS) $@ $(MODOBJS)
417 libpython$(VERSION).so: $(LIBRARY_OBJS)
418 if test $(INSTSONAME) != $(LDLIBRARY); then \
419 $(LDSHARED) $(LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
420 $(LN) -f $(INSTSONAME) $@; \
422 $(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
425 libpython$(VERSION).dylib: $(LIBRARY_OBJS)
426 $(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); \
429 libpython$(VERSION).sl: $(LIBRARY_OBJS)
430 $(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST)
432 # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
433 # minimal framework (not including the Lib directory and such) in the current
435 RESSRCDIR=Mac/Resources/framework
436 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
438 $(RESSRCDIR)/Info.plist
439 $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
440 if test "${UNIVERSALSDK}"; then \
441 $(CC) -o $(LDLIBRARY) @UNIVERSAL_ARCH_FLAGS@ -dynamiclib \
442 -isysroot "${UNIVERSALSDK}" \
443 -all_load $(LIBRARY) -Wl,-single_module \
444 -install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
445 -compatibility_version $(VERSION) \
446 -current_version $(VERSION); \
448 /usr/bin/libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
451 $(INSTALL) -d -m $(DIRMODE) \
452 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
453 $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
454 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
455 $(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
456 $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
457 $(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
458 $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
460 # This rule builds the Cygwin Python DLL and import library if configured
461 # for a shared core library; otherwise, this rule is a noop.
462 $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
463 if test -n "$(DLLLIBRARY)"; then \
464 $(LDSHARED) $(LDFLAGS) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
465 $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
470 oldsharedmods: $(SHAREDMODS)
473 Makefile Modules/config.c: Makefile.pre \
474 $(srcdir)/Modules/config.c.in \
476 Modules/Setup.config \
479 $(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
481 Modules/Setup.config \
482 Modules/Setup.local \
485 @echo "The Makefile was updated, you may need to re-run make."
488 Modules/Setup: $(srcdir)/Modules/Setup.dist
489 @if test -f Modules/Setup; then \
490 echo "-----------------------------------------------"; \
491 echo "Modules/Setup.dist is newer than Modules/Setup;"; \
492 echo "check to make sure you have all the updates you"; \
493 echo "need in your Modules/Setup file."; \
494 echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
495 echo "-----------------------------------------------"; \
498 ############################################################################
499 # Special rules for object files
501 Modules/getbuildinfo.o: $(PARSER_OBJS) \
507 $(srcdir)/Modules/getbuildinfo.c
508 $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
510 Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
511 $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
512 -DPREFIX='"$(prefix)"' \
513 -DEXEC_PREFIX='"$(exec_prefix)"' \
514 -DVERSION='"$(VERSION)"' \
515 -DVPATH='"$(VPATH)"' \
516 -o $@ $(srcdir)/Modules/getpath.c
518 Modules/python.o: $(srcdir)/Modules/python.c
519 $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
522 $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
523 -@$(INSTALL) -d Include
524 -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
527 $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
529 Parser/grammar.o: $(srcdir)/Parser/grammar.c \
530 $(srcdir)/Include/token.h \
531 $(srcdir)/Include/grammar.h
532 Parser/metagrammar.o: $(srcdir)/Parser/metagrammar.c
534 Parser/tokenizer_pgen.o: $(srcdir)/Parser/tokenizer.c
536 Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
538 $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
539 $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
541 $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
542 $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
544 Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H)
546 Python/getplatform.o: $(srcdir)/Python/getplatform.c
547 $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
549 Python/importdl.o: $(srcdir)/Python/importdl.c
550 $(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
552 Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \
553 $(srcdir)/Objects/unicodetype_db.h
556 $(srcdir)/Include/bytes_methods.h \
557 $(srcdir)/Objects/stringlib/count.h \
558 $(srcdir)/Objects/stringlib/ctype.h \
559 $(srcdir)/Objects/stringlib/fastsearch.h \
560 $(srcdir)/Objects/stringlib/find.h \
561 $(srcdir)/Objects/stringlib/formatter.h \
562 $(srcdir)/Objects/stringlib/partition.h \
563 $(srcdir)/Objects/stringlib/stringdefs.h \
564 $(srcdir)/Objects/stringlib/string_format.h \
565 $(srcdir)/Objects/stringlib/transmogrify.h \
566 $(srcdir)/Objects/stringlib/unicodedefs.h \
567 $(srcdir)/Objects/stringlib/localeutil.h
569 Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
572 Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c \
575 Objects/stringobject.o: $(srcdir)/Objects/stringobject.c \
578 Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
581 Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
584 ############################################################################
588 Include/Python-ast.h \
594 Include/boolobject.h \
595 Include/bytearrayobject.h \
596 Include/bytes_methods.h \
597 Include/bytesobject.h \
598 Include/bufferobject.h \
599 Include/cellobject.h \
601 Include/classobject.h \
606 Include/complexobject.h \
607 Include/descrobject.h \
608 Include/dictobject.h \
609 Include/enumobject.h \
612 Include/fileobject.h \
613 Include/floatobject.h \
614 Include/frameobject.h \
615 Include/funcobject.h \
616 Include/genobject.h \
618 Include/intobject.h \
619 Include/intrcheck.h \
620 Include/iterobject.h \
621 Include/listobject.h \
622 Include/longintrepr.h \
623 Include/longobject.h \
625 Include/memoryobject.h \
626 Include/metagrammar.h \
627 Include/methodobject.h \
628 Include/modsupport.h \
629 Include/moduleobject.h \
636 Include/patchlevel.h \
638 Include/pgenheaders.h \
651 Include/pythonrun.h \
653 Include/rangeobject.h \
654 Include/setobject.h \
655 Include/sliceobject.h \
656 Include/stringobject.h \
657 Include/structmember.h \
658 Include/structseq.h \
660 Include/sysmodule.h \
661 Include/traceback.h \
662 Include/tupleobject.h \
664 Include/unicodeobject.h \
666 Include/weakrefobject.h \
670 $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
673 ######################################################################
675 # Test the interpreter (twice, once without .pyc files, once with)
676 # In the past, we've had problems where bugs in the marshalling or
677 # elsewhere caused bytecode read from .pyc files to behave differently
678 # than bytecode generated directly from a .py source file. Sometimes
679 # the bytecode read from a .pyc file had the bug, somtimes the directly
680 # generated bytecode. This is sometimes a very shy bug needing a lot of
683 TESTOPTS= -l $(EXTRATESTOPTS)
684 TESTPROG= $(srcdir)/Lib/test/regrtest.py
685 TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -tt
687 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
688 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
689 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
691 testall: all platform
692 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
693 $(TESTPYTHON) $(srcdir)/Lib/compileall.py
694 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
695 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
696 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
698 # Run the unitests for both architectures in a Universal build on OSX
699 # Must be run on an Intel box.
700 testuniversal: all platform
701 if [ `arch` != 'i386' ];then \
702 echo "This can only be used on OSX/i386" ;\
705 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
706 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
707 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
708 $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) $(TESTOPTS) -uall
711 # Like testall, but with a single pass only
712 # run an optional script to include some information about the build environment
713 buildbottest: all platform
714 -@if which pybuildbot.identify >/dev/null 2>&1; then \
715 pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
717 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw
719 QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \
720 test_multibytecodec test_urllib2_localnet test_itertools \
721 test_multiprocessing test_mailbox test_socket test_poll \
722 test_select test_zipfile
723 quicktest: all platform
724 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
725 -$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
726 $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
728 MEMTESTOPTS= $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
730 memtest: all platform
731 -rm -f $(srcdir)/Lib/test/*.py[co]
732 -$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
733 $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
736 install: @FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@
738 # Install almost everything without disturbing previous versions
739 altinstall: @FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \
740 sharedinstall oldsharedinstall @FRAMEWORKALTINSTALLLAST@
742 # Install shared libraries enabled by Setup
743 DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
745 oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
746 @for i in X $(SHAREDMODS); do \
747 if test $$i != X; then \
748 echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
749 $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
754 @for i in $(DESTDIRS); \
756 if test ! -d $(DESTDIR)$$i; then \
757 echo "Creating directory $$i"; \
758 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
764 # Install the interpreter (by creating a hard link to python$(VERSION))
765 bininstall: altbininstall
766 -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
767 then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
770 (cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
771 -rm -f $(DESTDIR)$(BINDIR)/python-config
772 (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config)
774 # Install the interpreter with $(VERSION) affixed
775 # This goes into $(exec_prefix)
776 altbininstall: $(BUILDPYTHON)
777 @for i in $(BINDIR) $(LIBDIR); \
779 if test ! -d $(DESTDIR)$$i; then \
780 echo "Creating directory $$i"; \
781 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
785 $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
786 if test -f $(LDLIBRARY); then \
787 if test -n "$(DLLLIBRARY)" ; then \
788 $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
790 $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
791 if test $(LDLIBRARY) != $(INSTSONAME); then \
792 (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
798 # Install the manual page
800 @for i in $(MANDIR) $(MANDIR)/man1; \
802 if test ! -d $(DESTDIR)$$i; then \
803 echo "Creating directory $$i"; \
804 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
808 $(INSTALL_DATA) $(srcdir)/Misc/python.man \
809 $(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
811 # Install the library
812 PLATDIR= plat-$(MACHDEP)
813 EXTRAPLATDIR= @EXTRAPLATDIR@
814 EXTRAMACHDEPPATH=@EXTRAMACHDEPPATH@
815 MACHDEPS= $(PLATDIR) $(EXTRAPLATDIR)
816 XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
817 PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
818 plat-mac/lib-scriptpackages/_builtinSuites \
819 plat-mac/lib-scriptpackages/CodeWarrior \
820 plat-mac/lib-scriptpackages/Explorer \
821 plat-mac/lib-scriptpackages/Finder \
822 plat-mac/lib-scriptpackages/Netscape \
823 plat-mac/lib-scriptpackages/StdSuites \
824 plat-mac/lib-scriptpackages/SystemEvents \
825 plat-mac/lib-scriptpackages/Terminal
826 PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
827 LIBSUBDIRS= lib-tk site-packages test test/output test/data \
828 test/decimaltestdata \
829 encodings compiler hotshot \
830 email email/mime email/test email/test/data \
832 sqlite3 sqlite3/test \
833 logging bsddb bsddb/test csv importlib wsgiref \
834 lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
835 lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
836 ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
837 distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
838 multiprocessing multiprocessing/dummy \
840 curses pydoc_data $(MACHDEPS)
841 libinstall: build_all $(srcdir)/Lib/$(PLATDIR)
842 @for i in $(SCRIPTDIR) $(LIBDEST); \
844 if test ! -d $(DESTDIR)$$i; then \
845 echo "Creating directory $$i"; \
846 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
850 @for d in $(LIBSUBDIRS); \
852 a=$(srcdir)/Lib/$$d; \
853 if test ! -d $$a; then continue; else true; fi; \
855 if test ! -d $(DESTDIR)$$b; then \
856 echo "Creating directory $$b"; \
857 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
861 @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
863 if test -x $$i; then \
864 $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
865 echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
867 $(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
868 echo $(INSTALL_DATA) $$i $(LIBDEST); \
871 @for d in $(LIBSUBDIRS); \
873 a=$(srcdir)/Lib/$$d; \
874 if test ! -d $$a; then continue; else true; fi; \
875 if test `ls $$a | wc -l` -lt 1; then continue; fi; \
885 if test -d $$i; then continue; fi; \
886 if test -x $$i; then \
887 echo $(INSTALL_SCRIPT) $$i $$b; \
888 $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
890 echo $(INSTALL_DATA) $$i $$b; \
891 $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
896 $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
897 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
898 ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
900 -x 'bad_coding|badsyntax|site-packages|py3_test_grammar' \
902 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
903 ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
905 -x 'bad_coding|badsyntax|site-packages|py3_test_grammar' \
907 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
908 ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
909 -d $(LIBDEST)/site-packages -f \
910 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
911 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
912 ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
913 -d $(LIBDEST)/site-packages -f \
914 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
915 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
916 ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
918 # Create the PLATDIR source directory, if one wasn't distributed..
919 $(srcdir)/Lib/$(PLATDIR):
920 mkdir $(srcdir)/Lib/$(PLATDIR)
921 cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
922 export PATH; PATH="`pwd`:$$PATH"; \
923 export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
924 export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
925 export EXE; EXE="$(BUILDEXE)"; \
926 cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
928 # Install the include files
929 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
931 @for i in $(INCLDIRSTOMAKE); \
933 if test ! -d $(DESTDIR)$$i; then \
934 echo "Creating directory $$i"; \
935 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
939 @for i in $(srcdir)/Include/*.h; \
941 echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
942 $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
944 $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
946 # Install the library and miscellaneous stuff needed for extending/embedding
947 # This goes into $(exec_prefix)
948 LIBPL= $(LIBP)/config
950 @for i in $(LIBDIR) $(LIBP) $(LIBPL); \
952 if test ! -d $(DESTDIR)$$i; then \
953 echo "Creating directory $$i"; \
954 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
958 @if test -d $(LIBRARY); then :; else \
959 if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
960 if test "$(SO)" = .dll; then \
961 $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
963 $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
964 $(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
967 echo Skip install of $(LIBRARY) - use make frameworkinstall; \
970 $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
971 $(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
972 $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
973 $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
974 $(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
975 $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
976 $(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
977 $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
978 $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
979 # Substitution happens here, as the completely-expanded BINDIR
980 # is not available in configure
981 sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
982 $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
984 @if [ -s Modules/python.exp -a \
985 "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
986 echo; echo "Installing support files for building shared extension modules on AIX:"; \
987 $(INSTALL_DATA) Modules/python.exp \
988 $(DESTDIR)$(LIBPL)/python.exp; \
989 echo; echo "$(LIBPL)/python.exp"; \
990 $(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix \
991 $(DESTDIR)$(LIBPL)/makexp_aix; \
992 echo "$(LIBPL)/makexp_aix"; \
993 $(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix \
994 $(DESTDIR)$(LIBPL)/ld_so_aix; \
995 echo "$(LIBPL)/ld_so_aix"; \
996 echo; echo "See Misc/AIX-NOTES for details."; \
999 @case "$(MACHDEP)" in beos*) \
1000 echo; echo "Installing support files for building shared extension modules on BeOS:"; \
1001 $(INSTALL_DATA) Misc/BeOS-NOTES $(DESTDIR)$(LIBPL)/README; \
1002 echo; echo "$(LIBPL)/README"; \
1003 $(INSTALL_SCRIPT) Modules/ar_beos $(DESTDIR)$(LIBPL)/ar_beos; \
1004 echo "$(LIBPL)/ar_beos"; \
1005 $(INSTALL_SCRIPT) Modules/ld_so_beos $(DESTDIR)$(LIBPL)/ld_so_beos; \
1006 echo "$(LIBPL)/ld_so_beos"; \
1007 echo; echo "See Misc/BeOS-NOTES for details."; \
1011 # Install the dynamically loadable modules
1012 # This goes into $(exec_prefix)
1014 $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
1015 --prefix=$(prefix) \
1016 --install-scripts=$(BINDIR) \
1017 --install-platlib=$(DESTSHARED) \
1020 # Here are a couple of targets for MacOSX again, to install a full
1021 # framework-based Python. frameworkinstall installs everything, the
1022 # subtargets install specific parts. Much of the actual work is offloaded to
1023 # the Makefile in Mac
1026 # This target is here for backward compatiblity, previous versions of Python
1027 # hadn't integrated framework installation in the normal install process.
1028 frameworkinstall: install
1030 # On install, we re-make the framework
1031 # structure in the install location, /Library/Frameworks/ or the argument to
1032 # --enable-framework. If --enable-framework has been specified then we have
1033 # automatically set prefix to the location deep down in the framework, so we
1034 # only have to cater for the structural bits of the framework.
1036 frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
1038 frameworkinstallstructure: $(LDLIBRARY)
1039 @if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1040 echo Not configured with --enable-framework; \
1044 @for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1045 if test ! -d $(DESTDIR)$$i; then \
1046 echo "Creating directory $(DESTDIR)$$i"; \
1047 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1051 $(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
1052 sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1053 $(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
1054 $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1055 $(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
1056 $(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1057 $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1059 # This installs Mac/Lib into the framework
1060 # Install a number of symlinks to keep software that expects a normal unix
1061 # install (which includes python-config) happy.
1062 frameworkinstallmaclib:
1063 ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1064 cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
1066 # This installs the IDE, the Launcher and other apps into /Applications
1067 frameworkinstallapps:
1068 cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
1070 frameworkinstallapps4way:
1071 cd Mac && $(MAKE) installapps4way DESTDIR="$(DESTDIR)"
1073 # This install the unix python and pythonw tools in /usr/local/bin
1074 frameworkinstallunixtools:
1075 cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
1077 frameworkinstallunixtools4way:
1078 cd Mac && $(MAKE) installunixtools4way DESTDIR="$(DESTDIR)"
1080 frameworkaltinstallunixtools:
1081 cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1083 frameworkaltinstallunixtools4way:
1084 cd Mac && $(MAKE) altinstallunixtools4way DESTDIR="$(DESTDIR)"
1086 # This installs the Demos and Tools into the applications directory.
1087 # It is not part of a normal frameworkinstall
1088 frameworkinstallextras:
1089 cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
1091 # This installs a few of the useful scripts in Tools/scripts
1093 SRCDIR=$(srcdir) $(RUNSHARED) \
1094 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
1095 --prefix=$(prefix) \
1096 --install-scripts=$(BINDIR) \
1099 # Build the toplevel Makefile
1100 Makefile.pre: Makefile.pre.in config.status
1101 CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
1102 $(MAKE) -f Makefile.pre Makefile
1104 # Run the configure script.
1105 config.status: $(srcdir)/configure
1106 $(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1108 .PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1110 # Some make's put the object file in the current directory
1112 $(CC) -c $(PY_CFLAGS) -o $@ $<
1114 # Run reindent on the library
1116 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
1118 # Rerun configure with the same options as it was run last time,
1119 # provided the config.status script exists
1121 $(SHELL) config.status --recheck
1122 $(SHELL) config.status
1124 # Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
1126 (cd $(srcdir); autoconf)
1127 (cd $(srcdir); autoheader)
1129 # Create a tags file for vi
1132 ctags -w -t Include/*.h; \
1133 for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \
1137 # Create a tags file for GNU Emacs
1140 etags Include/*.h; \
1141 for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
1143 # Sanitation targets -- clean leaves libraries, executables and tags
1144 # files, which clobber removes those as well
1146 find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1149 find . -name '*.o' -exec rm -f {} ';'
1150 find . -name '*.s[ol]' -exec rm -f {} ';'
1151 find build -name 'fficonfig.h' -exec rm -f {} ';' || true
1152 find build -name 'fficonfig.py' -exec rm -f {} ';' || true
1155 find . -name '*.gc??' -exec rm -f {} ';'
1157 clobber: clean profile-removal
1158 -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1160 config.cache config.log pyconfig.h Modules/config.c
1161 -rm -rf build platform
1162 -rm -rf $(PYTHONFRAMEWORKDIR)
1164 # Make things extra clean, before making a distribution:
1165 # remove all generated files, even Makefile[.pre]
1166 # Keep configure and Python-ast.[ch], it's possible they can't be generated
1168 -rm -f core Makefile Makefile.pre config.status \
1169 Modules/Setup Modules/Setup.local Modules/Setup.config
1170 find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
1171 -o -name '[@,#]*' -o -name '*.old' \
1172 -o -name '*.orig' -o -name '*.rej' \
1173 -o -name '*.bak' ')' \
1176 # Check for smelly exported symbols (not starting with Py/_Py)
1178 nm -p $(LIBRARY) | \
1179 sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
1181 # Find files with funny names
1183 find $(DISTDIRS) -type d \
1184 -o -name '*.[chs]' \
1194 -o -name '*,[vpt]' \
1196 -o -name 'Setup.*' \
1199 -o -name ChangeLog \
1200 -o -name Repository \
1206 -o -name .cvsignore \
1210 # Perform some verification checks on any modified files.
1212 $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1216 Python/thread.o: @THREADHEADERS@
1218 # Declare targets that aren't real files
1219 .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1220 .PHONY: install altinstall oldsharedinstall bininstall altbininstall
1221 .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1222 .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
1223 .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1224 .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1225 .PHONY: smelly funny patchcheck
1227 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY