Makefile.pre.in 39.8 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
GNULD=          @GNULD@

41 42 43 44 45 46 47 48 49
# 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@
50
INSTALL_SCRIPT= @INSTALL_SCRIPT@
51 52 53 54 55 56 57 58 59 60
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@
61
BASECFLAGS=	@BASECFLAGS@
62
CFLAGS=		$(BASECFLAGS) @CFLAGS@ $(OPT) $(EXTRA_CFLAGS)
63 64 65
# 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
66
CPPFLAGS=	-I. -IInclude -I$(srcdir)/Include @CPPFLAGS@
67 68 69
LDFLAGS=	@LDFLAGS@
LDLAST=		@LDLAST@
SGI_ABI=	@SGI_ABI@
70 71
CCSHARED=	@CCSHARED@
LINKFORSHARED=	@LINKFORSHARED@
72
ARFLAGS=	@ARFLAGS@
73 74 75
# Extra C flags added for building the interpreter object files.
CFLAGSFORSHARED=@CFLAGSFORSHARED@
# C flags used for building the interpreter object files
76
PY_CFLAGS=	$(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
77

78 79 80 81 82 83 84 85 86 87

# Machine-dependent subdirectories
MACHDEP=	@MACHDEP@

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

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

88 89 90
# Install prefix for data files
datarootdir=    @datarootdir@

91
# Expanded directories
92 93
BINDIR=		@bindir@
LIBDIR=		@libdir@
94 95
MANDIR=		@mandir@
INCLUDEDIR=	@includedir@
96 97 98 99 100 101 102 103 104 105 106 107
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@
108 109
LDSHARED=	@LDSHARED@ $(LDFLAGS)
BLDSHARED=	@BLDSHARED@ $(LDFLAGS)
110
LDCXXSHARED=	@LDCXXSHARED@
111 112 113
DESTSHARED=	$(BINLIBDEST)/lib-dynload

# Executable suffix (.exe on Windows and Mac OS X)
114
EXE=		@EXEEXT@
115
BUILDEXE=	@BUILDEXEEXT@
116

117
# Short name and location for Mac OS X Python framework
118
UNIVERSALSDK=@UNIVERSALSDK@
119 120 121 122
PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
PYTHONFRAMEWORKDIR=	@PYTHONFRAMEWORKDIR@
PYTHONFRAMEWORKPREFIX=	@PYTHONFRAMEWORKPREFIX@
PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
123
# Deployment target selected during configure, to be checked
124 125 126 127 128
# 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

129 130
# Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@
131

132 133 134
# Environment to run shared python without installed libraries
RUNSHARED=       @RUNSHARED@

135 136 137 138 139 140
# 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

141 142
# configure script arguments
CONFIG_ARGS=	@CONFIG_ARGS@
143 144 145 146 147 148 149 150 151


# Subdirectories with code
SRCDIRS= 	@SRCDIRS@

# Other subdirectories
SUBDIRSTOO=	Include Lib Misc Demo

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


158
LIBRARY=	@LIBRARY@
159
LDLIBRARY=      @LDLIBRARY@
160
BLDLIBRARY=     @BLDLIBRARY@
161
DLLLIBRARY=	@DLLLIBRARY@
162
LDLIBRARYDIR=   @LDLIBRARYDIR@
163
INSTSONAME=	@INSTSONAME@
164 165 166 167 168 169


LIBS=		@LIBS@
LIBM=		@LIBM@
LIBC=		@LIBC@
SYSLIBS=	$(LIBM) $(LIBC)
170
SHLIBS=		@SHLIBS@
171

172
THREADOBJ=	@THREADOBJ@
173 174
DLINCLDIR=	@DLINCLDIR@
DYNLOADFILE=	@DYNLOADFILE@
175
MACHDEP_OBJS=	@MACHDEP_OBJS@
176 177
LIBOBJDIR=	Python/
LIBOBJS=	@LIBOBJS@
178
UNICODE_OBJS=   @UNICODE_OBJS@
179

180
PYTHON=		python$(EXE)
181
BUILDPYTHON=	python$(BUILDEXE)
182

183
# The task to run while instrument when building the profile-opt target
184 185
PROFILE_TASK=	$(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
#PROFILE_TASK=	$(srcdir)/Lib/test/regrtest.py
186

187 188 189 190 191 192 193 194
# === Definitions added by makesetup ===


##########################################################################
# Modules
MODULE_OBJS=	\
		Modules/config.o \
		Modules/getpath.o \
195 196
		Modules/main.o \
		Modules/gcmodule.o
197 198 199 200 201 202 203

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


##########################################################################
# Grammar
204 205
GRAMMAR_H=	$(srcdir)/Include/graminit.h
GRAMMAR_C=	$(srcdir)/Python/graminit.c
206 207 208
GRAMMAR_INPUT=	$(srcdir)/Grammar/Grammar


209 210
LIBFFI_INCLUDEDIR=	@LIBFFI_INCLUDEDIR@

211 212
##########################################################################
# Parser
213
PGEN=		Parser/pgen$(EXE)
214 215 216 217 218 219 220 221 222

POBJS=		\
		Parser/acceler.o \
		Parser/grammar1.o \
		Parser/listnode.o \
		Parser/node.o \
		Parser/parser.o \
		Parser/parsetok.o \
		Parser/bitset.o \
223 224 225 226
		Parser/metagrammar.o \
		Parser/firstsets.o \
		Parser/grammar.o \
		Parser/pgen.o
227

228
PARSER_OBJS=	$(POBJS) Parser/myreadline.o Parser/tokenizer.o
229 230

PGOBJS=		\
231
		Objects/obmalloc.o \
232
		Python/mysnprintf.o \
Benjamin Peterson's avatar
Benjamin Peterson committed
233
		Python/pyctype.o \
234
		Parser/tokenizer_pgen.o \
235 236 237
		Parser/printgrammar.o \
		Parser/pgenmain.o

238 239 240 241
PARSER_HEADERS= \
		Parser/parser.h \
		Parser/tokenizer.h

242 243
PGENOBJS=	$(PGENMAIN) $(POBJS) $(PGOBJS)

Jeremy Hylton's avatar
Jeremy Hylton committed
244 245
##########################################################################
# AST
246 247 248 249
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
250 251 252 253
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
254
ASDLGEN=	$(srcdir)/Parser/asdl_c.py
255 256 257 258

##########################################################################
# Python
PYTHON_OBJS=	\
259
		Python/_warnings.o \
Jeremy Hylton's avatar
Jeremy Hylton committed
260 261 262
		Python/Python-ast.o \
		Python/asdl.o \
		Python/ast.o \
263 264 265 266 267 268 269
		Python/bltinmodule.o \
		Python/ceval.o \
		Python/compile.o \
		Python/codecs.o \
		Python/errors.o \
		Python/frozen.o \
		Python/frozenmain.o \
270
		Python/future.o \
271 272 273 274 275 276 277 278 279 280 281
		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 \
282
		Python/mysnprintf.o \
283
		Python/peephole.o \
284
		Python/pyarena.o \
285
		Python/pyctype.o \
286
		Python/pyfpe.o \
287
		Python/pymath.o \
288 289 290
		Python/pystate.o \
		Python/pythonrun.o \
		Python/structmember.o \
291
		Python/symtable.o \
292 293 294
		Python/sysmodule.o \
		Python/traceback.o \
		Python/getopt.o \
295
		Python/pystrcmp.o \
296
		Python/pystrtod.o \
297
		Python/dtoa.o \
298 299
		Python/formatter_unicode.o \
		Python/formatter_string.o \
300
		Python/$(DYNLOADFILE) \
301
		$(LIBOBJS) \
302
		$(MACHDEP_OBJS) \
303
		$(THREADOBJ)
304 305 306 307 308 309


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


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

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

# Default target
364
all:		build_all
365
build_all:	$(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
366

367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
# 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"

388 389 390 391 392 393
coverage:
	@echo "Building with support for coverage checking:"
	$(MAKE) clean
	$(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"


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

400
platform: $(BUILDPYTHON)
401
	$(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
402 403 404


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

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

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

431 432 433 434
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); \
		 

435
libpython$(VERSION).sl: $(LIBRARY_OBJS)
436
	$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST)
437

438 439 440 441 442 443 444
# Copy up the gdb python hooks into a position where they can be automatically
# loaded by gdb during Lib/test/test_gdb.py
#
# Distributors are likely to want to install this somewhere else e.g. relative
# to the stripped DWARF data for the shared library.
gdbhooks: $(BUILDPYTHON)-gdb.py

445
SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py
446 447
$(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
	$(INSTALL_DATA) $(SRC_GDB_HOOKS) $(BUILDPYTHON)-gdb.py
448

449 450 451
# 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.
452
RESSRCDIR=Mac/Resources/framework
453 454
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
		$(LIBRARY) \
455
		$(RESSRCDIR)/Info.plist
456
	$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
457
	if test "${UNIVERSALSDK}"; then \
458
		$(CC) -o $(LDLIBRARY) @UNIVERSAL_ARCH_FLAGS@ -dynamiclib \
459 460
			-isysroot "${UNIVERSALSDK}" \
			-all_load $(LIBRARY) -Wl,-single_module \
461
			-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
462 463 464
			-compatibility_version $(VERSION) \
			-current_version $(VERSION); \
        else \
465
		/usr/bin/libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
466 467
			@LIBTOOL_CRUFT@ ;\
	fi
468 469 470 471
	$(INSTALL) -d -m $(DIRMODE)  \
		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
472
	$(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
473
	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
474 475
	$(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
	$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
476

477 478 479 480
# 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 \
481
		$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
482
			$(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
483 484
	else true; \
	fi
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510


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."; \
511
		echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
512
		echo "-----------------------------------------------"; \
513
	fi
514 515 516 517

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

518 519 520 521 522 523 524
Modules/getbuildinfo.o: $(PARSER_OBJS) \
		$(OBJECT_OBJS) \
		$(PYTHON_OBJS) \
		$(MODULE_OBJS) \
		$(SIGNAL_OBJS) \
		$(MODOBJS) \
		$(srcdir)/Modules/getbuildinfo.c
525
	$(CC) -c $(PY_CFLAGS) -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" -o $@ $(srcdir)/Modules/getbuildinfo.c
526

527
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
528 529 530 531 532
	$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
		-DPREFIX='"$(prefix)"' \
		-DEXEC_PREFIX='"$(exec_prefix)"' \
		-DVERSION='"$(VERSION)"' \
		-DVPATH='"$(VPATH)"' \
533
		-o $@ $(srcdir)/Modules/getpath.c
534

535 536
Modules/python.o: $(srcdir)/Modules/python.c
	$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
537 538 539


$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
540
		-@$(INSTALL) -d Include
541
		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
542 543

$(PGEN):	$(PGENOBJS)
544
		$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
545 546 547 548 549 550

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

551 552
Parser/tokenizer_pgen.o:	$(srcdir)/Parser/tokenizer.c

553 554
Parser/pgenmain.o:	$(srcdir)/Include/parsetok.h

555 556
$(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
	$(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
557

558 559
$(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
	$(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
560

561
Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
562

563
Python/getplatform.o: $(srcdir)/Python/getplatform.c
564
		$(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
565 566

Python/importdl.o: $(srcdir)/Python/importdl.c
567
		$(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
568 569 570 571

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

572
STRINGLIB_HEADERS= \
Christian Heimes's avatar
Christian Heimes committed
573
		$(srcdir)/Include/bytes_methods.h \
574
		$(srcdir)/Objects/stringlib/count.h \
Christian Heimes's avatar
Christian Heimes committed
575
		$(srcdir)/Objects/stringlib/ctype.h \
576 577 578 579
		$(srcdir)/Objects/stringlib/fastsearch.h \
		$(srcdir)/Objects/stringlib/find.h \
		$(srcdir)/Objects/stringlib/formatter.h \
		$(srcdir)/Objects/stringlib/partition.h \
580
		$(srcdir)/Objects/stringlib/split.h \
581 582
		$(srcdir)/Objects/stringlib/stringdefs.h \
		$(srcdir)/Objects/stringlib/string_format.h \
Christian Heimes's avatar
Christian Heimes committed
583
		$(srcdir)/Objects/stringlib/transmogrify.h \
584 585
		$(srcdir)/Objects/stringlib/unicodedefs.h \
		$(srcdir)/Objects/stringlib/localeutil.h
586

587
Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
588
				$(STRINGLIB_HEADERS)
589

590
Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c \
Benjamin Peterson's avatar
Benjamin Peterson committed
591
				$(STRINGLIB_HEADERS)
592

593
Objects/stringobject.o: $(srcdir)/Objects/stringobject.c \
594
				$(STRINGLIB_HEADERS)
595 596

Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
597
				$(STRINGLIB_HEADERS)
598 599

Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
600
				$(STRINGLIB_HEADERS)
601

602 603 604
############################################################################
# Header files

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

690
$(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
691

692 693 694 695

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

# Test the interpreter (twice, once without .pyc files, once with)
696 697 698
# 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
699
# the bytecode read from a .pyc file had the bug, sometimes the directly
700 701 702
# generated bytecode.  This is sometimes a very shy bug needing a lot of
# sample data.

703
TESTOPTS=	-l $(EXTRATESTOPTS)
704
TESTPROG=	$(srcdir)/Lib/test/regrtest.py
705
TESTPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS)
706
test:		all platform
Guido van Rossum's avatar
Guido van Rossum committed
707
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
708 709
		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
710

711
testall:	all platform
Christian Heimes's avatar
Christian Heimes committed
712
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
713
		$(TESTPYTHON) $(srcdir)/Lib/compileall.py
714
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
715 716
		-$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
		$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
717

718 719 720 721 722 723 724 725
#  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
726 727 728
		-$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
		$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
		$(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) -uall $(TESTOPTS)
729 730


731
# Like testall, but with a single pass only
732
# run an optional script to include some information about the build environment
733
buildbottest:	all platform
734 735 736
		-@if which pybuildbot.identify >/dev/null 2>&1; then \
			pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
		fi
737
		$(TESTPYTHON) $(TESTPROG) -uall -rwW $(TESTOPTS)
738

739 740 741 742
QUICKTESTOPTS=	$(TESTOPTS) -x test_subprocess test_io test_lib2to3 \
		test_multibytecodec test_urllib2_localnet test_itertools \
		test_multiprocessing test_mailbox test_socket test_poll \
		test_select test_zipfile
743
quicktest:	all platform
Guido van Rossum's avatar
Guido van Rossum committed
744
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
745 746
		-$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
747

748 749 750 751
MEMTESTOPTS=    $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
		test_longexp
memtest:	all platform
		-rm -f $(srcdir)/Lib/test/*.py[co]
752 753
		-$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
754

755
# Install everything
756
install:	@FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@
757 758

# Install almost everything without disturbing previous versions
759 760
altinstall:	@FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \
                sharedinstall oldsharedinstall @FRAMEWORKALTINSTALLLAST@
761 762 763 764 765 766

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

oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
		@for i in X $(SHAREDMODS); do \
767 768
		  if test $$i != X; then \
		    echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
769
		    $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
770
		  fi; \
771 772
		done

773
$(DESTSHARED):
774 775
		@for i in $(DESTDIRS); \
		do \
776
			if test ! -d $(DESTDIR)$$i; then \
777
				echo "Creating directory $$i"; \
778
				$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
779 780 781 782 783 784 785
			else    true; \
			fi; \
		done


# Install the interpreter (by creating a hard link to python$(VERSION))
bininstall:	altbininstall
786 787
	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
788 789
	else true; \
	fi
790
	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
791 792
	-rm -f $(DESTDIR)$(BINDIR)/python-config
	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config)
793
	-test -d $(DESTDIR)$(LIBPC) || $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC)
794 795
	-rm -f $(DESTDIR)$(LIBPC)/python.pc
	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python.pc)
796 797 798

# Install the interpreter with $(VERSION) affixed
# This goes into $(exec_prefix)
799
altbininstall:	$(BUILDPYTHON)
800
	@for i in $(BINDIR) $(LIBDIR); \
801
	do \
802
		if test ! -d $(DESTDIR)$$i; then \
803
			echo "Creating directory $$i"; \
804
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
805 806 807
		else	true; \
		fi; \
	done
808
	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
809
	if test -f $(LDLIBRARY); then \
810 811
		if test -n "$(DLLLIBRARY)" ; then \
			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
812
		else \
813 814 815
			$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
			if test $(LDLIBRARY) != $(INSTSONAME); then \
				(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
816
			fi \
817
		fi; \
818 819 820 821 822 823 824
	else	true; \
	fi

# Install the manual page
maninstall:
	@for i in $(MANDIR) $(MANDIR)/man1; \
	do \
825
		if test ! -d $(DESTDIR)$$i; then \
826
			echo "Creating directory $$i"; \
827
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
828 829 830 831
		else	true; \
		fi; \
	done
	$(INSTALL_DATA) $(srcdir)/Misc/python.man \
832
		$(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
833 834 835

# Install the library
PLATDIR=	plat-$(MACHDEP)
836
EXTRAPLATDIR= @EXTRAPLATDIR@
837
EXTRAMACHDEPPATH=@EXTRAMACHDEPPATH@
838
MACHDEPS=	$(PLATDIR) $(EXTRAPLATDIR)
839
XMLLIBSUBDIRS=  xml xml/dom xml/etree xml/parsers xml/sax
840
PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
841
	plat-mac/lib-scriptpackages/_builtinSuites \
842 843 844 845 846
	plat-mac/lib-scriptpackages/CodeWarrior \
	plat-mac/lib-scriptpackages/Explorer \
	plat-mac/lib-scriptpackages/Finder \
	plat-mac/lib-scriptpackages/Netscape \
	plat-mac/lib-scriptpackages/StdSuites \
847
	plat-mac/lib-scriptpackages/SystemEvents \
848
	plat-mac/lib-scriptpackages/Terminal 
849
PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
850 851
LIBSUBDIRS=	lib-tk lib-tk/test lib-tk/test/test_tkinter \
                lib-tk/test/test_ttk site-packages test test/data \
852
		test/decimaltestdata test/xmltestdata \
853
		test/tracedmodules \
854 855
		encodings compiler hotshot \
		email email/mime email/test email/test/data \
856
		json json/tests \
857
		sqlite3 sqlite3/test \
858
		logging bsddb bsddb/test csv importlib wsgiref \
Benjamin Peterson's avatar
Benjamin Peterson committed
859
		lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
Benjamin Peterson's avatar
Benjamin Peterson committed
860
		lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
861
		ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
862
		distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
863
		multiprocessing multiprocessing/dummy \
864
		unittest unittest/test \
865
		lib-old \
866
		curses pydoc_data $(MACHDEPS)
867
libinstall:	build_all $(srcdir)/Lib/$(PLATDIR)
868 869
	@for i in $(SCRIPTDIR) $(LIBDEST); \
	do \
870
		if test ! -d $(DESTDIR)$$i; then \
871
			echo "Creating directory $$i"; \
872
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
873 874 875 876 877 878 879 880
		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; \
881
		if test ! -d $(DESTDIR)$$b; then \
882
			echo "Creating directory $$b"; \
883
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
884 885 886
		else	true; \
		fi; \
	done
887
	@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
888 889
	do \
		if test -x $$i; then \
890
			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
891
			echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
892
		else \
893
			$(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
894 895 896 897 898 899 900
			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; \
901
		if test `ls $$a | wc -l` -lt 1; then continue; fi; \
902 903 904 905 906 907 908 909 910 911 912
		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 \
913
				    echo $(INSTALL_SCRIPT) $$i $$b; \
914
				    $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
915 916
				else \
				    echo $(INSTALL_DATA) $$i $$b; \
917
				    $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
918 919 920 921
				fi;; \
			esac; \
		done; \
	done
922 923 924
	$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
	PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
		./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
925
		-d $(LIBDEST) -f \
Benjamin Peterson's avatar
Benjamin Peterson committed
926
		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
927
		$(DESTDIR)$(LIBDEST)
928 929
	PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
		./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
930
		-d $(LIBDEST) -f \
Benjamin Peterson's avatar
Benjamin Peterson committed
931
		-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
932
		$(DESTDIR)$(LIBDEST)
933
	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
934
		./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
935
		-d $(LIBDEST)/site-packages -f \
936
		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
937
	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
938
		./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
939
		-d $(LIBDEST)/site-packages -f \
940
		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
Martin v. Löwis's avatar
Martin v. Löwis committed
941
	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
942
		./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
943 944 945 946 947 948 949

# 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"; \
950
	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
951
	export EXE; EXE="$(BUILDEXE)"; \
Ronald Oussoren's avatar
Ronald Oussoren committed
952
	cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
953

954 955 956 957 958
python-config: $(srcdir)/Misc/python-config.in
	# Substitution happens here, as the completely-expanded BINDIR
	# is not available in configure
	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config

959 960 961 962 963
# Install the include files
INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
inclinstall:
	@for i in $(INCLDIRSTOMAKE); \
	do \
964
		if test ! -d $(DESTDIR)$$i; then \
965
			echo "Creating directory $$i"; \
966
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
967 968 969 970 971 972
		else	true; \
		fi; \
	done
	@for i in $(srcdir)/Include/*.h; \
	do \
		echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
973
		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
974
	done
975
	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
976 977 978 979

# Install the library and miscellaneous stuff needed for extending/embedding
# This goes into $(exec_prefix)
LIBPL=		$(LIBP)/config
980 981 982 983

# pkgconfig directory
LIBPC=		$(LIBDIR)/pkgconfig

984
libainstall:	all python-config
985
	@for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
986
	do \
987
		if test ! -d $(DESTDIR)$$i; then \
988
			echo "Creating directory $$i"; \
989
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
990 991 992
		else	true; \
		fi; \
	done
993
	@if test -d $(LIBRARY); then :; else \
994
		if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
995
			if test "$(SO)" = .dll; then \
996
				$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
997
			else \
998 999
				$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
				$(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
1000
			fi; \
1001
		else \
1002
			echo Skip install of $(LIBRARY) - use make frameworkinstall; \
1003
		fi; \
1004
	fi
1005
	$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
1006
	$(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
1007 1008 1009 1010 1011
	$(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
1012
	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
1013 1014
	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
1015
	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
1016
	rm python-config
1017 1018 1019 1020
	@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		\
1021
				$(DESTDIR)$(LIBPL)/python.exp;		\
1022
		echo; echo "$(LIBPL)/python.exp";		\
1023
		$(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix	\
1024
				$(DESTDIR)$(LIBPL)/makexp_aix;		\
1025
		echo "$(LIBPL)/makexp_aix";			\
1026
		$(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix	\
1027
				$(DESTDIR)$(LIBPL)/ld_so_aix;		\
1028 1029 1030 1031 1032 1033
		echo "$(LIBPL)/ld_so_aix";			\
		echo; echo "See Misc/AIX-NOTES for details.";	\
	else true; \
	fi
	@case "$(MACHDEP)" in beos*) \
		echo; echo "Installing support files for building shared extension modules on BeOS:"; \
1034
		$(INSTALL_DATA) Misc/BeOS-NOTES $(DESTDIR)$(LIBPL)/README;	\
1035
		echo; echo "$(LIBPL)/README";			\
1036
		$(INSTALL_SCRIPT) Modules/ar_beos $(DESTDIR)$(LIBPL)/ar_beos; \
1037
		echo "$(LIBPL)/ar_beos";			\
1038
		$(INSTALL_SCRIPT) Modules/ld_so_beos $(DESTDIR)$(LIBPL)/ld_so_beos; \
1039 1040
		echo "$(LIBPL)/ld_so_beos";			\
		echo; echo "See Misc/BeOS-NOTES for details.";	\
1041 1042 1043 1044 1045
		;; \
	esac

# Install the dynamically loadable modules
# This goes into $(exec_prefix)
1046
sharedinstall: sharedmods
1047 1048
	$(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
	   	--prefix=$(prefix) \
1049
		--install-scripts=$(BINDIR) \
1050 1051
		--install-platlib=$(DESTSHARED) \
		--root=/$(DESTDIR)
1052

1053 1054 1055
# 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
1056
# the Makefile in Mac
1057
#
1058 1059 1060 1061
#
# This target is here for backward compatiblity, previous versions of Python
# hadn't integrated framework installation in the normal install process.
frameworkinstall: install
1062

1063 1064 1065 1066 1067 1068
# 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.

1069 1070 1071
frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib

frameworkinstallstructure:	$(LDLIBRARY)
1072
	@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1073
		echo Not configured with --enable-framework; \
1074
		exit 1; \
1075 1076
	else true; \
	fi
1077
	@for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1078
		if test ! -d $(DESTDIR)$$i; then \
1079 1080
			echo "Creating directory $(DESTDIR)$$i"; \
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1081 1082 1083
		else	true; \
		fi; \
	done
1084
	$(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
1085
	sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1086
	$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
1087
	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1088 1089
	$(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
	$(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1090
	$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1091

1092
# This installs Mac/Lib into the framework
1093 1094
# Install a number of symlinks to keep software that expects a normal unix
# install (which includes python-config) happy.
1095
frameworkinstallmaclib:
1096
	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1097
	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).dylib"
1098
	ln -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
1099
	cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
1100 1101 1102

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

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

1109
frameworkaltinstallunixtools:
1110
	cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1111

1112 1113 1114
# This installs the Demos and Tools into the applications directory.
# It is not part of a normal frameworkinstall
frameworkinstallextras:
1115
	cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
1116

1117 1118
# This installs a few of the useful scripts in Tools/scripts
scriptsinstall:
1119
	SRCDIR=$(srcdir) $(RUNSHARED) \
1120 1121
	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
	--prefix=$(prefix) \
1122 1123
	--install-scripts=$(BINDIR) \
	--root=/$(DESTDIR)
1124

1125 1126 1127 1128 1129
# 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

1130
# Run the configure script.
1131
config.status:	$(srcdir)/configure
1132
	$(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1133

1134
.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1135 1136 1137

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

Martin v. Löwis's avatar
Martin v. Löwis committed
1140 1141
# Run reindent on the library
reindent:
1142
	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
Martin v. Löwis's avatar
Martin v. Löwis committed
1143

1144 1145 1146 1147 1148 1149
# 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

1150
# Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160
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; \
1161
	sort -o tags tags
1162 1163 1164 1165 1166 1167 1168 1169

# 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
1170
# files, which clobber removes as well
1171 1172
pycremoval:
	find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1173

1174
clean: pycremoval
1175
	find . -name '*.[oa]' -exec rm -f {} ';'
1176
	find . -name '*.s[ol]' -exec rm -f {} ';'
1177
	find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
1178 1179
	find build -name 'fficonfig.h' -exec rm -f {} ';' || true
	find build -name 'fficonfig.py' -exec rm -f {} ';' || true
1180
	-rm -f Lib/lib2to3/*Grammar*.pickle
1181

1182 1183 1184 1185
profile-removal:
	find . -name '*.gc??' -exec rm -f {} ';'

clobber: clean profile-removal
1186
	-rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1187
		tags TAGS \
1188
		config.cache config.log pyconfig.h Modules/config.c
1189
	-rm -rf build platform
1190
	-rm -rf $(PYTHONFRAMEWORKDIR)
1191 1192 1193

# Make things extra clean, before making a distribution:
# remove all generated files, even Makefile[.pre]
1194
# Keep configure and Python-ast.[ch], it's possible they can't be generated
1195
distclean: clobber
1196 1197 1198
	for file in Lib/test/data/* ; do \
	    if test "$$file" != "Lib/test/data/README"; then rm "$$file"; fi; \
	done
1199
	-rm -f core Makefile Makefile.pre config.status \
1200
		Modules/Setup Modules/Setup.local Modules/Setup.config \
1201
		Modules/ld_so_aix Misc/python.pc
1202
	-rm -f python*-gdb.py
1203 1204 1205 1206 1207
	find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
			   -o -name '[@,#]*' -o -name '*.old' \
			   -o -name '*.orig' -o -name '*.rej' \
			   -o -name '*.bak' ')' \
			   -exec rm -f {} ';'
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242

# 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:
	find $(DISTDIRS) -type d \
		-o -name '*.[chs]' \
		-o -name '*.py' \
		-o -name '*.doc' \
		-o -name '*.sty' \
		-o -name '*.bib' \
		-o -name '*.dat' \
		-o -name '*.el' \
		-o -name '*.fd' \
		-o -name '*.in' \
		-o -name '*.tex' \
		-o -name '*,[vpt]' \
		-o -name 'Setup' \
		-o -name 'Setup.*' \
		-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

1243
# Perform some verification checks on any modified files.
1244
patchcheck:
1245
	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1246

1247 1248
# Dependencies

1249
Python/thread.o: @THREADHEADERS@
1250

1251
# Declare targets that aren't real files
1252
.PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1253 1254 1255 1256
.PHONY: install altinstall oldsharedinstall bininstall altbininstall
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1257
.PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean 
1258
.PHONY: smelly funny patchcheck
1259
.PHONY: gdbhooks
1260

1261
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY