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