Makefile.pre.in 37.6 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
UNICODE_OBJS=   @UNICODE_OBJS@
175

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

179 180 181 182
# The task to run while instrument when building the profile-opt target
PROFILE_TASK=	Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
#PROFILE_TASK=	Lib/test/regrtest.py

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


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

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


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


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

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

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

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

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

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

Jeremy Hylton's avatar
Jeremy Hylton committed
237 238
##########################################################################
# AST
239 240 241 242
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
243 244 245 246
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
247
ASDLGEN=	$(srcdir)/Parser/asdl_c.py
248 249 250 251

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


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


##########################################################################
# objects that get linked into the Python library
LIBRARY_OBJS=	\
342
		Modules/getbuildinfo.o \
343 344 345 346 347 348 349 350 351 352 353
		$(PARSER_OBJS) \
		$(OBJECT_OBJS) \
		$(PYTHON_OBJS) \
		$(MODULE_OBJS) \
		$(SIGNAL_OBJS) \
		$(MODOBJS)

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

# Default target
354 355
all:		build_all
build_all:	$(BUILDPYTHON) oldsharedmods sharedmods
356

357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
# 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"

378 379 380 381 382 383
coverage:
	@echo "Building with support for coverage checking:"
	$(MAKE) clean
	$(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"


384
# Build the interpreter
385
$(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY)
386
		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
387
			Modules/python.o \
388
			$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
389

390
platform: $(BUILDPYTHON)
391
	$(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
392 393 394


# Build the shared modules
395
sharedmods: $(BUILDPYTHON)
396
	@case $$MAKEFLAGS in \
397
	*s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
398
	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
399
	esac
400 401

# Build static library
402
# avoid long command lines, same as LIBRARY_OBJS
403 404
$(LIBRARY): $(LIBRARY_OBJS)
	-rm -f $@
405
	$(AR) cr $@ Modules/getbuildinfo.o
406 407 408 409 410 411 412
	$(AR) cr $@ $(PARSER_OBJS)
	$(AR) cr $@ $(OBJECT_OBJS)
	$(AR) cr $@ $(PYTHON_OBJS)
	$(AR) cr $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
	$(AR) cr $@ $(MODOBJS)
	$(RANLIB) $@

413
libpython$(VERSION).so: $(LIBRARY_OBJS)
414
	if test $(INSTSONAME) != $(LDLIBRARY); then \
415
		$(LDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
416 417 418 419
		$(LN) -f $(INSTSONAME) $@; \
	else\
		$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
	fi
420 421

libpython$(VERSION).sl: $(LIBRARY_OBJS)
422
	$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM)
423

424 425 426
# 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.
427
RESSRCDIR=Mac/Resources/framework
428 429
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
		$(LIBRARY) \
430
		$(RESSRCDIR)/Info.plist
431
	$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
432
	if test "${UNIVERSALSDK}"; then \
433
		$(CC) -o $(LDLIBRARY) @UNIVERSAL_ARCH_FLAGS@ -dynamiclib \
434 435
			-isysroot "${UNIVERSALSDK}" \
			-all_load $(LIBRARY) -Wl,-single_module \
436
			-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
437 438 439
			-compatibility_version $(VERSION) \
			-current_version $(VERSION); \
        else \
440
		/usr/bin/libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
441 442
			@LIBTOOL_CRUFT@ ;\
	fi
443 444 445 446
	$(INSTALL) -d -m $(DIRMODE)  \
		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
447
	$(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
448
	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
449 450
	$(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
	$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
451

452 453 454 455 456 457 458 459
# 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 \
		$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
			$(LIBS) $(MODLIBS) $(SYSLIBS); \
	else true; \
	fi
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485


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."; \
486
		echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
487
		echo "-----------------------------------------------"; \
488
	fi
489 490 491 492

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

493 494 495 496 497 498 499
Modules/getbuildinfo.o: $(PARSER_OBJS) \
		$(OBJECT_OBJS) \
		$(PYTHON_OBJS) \
		$(MODULE_OBJS) \
		$(SIGNAL_OBJS) \
		$(MODOBJS) \
		$(srcdir)/Modules/getbuildinfo.c
500
	$(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
501

502
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
503 504 505 506 507
	$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
		-DPREFIX='"$(prefix)"' \
		-DEXEC_PREFIX='"$(exec_prefix)"' \
		-DVERSION='"$(VERSION)"' \
		-DVPATH='"$(VPATH)"' \
508
		-o $@ $(srcdir)/Modules/getpath.c
509

510 511
Modules/python.o: $(srcdir)/Modules/python.c
	$(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c
512 513 514


$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
515
		-@$(INSTALL) -d Include
516
		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
517 518

$(PGEN):	$(PGENOBJS)
519
		$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
520 521 522 523 524 525

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

526 527
Parser/tokenizer_pgen.o:	$(srcdir)/Parser/tokenizer.c

528 529
Parser/pgenmain.o:	$(srcdir)/Include/parsetok.h

530 531
$(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
	$(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
532

533 534
$(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
	$(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
535

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

538
Python/getplatform.o: $(srcdir)/Python/getplatform.c
539
		$(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
540 541

Python/importdl.o: $(srcdir)/Python/importdl.c
542
		$(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
543 544 545 546

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

547
STRINGLIB_HEADERS= \
Christian Heimes's avatar
Christian Heimes committed
548
		$(srcdir)/Include/bytes_methods.h \
549
		$(srcdir)/Objects/stringlib/count.h \
Christian Heimes's avatar
Christian Heimes committed
550
		$(srcdir)/Objects/stringlib/ctype.h \
551 552 553 554 555 556
		$(srcdir)/Objects/stringlib/fastsearch.h \
		$(srcdir)/Objects/stringlib/find.h \
		$(srcdir)/Objects/stringlib/formatter.h \
		$(srcdir)/Objects/stringlib/partition.h \
		$(srcdir)/Objects/stringlib/stringdefs.h \
		$(srcdir)/Objects/stringlib/string_format.h \
Christian Heimes's avatar
Christian Heimes committed
557
		$(srcdir)/Objects/stringlib/transmogrify.h \
558 559
		$(srcdir)/Objects/stringlib/unicodedefs.h \
		$(srcdir)/Objects/stringlib/localeutil.h
560

561
Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
562
				$(STRINGLIB_HEADERS)
563 564

Objects/stringobject.o: $(srcdir)/Objects/stringobject.c \
565
				$(STRINGLIB_HEADERS)
566 567

Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
568
				$(STRINGLIB_HEADERS)
569 570

Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
571
				$(STRINGLIB_HEADERS)
572

573 574 575
############################################################################
# Header files

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

656
$(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
657

658 659 660 661

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

# Test the interpreter (twice, once without .pyc files, once with)
662 663 664 665 666 667 668
# 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.

669
TESTOPTS=	-l $(EXTRATESTOPTS)
670
TESTPROG=	$(srcdir)/Lib/test/regrtest.py
671
TESTPYTHON=	$(RUNSHARED) ./$(BUILDPYTHON) -E -tt
672
test:		all platform
Guido van Rossum's avatar
Guido van Rossum committed
673
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
674 675
		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
676

677
testall:	all platform
Christian Heimes's avatar
Christian Heimes committed
678
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
679
		$(TESTPYTHON) $(srcdir)/Lib/compileall.py
680 681 682 683
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall

684 685 686 687 688 689 690 691 692 693 694 695 696
#  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
		$(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) $(TESTOPTS) -uall


697
# Like testall, but with a single pass only
698
# run an optional script to include some information about the build environment
699
buildbottest:	all platform
700 701 702
		-@if which pybuildbot.identify >/dev/null 2>&1; then \
			pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
		fi
703 704
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw

705
QUICKTESTOPTS=	$(TESTOPTS) -x test_thread test_signal test_strftime \
706
		test_unicodedata test_re test_sre test_select test_poll \
707
		test_linuxaudiodev test_struct test_sunaudiodev test_zlib
708
quicktest:	all platform
Guido van Rossum's avatar
Guido van Rossum committed
709
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
710 711
		-$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
712

713 714 715 716
MEMTESTOPTS=    $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
		test_longexp
memtest:	all platform
		-rm -f $(srcdir)/Lib/test/*.py[co]
717 718
		-$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
719

720
# Install everything
721
install:	@FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@
722 723

# Install almost everything without disturbing previous versions
724 725
altinstall:	@FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \
                sharedinstall oldsharedinstall @FRAMEWORKALTINSTALLLAST@
726 727 728 729 730 731

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

oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
		@for i in X $(SHAREDMODS); do \
732 733
		  if test $$i != X; then \
		    echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
734
		    $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
735
		  fi; \
736 737
		done

738
$(DESTSHARED):
739 740
		@for i in $(DESTDIRS); \
		do \
741
			if test ! -d $(DESTDIR)$$i; then \
742
				echo "Creating directory $$i"; \
743
				$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
744 745 746 747 748 749 750
			else    true; \
			fi; \
		done


# Install the interpreter (by creating a hard link to python$(VERSION))
bininstall:	altbininstall
751 752
	-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
	then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
753 754
	else true; \
	fi
755
	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
756 757
	-rm -f $(DESTDIR)$(BINDIR)/python-config
	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config)
758 759 760

# Install the interpreter with $(VERSION) affixed
# This goes into $(exec_prefix)
761
altbininstall:	$(BUILDPYTHON)
762
	@for i in $(BINDIR) $(LIBDIR); \
763
	do \
764
		if test ! -d $(DESTDIR)$$i; then \
765
			echo "Creating directory $$i"; \
766
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
767 768 769
		else	true; \
		fi; \
	done
770
	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
771
	if test -f libpython$(VERSION)$(SO); then \
772
		if test "$(SO)" = .dll; then \
773
			$(INSTALL_SHARED) libpython$(VERSION)$(SO) $(DESTDIR)$(BINDIR); \
774
		else \
775
			$(INSTALL_SHARED) libpython$(VERSION)$(SO) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
776 777 778
			if test libpython$(VERSION)$(SO) != $(INSTSONAME); then \
				(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) libpython$(VERSION)$(SO)); \
			fi \
779
		fi; \
780 781 782 783 784 785 786
	else	true; \
	fi

# Install the manual page
maninstall:
	@for i in $(MANDIR) $(MANDIR)/man1; \
	do \
787
		if test ! -d $(DESTDIR)$$i; then \
788
			echo "Creating directory $$i"; \
789
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
790 791 792 793
		else	true; \
		fi; \
	done
	$(INSTALL_DATA) $(srcdir)/Misc/python.man \
794
		$(DESTDIR)$(MANDIR)/man1/python.1
795 796 797

# Install the library
PLATDIR=	plat-$(MACHDEP)
798
EXTRAPLATDIR= @EXTRAPLATDIR@
799
EXTRAMACHDEPPATH=@EXTRAMACHDEPPATH@
800
MACHDEPS=	$(PLATDIR) $(EXTRAPLATDIR)
801
XMLLIBSUBDIRS=  xml xml/dom xml/etree xml/parsers xml/sax
802
PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
803
	plat-mac/lib-scriptpackages/_builtinSuites \
804 805 806 807 808
	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 \
809
	plat-mac/lib-scriptpackages/SystemEvents \
810
	plat-mac/lib-scriptpackages/Terminal 
811
PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
812
LIBSUBDIRS=	lib-tk site-packages test test/output test/data \
813
		test/decimaltestdata \
814 815
		encodings compiler hotshot \
		email email/mime email/test email/test/data \
816
		json json/tests \
817
		sqlite3 sqlite3/test \
818
		logging bsddb bsddb/test csv wsgiref \
819
		lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
820
		ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
821
		distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
822
		multiprocessing multiprocessing/dummy \
823
		lib-old \
824
		curses $(MACHDEPS)
825
libinstall:	build_all $(srcdir)/Lib/$(PLATDIR)
826 827
	@for i in $(SCRIPTDIR) $(LIBDEST); \
	do \
828
		if test ! -d $(DESTDIR)$$i; then \
829
			echo "Creating directory $$i"; \
830
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
831 832 833 834 835 836 837 838
		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; \
839
		if test ! -d $(DESTDIR)$$b; then \
840
			echo "Creating directory $$b"; \
841
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
842 843 844
		else	true; \
		fi; \
	done
845
	@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
846 847
	do \
		if test -x $$i; then \
848
			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
849
			echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
850
		else \
851
			$(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
852 853 854 855 856 857 858
			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; \
859
		if test `ls $$a | wc -l` -lt 1; then continue; fi; \
860 861 862 863 864 865 866 867 868 869 870
		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 \
871
				    echo $(INSTALL_SCRIPT) $$i $$b; \
872
				    $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
873 874
				else \
				    echo $(INSTALL_DATA) $$i $$b; \
875
				    $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
876 877 878 879
				fi;; \
			esac; \
		done; \
	done
880 881 882
	$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
	PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
		./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
883
		-d $(LIBDEST) -f \
884
		-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
885 886
	PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
		./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
887
		-d $(LIBDEST) -f \
888
		-x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
889
	-PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
890
		./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
891
		-d $(LIBDEST)/site-packages -f \
892
		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
893
	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
894
		./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
895
		-d $(LIBDEST)/site-packages -f \
896
		-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
Martin v. Löwis's avatar
Martin v. Löwis committed
897 898
	-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
		./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram"
899 900 901 902 903 904 905

# 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"; \
906
	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
907
	export EXE; EXE="$(BUILDEXE)"; \
908 909 910 911 912 913 914
	cd $(srcdir)/Lib/$(PLATDIR); ./regen

# Install the include files
INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
inclinstall:
	@for i in $(INCLDIRSTOMAKE); \
	do \
915
		if test ! -d $(DESTDIR)$$i; then \
916
			echo "Creating directory $$i"; \
917
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
918 919 920 921 922 923
		else	true; \
		fi; \
	done
	@for i in $(srcdir)/Include/*.h; \
	do \
		echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
924
		$(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
925
	done
926
	$(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
927 928 929 930 931 932 933

# 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 \
934
		if test ! -d $(DESTDIR)$$i; then \
935
			echo "Creating directory $$i"; \
936
			$(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
937 938 939
		else	true; \
		fi; \
	done
940
	@if test -d $(LIBRARY); then :; else \
941
		if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
942
			if test "$(SO)" = .dll; then \
943
				$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
944
			else \
945 946
				$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
				$(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
947
			fi; \
948
		else \
949
			echo Skip install of $(LIBRARY) - use make frameworkinstall; \
950
		fi; \
951
	fi
952
	$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
953
	$(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
954 955 956 957 958 959 960
	$(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
961 962
	# Substitution happens here, as the completely-expanded BINDIR
	# is not available in configure
963
	sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
964
	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
965
	rm python-config
966 967 968 969
	@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		\
970
				$(DESTDIR)$(LIBPL)/python.exp;		\
971
		echo; echo "$(LIBPL)/python.exp";		\
972
		$(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix	\
973
				$(DESTDIR)$(LIBPL)/makexp_aix;		\
974
		echo "$(LIBPL)/makexp_aix";			\
975
		$(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix	\
976
				$(DESTDIR)$(LIBPL)/ld_so_aix;		\
977 978 979 980 981 982
		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:"; \
983
		$(INSTALL_DATA) Misc/BeOS-NOTES $(DESTDIR)$(LIBPL)/README;	\
984
		echo; echo "$(LIBPL)/README";			\
985
		$(INSTALL_SCRIPT) Modules/ar_beos $(DESTDIR)$(LIBPL)/ar_beos; \
986
		echo "$(LIBPL)/ar_beos";			\
987
		$(INSTALL_SCRIPT) Modules/ld_so_beos $(DESTDIR)$(LIBPL)/ld_so_beos; \
988 989
		echo "$(LIBPL)/ld_so_beos";			\
		echo; echo "See Misc/BeOS-NOTES for details.";	\
990 991 992 993 994 995
		;; \
	esac

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

1002 1003 1004
# 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
1005
# the Makefile in Mac
1006
#
1007 1008 1009 1010
#
# This target is here for backward compatiblity, previous versions of Python
# hadn't integrated framework installation in the normal install process.
frameworkinstall: install
1011

1012 1013 1014 1015 1016 1017
# 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.

1018 1019 1020
frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib

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

1041
# This installs Mac/Lib into the framework
1042 1043
# Install a number of symlinks to keep software that expects a normal unix
# install (which includes python-config) happy.
1044
frameworkinstallmaclib:
1045
	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1046
	cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
1047 1048 1049

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

1052 1053 1054
frameworkinstallapps4way:
	cd Mac && $(MAKE) installapps4way DESTDIR="$(DESTDIR)"

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

1059 1060 1061
frameworkinstallunixtools4way:
	cd Mac && $(MAKE) installunixtools4way DESTDIR="$(DESTDIR)"

1062
frameworkaltinstallunixtools:
1063
	cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1064

1065 1066 1067
frameworkaltinstallunixtools4way:
	cd Mac && $(MAKE) altinstallunixtools4way DESTDIR="$(DESTDIR)"

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

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

1081 1082 1083 1084 1085
# 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

1086
# Run the configure script.
1087
config.status:	$(srcdir)/configure
1088
	$(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1089

1090
.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1091 1092 1093

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

Martin v. Löwis's avatar
Martin v. Löwis committed
1096 1097
# Run reindent on the library
reindent:
1098
	./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
Martin v. Löwis's avatar
Martin v. Löwis committed
1099

1100 1101 1102 1103 1104 1105
# 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

1106
# Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116
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; \
1117
	sort -o tags tags
1118 1119 1120 1121 1122 1123 1124 1125 1126

# 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
1127 1128
pycremoval:
	find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1129

1130
clean: pycremoval
1131
	find . -name '*.o' -exec rm -f {} ';'
1132
	find . -name '*.s[ol]' -exec rm -f {} ';'
1133 1134
	find $(srcdir)/build -name 'fficonfig.h' -exec rm -f {} ';' || true
	find $(srcdir)/build -name 'fficonfig.py' -exec rm -f {} ';' || true
1135

1136 1137 1138 1139
profile-removal:
	find . -name '*.gc??' -exec rm -f {} ';'

clobber: clean profile-removal
1140
	-rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1141
		tags TAGS \
1142
		config.cache config.log pyconfig.h Modules/config.c
1143
	-rm -rf build platform
1144
	-rm -rf $(PYTHONFRAMEWORKDIR)
1145 1146 1147

# Make things extra clean, before making a distribution:
# remove all generated files, even Makefile[.pre]
1148
# Keep configure and Python-ast.[ch], it's possible they can't be generated
1149
distclean: clobber
1150
	-rm -f core Makefile Makefile.pre config.status \
1151
		Modules/Setup Modules/Setup.local Modules/Setup.config
1152 1153 1154 1155 1156
	find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
			   -o -name '[@,#]*' -o -name '*.old' \
			   -o -name '*.orig' -o -name '*.rej' \
			   -o -name '*.bak' ')' \
			   -exec rm -f {} ';'
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191

# 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

1192 1193
# Perform some verification checks on any modified files.
check:
1194
	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1195

1196 1197
# Dependencies

1198
Python/thread.o: @THREADHEADERS@
1199

1200
# Declare targets that aren't real files
1201
.PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1202 1203 1204 1205
.PHONY: install altinstall oldsharedinstall bininstall altbininstall
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1206 1207
.PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean 
.PHONY: smelly funny
1208

1209
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY