PageRenderTime 85ms CodeModel.GetById 26ms app.highlight 49ms RepoModel.GetById 1ms app.codeStats 0ms

/Makefile.pre.in

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