Makefile.pre.in 25.9 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 33 34 35 36 37 38 39 40 41 42 43 44 45
# 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@
LINKCC=		@LINKCC@
AR=		@AR@
RANLIB=		@RANLIB@

# 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@
46
INSTALL_SCRIPT= @INSTALL_SCRIPT@
47 48 49 50 51 52 53 54 55 56 57
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@
DEFS=		@DEFS@
58 59
CFLAGS=		$(OPT)
CPPFLAGS=	-I. -I$(srcdir)/Include $(DEFS)
60 61 62
LDFLAGS=	@LDFLAGS@
LDLAST=		@LDLAST@
SGI_ABI=	@SGI_ABI@
63 64 65 66 67
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
68
PY_CFLAGS=	$(CFLAGS) $(CPPFLAGS) $(CFLAGSFORSHARED)
69

70 71 72 73 74 75 76 77 78 79 80 81 82

# Machine-dependent subdirectories
MACHDEP=	@MACHDEP@

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

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

# Expanded directories
BINDIR=		$(exec_prefix)/bin
LIBDIR=		$(exec_prefix)/lib
83 84
MANDIR=		@mandir@
INCLUDEDIR=	@includedir@
85 86 87 88 89 90 91 92 93 94 95 96 97
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@
98
BLDSHARED=	@BLDSHARED@
99 100 101
DESTSHARED=	$(BINLIBDEST)/lib-dynload

# Executable suffix (.exe on Windows and Mac OS X)
102
EXE=		@EXEEXT@
103
BUILDEXE=	@BUILDEXEEXT@
104

105 106 107 108 109 110
# Short name and location for Mac OS X Python framework
PYTHONFRAMEWORK=	@PYTHONFRAMEWORK@
PYTHONFRAMEWORKDIR=	@PYTHONFRAMEWORKDIR@
PYTHONFRAMEWORKPREFIX=	@PYTHONFRAMEWORKPREFIX@
PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@

111 112 113 114 115 116
# 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

117 118
# configure script arguments
CONFIG_ARGS=	@CONFIG_ARGS@
119 120 121 122 123 124 125 126 127


# Subdirectories with code
SRCDIRS= 	@SRCDIRS@

# Other subdirectories
SUBDIRSTOO=	Include Lib Misc Demo

# Files and directories to be distributed
128
CONFIGFILES=	configure configure.in acconfig.h pyconfig.h.in Makefile.pre.in
129 130 131 132 133
DISTFILES=	README ChangeLog $(CONFIGFILES)
DISTDIRS=	$(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
DIST=		$(DISTFILES) $(DISTDIRS)


134
LIBRARY=	@LIBRARY@
135
LDLIBRARY=      @LDLIBRARY@
136
BLDLIBRARY=     @BLDLIBRARY@
137
DLLLIBRARY=	@DLLLIBRARY@
138
LDLIBRARYDIR=   @LDLIBRARYDIR@
139 140 141 142 143 144 145 146 147 148 149


LIBS=		@LIBS@
LIBM=		@LIBM@
LIBC=		@LIBC@
SYSLIBS=	$(LIBM) $(LIBC)

MAINOBJ=	@MAINOBJ@
LIBOBJS=	@LIBOBJS@
DLINCLDIR=	@DLINCLDIR@
DYNLOADFILE=	@DYNLOADFILE@
150
MACHDEP_OBJS=	@MACHDEP_OBJS@
151
UNICODE_OBJS=   @UNICODE_OBJS@
152

153
PYTHON=		python$(EXE)
154
BUILDPYTHON=	python$(BUILDEXE)
155 156 157 158 159 160 161 162 163

# === Definitions added by makesetup ===


##########################################################################
# Modules
MODULE_OBJS=	\
		Modules/config.o \
		Modules/getpath.o \
164 165
		Modules/main.o \
		Modules/gcmodule.o
166 167 168 169 170 171 172

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


##########################################################################
# Grammar
173 174
GRAMMAR_H=	$(srcdir)/Include/graminit.h
GRAMMAR_C=	$(srcdir)/Python/graminit.c
175 176 177 178 179
GRAMMAR_INPUT=	$(srcdir)/Grammar/Grammar


##########################################################################
# Parser
180
PGEN=		Parser/pgen$(EXE)
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195

POBJS=		\
		Parser/acceler.o \
		Parser/grammar1.o \
		Parser/listnode.o \
		Parser/node.o \
		Parser/parser.o \
		Parser/parsetok.o \
		Parser/tokenizer.o \
		Parser/bitset.o \
		Parser/metagrammar.o

PARSER_OBJS=	$(POBJS) Parser/myreadline.o

PGOBJS=		\
196
		Python/mysnprintf.o \
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
		Parser/firstsets.o \
		Parser/grammar.o \
		Parser/pgen.o \
		Parser/printgrammar.o \
		Parser/pgenmain.o

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


##########################################################################
# Python
PYTHON_OBJS=	\
		Python/bltinmodule.o \
		Python/exceptions.o \
		Python/ceval.o \
		Python/compile.o \
		Python/codecs.o \
		Python/errors.o \
		Python/frozen.o \
		Python/frozenmain.o \
217
		Python/future.o \
218 219 220 221 222 223 224 225 226 227 228 229
		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 \
230
		Python/mysnprintf.o \
231 232 233 234
		Python/pyfpe.o \
		Python/pystate.o \
		Python/pythonrun.o \
		Python/structmember.o \
235
		Python/symtable.o \
236 237 238 239
		Python/sysmodule.o \
		Python/traceback.o \
		Python/getopt.o \
		Python/$(DYNLOADFILE) \
240
		$(MACHDEP_OBJS) \
241 242 243 244 245 246 247 248
		$(LIBOBJS)


##########################################################################
# Objects
OBJECT_OBJS=	\
		Objects/abstract.o \
		Objects/bufferobject.o \
Jeremy Hylton's avatar
Jeremy Hylton committed
249
		Objects/cellobject.o \
250 251 252
		Objects/classobject.o \
		Objects/cobject.o \
		Objects/complexobject.o \
253
		Objects/descrobject.o \
254 255 256 257 258
		Objects/fileobject.o \
		Objects/floatobject.o \
		Objects/frameobject.o \
		Objects/funcobject.o \
		Objects/intobject.o \
259
		Objects/iterobject.o \
260 261 262 263 264 265 266 267 268
		Objects/listobject.o \
		Objects/longobject.o \
		Objects/dictobject.o \
		Objects/methodobject.o \
		Objects/moduleobject.o \
		Objects/object.o \
		Objects/rangeobject.o \
		Objects/sliceobject.o \
		Objects/stringobject.o \
269
		Objects/structseq.o \
270 271
		Objects/tupleobject.o \
		Objects/typeobject.o \
272
		Objects/weakrefobject.o \
273
		$(UNICODE_OBJS)
274 275 276 277 278


##########################################################################
# objects that get linked into the Python library
LIBRARY_OBJS=	\
279
		Modules/getbuildinfo.o \
280 281 282 283 284 285 286 287 288 289 290
		$(PARSER_OBJS) \
		$(OBJECT_OBJS) \
		$(PYTHON_OBJS) \
		$(MODULE_OBJS) \
		$(SIGNAL_OBJS) \
		$(MODOBJS)

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

# Default target
291
all:		$(BUILDPYTHON) oldsharedmods sharedmods
292 293

# Build the interpreter
294
$(BUILDPYTHON):	Modules/$(MAINOBJ) $(LDLIBRARY)
295 296
		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
			Modules/$(MAINOBJ) \
297
			$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
298

299 300
platform: $(BUILDPYTHON)
	./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
301 302 303


# Build the shared modules
304
sharedmods: $(BUILDPYTHON)
305
	case $$MAKEFLAGS in \
306 307
	*-s*) CC='$(CC)' LDSHARED='$(LDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
	*) CC='$(CC)' LDSHARED='$(LDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
308
	esac
309

310 311 312 313 314 315 316 317 318 319 320 321 322
# buildno should really depend on something like LIBRARY_SRC
buildno: $(PARSER_OBJS) \
		$(OBJECT_OBJS) \
		$(PYTHON_OBJS) \
		$(MODULE_OBJS) \
		$(SIGNAL_OBJS) \
		$(MODOBJS) \
		$(srcdir)/Modules/getbuildinfo.c
	if test -f buildno; then \
		expr `cat buildno` + 1 >buildno1; \
		mv -f buildno1 buildno; \
	else echo 1 >buildno; fi

323
# Build static library
324
# avoid long command lines, same as LIBRARY_OBJS
325 326
$(LIBRARY): $(LIBRARY_OBJS)
	-rm -f $@
327
	$(AR) cr $@ Modules/getbuildinfo.o
328 329 330 331 332 333 334
	$(AR) cr $@ $(PARSER_OBJS)
	$(AR) cr $@ $(OBJECT_OBJS)
	$(AR) cr $@ $(PYTHON_OBJS)
	$(AR) cr $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
	$(AR) cr $@ $(MODOBJS)
	$(RANLIB) $@

335
# This rule is only here for DG/UX and BeOS!!!
336 337 338 339 340 341 342 343
libpython$(VERSION).so:	$(LIBRARY)
	case `uname -s | tr -d '/ ' | tr '[A-Z]' '[a-z]'` in \
	*dgux*) \
	    test -d dgux || mkdir dgux; \
	    (cd dgux;ar x ../$^;ld -G -o ../$@ * ); \
	    /bin/rm -rf ./dgux \
	    ;; \
	beos) \
344
	    $(AR) so $(LIBRARY) $@ \
345 346 347 348
	    ;; \
	esac

# This rule is here for OPENSTEP/Rhapsody/MacOSX
349
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): $(LIBRARY) $(PYTHONFRAMEWORKDIR)
350
	libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
351
		-framework System @LIBTOOL_CRUFT@
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383

# This rule builds the Cygwin Python DLL
libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
	dlltool --export-all --output-def $@ $^
	$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
		$(LIBS) $(MODLIBS) $(SYSLIBS)


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."; \
384
		echo "Usually, copying Setup.dist to Setup will work."; \
385
		echo "-----------------------------------------------"; \
386
	fi
387 388 389 390 391

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

Modules/getbuildinfo.o: $(srcdir)/Modules/getbuildinfo.c buildno
392
	$(CC) -c $(PY_CFLAGS) -DBUILD=`cat buildno` -o $@ $(srcdir)/Modules/getbuildinfo.c
393

394
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
395 396 397 398 399
	$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
		-DPREFIX='"$(prefix)"' \
		-DEXEC_PREFIX='"$(exec_prefix)"' \
		-DVERSION='"$(VERSION)"' \
		-DVPATH='"$(VPATH)"' \
400
		-o $@ $(srcdir)/Modules/getpath.c
401

402 403
Modules/ccpython.o: $(srcdir)/Modules/ccpython.cc
	$(CXX) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/ccpython.cc
404 405 406


$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
407
		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
408 409 410 411 412 413 414 415 416 417

$(PGEN):	$(PGENOBJS)
		$(CC) $(OPT) $(PGENOBJS) $(LIBS) -o $(PGEN)

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


418 419
Python/compile.o Python/symtable.o: $(GRAMMAR_H)

420
Python/getplatform.o: $(srcdir)/Python/getplatform.c
421
		$(CC) -c $(CFLAGS) $(CPPFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
422 423

Python/importdl.o: $(srcdir)/Python/importdl.c
424
		$(CC) -c $(CFLAGS) $(CPPFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
425

426
Objects/object.o: $(srcdir)/Objects/object.c $(srcdir)/Objects/obmalloc.c
427 428 429 430 431 432 433

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

############################################################################
# Header files

434
PYTHON_HEADERS= \
435
		Include/Python.h \
436 437 438 439 440 441
		Include/abstract.h \
		Include/bufferobject.h \
		Include/ceval.h \
		Include/classobject.h \
		Include/cobject.h \
		Include/codecs.h \
442
		Include/compile.h \
443
		Include/complexobject.h \
444
		Include/descrobject.h \
445
		Include/dictobject.h \
446 447 448 449 450 451 452 453 454
		Include/fileobject.h \
		Include/floatobject.h \
		Include/funcobject.h \
		Include/import.h \
		Include/intobject.h \
		Include/intrcheck.h \
		Include/iterobject.h \
		Include/listobject.h \
		Include/longobject.h \
455
		Include/methodobject.h \
456
		Include/modsupport.h \
457
		Include/moduleobject.h \
458 459 460 461
		Include/object.h \
		Include/objimpl.h \
		Include/patchlevel.h \
		Include/pydebug.h \
462
		Include/pyerrors.h \
463 464 465
		Include/pyfpe.h \
		Include/pymem.h \
		Include/pyport.h \
466 467
		Include/pystate.h \
		Include/pythonrun.h \
468 469 470
		Include/rangeobject.h \
		Include/sliceobject.h \
		Include/stringobject.h \
471
		Include/structseq.h \
472 473
		Include/structmember.h \
		Include/symtable.h \
474
		Include/sysmodule.h \
475 476 477
		Include/traceback.h \
		Include/tupleobject.h \
		Include/unicodeobject.h \
478
		Include/weakrefobject.h \
479
		pyconfig.h
480

481
$(LIBRARY_OBJS) $(MODOBJS) Modules/$(MAINOBJ): $(PYTHON_HEADERS)
482

483 484 485 486 487 488

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

# Test the interpreter (twice, once without .pyc files, once with)
TESTOPTS=	-l
TESTPROG=	$(srcdir)/Lib/test/regrtest.py
489
TESTPYTHON=	./$(BUILDPYTHON) -E -tt
490
test:		all platform
Guido van Rossum's avatar
Guido van Rossum committed
491
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
492 493
		-$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
494

495
QUICKTESTOPTS=	$(TESTOPTS) -x test_thread test_signal test_strftime \
496
		test_unicodedata test_re test_sre test_select test_poll \
497
		test_linuxaudiodev test_sunaudiodev
498
quicktest:	all platform
Guido van Rossum's avatar
Guido van Rossum committed
499
		-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
500 501
		-$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
502

503 504 505 506
MEMTESTOPTS=    $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
		test_longexp
memtest:	all platform
		-rm -f $(srcdir)/Lib/test/*.py[co]
507 508
		-$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
		$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
509

510 511 512 513
# Install everything
install:	altinstall bininstall maninstall

# Install almost everything without disturbing previous versions
514
altinstall:	altbininstall libinstall inclinstall libainstall \
515
                sharedinstall oldsharedinstall
516 517 518 519 520 521

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

oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
		@for i in X $(SHAREDMODS); do \
522 523 524 525
		  if test $$i != X; then \
		    echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
		    $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
		  fi; \
526 527
		done

528
$(DESTSHARED):
529 530 531 532
		@for i in $(DESTDIRS); \
		do \
			if test ! -d $$i; then \
				echo "Creating directory $$i"; \
533
				$(INSTALL) -d -m $(DIRMODE) $$i; \
534 535 536 537 538 539 540 541 542 543 544
			else    true; \
			fi; \
		done


# Install the interpreter (by creating a hard link to python$(VERSION))
bininstall:	altbininstall
	-if test -f $(BINDIR)/$(PYTHON); \
	then rm -f $(BINDIR)/$(PYTHON); \
	else true; \
	fi
545
	(cd $(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
546 547 548

# Install the interpreter with $(VERSION) affixed
# This goes into $(exec_prefix)
549
altbininstall:	$(BUILDPYTHON)
550 551 552 553
	@for i in $(BINDIR); \
	do \
		if test ! -d $$i; then \
			echo "Creating directory $$i"; \
554
			$(INSTALL) -d -m $(DIRMODE) $$i; \
555 556 557
		else	true; \
		fi; \
	done
558
	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(BINDIR)/python$(VERSION)$(EXE)
559 560 561 562 563
	if test -f libpython$(VERSION).so; then \
		$(INSTALL_DATA) libpython$(VERSION).so $(LIBDIR); \
	else	true; \
	fi
	if test -f "$(DLLLIBRARY)"; then \
564
		$(INSTALL_SHARED) $(DLLLIBRARY) $(BINDIR); \
565 566 567 568 569 570 571 572 573
	else	true; \
	fi

# Install the manual page
maninstall:
	@for i in $(MANDIR) $(MANDIR)/man1; \
	do \
		if test ! -d $$i; then \
			echo "Creating directory $$i"; \
574
			$(INSTALL) -d -m $(DIRMODE) $$i; \
575 576 577 578 579 580 581 582 583 584
		else	true; \
		fi; \
	done
	$(INSTALL_DATA) $(srcdir)/Misc/python.man \
		$(MANDIR)/man1/python.1

# Install the library
PLATDIR=	plat-$(MACHDEP)
MACHDEPS=	$(PLATDIR)
XMLLIBSUBDIRS=  xml xml/dom xml/parsers xml/sax
585 586
LIBSUBDIRS=	lib-old lib-tk site-packages test test/output test/data \
		encodings email compiler hotshot \
587
		distutils distutils/command $(XMLLIBSUBDIRS) curses $(MACHDEPS)
588
libinstall:	$(BUILDPYTHON) $(srcdir)/Lib/$(PLATDIR)
589 590 591 592
	@for i in $(SCRIPTDIR) $(LIBDEST); \
	do \
		if test ! -d $$i; then \
			echo "Creating directory $$i"; \
593
			$(INSTALL) -d -m $(DIRMODE) $$i; \
594 595 596 597 598 599 600 601 602 603
		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; \
		if test ! -d $$b; then \
			echo "Creating directory $$b"; \
604
			$(INSTALL) -d -m $(DIRMODE) $$b; \
605 606 607 608 609 610
		else	true; \
		fi; \
	done
	@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc; \
	do \
		if test -x $$i; then \
611 612
			$(INSTALL_SCRIPT) $$i $(LIBDEST); \
			echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
		else \
			$(INSTALL_DATA) $$i $(LIBDEST); \
			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; \
		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 \
633 634
				    echo $(INSTALL_SCRIPT) $$i $$b; \
				    $(INSTALL_SCRIPT) $$i $$b; \
635 636 637 638 639 640 641 642 643
				else \
				    echo $(INSTALL_DATA) $$i $$b; \
				    $(INSTALL_DATA) $$i $$b; \
				fi;; \
			esac; \
		done; \
	done
	$(INSTALL_DATA) $(srcdir)/LICENSE $(LIBDEST)/LICENSE.txt
	PYTHONPATH=$(LIBDEST) \
644
		./$(BUILDPYTHON) -tt $(LIBDEST)/compileall.py -x badsyntax \
645
	        $(LIBDEST)
646
	PYTHONPATH=$(LIBDEST) \
647
		./$(BUILDPYTHON) -O $(LIBDEST)/compileall.py -x badsyntax $(LIBDEST)
648 649 650 651 652 653 654

# 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"; \
655
	export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
656
	export EXE; EXE="$(EXE)"; \
657 658 659 660 661 662 663 664 665
	cd $(srcdir)/Lib/$(PLATDIR); ./regen

# Install the include files
INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
inclinstall:
	@for i in $(INCLDIRSTOMAKE); \
	do \
		if test ! -d $$i; then \
			echo "Creating directory $$i"; \
666
			$(INSTALL) -d -m $(DIRMODE) $$i; \
667 668 669 670 671 672 673 674
		else	true; \
		fi; \
	done
	@for i in $(srcdir)/Include/*.h; \
	do \
		echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
		$(INSTALL_DATA) $$i $(INCLUDEPY); \
	done
675
	$(INSTALL_DATA) pyconfig.h $(CONFINCLUDEPY)/pyconfig.h
676 677 678 679 680 681 682 683 684

# 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 \
		if test ! -d $$i; then \
			echo "Creating directory $$i"; \
685
			$(INSTALL) -d -m $(DIRMODE) $$i; \
686 687 688 689
		else	true; \
		fi; \
	done
	@if test -d $(LDLIBRARY); then :; else \
690
		if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
691 692 693 694 695
			$(INSTALL_DATA) $(LDLIBRARY) $(LIBPL)/$(LDLIBRARY) ; \
			$(RANLIB) $(LIBPL)/$(LDLIBRARY) ; \
		else \
			echo Skip install of $(LDLIBRARY) - use make frameworkinstall; \
		fi; \
696 697
	fi
	$(INSTALL_DATA) Modules/config.c $(LIBPL)/config.c
698
	$(INSTALL_DATA) Modules/$(MAINOBJ) $(LIBPL)/$(MAINOBJ)
699 700 701 702 703
	$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(LIBPL)/config.c.in
	$(INSTALL_DATA) Makefile $(LIBPL)/Makefile
	$(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup
	$(INSTALL_DATA) Modules/Setup.local $(LIBPL)/Setup.local
	$(INSTALL_DATA) Modules/Setup.config $(LIBPL)/Setup.config
704 705
	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup
	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(LIBPL)/install-sh
706 707 708 709 710 711
	@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		\
				$(LIBPL)/python.exp;		\
		echo; echo "$(LIBPL)/python.exp";		\
712
		$(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix	\
713 714
				$(LIBPL)/makexp_aix;		\
		echo "$(LIBPL)/makexp_aix";			\
715
		$(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix	\
716 717 718 719 720 721 722
				$(LIBPL)/ld_so_aix;		\
		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:"; \
723
		$(INSTALL_DATA) Misc/BeOS-NOTES $(LIBPL)/README;	\
724
		echo; echo "$(LIBPL)/README";			\
725
		$(INSTALL_SCRIPT) Modules/ar_beos $(LIBPL)/ar_beos; \
726
		echo "$(LIBPL)/ar_beos";			\
727
		$(INSTALL_SCRIPT) Modules/ld_so_beos $(LIBPL)/ld_so_beos; \
728 729
		echo "$(LIBPL)/ld_so_beos";			\
		echo; echo "See Misc/BeOS-NOTES for details.";	\
730 731 732 733 734 735
		;; \
	esac

# Install the dynamically loadable modules
# This goes into $(exec_prefix)
sharedinstall:
736
	./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
737
		--install-scripts=$(BINDIR) \
738
		--install-platlib=$(DESTSHARED)
739

740 741 742 743 744 745 746 747 748 749 750
# Install a MacOSX framework During build (before
# setup.py), make a minimal Python.framework directory structure in the build
# directory. This framework is minimal, it doesn't contain the Lib directory
# and such, but together with some magic in Modules/getpath.c it is good enough
# to run python from the install dir.

FRAMEWORKDEST=$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
RESSRCDIR=$(srcdir)/Mac/OSXResources/framework
$(PYTHONFRAMEWORKDIR): $(RESSRCDIR)/Info.plist \
                $(RESSRCDIR)/version.plist \
                $(RESSRCDIR)/English.lproj/InfoPlist.strings
751
	@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
752
		echo Not configured with --enable-framework; \
753
		exit 1; \
754 755 756 757 758 759 760 761 762 763 764
	else true; \
	fi
	$(INSTALL) -d -m $(DIRMODE)  $(FRAMEWORKDEST)/Resources/English.lproj
	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist $(FRAMEWORKDEST)/Resources/Info.plist
	$(INSTALL_DATA) $(RESSRCDIR)/version.plist $(FRAMEWORKDEST)/Resources/version.plist
	$(INSTALL_DATA) $(RESSRCDIR)/English.lproj/InfoPlist.strings \
		$(FRAMEWORKDEST)/Resources/English.lproj/InfoPlist.strings
	$(LN) -fs $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
	$(LN) -fs Versions/Current/Python $(PYTHONFRAMEWORKDIR)/Python
	$(LN) -fs Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
	$(LN) -fs Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
765

766 767 768 769 770 771 772 773 774
# 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.

frameworkinstall: install frameworkinfrastructureinstall
FRAMEWORKFINALDEST=$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)
frameworkinfrastructureinstall:	$(LDLIBRARY)
775
	@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
776
		echo Not configured with --enable-framework; \
777
		exit 1; \
778 779 780 781 782 783 784 785 786
	else true; \
	fi
	@for i in $(FRAMEWORKFINALDEST)/Resources/English.lproj $(FRAMEWORKFINALDEST)/lib; do\
		if test ! -d $$i; then \
			echo "Creating directory $$i"; \
			$(INSTALL) -d -m $(DIRMODE) $$i; \
		else	true; \
		fi; \
	done
787
	$(LN) -sf $(INCLUDEPY) $(FRAMEWORKFINALDEST)/Headers
788 789 790 791 792 793 794 795 796
	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist $(FRAMEWORKFINALDEST)/Resources/Info.plist
	$(INSTALL_DATA) $(RESSRCDIR)/version.plist $(FRAMEWORKFINALDEST)/Resources/version.plist
	$(INSTALL_DATA) $(RESSRCDIR)/English.lproj/InfoPlist.strings \
		$(FRAMEWORKFINALDEST)/Resources/English.lproj/InfoPlist.strings
	$(LN) -fs $(VERSION) $(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
	$(LN) -fs Versions/Current/Python $(PYTHONFRAMEWORKINSTALLDIR)/Python
	$(LN) -fs Versions/Current/Headers $(PYTHONFRAMEWORKINSTALLDIR)/Headers
	$(LN) -fs Versions/Current/Resources $(PYTHONFRAMEWORKINSTALLDIR)/Resources
	$(INSTALL_DATA) $(LDLIBRARY) $(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
797

798 799 800 801 802
# 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

803
# Run the configure script.
804
config.status:	$(srcdir)/configure
805
	$(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
806

807
.PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
808 809 810

# Some make's put the object file in the current directory
.c.o:
811
	$(CC) -c $(PY_CFLAGS) -o $@ $<
812 813 814 815 816 817 818

# 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

819
# Rebuild the configure script from configure.in; also rebuild pyconfig.h.in
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841
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; \
	sort tags -o tags

# 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

clean:
842
	find . -name '*.o' -exec rm -f {} ';'
843
	find . -name '*.s[ol]' -exec rm -f {} ';'
844
	find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
845 846

clobber: clean
847
	-rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
848
		tags TAGS \
849
		config.cache config.log pyconfig.h Modules/config.c
850
	-rm -rf build platform
851 852 853 854

# Make things extra clean, before making a distribution:
# remove all generated files, even Makefile[.pre]
distclean: clobber
855
	-rm -f core Makefile Makefile.pre buildno config.status \
856
		Modules/Setup Modules/Setup.local Modules/Setup.config
857 858 859 860 861
	find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
			   -o -name '[@,#]*' -o -name '*.old' \
			   -o -name '*.orig' -o -name '*.rej' \
			   -o -name '*.bak' ')' \
			   -exec rm -f {} ';'
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896

# 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

897 898
# Dependencies

899
Python/thread.o: @THREADHEADERS@
900

901
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY