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= Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
181 #PROFILE_TASK= 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 \
268 Python/getplatform.o \
269 Python/getversion.o \
274 Python/modsupport.o \
276 Python/mysnprintf.o \
283 Python/structmember.o \
290 Python/formatter_unicode.o \
291 Python/formatter_string.o \
292 Python/$(DYNLOADFILE) \
298 ##########################################################################
302 Objects/boolobject.o \
303 Objects/bufferobject.o \
304 Objects/bytes_methods.o \
305 Objects/bytesobject.o \
306 Objects/cellobject.o \
307 Objects/classobject.o \
309 Objects/codeobject.o \
310 Objects/complexobject.o \
311 Objects/descrobject.o \
312 Objects/enumobject.o \
313 Objects/exceptions.o \
314 Objects/genobject.o \
315 Objects/fileobject.o \
316 Objects/floatobject.o \
317 Objects/frameobject.o \
318 Objects/funcobject.o \
319 Objects/intobject.o \
320 Objects/iterobject.o \
321 Objects/listobject.o \
322 Objects/longobject.o \
323 Objects/dictobject.o \
324 Objects/methodobject.o \
325 Objects/moduleobject.o \
328 Objects/rangeobject.o \
329 Objects/setobject.o \
330 Objects/sliceobject.o \
331 Objects/stringobject.o \
332 Objects/structseq.o \
333 Objects/tupleobject.o \
334 Objects/typeobject.o \
335 Objects/weakrefobject.o \
339 ##########################################################################
340 # objects that get linked into the Python library
342 Modules/getbuildinfo.o \
350 #########################################################################
355 build_all: $(BUILDPYTHON) oldsharedmods sharedmods
357 # Compile a binary with gcc profile guided optimization.
359 @echo "Building with support for profile generation:"
361 $(MAKE) build_all_generate_profile
362 @echo "Running benchmark to generate profile data:"
363 $(MAKE) profile-removal
364 $(MAKE) run_profile_task
365 @echo "Rebuilding with profile guided optimizations:"
367 $(MAKE) build_all_use_profile
369 build_all_generate_profile:
370 $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"
373 ./$(BUILDPYTHON) $(PROFILE_TASK)
375 build_all_use_profile:
376 $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"
379 @echo "Building with support for coverage checking:"
381 $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
384 # Build the interpreter
385 $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
386 $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
388 $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
390 platform: $(BUILDPYTHON)
391 $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
394 # Build the shared modules
395 sharedmods: $(BUILDPYTHON)
396 @case $$MAKEFLAGS in \
397 *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
398 *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
401 # Build static library
402 # avoid long command lines, same as LIBRARY_OBJS
403 $(LIBRARY): $(LIBRARY_OBJS)
405 $(AR) cr $@ Modules/getbuildinfo.o
406 $(AR) cr $@ $(PARSER_OBJS)
407 $(AR) cr $@ $(OBJECT_OBJS)
408 $(AR) cr $@ $(PYTHON_OBJS)
409 $(AR) cr $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
410 $(AR) cr $@ $(MODOBJS)
413 libpython$(VERSION).so: $(LIBRARY_OBJS)
414 if test $(INSTSONAME) != $(LDLIBRARY); then \
415 $(LDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
416 $(LN) -f $(INSTSONAME) $@; \
418 $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
421 libpython$(VERSION).sl: $(LIBRARY_OBJS)
422 $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM)
424 # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
425 # minimal framework (not including the Lib directory and such) in the current
427 RESSRCDIR=Mac/Resources/framework
428 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
430 $(RESSRCDIR)/Info.plist
431 $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
432 if test "${UNIVERSALSDK}"; then \
433 $(CC) -o $(LDLIBRARY) -arch i386 -arch ppc -dynamiclib \
434 -isysroot "${UNIVERSALSDK}" \
435 -all_load $(LIBRARY) -Wl,-single_module \
436 -install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
437 -compatibility_version $(VERSION) \
438 -current_version $(VERSION); \
440 /usr/bin/libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
443 $(INSTALL) -d -m $(DIRMODE) \
444 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
445 $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
446 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
447 $(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
448 $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
449 $(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
450 $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
452 # This rule builds the Cygwin Python DLL and import library if configured
453 # for a shared core library; otherwise, this rule is a noop.
454 $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
455 if test -n "$(DLLLIBRARY)"; then \
456 $(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
457 $(LIBS) $(MODLIBS) $(SYSLIBS); \
462 oldsharedmods: $(SHAREDMODS)
465 Makefile Modules/config.c: Makefile.pre \
466 $(srcdir)/Modules/config.c.in \
468 Modules/Setup.config \
471 $(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
473 Modules/Setup.config \
474 Modules/Setup.local \
477 @echo "The Makefile was updated, you may need to re-run make."
480 Modules/Setup: $(srcdir)/Modules/Setup.dist
481 @if test -f Modules/Setup; then \
482 echo "-----------------------------------------------"; \
483 echo "Modules/Setup.dist is newer than Modules/Setup;"; \
484 echo "check to make sure you have all the updates you"; \
485 echo "need in your Modules/Setup file."; \
486 echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
487 echo "-----------------------------------------------"; \
490 ############################################################################
491 # Special rules for object files
493 Modules/getbuildinfo.o: $(PARSER_OBJS) \
499 $(srcdir)/Modules/getbuildinfo.c
500 $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
502 Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
503 $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
504 -DPREFIX='"$(prefix)"' \
505 -DEXEC_PREFIX='"$(exec_prefix)"' \
506 -DVERSION='"$(VERSION)"' \
507 -DVPATH='"$(VPATH)"' \
508 -o $@ $(srcdir)/Modules/getpath.c
510 Modules/python.o: $(srcdir)/Modules/python.c
511 $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
514 $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
515 -@$(INSTALL) -d Include
516 -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
519 $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
521 Parser/grammar.o: $(srcdir)/Parser/grammar.c \
522 $(srcdir)/Include/token.h \
523 $(srcdir)/Include/grammar.h
524 Parser/metagrammar.o: $(srcdir)/Parser/metagrammar.c
526 Parser/tokenizer_pgen.o: $(srcdir)/Parser/tokenizer.c
528 Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
530 $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
531 $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
533 $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
534 $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
536 Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H)
538 Python/getplatform.o: $(srcdir)/Python/getplatform.c
539 $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
541 Python/importdl.o: $(srcdir)/Python/importdl.c
542 $(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
544 Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \
545 $(srcdir)/Objects/unicodetype_db.h
548 $(srcdir)/Include/bytes_methods.h \
549 $(srcdir)/Objects/stringlib/count.h \
550 $(srcdir)/Objects/stringlib/ctype.h \
551 $(srcdir)/Objects/stringlib/fastsearch.h \
552 $(srcdir)/Objects/stringlib/find.h \
553 $(srcdir)/Objects/stringlib/formatter.h \
554 $(srcdir)/Objects/stringlib/partition.h \
555 $(srcdir)/Objects/stringlib/stringdefs.h \
556 $(srcdir)/Objects/stringlib/string_format.h \
557 $(srcdir)/Objects/stringlib/transmogrify.h \
558 $(srcdir)/Objects/stringlib/unicodedefs.h \
559 $(srcdir)/Objects/stringlib/localeutil.h
561 Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
564 Objects/stringobject.o: $(srcdir)/Objects/stringobject.c \
566 Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c \
569 Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
572 Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
575 ############################################################################
579 Include/Python-ast.h \
585 Include/boolobject.h \
586 Include/bytes_methods.h \
587 Include/bytesobject.h \
588 Include/bufferobject.h \
589 Include/cellobject.h \
591 Include/classobject.h \
596 Include/complexobject.h \
597 Include/descrobject.h \
598 Include/dictobject.h \
599 Include/enumobject.h \
602 Include/fileobject.h \
603 Include/floatobject.h \
604 Include/frameobject.h \
605 Include/funcobject.h \
606 Include/genobject.h \
608 Include/intobject.h \
609 Include/intrcheck.h \
610 Include/iterobject.h \
611 Include/listobject.h \
612 Include/longintrepr.h \
613 Include/longobject.h \
615 Include/metagrammar.h \
616 Include/methodobject.h \
617 Include/modsupport.h \
618 Include/moduleobject.h \
625 Include/patchlevel.h \
627 Include/pgenheaders.h \
639 Include/pythonrun.h \
641 Include/rangeobject.h \
642 Include/setobject.h \
643 Include/sliceobject.h \
644 Include/stringobject.h \
645 Include/structmember.h \
646 Include/structseq.h \
648 Include/sysmodule.h \
649 Include/traceback.h \
650 Include/tupleobject.h \
652 Include/unicodeobject.h \
654 Include/weakrefobject.h \
658 $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
661 ######################################################################
663 # Test the interpreter (twice, once without .pyc files, once with)
664 # In the past, we've had problems where bugs in the marshalling or
665 # elsewhere caused bytecode read from .pyc files to behave differently
666 # than bytecode generated directly from a .py source file. Sometimes
667 # the bytecode read from a .pyc file had the bug, somtimes the directly
668 # generated bytecode. This is sometimes a very shy bug needing a lot of
671 TESTOPTS= -l $(EXTRATESTOPTS)
672 TESTPROG= $(srcdir)/Lib/test/regrtest.py
673 TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -tt
675 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
676 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
677 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
679 testall: all platform
680 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
681 $(TESTPYTHON) $(srcdir)/Lib/compileall.py
682 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
683 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
684 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
686 # Run the unitests for both architectures in a Universal build on OSX
687 # Must be run on an Intel box.
688 testuniversal: all platform
689 if [ `arch` != 'i386' ];then \
690 echo "This can only be used on OSX/i386" ;\
693 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
694 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
695 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
696 $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) $(TESTOPTS) -uall
699 # Like testall, but with a single pass only
700 # run an optional script to include some information about the build environment
701 buildbottest: all platform
702 -@if which pybuildbot.identify >/dev/null 2>&1; then \
703 pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
705 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw
707 QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \
708 test_unicodedata test_re test_sre test_select test_poll \
709 test_linuxaudiodev test_struct test_sunaudiodev test_zlib
710 quicktest: all platform
711 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
712 -$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
713 $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
715 MEMTESTOPTS= $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
717 memtest: all platform
718 -rm -f $(srcdir)/Lib/test/*.py[co]
719 -$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
720 $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
723 install: @FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@
725 # Install almost everything without disturbing previous versions
726 altinstall: @FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \
727 sharedinstall oldsharedinstall @FRAMEWORKALTINSTALLLAST@
729 # Install shared libraries enabled by Setup
730 DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
732 oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
733 @for i in X $(SHAREDMODS); do \
734 if test $$i != X; then \
735 echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
736 $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
741 @for i in $(DESTDIRS); \
743 if test ! -d $(DESTDIR)$$i; then \
744 echo "Creating directory $$i"; \
745 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
751 # Install the interpreter (by creating a hard link to python$(VERSION))
752 bininstall: altbininstall
753 -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
754 then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
757 (cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
758 -rm -f $(DESTDIR)$(BINDIR)/python-config
759 (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config)
761 # Install the interpreter with $(VERSION) affixed
762 # This goes into $(exec_prefix)
763 altbininstall: $(BUILDPYTHON)
764 @for i in $(BINDIR) $(LIBDIR); \
766 if test ! -d $(DESTDIR)$$i; then \
767 echo "Creating directory $$i"; \
768 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
772 $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
773 if test -f libpython$(VERSION)$(SO); then \
774 if test "$(SO)" = .dll; then \
775 $(INSTALL_SHARED) libpython$(VERSION)$(SO) $(DESTDIR)$(BINDIR); \
777 $(INSTALL_SHARED) libpython$(VERSION)$(SO) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
778 if test libpython$(VERSION)$(SO) != $(INSTSONAME); then \
779 (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) libpython$(VERSION)$(SO)); \
785 # Install the manual page
787 @for i in $(MANDIR) $(MANDIR)/man1; \
789 if test ! -d $(DESTDIR)$$i; then \
790 echo "Creating directory $$i"; \
791 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
795 $(INSTALL_DATA) $(srcdir)/Misc/python.man \
796 $(DESTDIR)$(MANDIR)/man1/python.1
798 # Install the library
799 PLATDIR= plat-$(MACHDEP)
800 EXTRAPLATDIR= @EXTRAPLATDIR@
801 EXTRAMACHDEPPATH=@EXTRAMACHDEPPATH@
802 MACHDEPS= $(PLATDIR) $(EXTRAPLATDIR)
803 XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
804 PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
805 plat-mac/lib-scriptpackages/_builtinSuites \
806 plat-mac/lib-scriptpackages/CodeWarrior \
807 plat-mac/lib-scriptpackages/Explorer \
808 plat-mac/lib-scriptpackages/Finder \
809 plat-mac/lib-scriptpackages/Netscape \
810 plat-mac/lib-scriptpackages/StdSuites \
811 plat-mac/lib-scriptpackages/SystemEvents \
812 plat-mac/lib-scriptpackages/Terminal
813 PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
814 LIBSUBDIRS= lib-tk site-packages test test/output test/data \
815 test/decimaltestdata \
816 encodings compiler hotshot \
817 email email/mime email/test email/test/data \
819 sqlite3 sqlite3/test \
820 logging bsddb bsddb/test csv wsgiref \
821 lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
822 ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
823 distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
826 libinstall: build_all $(srcdir)/Lib/$(PLATDIR)
827 @for i in $(SCRIPTDIR) $(LIBDEST); \
829 if test ! -d $(DESTDIR)$$i; then \
830 echo "Creating directory $$i"; \
831 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
835 @for d in $(LIBSUBDIRS); \
837 a=$(srcdir)/Lib/$$d; \
838 if test ! -d $$a; then continue; else true; fi; \
840 if test ! -d $(DESTDIR)$$b; then \
841 echo "Creating directory $$b"; \
842 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
846 @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
848 if test -x $$i; then \
849 $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
850 echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
852 $(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
853 echo $(INSTALL_DATA) $$i $(LIBDEST); \
856 @for d in $(LIBSUBDIRS); \
858 a=$(srcdir)/Lib/$$d; \
859 if test ! -d $$a; then continue; else true; fi; \
860 if test `ls $$a | wc -l` -lt 1; then continue; fi; \
870 if test -d $$i; then continue; fi; \
871 if test -x $$i; then \
872 echo $(INSTALL_SCRIPT) $$i $$b; \
873 $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
875 echo $(INSTALL_DATA) $$i $$b; \
876 $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
881 $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
882 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
883 ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
885 -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
886 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
887 ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
889 -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
890 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
891 ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
892 -d $(LIBDEST)/site-packages -f \
893 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
894 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
895 ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
896 -d $(LIBDEST)/site-packages -f \
897 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
898 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
899 ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram"
901 # Create the PLATDIR source directory, if one wasn't distributed..
902 $(srcdir)/Lib/$(PLATDIR):
903 mkdir $(srcdir)/Lib/$(PLATDIR)
904 cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
905 export PATH; PATH="`pwd`:$$PATH"; \
906 export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
907 export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
908 export EXE; EXE="$(BUILDEXE)"; \
909 cd $(srcdir)/Lib/$(PLATDIR); ./regen
911 # Install the include files
912 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
914 @for i in $(INCLDIRSTOMAKE); \
916 if test ! -d $(DESTDIR)$$i; then \
917 echo "Creating directory $$i"; \
918 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
922 @for i in $(srcdir)/Include/*.h; \
924 echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
925 $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
927 $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
929 # Install the library and miscellaneous stuff needed for extending/embedding
930 # This goes into $(exec_prefix)
931 LIBPL= $(LIBP)/config
933 @for i in $(LIBDIR) $(LIBP) $(LIBPL); \
935 if test ! -d $(DESTDIR)$$i; then \
936 echo "Creating directory $$i"; \
937 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
941 @if test -d $(LIBRARY); then :; else \
942 if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
943 if test "$(SO)" = .dll; then \
944 $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
946 $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
947 $(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
950 echo Skip install of $(LIBRARY) - use make frameworkinstall; \
953 $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
954 $(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
955 $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
956 $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
957 $(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
958 $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
959 $(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
960 $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
961 $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
962 # Substitution happens here, as the completely-expanded BINDIR
963 # is not available in configure
964 sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
965 $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
967 @if [ -s Modules/python.exp -a \
968 "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
969 echo; echo "Installing support files for building shared extension modules on AIX:"; \
970 $(INSTALL_DATA) Modules/python.exp \
971 $(DESTDIR)$(LIBPL)/python.exp; \
972 echo; echo "$(LIBPL)/python.exp"; \
973 $(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix \
974 $(DESTDIR)$(LIBPL)/makexp_aix; \
975 echo "$(LIBPL)/makexp_aix"; \
976 $(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix \
977 $(DESTDIR)$(LIBPL)/ld_so_aix; \
978 echo "$(LIBPL)/ld_so_aix"; \
979 echo; echo "See Misc/AIX-NOTES for details."; \
982 @case "$(MACHDEP)" in beos*) \
983 echo; echo "Installing support files for building shared extension modules on BeOS:"; \
984 $(INSTALL_DATA) Misc/BeOS-NOTES $(DESTDIR)$(LIBPL)/README; \
985 echo; echo "$(LIBPL)/README"; \
986 $(INSTALL_SCRIPT) Modules/ar_beos $(DESTDIR)$(LIBPL)/ar_beos; \
987 echo "$(LIBPL)/ar_beos"; \
988 $(INSTALL_SCRIPT) Modules/ld_so_beos $(DESTDIR)$(LIBPL)/ld_so_beos; \
989 echo "$(LIBPL)/ld_so_beos"; \
990 echo; echo "See Misc/BeOS-NOTES for details."; \
994 # Install the dynamically loadable modules
995 # This goes into $(exec_prefix)
997 $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
999 --install-scripts=$(BINDIR) \
1000 --install-platlib=$(DESTSHARED) \
1003 # Here are a couple of targets for MacOSX again, to install a full
1004 # framework-based Python. frameworkinstall installs everything, the
1005 # subtargets install specific parts. Much of the actual work is offloaded to
1006 # the Makefile in Mac
1009 # This target is here for backward compatiblity, previous versions of Python
1010 # hadn't integrated framework installation in the normal install process.
1011 frameworkinstall: install
1013 # On install, we re-make the framework
1014 # structure in the install location, /Library/Frameworks/ or the argument to
1015 # --enable-framework. If --enable-framework has been specified then we have
1016 # automatically set prefix to the location deep down in the framework, so we
1017 # only have to cater for the structural bits of the framework.
1019 frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
1021 frameworkinstallstructure: $(LDLIBRARY)
1022 @if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1023 echo Not configured with --enable-framework; \
1027 @for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1028 if test ! -d $(DESTDIR)$$i; then \
1029 echo "Creating directory $(DESTDIR)$$i"; \
1030 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1034 $(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
1035 sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1036 $(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
1037 $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1038 $(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
1039 $(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1040 $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1042 # This installs Mac/Lib into the framework
1043 # Install a number of symlinks to keep software that expects a normal unix
1044 # install (which includes python-config) happy.
1045 frameworkinstallmaclib:
1046 ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1047 cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
1049 # This installs the IDE, the Launcher and other apps into /Applications
1050 frameworkinstallapps:
1051 cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
1053 # This install the unix python and pythonw tools in /usr/local/bin
1054 frameworkinstallunixtools:
1055 cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
1057 frameworkaltinstallunixtools:
1058 cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1060 # This installs the Demos and Tools into the applications directory.
1061 # It is not part of a normal frameworkinstall
1062 frameworkinstallextras:
1063 cd Mac && Make installextras DESTDIR="$(DESTDIR)"
1065 # This installs a few of the useful scripts in Tools/scripts
1067 SRCDIR=$(srcdir) $(RUNSHARED) \
1068 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
1069 --prefix=$(prefix) \
1070 --install-scripts=$(BINDIR) \
1073 # Build the toplevel Makefile
1074 Makefile.pre: Makefile.pre.in config.status
1075 CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
1076 $(MAKE) -f Makefile.pre Makefile
1078 # Run the configure script.
1079 config.status: $(srcdir)/configure
1080 $(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1082 .PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1084 # Some make's put the object file in the current directory
1086 $(CC) -c $(PY_CFLAGS) -o $@ $<
1088 # Run reindent on the library
1090 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
1092 # Rerun configure with the same options as it was run last time,
1093 # provided the config.status script exists
1095 $(SHELL) config.status --recheck
1096 $(SHELL) config.status
1098 # Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
1100 (cd $(srcdir); autoconf)
1101 (cd $(srcdir); autoheader)
1103 # Create a tags file for vi
1106 ctags -w -t Include/*.h; \
1107 for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \
1111 # Create a tags file for GNU Emacs
1114 etags Include/*.h; \
1115 for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
1117 # Sanitation targets -- clean leaves libraries, executables and tags
1118 # files, which clobber removes those as well
1120 find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1123 find . -name '*.o' -exec rm -f {} ';'
1124 find . -name '*.s[ol]' -exec rm -f {} ';'
1125 find $(srcdir)/build -name 'fficonfig.h' -exec rm -f {} ';' || true
1126 find $(srcdir)/build -name 'fficonfig.py' -exec rm -f {} ';' || true
1129 find . -name '*.gc??' -exec rm -f {} ';'
1131 clobber: clean profile-removal
1132 -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1134 config.cache config.log pyconfig.h Modules/config.c
1135 -rm -rf build platform
1136 -rm -rf $(PYTHONFRAMEWORKDIR)
1138 # Make things extra clean, before making a distribution:
1139 # remove all generated files, even Makefile[.pre]
1140 # Keep configure and Python-ast.[ch], it's possible they can't be generated
1142 -rm -f core Makefile Makefile.pre config.status \
1143 Modules/Setup Modules/Setup.local Modules/Setup.config
1144 find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
1145 -o -name '[@,#]*' -o -name '*.old' \
1146 -o -name '*.orig' -o -name '*.rej' \
1147 -o -name '*.bak' ')' \
1150 # Check for smelly exported symbols (not starting with Py/_Py)
1152 nm -p $(LIBRARY) | \
1153 sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
1155 # Find files with funny names
1157 find $(DISTDIRS) -type d \
1158 -o -name '*.[chs]' \
1168 -o -name '*,[vpt]' \
1170 -o -name 'Setup.*' \
1173 -o -name ChangeLog \
1174 -o -name Repository \
1180 -o -name .cvsignore \
1184 # Perform some verification checks on any modified files.
1186 ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1190 Python/thread.o: @THREADHEADERS@
1192 # Declare targets that aren't real files
1193 .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1194 .PHONY: install altinstall oldsharedinstall bininstall altbininstall
1195 .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1196 .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
1197 .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1198 .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1199 .PHONY: smelly funny
1201 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY