Makefile.pre.in 38.1 KB
Newer Older
1
# Top-level Makefile for Python
2
#
3 4 5 6 7
# As distributed, this file is called Makefile.pre.in; it is processed
# into the real Makefile by running the script ./configure, which
# replaces things like @spam@ with values appropriate for your system.
# This means that if you edit Makefile, your changes get lost the next
# time you run the configure script.  Ideally, you can do:
8
#
9 10 11 12
#	./configure
#	make
#	make test
#	make install
13
#
14 15
# If you have a previous version of Python installed that you don't
# want to overwrite, you can use "make altinstall" instead of "make
16 17
# install".  Refer to the "Installing" section in the README file for
# additional details.
18
#
19 20 21 22 23 24 25 26 27 28 29 30 31 32
# See also the section "Build instructions" in the README file.

# === Variables set by makesetup ===

MODOBJS=        _MODOBJS_
MODLIBS=        _MODLIBS_

# === Variables set by configure
VERSION=	@VERSION@
srcdir=		@srcdir@
VPATH=		@srcdir@

CC=		@CC@
CXX=		@CXX@
33
MAINCC=		@MAINCC@
34 35 36
LINKCC=		@LINKCC@
AR=		@AR@
RANLIB=		@RANLIB@
37
SVNVERSION=	@SVNVERSION@
38 39 40 41 42 43 44 45 46 47

# Shell used by make (some versions default to the login shell, which is bad)
SHELL=		/bin/sh

# Use this to make a link between python$(VERSION) and python in $(BINDIR)
LN=		@LN@

# Portable install script (configure doesn't always guess right)
INSTALL=	@INSTALL@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
48
INSTALL_SCRIPT= @INSTALL_SCRIPT@
49 50 51 52 53 54 55 56 57 58
INSTALL_DATA=	@INSTALL_DATA@
# Shared libraries must be installed with executable mode on some systems;
# rather than figuring out exactly which, we always give them executable mode.
# Also, making them read-only seems to be a good idea...
INSTALL_SHARED= ${INSTALL} -m 555

MAKESETUP=      $(srcdir)/Modules/makesetup

# Compiler options
OPT=		@OPT@
59
BASECFLAGS=	@BASECFLAGS@
60
CFLAGS=		$(BASECFLAGS) $(OPT) $(EXTRA_CFLAGS)
61 62 63
# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
# be able to build extension modules using the directories specified in the
# environment variables
64
CPPFLAGS=	-I. -IInclude -I$(srcdir)/Include @CPPFLAGS@
65 66 67
LDFLAGS=	@LDFLAGS@
LDLAST=		@LDLAST@
SGI_ABI=	@SGI_ABI@
68 69 70 71 72
CCSHARED=	@CCSHARED@
LINKFORSHARED=	@LINKFORSHARED@
# Extra C flags added for building the interpreter object files.
CFLAGSFORSHARED=@CFLAGSFORSHARED@
# C flags used for building the interpreter object files
73
PY_CFLAGS=	$(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
74

75 76 77 78 79 80 81 82 83 84

# Machine-dependent subdirectories
MACHDEP=	@MACHDEP@

# Install prefix for architecture-independent files
prefix=		@prefix@

# Install prefix for architecture-dependent files
exec_prefix=	@exec_prefix@

85 86 87
# Install prefix for data files
datarootdir=    @datarootdir@

88 89 90
# Expanded directories
BINDIR=		$(exec_prefix)/bin
LIBDIR=		$(exec_prefix)/lib
91 92
MANDIR=		@mandir@
INCLUDEDIR=	@includedir@
93 94 95 96 97 98 99 100 101 102 103 104 105
CONFINCLUDEDIR=	$(exec_prefix)/include
SCRIPTDIR=	$(prefix)/lib

# Detailed destination directories
BINLIBDEST=	$(LIBDIR)/python$(VERSION)
LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)
CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)
LIBP=		$(LIBDIR)/python$(VERSION)

# Symbols used for using shared libraries
SO=		@SO@
LDSHARED=	@LDSHARED@
106
BLDSHARED=	@BLDSHARED@
107 108 109
DESTSHARED=	$(BINLIBDEST)/lib-dynload

# Executable suffix (.exe on Windows and Mac OS X)
110
EXE=		@EXEEXT@
111
BUILDEXE=	@BUILDEXEEXT@
112

113
# Short name and location for Mac OS X Python framework
114
UNIVERSALSDK=@UNIVERSALSDK@
115 116 117 118
PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
PYTHONFRAMEWORKDIR=	@PYTHONFRAMEWORKDIR@
PYTHONFRAMEWORKPREFIX=	@PYTHONFRAMEWORKPREFIX@
PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
119
# Deployment target selected during configure, to be checked
120 121 122 123 124
# by distutils. The export statement is needed to ensure that the
# deployment target is active during build.
MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET

125 126
# Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@
127

128 129 130
# Environment to run shared python without installed libraries
RUNSHARED=       @RUNSHARED@

131 132 133 134 135 136
# Modes for directories, executables and data files created by the
# install process.  Default to user-only-writable for all file types.
DIRMODE=	755
EXEMODE=	755
FILEMODE=	644

137 138
# configure script arguments
CONFIG_ARGS=	@CONFIG_ARGS@
139 140 141 142 143 144 145 146 147


# Subdirectories with code
SRCDIRS= 	@SRCDIRS@

# Other subdirectories
SUBDIRSTOO=	Include Lib Misc Demo

# Files and directories to be distributed
148
CONFIGFILES=	configure configure.in acconfig.h pyconfig.h.in Makefile.pre.in
149 150 151 152 153
DISTFILES=	README ChangeLog $(CONFIGFILES)
DISTDIRS=	$(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
DIST=		$(DISTFILES) $(DISTDIRS)


154
LIBRARY=	@LIBRARY@
155
LDLIBRARY=      @LDLIBRARY@
156
BLDLIBRARY=     @BLDLIBRARY@
157
DLLLIBRARY=	@DLLLIBRARY@
158
LDLIBRARYDIR=   @LDLIBRARYDIR@
159
INSTSONAME=	@INSTSONAME@
160 161 162 163 164 165


LIBS=		@LIBS@
LIBM=		@LIBM@
LIBC=		@LIBC@
SYSLIBS=	$(LIBM) $(LIBC)
166
SHLIBS=		@SHLIBS@
167

168
THREADOBJ=	@THREADOBJ@
169 170
DLINCLDIR=	@DLINCLDIR@
DYNLOADFILE=	@DYNLOADFILE@
171
MACHDEP_OBJS=	@MACHDEP_OBJS@
172 173
LIBOBJDIR=	Python/
LIBOBJS=	@LIBOBJS@
174

175
PYTHON=		python$(EXE)
176
BUILDPYTHON=	python$(BUILDEXE)
177

Christian Heimes's avatar
Christian Heimes committed
178
# The task to run while instrument when building the profile-opt target
Benjamin Peterson's avatar
Benjamin Peterson committed
179 180
PROFILE_TASK=	$(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
#PROFILE_TASK=	$(srcdir)/Lib/test/regrtest.py
Christian Heimes's avatar
Christian Heimes committed
181

182 183 184 185 186 187 188 189
# === Definitions added by makesetup ===


##########################################################################
# Modules
MODULE_OBJS=	\
		Modules/config.o \
		Modules/getpath.o \
190 191
		Modules/main.o \
		Modules/gcmodule.o
192 193 194 195 196 197 198

# Used of signalmodule.o is not available
SIGNAL_OBJS=	@SIGNAL_OBJS@


##########################################################################
# Grammar
199 200
GRAMMAR_H=	$(srcdir)/Include/graminit.h
GRAMMAR_C=	$(srcdir)/Python/graminit.c
201 202 203 204 205
GRAMMAR_INPUT=	$(srcdir)/Grammar/Grammar


##########################################################################
# Parser
206
PGEN=		Parser/pgen$(EXE)
207 208 209 210 211 212 213 214 215

POBJS=		\
		Parser/acceler.o \
		Parser/grammar1.o \
		Parser/listnode.o \
		Parser/node.o \
		Parser/parser.o \
		Parser/parsetok.o \
		Parser/bitset.o \
216 217 218 219
		Parser/metagrammar.o \
		Parser/firstsets.o \
		Parser/grammar.o \
		Parser/pgen.o
220

221
PARSER_OBJS=	$(POBJS) Parser/myreadline.o Parser/tokenizer.o
222 223

PGOBJS=		\
224
		Objects/obmalloc.o \
225
		Python/mysnprintf.o \
226
		Parser/tokenizer_pgen.o \
227 228 229
		Parser/printgrammar.o \
		Parser/pgenmain.o

230 231 232 233
PARSER_HEADERS= \
		Parser/parser.h \
		Parser/tokenizer.h

234 235
PGENOBJS=	$(PGENMAIN) $(POBJS) $(PGOBJS)

Jeremy Hylton's avatar
Jeremy Hylton committed
236 237
##########################################################################
# AST
238 239 240 241
AST_H_DIR=	$(srcdir)/Include
AST_H=		$(AST_H_DIR)/Python-ast.h
AST_C_DIR=	$(srcdir)/Python
AST_C=		$(AST_C_DIR)/Python-ast.c
Jeremy Hylton's avatar
Jeremy Hylton committed
242 243 244 245
AST_ASDL=	$(srcdir)/Parser/Python.asdl

ASDLGEN_FILES=	$(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
# XXX Note that a build now requires Python exist before the build starts
246
ASDLGEN=	$(srcdir)/Parser/asdl_c.py
247 248 249

##########################################################################
# Python
250 251 252 253 254 255 256 257 258 259

OPCODETARGETS_H= \
		$(srcdir)/Python/opcode_targets.h

OPCODETARGETGEN= \
		$(srcdir)/Python/makeopcodetargets.py

OPCODETARGETGEN_FILES= \
		$(OPCODETARGETGEN) $(srcdir)/Lib/opcode.py

260
PYTHON_OBJS=	\
Christian Heimes's avatar
Christian Heimes committed
261
		Python/_warnings.o \
Jeremy Hylton's avatar
Jeremy Hylton committed
262 263 264
		Python/Python-ast.o \
		Python/asdl.o \
		Python/ast.o \
265 266 267 268 269 270 271
		Python/bltinmodule.o \
		Python/ceval.o \
		Python/compile.o \
		Python/codecs.o \
		Python/errors.o \
		Python/frozen.o \
		Python/frozenmain.o \
272
		Python/future.o \
273 274 275 276 277 278 279 280 281 282 283
		Python/getargs.o \
		Python/getcompiler.o \
		Python/getcopyright.o \
		Python/getplatform.o \
		Python/getversion.o \
		Python/graminit.o \
		Python/import.o \
		Python/importdl.o \
		Python/marshal.o \
		Python/modsupport.o \
		Python/mystrtoul.o \
284
		Python/mysnprintf.o \
285
		Python/peephole.o \
286
		Python/pyarena.o \
287
		Python/pyfpe.o \
288
		Python/pymath.o \
289 290 291
		Python/pystate.o \
		Python/pythonrun.o \
		Python/structmember.o \
292
		Python/symtable.o \
293 294 295
		Python/sysmodule.o \
		Python/traceback.o \
		Python/getopt.o \
296
		Python/pystrcmp.o \
297
		Python/pystrtod.o \
298
		Python/formatter_unicode.o \
299
		Python/$(DYNLOADFILE) \
300
		$(LIBOBJS) \
301
		$(MACHDEP_OBJS) \
302
		$(THREADOBJ)
303 304 305 306 307 308


##########################################################################
# Objects
OBJECT_OBJS=	\
		Objects/abstract.o \
309
		Objects/boolobject.o \
310
		Objects/bytes_methods.o \
311
		Objects/bytearrayobject.o \
312
		Objects/bytesobject.o \
Jeremy Hylton's avatar
Jeremy Hylton committed
313
		Objects/cellobject.o \
314 315
		Objects/classobject.o \
		Objects/cobject.o \
Jeremy Hylton's avatar
Jeremy Hylton committed
316
		Objects/codeobject.o \
317
		Objects/complexobject.o \
318
		Objects/descrobject.o \
319
		Objects/enumobject.o \
320
		Objects/exceptions.o \
321
		Objects/genobject.o \
322 323 324 325
		Objects/fileobject.o \
		Objects/floatobject.o \
		Objects/frameobject.o \
		Objects/funcobject.o \
326
		Objects/iterobject.o \
327 328 329
		Objects/listobject.o \
		Objects/longobject.o \
		Objects/dictobject.o \
330
		Objects/memoryobject.o \
331 332 333
		Objects/methodobject.o \
		Objects/moduleobject.o \
		Objects/object.o \
334
		Objects/obmalloc.o \
335
		Objects/rangeobject.o \
336
                Objects/setobject.o \
337
		Objects/sliceobject.o \
338
		Objects/structseq.o \
339 340
		Objects/tupleobject.o \
		Objects/typeobject.o \
341 342 343
		Objects/unicodeobject.o \
		Objects/unicodectype.o \
		Objects/weakrefobject.o
344 345 346 347 348


##########################################################################
# objects that get linked into the Python library
LIBRARY_OBJS=	\
349
		Modules/getbuildinfo.o \
350 351 352 353 354 355 356 357 358 359 360
		$(PARSER_OBJS) \
		$(OBJECT_OBJS) \
		$(PYTHON_OBJS) \
		$(MODULE_OBJS) \
		$(SIGNAL_OBJS) \
		$(MODOBJS)

#########################################################################
# Rules

# Default target
361 362
all:		build_all
build_all:	$(BUILDPYTHON) oldsharedmods sharedmods
363

Christian Heimes's avatar
Christian Heimes committed
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
# Compile a binary with gcc profile guided optimization.
profile-opt:
	@echo "Building with support for profile generation:"
	$(MAKE) clean
	$(MAKE) build_all_generate_profile
	@echo "Running benchmark to generate profile data:"
	$(MAKE) profile-removal
	$(MAKE) run_profile_task
	@echo "Rebuilding with profile guided optimizations:"
	$(MAKE) clean
	$(MAKE) build_all_use_profile

build_all_generate_profile:
	$(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"

run_profile_task:
	./$(BUILDPYTHON) $(PROFILE_TASK)

build_all_use_profile:
	$(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"

Georg Brandl's avatar
Georg Brandl committed
385 386 387 388 389 390
coverage:
	@echo "Building with support for coverage checking:"
	$(MAKE) clean
	$(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"


391
# Build the interpreter
392
$(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY)
393
		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
394
			Modules/python.o \
395
			$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
396

397
platform: $(BUILDPYTHON)
398
	$(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform
399 400 401


# Build the shared modules
402
sharedmods: $(BUILDPYTHON)
403
	@case $$MAKEFLAGS in \
404
	*s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
405
	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
406
	esac
407 408

# Build static library
409
# avoid long command lines, same as LIBRARY_OBJS
410 411
$(LIBRARY): $(LIBRARY_OBJS)
	-rm -f $@
412
	$(AR) cr $@ Modules/getbuildinfo.o
413 414 415 416 417 418 419
	$(AR) cr $@ $(PARSER_OBJS)
	$(AR) cr $@ $(OBJECT_OBJS)
	$(AR) cr $@ $(PYTHON_OBJS)
	$(AR) cr $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
	$(AR) cr $@ $(MODOBJS)
	$(RANLIB) $@

420
libpython$(VERSION).so: $(LIBRARY_OBJS)
421
	if test $(INSTSONAME) != $(LDLIBRARY); then \
422
		$(LDSHARED) $(LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
423
		$(LN) -f $(INSTSONAME) $@; \
424
	else \
425
		$(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
426
	fi
427

428 429 430 431
libpython$(VERSION).dylib: $(LIBRARY_OBJS)
	 $(CC) -dynamiclib -Wl,-single_module $(LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
		 

432
libpython$(VERSION).sl: $(LIBRARY_OBJS)
433
	$(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST)
434

435 436 437
# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
# minimal framework (not including the Lib directory and such) in the current
# directory.
Christian Heimes's avatar
Christian Heimes committed
438
RESSRCDIR=Mac/Resources/framework
439 440
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
		$(LIBRARY) \
Christian Heimes's avatar
Christian Heimes committed
441
		$(RESSRCDIR)/Info.plist
442
	$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
443
	if test "${UNIVERSALSDK}"; then \
444
		$(CC) -o $(LDLIBRARY) @UNIVERSAL_ARCH_FLAGS@ -dynamiclib \
445 446
			-isysroot "${UNIVERSALSDK}" \
			-all_load $(LIBRARY) -Wl,-single_module \
Christian Heimes's avatar
Christian Heimes committed
447
			-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
448 449 450
			-compatibility_version $(VERSION) \
			-current_version $(VERSION); \
        else \
451
		/usr/bin/libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
452 453
			@LIBTOOL_CRUFT@ ;\
	fi
454 455 456 457
	$(INSTALL) -d -m $(DIRMODE)  \
		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
458
	$(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
459
	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
460 461
	$(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
	$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
462

463 464 465 466
# This rule builds the Cygwin Python DLL and import library if configured
# for a shared core library; otherwise, this rule is a noop.
$(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
	if test -n "$(DLLLIBRARY)"; then \
Benjamin Peterson's avatar
Benjamin Peterson committed
467 468
		$(LDSHARED) $(LDFLAGS) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
			$(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
469 470
	else true; \
	fi
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496


oldsharedmods: $(SHAREDMODS)


Makefile Modules/config.c: Makefile.pre \
				$(srcdir)/Modules/config.c.in \
				$(MAKESETUP) \
				Modules/Setup.config \
				Modules/Setup \
				Modules/Setup.local
	$(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
				-s Modules \
				Modules/Setup.config \
				Modules/Setup.local \
				Modules/Setup
	@mv config.c Modules
	@echo "The Makefile was updated, you may need to re-run make."


Modules/Setup: $(srcdir)/Modules/Setup.dist
	@if test -f Modules/Setup; then \
		echo "-----------------------------------------------"; \
		echo "Modules/Setup.dist is newer than Modules/Setup;"; \
		echo "check to make sure you have all the updates you"; \
		echo "need in your Modules/Setup file."; \
497
		echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
498
		echo "-----------------------------------------------"; \
499
	fi
500 501 502 503

############################################################################
# Special rules for object files

504 505 506 507 508 509 510
Modules/getbuildinfo.o: $(PARSER_OBJS) \
		$(OBJECT_OBJS) \
		$(PYTHON_OBJS) \
		$(MODULE_OBJS) \
		$(SIGNAL_OBJS) \
		$(MODOBJS) \
		$(srcdir)/Modules/getbuildinfo.c
511
	$(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
512

513
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
514 515 516 517 518
	$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
		-DPREFIX='"$(prefix)"' \
		-DEXEC_PREFIX='"$(exec_prefix)"' \
		-DVERSION='"$(VERSION)"' \
		-DVPATH='"$(VPATH)"' \
519
		-o $@ $(srcdir)/Modules/getpath.c
520

521 522
Modules/python.o: $(srcdir)/Modules/python.c
	$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
523 524 525


$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
526
		-@$(INSTALL) -d Include
527
		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
528 529

$(PGEN):	$(PGENOBJS)
530
		$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
531 532 533 534 535 536

Parser/grammar.o:	$(srcdir)/Parser/grammar.c \
				$(srcdir)/Include/token.h \
				$(srcdir)/Include/grammar.h
Parser/metagrammar.o:	$(srcdir)/Parser/metagrammar.c

537 538
Parser/tokenizer_pgen.o:	$(srcdir)/Parser/tokenizer.c

539 540
Parser/pgenmain.o:	$(srcdir)/Include/parsetok.h

541 542
$(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
	$(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
543

544 545
$(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
	$(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
546

Jeremy Hylton's avatar
Jeremy Hylton committed
547
Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H)
548

549
Python/getplatform.o: $(srcdir)/Python/getplatform.c
550
		$(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
551 552

Python/importdl.o: $(srcdir)/Python/importdl.c
553
		$(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
554 555 556 557

Objects/unicodectype.o:	$(srcdir)/Objects/unicodectype.c \
				$(srcdir)/Objects/unicodetype_db.h

558
BYTESTR_DEPS = \
Neal Norwitz's avatar
Neal Norwitz committed
559
		$(srcdir)/Include/bytes_methods.h \
560 561 562 563 564 565 566 567 568 569
		$(srcdir)/Objects/stringlib/count.h \
		$(srcdir)/Objects/stringlib/ctype.h \
		$(srcdir)/Objects/stringlib/eq.h \
		$(srcdir)/Objects/stringlib/fastsearch.h \
		$(srcdir)/Objects/stringlib/find.h \
		$(srcdir)/Objects/stringlib/partition.h \
		$(srcdir)/Objects/stringlib/stringdefs.h \
		$(srcdir)/Objects/stringlib/string_format.h \
		$(srcdir)/Objects/stringlib/transmogrify.h \
		$(srcdir)/Objects/stringlib/unicodedefs.h \
570
		$(srcdir)/Objects/stringlib/localeutil.h
571

572
Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS)
573

574
Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c $(BYTESTR_DEPS) 
575

576
Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
Benjamin Peterson's avatar
Benjamin Peterson committed
577 578
				$(BYTESTR_DEPS) \
				$(srcdir)/Objects/stringlib/formatter.h
579

580 581 582 583 584
$(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
	$(OPCODETARGETGEN) $(OPCODETARGETS_H)

Python/ceval.o: $(OPCODETARGETS_H)

585
Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
Benjamin Peterson's avatar
Benjamin Peterson committed
586
				$(BYTESTR_DEPS)
587 588


589 590 591
############################################################################
# Header files

592
PYTHON_HEADERS= \
Jeremy Hylton's avatar
Jeremy Hylton committed
593
		Include/Python-ast.h \
594
		Include/Python.h \
595
		Include/abstract.h \
596 597 598
		Include/asdl.h \
		Include/ast.h \
		Include/bitset.h \
599
		Include/boolobject.h \
600
		Include/bytes_methods.h \
601
		Include/bytearrayobject.h \
602
		Include/bytesobject.h \
603
		Include/cellobject.h \
604 605 606
		Include/ceval.h \
		Include/classobject.h \
		Include/cobject.h \
Jeremy Hylton's avatar
Jeremy Hylton committed
607
		Include/code.h \
608
		Include/codecs.h \
609
		Include/compile.h \
610
		Include/complexobject.h \
611
		Include/descrobject.h \
612
		Include/dictobject.h \
613
		Include/enumobject.h \
614 615
		Include/errcode.h \
		Include/eval.h \
616 617
		Include/fileobject.h \
		Include/floatobject.h \
618
		Include/frameobject.h \
619
		Include/funcobject.h \
620
		Include/genobject.h \
621 622 623 624
		Include/import.h \
		Include/intrcheck.h \
		Include/iterobject.h \
		Include/listobject.h \
625
		Include/longintrepr.h \
626
		Include/longobject.h \
627
		Include/marshal.h \
628
		Include/memoryobject.h \
629
		Include/metagrammar.h \
630
		Include/methodobject.h \
631
		Include/modsupport.h \
632
		Include/moduleobject.h \
633
		Include/node.h \
634 635
		Include/object.h \
		Include/objimpl.h \
636 637
		Include/opcode.h \
		Include/osdefs.h \
638
		Include/parsetok.h \
639
		Include/patchlevel.h \
640 641
		Include/pgen.h \
		Include/pgenheaders.h \
642
		Include/pyarena.h \
643
		Include/pydebug.h \
644
		Include/pyerrors.h \
645
		Include/pyfpe.h \
646
		Include/pymath.h \
647
		Include/pygetopt.h \
648 649
		Include/pymem.h \
		Include/pyport.h \
650
		Include/pystate.h \
651
		Include/pystrcmp.h \
652
		Include/pystrtod.h \
653
		Include/pythonrun.h \
654
		Include/pythread.h \
655
		Include/rangeobject.h \
656
		Include/setobject.h \
657 658
		Include/sliceobject.h \
		Include/structmember.h \
659
		Include/structseq.h \
660
		Include/symtable.h \
661
		Include/sysmodule.h \
662 663
		Include/traceback.h \
		Include/tupleobject.h \
664
		Include/ucnhash.h \
665
		Include/unicodeobject.h \
Christian Heimes's avatar
Christian Heimes committed
666
		Include/warnings.h \
667
		Include/weakrefobject.h \
668 669
		pyconfig.h \
		$(PARSER_HEADERS)
670

671
$(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
672

673 674 675 676

######################################################################

# Test the interpreter (twice, once without .pyc files, once with)
677 678 679 680 681 682 683
# In the past, we've had problems where bugs in the marshalling or
# elsewhere caused bytecode read from .pyc files to behave differently
# than bytecode generated directly from a .py source file.  Sometimes
# the bytecode read from a .pyc file had the bug, somtimes the directly
# generated bytecode.  This is sometimes a very shy bug needing a lot of
# sample data.

684
TESTOPTS=	-l $(EXTRATESTOPTS)
685
TESTPROG=	$(srcdir)/Lib/test/regrtest.py
686
TESTPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON) -E -bb
687
test:		all platform
Guido van Rossum's avatar
Guido van Rossum committed
688
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
689 690
		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
691

692
testall:	all platform
Christian Heimes's avatar
Christian Heimes committed
693
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
694
		$(TESTPYTHON) $(srcdir)/Lib/compileall.py
695 696 697 698
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall

699 700 701 702 703 704 705 706 707 708
#  Run the unitests for both architectures in a Universal build on OSX
#  Must be run on an Intel box.
testuniversal:	all platform
		if [ `arch` != 'i386' ];then \
			echo "This can only be used on OSX/i386" ;\
			exit 1 ;\
		fi
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
709
		$(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E $(TESTPROG) $(TESTOPTS) -uall
710 711


712
# Like testall, but with a single pass only
713
# run an optional script to include some information about the build environment
714
buildbottest:	all platform
715 716 717
		-@if which pybuildbot.identify >/dev/null 2>&1; then \
			pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
		fi
718 719
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw

720
QUICKTESTOPTS=	$(TESTOPTS) -x test_thread test_signal test_strftime \
721
		test_unicodedata test_re test_sre test_select test_poll \
722
		test_struct test_zlib
723
quicktest:	all platform
Guido van Rossum's avatar
Guido van Rossum committed
724
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
725 726
		-$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
727

728 729 730 731
MEMTESTOPTS=    $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
		test_longexp
memtest:	all platform
		-rm -f $(srcdir)/Lib/test/*.py[co]
732 733
		-$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
734

735
# Install everything
736 737 738 739 740
fullinstall:	@FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@

# "make install" is an alias for "make altinstall" since we never want to
# overwrite Python 2.x.
install:	altinstall
741 742 743 744
		@echo "* Note: not installed as 'python'."
		@echo "* Use 'make fullinstall' to install as 'python'."
		@echo "* However, 'make fullinstall' is discouraged,"
		@echo "* as it will clobber your Python 2.x installation."
745 746

# Install almost everything without disturbing previous versions
747 748
altinstall:	@FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \
                sharedinstall oldsharedinstall @FRAMEWORKALTINSTALLLAST@
749 750 751 752 753 754

# Install shared libraries enabled by Setup
DESTDIRS=	$(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)

oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
		@for i in X $(SHAREDMODS); do \
755 756
		  if test $$i != X; then \
		    echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
757
		    $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
758
		  fi; \
759 760
		done

761
$(DESTSHARED):
762 763
		@for i in $(DESTDIRS); \
		do \
764
			if test ! -d $(DESTDIR)$$i; then \
765
				echo "Creating directory $$i"; \
766
				$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
767 768 769 770 771 772 773
			else    true; \
			fi; \
		done


# Install the interpreter (by creating a hard link to python$(VERSION))
bininstall:	altbininstall
774 775
	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
776 777
	else true; \
	fi
778
	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
779 780
	-rm -f $(DESTDIR)$(BINDIR)/python-config
	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config)
781 782 783

# Install the interpreter with $(VERSION) affixed
# This goes into $(exec_prefix)
784
altbininstall:	$(BUILDPYTHON)
785
	@for i in $(BINDIR) $(LIBDIR); \
786
	do \
787
		if test ! -d $(DESTDIR)$$i; then \
788
			echo "Creating directory $$i"; \
789
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
790 791 792
		else	true; \
		fi; \
	done
793
	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
794
	if test -f $(LDLIBRARY); then \
795 796
		if test -n "$(DLLLIBRARY)" ; then \
			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
797
		else \
798 799 800
			$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
			if test $(LDLIBRARY) != $(INSTSONAME); then \
				(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
801
			fi \
802
		fi; \
803 804 805 806 807 808 809
	else	true; \
	fi

# Install the manual page
maninstall:
	@for i in $(MANDIR) $(MANDIR)/man1; \
	do \
810
		if test ! -d $(DESTDIR)$$i; then \
811
			echo "Creating directory $$i"; \
812
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
813 814 815 816
		else	true; \
		fi; \
	done
	$(INSTALL_DATA) $(srcdir)/Misc/python.man \
Benjamin Peterson's avatar
Benjamin Peterson committed
817
		$(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
818 819 820

# Install the library
PLATDIR=	plat-$(MACHDEP)
821 822
EXTRAPLATDIR= @EXTRAPLATDIR@
MACHDEPS=	$(PLATDIR) $(EXTRAPLATDIR)
823
XMLLIBSUBDIRS=  xml xml/dom xml/etree xml/parsers xml/sax
824
LIBSUBDIRS=	tkinter site-packages test test/output test/data \
825
		test/decimaltestdata \
826
		encodings \
827
		email email/mime email/test email/test/data \
828
		html json json/tests http dbm xmlrpc \
829
		sqlite3 sqlite3/test \
830
		logging bsddb bsddb/test csv wsgiref urllib \
831
		lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
832
		ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
833
		distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
834 835 836
		importlib importlib/test importlib/test/builtin \
		importlib/test/extension importlib/test/frozen \
		importlib/test/import_ importlib/test/source \
837
		setuptools setuptools/command setuptools/tests setuptools.egg-info \
838
		multiprocessing multiprocessing/dummy \
839
		curses $(MACHDEPS)
840
libinstall:	build_all $(srcdir)/Lib/$(PLATDIR)
841 842
	@for i in $(SCRIPTDIR) $(LIBDEST); \
	do \
843
		if test ! -d $(DESTDIR)$$i; then \
844
			echo "Creating directory $$i"; \
845
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
846 847 848 849 850 851 852 853
		else	true; \
		fi; \
	done
	@for d in $(LIBSUBDIRS); \
	do \
		a=$(srcdir)/Lib/$$d; \
		if test ! -d $$a; then continue; else true; fi; \
		b=$(LIBDEST)/$$d; \
854
		if test ! -d $(DESTDIR)$$b; then \
855
			echo "Creating directory $$b"; \
856
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
857 858 859
		else	true; \
		fi; \
	done
860
	@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
861 862
	do \
		if test -x $$i; then \
863
			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
864
			echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
865
		else \
866
			$(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
867 868 869 870 871 872 873
			echo $(INSTALL_DATA) $$i $(LIBDEST); \
		fi; \
	done
	@for d in $(LIBSUBDIRS); \
	do \
		a=$(srcdir)/Lib/$$d; \
		if test ! -d $$a; then continue; else true; fi; \
874
		if test `ls $$a | wc -l` -lt 1; then continue; fi; \
875 876 877 878 879 880 881 882 883 884 885
		b=$(LIBDEST)/$$d; \
		for i in $$a/*; \
		do \
			case $$i in \
			*CVS) ;; \
			*.py[co]) ;; \
			*.orig) ;; \
			*~) ;; \
			*) \
				if test -d $$i; then continue; fi; \
				if test -x $$i; then \
886
				    echo $(INSTALL_SCRIPT) $$i $$b; \
887
				    $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
888 889
				else \
				    echo $(INSTALL_DATA) $$i $$b; \
890
				    $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
891 892 893 894
				fi;; \
			esac; \
		done; \
	done
895
	$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
896
	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
897
		./$(BUILDPYTHON) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
898
		-d $(LIBDEST) -f \
899
		-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
900
	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
901
		./$(BUILDPYTHON) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
902
		-d $(LIBDEST) -f \
903
		-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
904
	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
905
		./$(BUILDPYTHON) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
906
		-d $(LIBDEST)/site-packages -f \
907
		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
908
	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
909
		./$(BUILDPYTHON) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
910
		-d $(LIBDEST)/site-packages -f \
911
		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
912
	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
913
		./$(BUILDPYTHON) -Wi -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
914 915 916 917 918 919 920

# Create the PLATDIR source directory, if one wasn't distributed..
$(srcdir)/Lib/$(PLATDIR):
	mkdir $(srcdir)/Lib/$(PLATDIR)
	cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
	export PATH; PATH="`pwd`:$$PATH"; \
	export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
921
	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
922
	export EXE; EXE="$(BUILDEXE)"; \
923
	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
924 925 926 927 928 929

# Install the include files
INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
inclinstall:
	@for i in $(INCLDIRSTOMAKE); \
	do \
930
		if test ! -d $(DESTDIR)$$i; then \
931
			echo "Creating directory $$i"; \
932
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
933 934 935 936 937 938
		else	true; \
		fi; \
	done
	@for i in $(srcdir)/Include/*.h; \
	do \
		echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
939
		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
940
	done
941
	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
942 943 944 945 946 947 948

# Install the library and miscellaneous stuff needed for extending/embedding
# This goes into $(exec_prefix)
LIBPL=		$(LIBP)/config
libainstall:	all
	@for i in $(LIBDIR) $(LIBP) $(LIBPL); \
	do \
949
		if test ! -d $(DESTDIR)$$i; then \
950
			echo "Creating directory $$i"; \
951
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
952 953 954
		else	true; \
		fi; \
	done
955
	@if test -d $(LIBRARY); then :; else \
956
		if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
957
			if test "$(SO)" = .dll; then \
958
				$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
959
			else \
960 961
				$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
				$(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
962
			fi; \
963
		else \
964
			echo Skip install of $(LIBRARY) - use make frameworkinstall; \
965
		fi; \
966
	fi
967
	$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
968
	$(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
969 970 971 972 973 974 975
	$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
	$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
	$(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
	$(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
	$(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
976 977
	# Substitution happens here, as the completely-expanded BINDIR
	# is not available in configure
978 979
	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
980
	rm python-config
981 982 983 984
	@if [ -s Modules/python.exp -a \
		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
		echo; echo "Installing support files for building shared extension modules on AIX:"; \
		$(INSTALL_DATA) Modules/python.exp		\
985
				$(DESTDIR)$(LIBPL)/python.exp;		\
986
		echo; echo "$(LIBPL)/python.exp";		\
987
		$(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix	\
988
				$(DESTDIR)$(LIBPL)/makexp_aix;		\
989
		echo "$(LIBPL)/makexp_aix";			\
990
		$(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix	\
991
				$(DESTDIR)$(LIBPL)/ld_so_aix;		\
992 993 994 995 996 997 998 999
		echo "$(LIBPL)/ld_so_aix";			\
		echo; echo "See Misc/AIX-NOTES for details.";	\
	else true; \
	fi

# Install the dynamically loadable modules
# This goes into $(exec_prefix)
sharedinstall:
1000 1001
	$(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
	   	--prefix=$(prefix) \
1002
		--install-scripts=$(BINDIR) \
1003 1004
		--install-platlib=$(DESTSHARED) \
		--root=/$(DESTDIR)
1005

1006 1007 1008
# Here are a couple of targets for MacOSX again, to install a full
# framework-based Python. frameworkinstall installs everything, the
# subtargets install specific parts. Much of the actual work is offloaded to
1009
# the Makefile in Mac
1010
#
1011 1012 1013 1014
#
# This target is here for backward compatiblity, previous versions of Python
# hadn't integrated framework installation in the normal install process.
frameworkinstall: install
1015

1016 1017 1018 1019 1020 1021
# On install, we re-make the framework
# structure in the install location, /Library/Frameworks/ or the argument to
# --enable-framework. If --enable-framework has been specified then we have
# automatically set prefix to the location deep down in the framework, so we
# only have to cater for the structural bits of the framework.

1022 1023 1024
frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib

frameworkinstallstructure:	$(LDLIBRARY)
1025
	@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1026
		echo Not configured with --enable-framework; \
1027
		exit 1; \
1028 1029
	else true; \
	fi
1030
	@for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1031
		if test ! -d $(DESTDIR)$$i; then \
1032 1033
			echo "Creating directory $(DESTDIR)$$i"; \
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1034 1035 1036
		else	true; \
		fi; \
	done
1037
	$(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
Benjamin Peterson's avatar
Benjamin Peterson committed
1038
	sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1039
	$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
Christian Heimes's avatar
Christian Heimes committed
1040
	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1041 1042
	$(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
	$(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1043
	$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1044

1045
# This installs Mac/Lib into the framework
1046 1047
# Install a number of symlinks to keep software that expects a normal unix
# install (which includes python-config) happy.
1048
frameworkinstallmaclib:
Christian Heimes's avatar
Christian Heimes committed
1049
	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1050 1051 1052

# This installs the IDE, the Launcher and other apps into /Applications
frameworkinstallapps:
1053
	cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
1054

1055 1056 1057
frameworkinstallapps4way:
	cd Mac && $(MAKE) installapps4way DESTDIR="$(DESTDIR)"

1058 1059
# This install the unix python and pythonw tools in /usr/local/bin
frameworkinstallunixtools:
1060 1061
	cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"

1062 1063 1064
frameworkinstallunixtools4way:
	cd Mac && $(MAKE) installunixtools4way DESTDIR="$(DESTDIR)"

1065 1066
frameworkaltinstallunixtools:
	cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1067

1068 1069 1070
frameworkaltinstallunixtools4way:
	cd Mac && $(MAKE) altinstallunixtools4way DESTDIR="$(DESTDIR)"

1071 1072 1073
# This installs the Demos and Tools into the applications directory.
# It is not part of a normal frameworkinstall
frameworkinstallextras:
1074
	cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
1075

1076 1077
# This installs a few of the useful scripts in Tools/scripts
scriptsinstall:
1078
	SRCDIR=$(srcdir) $(RUNSHARED) \
1079 1080
	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
	--prefix=$(prefix) \
1081 1082
	--install-scripts=$(BINDIR) \
	--root=/$(DESTDIR)
1083

1084 1085 1086 1087 1088
# Build the toplevel Makefile
Makefile.pre: Makefile.pre.in config.status
	CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
	$(MAKE) -f Makefile.pre Makefile

1089
# Run the configure script.
1090
config.status:	$(srcdir)/configure
1091
	$(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1092

1093
.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1094 1095 1096

# Some make's put the object file in the current directory
.c.o:
1097
	$(CC) -c $(PY_CFLAGS) -o $@ $<
1098

1099 1100
# Run reindent on the library
reindent:
1101
	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
1102

1103 1104 1105 1106 1107 1108
# Rerun configure with the same options as it was run last time,
# provided the config.status script exists
recheck:
	$(SHELL) config.status --recheck
	$(SHELL) config.status

1109
# Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119
autoconf:
	(cd $(srcdir); autoconf)
	(cd $(srcdir); autoheader)

# Create a tags file for vi
tags::
	cd $(srcdir); \
	ctags -w -t Include/*.h; \
	for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \
	done; \
1120
	sort -o tags tags
1121 1122 1123 1124 1125 1126 1127 1128 1129

# Create a tags file for GNU Emacs
TAGS::
	cd $(srcdir); \
	etags Include/*.h; \
	for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done

# Sanitation targets -- clean leaves libraries, executables and tags
# files, which clobber removes those as well
1130 1131
pycremoval:
	find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1132

1133 1134 1135 1136 1137 1138 1139
rmtestturds:
	-rm -f *BAD *GOOD *SKIPPED
	-rm -rf OUT
	-rm -f *.TXT
	-rm -f *.txt
	-rm -f gb-18030-2000.xml

1140 1141 1142 1143
docclean:
	-rm -rf Doc/build
	-rm -rf Doc/tools/sphinx Doc/tools/pygments Doc/tools/docutils

1144
clean: pycremoval
1145
	find . -name '*.o' -exec rm -f {} ';'
1146
	find . -name '*.s[ol]' -exec rm -f {} ';'
1147 1148
	find $(srcdir)/build -name 'fficonfig.h' -exec rm -f {} ';' || true
	find $(srcdir)/build -name 'fficonfig.py' -exec rm -f {} ';' || true
1149

Christian Heimes's avatar
Christian Heimes committed
1150 1151 1152 1153
profile-removal:
	find . -name '*.gc??' -exec rm -f {} ';'

clobber: clean profile-removal
1154
	-rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1155
		tags TAGS \
1156
		config.cache config.log pyconfig.h Modules/config.c
1157
	-rm -rf build platform
1158
	-rm -rf $(PYTHONFRAMEWORKDIR)
1159 1160 1161

# Make things extra clean, before making a distribution:
# remove all generated files, even Makefile[.pre]
1162
# Keep configure and Python-ast.[ch], it's possible they can't be generated
1163
distclean: clobber
1164
	-rm -f core Makefile Makefile.pre config.status \
1165
		Modules/Setup Modules/Setup.local Modules/Setup.config
1166 1167 1168 1169 1170
	find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
			   -o -name '[@,#]*' -o -name '*.old' \
			   -o -name '*.orig' -o -name '*.rej' \
			   -o -name '*.bak' ')' \
			   -exec rm -f {} ';'
1171 1172 1173 1174 1175 1176 1177 1178

# Check for smelly exported symbols (not starting with Py/_Py)
smelly: all
	nm -p $(LIBRARY) | \
		sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \

# Find files with funny names
funny:
1179 1180 1181
	find $(DISTDIRS) \
		-name .svn -prune \
		-o -type d \
1182 1183 1184 1185 1186 1187 1188
		-o -name '*.[chs]' \
		-o -name '*.py' \
		-o -name '*.doc' \
		-o -name '*.dat' \
		-o -name '*.el' \
		-o -name '*.fd' \
		-o -name '*.in' \
1189 1190 1191 1192 1193 1194 1195
		-o -name '*.gif' \
		-o -name '*.txt' \
		-o -name '*.xml' \
		-o -name '*.xbm' \
		-o -name '*.xpm' \
		-o -name '*.uue' \
		-o -name '*.decTest' \
1196 1197 1198
		-o -name '*,[vpt]' \
		-o -name 'Setup' \
		-o -name 'Setup.*' \
1199
		-o -name regen \
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212
		-o -name README \
		-o -name Makefile \
		-o -name ChangeLog \
		-o -name Repository \
		-o -name Root \
		-o -name Entries \
		-o -name Tag \
		-o -name tags \
		-o -name TAGS \
		-o -name .cvsignore \
		-o -name MANIFEST \
		-o -print

1213
# Perform some verification checks on any modified files.
1214
patchcheck:
1215
	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1216

1217 1218
# Dependencies

1219
Python/thread.o: @THREADHEADERS@
1220

1221
# Declare targets that aren't real files
1222
.PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1223 1224 1225 1226
.PHONY: install altinstall oldsharedinstall bininstall altbininstall
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1227
.PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean 
1228
.PHONY: smelly funny patchcheck
1229

1230
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY