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@
39 # Shell used by make (some versions default to the login shell, which is bad)
42 # Use this to make a link between python$(VERSION) and python in $(BINDIR)
45 # Portable install script (configure doesn't always guess right)
47 INSTALL_PROGRAM=@INSTALL_PROGRAM@
48 INSTALL_SCRIPT= @INSTALL_SCRIPT@
49 INSTALL_DATA= @INSTALL_DATA@
50 # Shared libraries must be installed with executable mode on some systems;
51 # rather than figuring out exactly which, we always give them executable mode.
52 # Also, making them read-only seems to be a good idea...
53 INSTALL_SHARED= ${INSTALL} -m 555
55 MAKESETUP= $(srcdir)/Modules/makesetup
59 BASECFLAGS= @BASECFLAGS@
60 CFLAGS= $(BASECFLAGS) $(OPT) $(EXTRA_CFLAGS)
61 # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
62 # be able to build extension modules using the directories specified in the
63 # environment variables
64 CPPFLAGS= -I. -IInclude -I$(srcdir)/Include @CPPFLAGS@
69 LINKFORSHARED= @LINKFORSHARED@
70 # Extra C flags added for building the interpreter object files.
71 CFLAGSFORSHARED=@CFLAGSFORSHARED@
72 # C flags used for building the interpreter object files
73 PY_CFLAGS= $(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
76 # Machine-dependent subdirectories
79 # Install prefix for architecture-independent files
82 # Install prefix for architecture-dependent files
83 exec_prefix= @exec_prefix@
85 # Install prefix for data files
86 datarootdir= @datarootdir@
88 # Expanded directories
89 BINDIR= $(exec_prefix)/bin
90 LIBDIR= $(exec_prefix)/lib
92 INCLUDEDIR= @includedir@
93 CONFINCLUDEDIR= $(exec_prefix)/include
94 SCRIPTDIR= $(prefix)/lib
96 # Detailed destination directories
97 BINLIBDEST= $(LIBDIR)/python$(VERSION)
98 LIBDEST= $(SCRIPTDIR)/python$(VERSION)
99 INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
100 CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(VERSION)
101 LIBP= $(LIBDIR)/python$(VERSION)
103 # Symbols used for using shared libraries
106 BLDSHARED= @BLDSHARED@
107 DESTSHARED= $(BINLIBDEST)/lib-dynload
109 # Executable suffix (.exe on Windows and Mac OS X)
111 BUILDEXE= @BUILDEXEEXT@
113 # Short name and location for Mac OS X Python framework
114 UNIVERSALSDK=@UNIVERSALSDK@
115 PYTHONFRAMEWORK= @PYTHONFRAMEWORK@
116 PYTHONFRAMEWORKDIR= @PYTHONFRAMEWORKDIR@
117 PYTHONFRAMEWORKPREFIX= @PYTHONFRAMEWORKPREFIX@
118 PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
119 # Deployment target selected during configure, to be checked
120 # by distutils. The export statement is needed to ensure that the
121 # deployment target is active during build.
122 MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
123 @EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
125 # Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
126 OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@
128 # Environment to run shared python without installed libraries
129 RUNSHARED= @RUNSHARED@
131 # Modes for directories, executables and data files created by the
132 # install process. Default to user-only-writable for all file types.
137 # configure script arguments
138 CONFIG_ARGS= @CONFIG_ARGS@
141 # Subdirectories with code
144 # Other subdirectories
145 SUBDIRSTOO= Include Lib Misc Demo
147 # Files and directories to be distributed
148 CONFIGFILES= configure configure.in acconfig.h pyconfig.h.in Makefile.pre.in
149 DISTFILES= README ChangeLog $(CONFIGFILES)
150 DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
151 DIST= $(DISTFILES) $(DISTDIRS)
155 LDLIBRARY= @LDLIBRARY@
156 BLDLIBRARY= @BLDLIBRARY@
157 DLLLIBRARY= @DLLLIBRARY@
158 LDLIBRARYDIR= @LDLIBRARYDIR@
159 INSTSONAME= @INSTSONAME@
165 SYSLIBS= $(LIBM) $(LIBC)
168 THREADOBJ= @THREADOBJ@
169 DLINCLDIR= @DLINCLDIR@
170 DYNLOADFILE= @DYNLOADFILE@
171 MACHDEP_OBJS= @MACHDEP_OBJS@
174 UNICODE_OBJS= @UNICODE_OBJS@
177 BUILDPYTHON= python$(BUILDEXE)
179 # The task to run while instrument when building the profile-opt target
180 PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
181 #PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py
183 # === Definitions added by makesetup ===
186 ##########################################################################
194 # Used of signalmodule.o is not available
195 SIGNAL_OBJS= @SIGNAL_OBJS@
198 ##########################################################################
200 GRAMMAR_H= $(srcdir)/Include/graminit.h
201 GRAMMAR_C= $(srcdir)/Python/graminit.c
202 GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
205 ##########################################################################
207 PGEN= Parser/pgen$(EXE)
217 Parser/metagrammar.o \
222 PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/tokenizer.o
226 Python/mysnprintf.o \
227 Parser/tokenizer_pgen.o \
228 Parser/printgrammar.o \
235 PGENOBJS= $(PGENMAIN) $(POBJS) $(PGOBJS)
237 ##########################################################################
239 AST_H_DIR= $(srcdir)/Include
240 AST_H= $(AST_H_DIR)/Python-ast.h
241 AST_C_DIR= $(srcdir)/Python
242 AST_C= $(AST_C_DIR)/Python-ast.c
243 AST_ASDL= $(srcdir)/Parser/Python.asdl
245 ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
246 # XXX Note that a build now requires Python exist before the build starts
247 ASDLGEN= $(srcdir)/Parser/asdl_c.py
249 ##########################################################################
253 Python/Python-ast.o \
256 Python/bltinmodule.o \
262 Python/frozenmain.o \
265 Python/getcompiler.o \
266 Python/getcopyright.o \
267 Python/getplatform.o \
268 Python/getversion.o \
273 Python/modsupport.o \
275 Python/mysnprintf.o \
282 Python/structmember.o \
289 Python/formatter_unicode.o \
290 Python/formatter_string.o \
291 Python/$(DYNLOADFILE) \
297 ##########################################################################
301 Objects/boolobject.o \
302 Objects/bufferobject.o \
303 Objects/bytes_methods.o \
304 Objects/bytearrayobject.o \
305 Objects/cellobject.o \
306 Objects/classobject.o \
308 Objects/codeobject.o \
309 Objects/complexobject.o \
310 Objects/descrobject.o \
311 Objects/enumobject.o \
312 Objects/exceptions.o \
313 Objects/genobject.o \
314 Objects/fileobject.o \
315 Objects/floatobject.o \
316 Objects/frameobject.o \
317 Objects/funcobject.o \
318 Objects/intobject.o \
319 Objects/iterobject.o \
320 Objects/listobject.o \
321 Objects/longobject.o \
322 Objects/dictobject.o \
323 Objects/methodobject.o \
324 Objects/moduleobject.o \
327 Objects/rangeobject.o \
328 Objects/setobject.o \
329 Objects/sliceobject.o \
330 Objects/stringobject.o \
331 Objects/structseq.o \
332 Objects/tupleobject.o \
333 Objects/typeobject.o \
334 Objects/weakrefobject.o \
338 ##########################################################################
339 # objects that get linked into the Python library
341 Modules/getbuildinfo.o \
349 #########################################################################
354 build_all: $(BUILDPYTHON) oldsharedmods sharedmods
356 # Compile a binary with gcc profile guided optimization.
358 @echo "Building with support for profile generation:"
360 $(MAKE) build_all_generate_profile
361 @echo "Running benchmark to generate profile data:"
362 $(MAKE) profile-removal
363 $(MAKE) run_profile_task
364 @echo "Rebuilding with profile guided optimizations:"
366 $(MAKE) build_all_use_profile
368 build_all_generate_profile:
369 $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"
372 ./$(BUILDPYTHON) $(PROFILE_TASK)
374 build_all_use_profile:
375 $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"
378 @echo "Building with support for coverage checking:"
380 $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
383 # Build the interpreter
384 $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
385 $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
387 $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
389 platform: $(BUILDPYTHON)
390 $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
393 # Build the shared modules
394 sharedmods: $(BUILDPYTHON)
395 @case $$MAKEFLAGS in \
396 *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
397 *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
400 # Build static library
401 # avoid long command lines, same as LIBRARY_OBJS
402 $(LIBRARY): $(LIBRARY_OBJS)
404 $(AR) cr $@ Modules/getbuildinfo.o
405 $(AR) cr $@ $(PARSER_OBJS)
406 $(AR) cr $@ $(OBJECT_OBJS)
407 $(AR) cr $@ $(PYTHON_OBJS)
408 $(AR) cr $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
409 $(AR) cr $@ $(MODOBJS)
412 libpython$(VERSION).so: $(LIBRARY_OBJS)
413 if test $(INSTSONAME) != $(LDLIBRARY); then \
414 $(LDSHARED) $(LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
415 $(LN) -f $(INSTSONAME) $@; \
417 $(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
420 libpython$(VERSION).dylib: $(LIBRARY_OBJS)
421 $(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); \
424 libpython$(VERSION).sl: $(LIBRARY_OBJS)
425 $(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST)
427 # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
428 # minimal framework (not including the Lib directory and such) in the current
430 RESSRCDIR=Mac/Resources/framework
431 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
433 $(RESSRCDIR)/Info.plist
434 $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
435 if test "${UNIVERSALSDK}"; then \
436 $(CC) -o $(LDLIBRARY) @UNIVERSAL_ARCH_FLAGS@ -dynamiclib \
437 -isysroot "${UNIVERSALSDK}" \
438 -all_load $(LIBRARY) -Wl,-single_module \
439 -install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
440 -compatibility_version $(VERSION) \
441 -current_version $(VERSION); \
443 /usr/bin/libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
446 $(INSTALL) -d -m $(DIRMODE) \
447 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
448 $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
449 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
450 $(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
451 $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
452 $(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
453 $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
455 # This rule builds the Cygwin Python DLL and import library if configured
456 # for a shared core library; otherwise, this rule is a noop.
457 $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
458 if test -n "$(DLLLIBRARY)"; then \
459 $(LDSHARED) $(LDFLAGS) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
460 $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
465 oldsharedmods: $(SHAREDMODS)
468 Makefile Modules/config.c: Makefile.pre \
469 $(srcdir)/Modules/config.c.in \
471 Modules/Setup.config \
474 $(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
476 Modules/Setup.config \
477 Modules/Setup.local \
480 @echo "The Makefile was updated, you may need to re-run make."
483 Modules/Setup: $(srcdir)/Modules/Setup.dist
484 @if test -f Modules/Setup; then \
485 echo "-----------------------------------------------"; \
486 echo "Modules/Setup.dist is newer than Modules/Setup;"; \
487 echo "check to make sure you have all the updates you"; \
488 echo "need in your Modules/Setup file."; \
489 echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
490 echo "-----------------------------------------------"; \
493 ############################################################################
494 # Special rules for object files
496 Modules/getbuildinfo.o: $(PARSER_OBJS) \
502 $(srcdir)/Modules/getbuildinfo.c
503 $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
505 Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
506 $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
507 -DPREFIX='"$(prefix)"' \
508 -DEXEC_PREFIX='"$(exec_prefix)"' \
509 -DVERSION='"$(VERSION)"' \
510 -DVPATH='"$(VPATH)"' \
511 -o $@ $(srcdir)/Modules/getpath.c
513 Modules/python.o: $(srcdir)/Modules/python.c
514 $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
517 $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
518 -@$(INSTALL) -d Include
519 -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
522 $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
524 Parser/grammar.o: $(srcdir)/Parser/grammar.c \
525 $(srcdir)/Include/token.h \
526 $(srcdir)/Include/grammar.h
527 Parser/metagrammar.o: $(srcdir)/Parser/metagrammar.c
529 Parser/tokenizer_pgen.o: $(srcdir)/Parser/tokenizer.c
531 Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
533 $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
534 $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
536 $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
537 $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
539 Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H)
541 Python/getplatform.o: $(srcdir)/Python/getplatform.c
542 $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
544 Python/importdl.o: $(srcdir)/Python/importdl.c
545 $(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
547 Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \
548 $(srcdir)/Objects/unicodetype_db.h
551 $(srcdir)/Include/bytes_methods.h \
552 $(srcdir)/Objects/stringlib/count.h \
553 $(srcdir)/Objects/stringlib/ctype.h \
554 $(srcdir)/Objects/stringlib/fastsearch.h \
555 $(srcdir)/Objects/stringlib/find.h \
556 $(srcdir)/Objects/stringlib/formatter.h \
557 $(srcdir)/Objects/stringlib/partition.h \
558 $(srcdir)/Objects/stringlib/stringdefs.h \
559 $(srcdir)/Objects/stringlib/string_format.h \
560 $(srcdir)/Objects/stringlib/transmogrify.h \
561 $(srcdir)/Objects/stringlib/unicodedefs.h \
562 $(srcdir)/Objects/stringlib/localeutil.h
564 Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
567 Objects/stringobject.o: $(srcdir)/Objects/stringobject.c \
570 Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
573 Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
576 ############################################################################
580 Include/Python-ast.h \
586 Include/boolobject.h \
587 Include/bytes_methods.h \
588 Include/bytesobject.h \
589 Include/bufferobject.h \
590 Include/cellobject.h \
592 Include/classobject.h \
597 Include/complexobject.h \
598 Include/descrobject.h \
599 Include/dictobject.h \
600 Include/enumobject.h \
603 Include/fileobject.h \
604 Include/floatobject.h \
605 Include/frameobject.h \
606 Include/funcobject.h \
607 Include/genobject.h \
609 Include/intobject.h \
610 Include/intrcheck.h \
611 Include/iterobject.h \
612 Include/listobject.h \
613 Include/longintrepr.h \
614 Include/longobject.h \
616 Include/metagrammar.h \
617 Include/methodobject.h \
618 Include/modsupport.h \
619 Include/moduleobject.h \
626 Include/patchlevel.h \
628 Include/pgenheaders.h \
640 Include/pythonrun.h \
642 Include/rangeobject.h \
643 Include/setobject.h \
644 Include/sliceobject.h \
645 Include/stringobject.h \
646 Include/structmember.h \
647 Include/structseq.h \
649 Include/sysmodule.h \
650 Include/traceback.h \
651 Include/tupleobject.h \
653 Include/unicodeobject.h \
655 Include/weakrefobject.h \
659 $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
662 ######################################################################
664 # Test the interpreter (twice, once without .pyc files, once with)
665 # In the past, we've had problems where bugs in the marshalling or
666 # elsewhere caused bytecode read from .pyc files to behave differently
667 # than bytecode generated directly from a .py source file. Sometimes
668 # the bytecode read from a .pyc file had the bug, somtimes the directly
669 # generated bytecode. This is sometimes a very shy bug needing a lot of
672 TESTOPTS= -l $(EXTRATESTOPTS)
673 TESTPROG= $(srcdir)/Lib/test/regrtest.py
674 TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -tt
676 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
677 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
678 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
680 testall: all platform
681 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
682 $(TESTPYTHON) $(srcdir)/Lib/compileall.py
683 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
684 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
685 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
687 # Run the unitests for both architectures in a Universal build on OSX
688 # Must be run on an Intel box.
689 testuniversal: all platform
690 if [ `arch` != 'i386' ];then \
691 echo "This can only be used on OSX/i386" ;\
694 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
695 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
696 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
697 $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) $(TESTOPTS) -uall
700 # Like testall, but with a single pass only
701 # run an optional script to include some information about the build environment
702 buildbottest: all platform
703 -@if which pybuildbot.identify >/dev/null 2>&1; then \
704 pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
706 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw
708 QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \
709 test_unicodedata test_re test_sre test_select test_poll \
710 test_linuxaudiodev test_struct test_sunaudiodev test_zlib
711 quicktest: all platform
712 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
713 -$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
714 $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
716 MEMTESTOPTS= $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
718 memtest: all platform
719 -rm -f $(srcdir)/Lib/test/*.py[co]
720 -$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
721 $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
724 install: @FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@
726 # Install almost everything without disturbing previous versions
727 altinstall: @FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \
728 sharedinstall oldsharedinstall @FRAMEWORKALTINSTALLLAST@
730 # Install shared libraries enabled by Setup
731 DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
733 oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
734 @for i in X $(SHAREDMODS); do \
735 if test $$i != X; then \
736 echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
737 $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
742 @for i in $(DESTDIRS); \
744 if test ! -d $(DESTDIR)$$i; then \
745 echo "Creating directory $$i"; \
746 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
752 # Install the interpreter (by creating a hard link to python$(VERSION))
753 bininstall: altbininstall
754 -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
755 then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
758 (cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
759 -rm -f $(DESTDIR)$(BINDIR)/python-config
760 (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config)
762 # Install the interpreter with $(VERSION) affixed
763 # This goes into $(exec_prefix)
764 altbininstall: $(BUILDPYTHON)
765 @for i in $(BINDIR) $(LIBDIR); \
767 if test ! -d $(DESTDIR)$$i; then \
768 echo "Creating directory $$i"; \
769 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
773 $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
774 if test -f $(LDLIBRARY); then \
775 if test -n "$(DLLLIBRARY)" ; then \
776 $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
778 $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
779 if test $(LDLIBRARY) != $(INSTSONAME); then \
780 (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
786 # Install the manual page
788 @for i in $(MANDIR) $(MANDIR)/man1; \
790 if test ! -d $(DESTDIR)$$i; then \
791 echo "Creating directory $$i"; \
792 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
796 $(INSTALL_DATA) $(srcdir)/Misc/python.man \
797 $(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
799 # Install the library
800 PLATDIR= plat-$(MACHDEP)
801 EXTRAPLATDIR= @EXTRAPLATDIR@
802 EXTRAMACHDEPPATH=@EXTRAMACHDEPPATH@
803 MACHDEPS= $(PLATDIR) $(EXTRAPLATDIR)
804 XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
805 PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
806 plat-mac/lib-scriptpackages/_builtinSuites \
807 plat-mac/lib-scriptpackages/CodeWarrior \
808 plat-mac/lib-scriptpackages/Explorer \
809 plat-mac/lib-scriptpackages/Finder \
810 plat-mac/lib-scriptpackages/Netscape \
811 plat-mac/lib-scriptpackages/StdSuites \
812 plat-mac/lib-scriptpackages/SystemEvents \
813 plat-mac/lib-scriptpackages/Terminal
814 PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
815 LIBSUBDIRS= lib-tk site-packages test test/output test/data \
816 test/decimaltestdata \
817 encodings compiler hotshot \
818 email email/mime email/test email/test/data \
820 sqlite3 sqlite3/test \
821 logging bsddb bsddb/test csv wsgiref \
822 lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
823 ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
824 distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
825 multiprocessing multiprocessing/dummy \
828 libinstall: build_all $(srcdir)/Lib/$(PLATDIR)
829 @for i in $(SCRIPTDIR) $(LIBDEST); \
831 if test ! -d $(DESTDIR)$$i; then \
832 echo "Creating directory $$i"; \
833 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
837 @for d in $(LIBSUBDIRS); \
839 a=$(srcdir)/Lib/$$d; \
840 if test ! -d $$a; then continue; else true; fi; \
842 if test ! -d $(DESTDIR)$$b; then \
843 echo "Creating directory $$b"; \
844 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
848 @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
850 if test -x $$i; then \
851 $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
852 echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
854 $(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
855 echo $(INSTALL_DATA) $$i $(LIBDEST); \
858 @for d in $(LIBSUBDIRS); \
860 a=$(srcdir)/Lib/$$d; \
861 if test ! -d $$a; then continue; else true; fi; \
862 if test `ls $$a | wc -l` -lt 1; then continue; fi; \
872 if test -d $$i; then continue; fi; \
873 if test -x $$i; then \
874 echo $(INSTALL_SCRIPT) $$i $$b; \
875 $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
877 echo $(INSTALL_DATA) $$i $$b; \
878 $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
883 $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
884 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
885 ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
887 -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
888 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
889 ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
891 -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
892 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
893 ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
894 -d $(LIBDEST)/site-packages -f \
895 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
896 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
897 ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
898 -d $(LIBDEST)/site-packages -f \
899 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
900 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
901 ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
903 # Create the PLATDIR source directory, if one wasn't distributed..
904 $(srcdir)/Lib/$(PLATDIR):
905 mkdir $(srcdir)/Lib/$(PLATDIR)
906 cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
907 export PATH; PATH="`pwd`:$$PATH"; \
908 export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
909 export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
910 export EXE; EXE="$(BUILDEXE)"; \
911 cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
913 # Install the include files
914 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
916 @for i in $(INCLDIRSTOMAKE); \
918 if test ! -d $(DESTDIR)$$i; then \
919 echo "Creating directory $$i"; \
920 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
924 @for i in $(srcdir)/Include/*.h; \
926 echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
927 $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
929 $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
931 # Install the library and miscellaneous stuff needed for extending/embedding
932 # This goes into $(exec_prefix)
933 LIBPL= $(LIBP)/config
935 @for i in $(LIBDIR) $(LIBP) $(LIBPL); \
937 if test ! -d $(DESTDIR)$$i; then \
938 echo "Creating directory $$i"; \
939 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
943 @if test -d $(LIBRARY); then :; else \
944 if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
945 if test "$(SO)" = .dll; then \
946 $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
948 $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
949 $(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
952 echo Skip install of $(LIBRARY) - use make frameworkinstall; \
955 $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
956 $(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
957 $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
958 $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
959 $(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
960 $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
961 $(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
962 $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
963 $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
964 # Substitution happens here, as the completely-expanded BINDIR
965 # is not available in configure
966 sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
967 $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
969 @if [ -s Modules/python.exp -a \
970 "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
971 echo; echo "Installing support files for building shared extension modules on AIX:"; \
972 $(INSTALL_DATA) Modules/python.exp \
973 $(DESTDIR)$(LIBPL)/python.exp; \
974 echo; echo "$(LIBPL)/python.exp"; \
975 $(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix \
976 $(DESTDIR)$(LIBPL)/makexp_aix; \
977 echo "$(LIBPL)/makexp_aix"; \
978 $(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix \
979 $(DESTDIR)$(LIBPL)/ld_so_aix; \
980 echo "$(LIBPL)/ld_so_aix"; \
981 echo; echo "See Misc/AIX-NOTES for details."; \
984 @case "$(MACHDEP)" in beos*) \
985 echo; echo "Installing support files for building shared extension modules on BeOS:"; \
986 $(INSTALL_DATA) Misc/BeOS-NOTES $(DESTDIR)$(LIBPL)/README; \
987 echo; echo "$(LIBPL)/README"; \
988 $(INSTALL_SCRIPT) Modules/ar_beos $(DESTDIR)$(LIBPL)/ar_beos; \
989 echo "$(LIBPL)/ar_beos"; \
990 $(INSTALL_SCRIPT) Modules/ld_so_beos $(DESTDIR)$(LIBPL)/ld_so_beos; \
991 echo "$(LIBPL)/ld_so_beos"; \
992 echo; echo "See Misc/BeOS-NOTES for details."; \
996 # Install the dynamically loadable modules
997 # This goes into $(exec_prefix)
999 $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
1000 --prefix=$(prefix) \
1001 --install-scripts=$(BINDIR) \
1002 --install-platlib=$(DESTSHARED) \
1005 # Here are a couple of targets for MacOSX again, to install a full
1006 # framework-based Python. frameworkinstall installs everything, the
1007 # subtargets install specific parts. Much of the actual work is offloaded to
1008 # the Makefile in Mac
1011 # This target is here for backward compatiblity, previous versions of Python
1012 # hadn't integrated framework installation in the normal install process.
1013 frameworkinstall: install
1015 # On install, we re-make the framework
1016 # structure in the install location, /Library/Frameworks/ or the argument to
1017 # --enable-framework. If --enable-framework has been specified then we have
1018 # automatically set prefix to the location deep down in the framework, so we
1019 # only have to cater for the structural bits of the framework.
1021 frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
1023 frameworkinstallstructure: $(LDLIBRARY)
1024 @if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1025 echo Not configured with --enable-framework; \
1029 @for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1030 if test ! -d $(DESTDIR)$$i; then \
1031 echo "Creating directory $(DESTDIR)$$i"; \
1032 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1036 $(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
1037 sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1038 $(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
1039 $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1040 $(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
1041 $(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1042 $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1044 # This installs Mac/Lib into the framework
1045 # Install a number of symlinks to keep software that expects a normal unix
1046 # install (which includes python-config) happy.
1047 frameworkinstallmaclib:
1048 ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1049 cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
1051 # This installs the IDE, the Launcher and other apps into /Applications
1052 frameworkinstallapps:
1053 cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
1055 frameworkinstallapps4way:
1056 cd Mac && $(MAKE) installapps4way DESTDIR="$(DESTDIR)"
1058 # This install the unix python and pythonw tools in /usr/local/bin
1059 frameworkinstallunixtools:
1060 cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
1062 frameworkinstallunixtools4way:
1063 cd Mac && $(MAKE) installunixtools4way DESTDIR="$(DESTDIR)"
1065 frameworkaltinstallunixtools:
1066 cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1068 frameworkaltinstallunixtools4way:
1069 cd Mac && $(MAKE) altinstallunixtools4way DESTDIR="$(DESTDIR)"
1071 # This installs the Demos and Tools into the applications directory.
1072 # It is not part of a normal frameworkinstall
1073 frameworkinstallextras:
1074 cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
1076 # This installs a few of the useful scripts in Tools/scripts
1078 SRCDIR=$(srcdir) $(RUNSHARED) \
1079 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
1080 --prefix=$(prefix) \
1081 --install-scripts=$(BINDIR) \
1084 # Build the toplevel Makefile
1085 Makefile.pre: Makefile.pre.in config.status
1086 CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
1087 $(MAKE) -f Makefile.pre Makefile
1089 # Run the configure script.
1090 config.status: $(srcdir)/configure
1091 $(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1093 .PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1095 # Some make's put the object file in the current directory
1097 $(CC) -c $(PY_CFLAGS) -o $@ $<
1099 # Run reindent on the library
1101 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
1103 # Rerun configure with the same options as it was run last time,
1104 # provided the config.status script exists
1106 $(SHELL) config.status --recheck
1107 $(SHELL) config.status
1109 # Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
1111 (cd $(srcdir); autoconf)
1112 (cd $(srcdir); autoheader)
1114 # Create a tags file for vi
1117 ctags -w -t Include/*.h; \
1118 for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \
1122 # Create a tags file for GNU Emacs
1125 etags Include/*.h; \
1126 for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
1128 # Sanitation targets -- clean leaves libraries, executables and tags
1129 # files, which clobber removes those as well
1131 find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1134 find . -name '*.o' -exec rm -f {} ';'
1135 find . -name '*.s[ol]' -exec rm -f {} ';'
1136 find $(srcdir)/build -name 'fficonfig.h' -exec rm -f {} ';' || true
1137 find $(srcdir)/build -name 'fficonfig.py' -exec rm -f {} ';' || true
1140 find . -name '*.gc??' -exec rm -f {} ';'
1142 clobber: clean profile-removal
1143 -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1145 config.cache config.log pyconfig.h Modules/config.c
1146 -rm -rf build platform
1147 -rm -rf $(PYTHONFRAMEWORKDIR)
1149 # Make things extra clean, before making a distribution:
1150 # remove all generated files, even Makefile[.pre]
1151 # Keep configure and Python-ast.[ch], it's possible they can't be generated
1153 -rm -f core Makefile Makefile.pre config.status \
1154 Modules/Setup Modules/Setup.local Modules/Setup.config
1155 find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
1156 -o -name '[@,#]*' -o -name '*.old' \
1157 -o -name '*.orig' -o -name '*.rej' \
1158 -o -name '*.bak' ')' \
1161 # Check for smelly exported symbols (not starting with Py/_Py)
1163 nm -p $(LIBRARY) | \
1164 sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
1166 # Find files with funny names
1168 find $(DISTDIRS) -type d \
1169 -o -name '*.[chs]' \
1179 -o -name '*,[vpt]' \
1181 -o -name 'Setup.*' \
1184 -o -name ChangeLog \
1185 -o -name Repository \
1191 -o -name .cvsignore \
1195 # Perform some verification checks on any modified files.
1197 $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1201 Python/thread.o: @THREADHEADERS@
1203 # Declare targets that aren't real files
1204 .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1205 .PHONY: install altinstall oldsharedinstall bininstall altbininstall
1206 .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1207 .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
1208 .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1209 .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1210 .PHONY: smelly funny patchcheck
1212 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY