blob: efe8862a642cf9120185856174a31013bbb1ca0e [file] [log] [blame]
Neil Schemenauer85515ad2001-01-24 17:11:43 +00001# 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". This changes the install procedure so it installs the
17# Python binary as "python<version>". The libraries and include files
18# are always installed in a subdirectory called "python<version>".
19# "make altinstall" does not install the manual page. If you want to
20# make this installation the "official" installation but want to keep
21# the old binary around "just in case", rename the installed python
22# binary to "python<oldversion>" before running "make install".
23# (This only works between different versions, e.g. 1.3 and 1.4 --
24# different betas of the same version will overwrite each other in
25# installation unless you override the VERSION Make variable.)
26#
27# In fact, "make install" or "make bininstall" installs the binary
28# as python<version> and makes a hard link to python, so when
29# installing a new version in the future, nothing of the current
30# version will be lost (except for the man page).
31#
32# See also the section "Build instructions" in the README file.
33
34# === Variables set by makesetup ===
35
36MODOBJS= _MODOBJS_
37MODLIBS= _MODLIBS_
38
39# === Variables set by configure
40VERSION= @VERSION@
41srcdir= @srcdir@
42VPATH= @srcdir@
43
44CC= @CC@
45CXX= @CXX@
46LINKCC= @LINKCC@
47AR= @AR@
48RANLIB= @RANLIB@
49
50# Shell used by make (some versions default to the login shell, which is bad)
51SHELL= /bin/sh
52
53# Use this to make a link between python$(VERSION) and python in $(BINDIR)
54LN= @LN@
55
56# Portable install script (configure doesn't always guess right)
57INSTALL= @INSTALL@
58INSTALL_PROGRAM=@INSTALL_PROGRAM@
59INSTALL_DATA= @INSTALL_DATA@
60# Shared libraries must be installed with executable mode on some systems;
61# rather than figuring out exactly which, we always give them executable mode.
62# Also, making them read-only seems to be a good idea...
63INSTALL_SHARED= ${INSTALL} -m 555
64
65MAKESETUP= $(srcdir)/Modules/makesetup
66
67# Compiler options
68OPT= @OPT@
69DEFS= @DEFS@
70CFLAGS= $(OPT) -I. -I$(srcdir)/Include $(DEFS)
71LDFLAGS= @LDFLAGS@
72LDLAST= @LDLAST@
73SGI_ABI= @SGI_ABI@
Neil Schemenauer7ac954b2001-01-26 16:14:41 +000074CCSHARED= @CCSHARED@
75LINKFORSHARED= @LINKFORSHARED@
76# Extra C flags added for building the interpreter object files.
77CFLAGSFORSHARED=@CFLAGSFORSHARED@
78# C flags used for building the interpreter object files
79PY_CFLAGS= $(CFLAGS) $(CFLAGSFORSHARED)
80
Neil Schemenauer85515ad2001-01-24 17:11:43 +000081
82# Machine-dependent subdirectories
83MACHDEP= @MACHDEP@
84
85# Install prefix for architecture-independent files
86prefix= @prefix@
87
88# Install prefix for architecture-dependent files
89exec_prefix= @exec_prefix@
90
91# Expanded directories
92BINDIR= $(exec_prefix)/bin
93LIBDIR= $(exec_prefix)/lib
94MANDIR= $(prefix)/man
95INCLUDEDIR= $(prefix)/include
96CONFINCLUDEDIR= $(exec_prefix)/include
97SCRIPTDIR= $(prefix)/lib
98
99# Detailed destination directories
100BINLIBDEST= $(LIBDIR)/python$(VERSION)
101LIBDEST= $(SCRIPTDIR)/python$(VERSION)
102INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
103CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(VERSION)
104LIBP= $(LIBDIR)/python$(VERSION)
105
106# Symbols used for using shared libraries
107SO= @SO@
108LDSHARED= @LDSHARED@
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000109DESTSHARED= $(BINLIBDEST)/lib-dynload
110
111# Executable suffix (.exe on Windows and Mac OS X)
112EXEEXT= @EXEEXT@
113
114# Modes for directories, executables and data files created by the
115# install process. Default to user-only-writable for all file types.
116DIRMODE= 755
117EXEMODE= 755
118FILEMODE= 644
119
120# --with-PACKAGE options for configure script
121# e.g. --with-readline --with-svr5 --with-solaris --with-thread
122# (see README for an explanation)
123WITH=
124
125
126# Subdirectories with code
127SRCDIRS= @SRCDIRS@
128
129# Other subdirectories
130SUBDIRSTOO= Include Lib Misc Demo
131
132# Files and directories to be distributed
133CONFIGFILES= configure configure.in acconfig.h config.h.in Makefile.pre.in
134DISTFILES= README ChangeLog $(CONFIGFILES)
135DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
136DIST= $(DISTFILES) $(DISTDIRS)
137
138
Neil Schemenauer7ac954b2001-01-26 16:14:41 +0000139LIBRARY= @LIBRARY@
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000140LDLIBRARY= @LDLIBRARY@
141DLLLIBRARY= @DLLLIBRARY@
142
143
144LIBS= @LIBS@
145LIBM= @LIBM@
146LIBC= @LIBC@
147SYSLIBS= $(LIBM) $(LIBC)
148
149MAINOBJ= @MAINOBJ@
150LIBOBJS= @LIBOBJS@
151DLINCLDIR= @DLINCLDIR@
152DYNLOADFILE= @DYNLOADFILE@
153
154PYTHON= python$(EXEEXT)
155
156# === Definitions added by makesetup ===
157
158
159##########################################################################
160# Modules
161MODULE_OBJS= \
162 Modules/config.o \
163 Modules/getpath.o \
Neil Schemenauer18821822001-01-27 21:42:38 +0000164 Modules/main.o
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000165
166# Used of signalmodule.o is not available
167SIGNAL_OBJS= @SIGNAL_OBJS@
168
169
170##########################################################################
171# Grammar
172GRAMMAR_H= $(srcdir)/Include/graminit.h
173GRAMMAR_C= $(srcdir)/Python/graminit.c
174GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
175
176
177##########################################################################
178# Parser
179PGEN= Parser/pgen$(EXEEXT)
180
181POBJS= \
182 Parser/acceler.o \
183 Parser/grammar1.o \
184 Parser/listnode.o \
185 Parser/node.o \
186 Parser/parser.o \
187 Parser/parsetok.o \
188 Parser/tokenizer.o \
189 Parser/bitset.o \
190 Parser/metagrammar.o
191
192PARSER_OBJS= $(POBJS) Parser/myreadline.o
193
194PGOBJS= \
195 Parser/firstsets.o \
196 Parser/grammar.o \
197 Parser/pgen.o \
198 Parser/printgrammar.o \
199 Parser/pgenmain.o
200
201PGENOBJS= $(PGENMAIN) $(POBJS) $(PGOBJS)
202
203
204##########################################################################
205# Python
206PYTHON_OBJS= \
207 Python/bltinmodule.o \
208 Python/exceptions.o \
209 Python/ceval.o \
210 Python/compile.o \
211 Python/codecs.o \
212 Python/errors.o \
213 Python/frozen.o \
214 Python/frozenmain.o \
215 Python/getargs.o \
216 Python/getcompiler.o \
217 Python/getcopyright.o \
218 Python/getmtime.o \
219 Python/getplatform.o \
220 Python/getversion.o \
221 Python/graminit.o \
222 Python/import.o \
223 Python/importdl.o \
224 Python/marshal.o \
225 Python/modsupport.o \
226 Python/mystrtoul.o \
227 Python/pyfpe.o \
228 Python/pystate.o \
229 Python/pythonrun.o \
230 Python/structmember.o \
Jeremy Hyltoncb17ae82001-02-09 22:22:18 +0000231 Python/symtable.o \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000232 Python/sysmodule.o \
233 Python/traceback.o \
234 Python/getopt.o \
235 Python/$(DYNLOADFILE) \
236 $(LIBOBJS)
237
238
239##########################################################################
240# Objects
241OBJECT_OBJS= \
242 Objects/abstract.o \
243 Objects/bufferobject.o \
Jeremy Hyltonfbd849f2001-01-25 20:04:14 +0000244 Objects/cellobject.o \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000245 Objects/classobject.o \
246 Objects/cobject.o \
247 Objects/complexobject.o \
248 Objects/fileobject.o \
249 Objects/floatobject.o \
250 Objects/frameobject.o \
251 Objects/funcobject.o \
252 Objects/intobject.o \
253 Objects/listobject.o \
254 Objects/longobject.o \
255 Objects/dictobject.o \
256 Objects/methodobject.o \
257 Objects/moduleobject.o \
258 Objects/object.o \
259 Objects/rangeobject.o \
260 Objects/sliceobject.o \
261 Objects/stringobject.o \
262 Objects/tupleobject.o \
263 Objects/typeobject.o \
264 Objects/unicodeobject.o \
265 Objects/unicodectype.o
266
267
268##########################################################################
269# objects that get linked into the Python library
270LIBRARY_OBJS= \
Neil Schemenauer18821822001-01-27 21:42:38 +0000271 Modules/getbuildinfo.o \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000272 $(PARSER_OBJS) \
273 $(OBJECT_OBJS) \
274 $(PYTHON_OBJS) \
275 $(MODULE_OBJS) \
276 $(SIGNAL_OBJS) \
277 $(MODOBJS)
278
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000279#########################################################################
280# Rules
281
282# Default target
Andrew M. Kuchlingbddd8782001-01-29 20:18:59 +0000283all: $(PYTHON) oldsharedmods sharedmods
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000284
285# Build the interpreter
286$(PYTHON): $(MAINOBJ) $(LDLIBRARY)
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000287 $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ $(MAINOBJ) \
288 $(LDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
289
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000290platform: $(PYTHON)
291 ./$(PYTHON) -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
292
293
294# Build the shared modules
295sharedmods: $(PYTHON)
296 ./$(PYTHON) $(srcdir)/setup.py build
297
Neil Schemenauer18821822001-01-27 21:42:38 +0000298# buildno should really depend on something like LIBRARY_SRC
299buildno: $(PARSER_OBJS) \
300 $(OBJECT_OBJS) \
301 $(PYTHON_OBJS) \
302 $(MODULE_OBJS) \
303 $(SIGNAL_OBJS) \
304 $(MODOBJS) \
305 $(srcdir)/Modules/getbuildinfo.c
306 if test -f buildno; then \
307 expr `cat buildno` + 1 >buildno1; \
308 mv -f buildno1 buildno; \
309 else echo 1 >buildno; fi
310
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000311# Build static library
312$(LIBRARY): $(LIBRARY_OBJS)
313 -rm -f $@
314 # avoid long command lines, same as LIBRARY_OBJS
Neil Schemenauer18821822001-01-27 21:42:38 +0000315 $(AR) cr $@ Modules/getbuildinfo.o
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000316 $(AR) cr $@ $(PARSER_OBJS)
317 $(AR) cr $@ $(OBJECT_OBJS)
318 $(AR) cr $@ $(PYTHON_OBJS)
319 $(AR) cr $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
320 $(AR) cr $@ $(MODOBJS)
321 $(RANLIB) $@
322
323# This rule is only here for DG/UX and BeOS!!!
324libpython$(VERSION).so: $(LIBRARY)
325 case `uname -s | tr -d '/ ' | tr '[A-Z]' '[a-z]'` in \
326 *dgux*) \
327 test -d dgux || mkdir dgux; \
328 (cd dgux;ar x ../$^;ld -G -o ../$@ * ); \
329 /bin/rm -rf ./dgux \
330 ;; \
331 beos) \
332 $(srcdir)/BeOS/ar-fake so $(LIBRARY) $@ \
333 ;; \
334 esac
335
336# This rule is here for OPENSTEP/Rhapsody/MacOSX
337libpython$(VERSION).dylib: $(LIBRARY)
338 libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
339 -framework System @LIBTOOL_CRUFT@
340
341# This rule builds the Cygwin Python DLL
342libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
343 dlltool --export-all --output-def $@ $^
344 $(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
345 $(LIBS) $(MODLIBS) $(SYSLIBS)
346
347
348oldsharedmods: $(SHAREDMODS)
349
350
351Makefile Modules/config.c: Makefile.pre \
352 $(srcdir)/Modules/config.c.in \
353 $(MAKESETUP) \
354 Modules/Setup.config \
355 Modules/Setup \
356 Modules/Setup.local
357 $(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
358 -s Modules \
359 Modules/Setup.config \
360 Modules/Setup.local \
361 Modules/Setup
362 @mv config.c Modules
363 @echo "The Makefile was updated, you may need to re-run make."
364
365
366Modules/Setup: $(srcdir)/Modules/Setup.dist
367 @if test -f Modules/Setup; then \
368 echo "-----------------------------------------------"; \
369 echo "Modules/Setup.dist is newer than Modules/Setup;"; \
370 echo "check to make sure you have all the updates you"; \
371 echo "need in your Modules/Setup file."; \
372 echo "-----------------------------------------------"; \
Neil Schemenauer7ac954b2001-01-26 16:14:41 +0000373 fi
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000374
375############################################################################
376# Special rules for object files
377
378Modules/getbuildinfo.o: $(srcdir)/Modules/getbuildinfo.c buildno
Sjoerd Mullender30be8702001-01-29 09:39:14 +0000379 $(CC) -c $(PY_CFLAGS) -DBUILD=`cat buildno` -o $@ $(srcdir)/Modules/getbuildinfo.c
Andrew M. Kuchling03184e22001-01-26 22:52:45 +0000380
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000381Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
Neil Schemenauer7ac954b2001-01-26 16:14:41 +0000382 $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
383 -DPREFIX='"$(prefix)"' \
384 -DEXEC_PREFIX='"$(exec_prefix)"' \
385 -DVERSION='"$(VERSION)"' \
386 -DVPATH='"$(VPATH)"' \
Sjoerd Mullender30be8702001-01-29 09:39:14 +0000387 -o $@ $(srcdir)/Modules/getpath.c
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000388
Sjoerd Mullender30be8702001-01-29 09:39:14 +0000389Modules/ccpython.o: $(srcdir)/Modules/ccpython.cc
390 $(CXX) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/ccpython.cc
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000391
392
393$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
394 $(PGEN) $(GRAMMAR_INPUT)
395 mv graminit.h $(GRAMMAR_H)
396 mv graminit.c $(GRAMMAR_C)
397
398$(PGEN): $(PGENOBJS)
399 $(CC) $(OPT) $(PGENOBJS) $(LIBS) -o $(PGEN)
400
401Parser/grammar.o: $(srcdir)/Parser/grammar.c \
402 $(srcdir)/Parser/assert.h \
403 $(srcdir)/Include/token.h \
404 $(srcdir)/Include/grammar.h
405Parser/metagrammar.o: $(srcdir)/Parser/metagrammar.c
406
407
408Python/getplatform.o: $(srcdir)/Python/getplatform.c
Sjoerd Mullender30be8702001-01-29 09:39:14 +0000409 $(CC) -c $(CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000410
411Python/importdl.o: $(srcdir)/Python/importdl.c
Sjoerd Mullender30be8702001-01-29 09:39:14 +0000412 $(CC) -c $(CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000413
414
415Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \
416 $(srcdir)/Objects/unicodetype_db.h
417
418
419############################################################################
420# Header files
421
Neil Schemenauerf65e5002001-01-25 20:07:50 +0000422PYTHON_HEADERS= \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000423 Include/Python.h \
Neil Schemenauerf65e5002001-01-25 20:07:50 +0000424 config.h \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000425 Include/patchlevel.h \
426 Include/pyport.h \
427 Include/pymem.h \
428 Include/object.h \
429 Include/objimpl.h \
Jeremy Hylton96da8b62001-02-02 19:54:23 +0000430 Include/compile.h \
431 Include/symtable.h \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000432 Include/pydebug.h \
433 Include/unicodeobject.h \
434 Include/intobject.h \
435 Include/longobject.h \
436 Include/floatobject.h \
437 Include/complexobject.h \
438 Include/rangeobject.h \
439 Include/stringobject.h \
440 Include/bufferobject.h \
441 Include/tupleobject.h \
442 Include/listobject.h \
443 Include/dictobject.h \
444 Include/methodobject.h \
445 Include/moduleobject.h \
446 Include/funcobject.h \
447 Include/classobject.h \
448 Include/fileobject.h \
449 Include/cobject.h \
450 Include/traceback.h \
451 Include/sliceobject.h \
452 Include/codecs.h \
453 Include/pyerrors.h \
454 Include/pystate.h \
455 Include/modsupport.h \
456 Include/ceval.h \
457 Include/pythonrun.h \
458 Include/sysmodule.h \
459 Include/intrcheck.h \
460 Include/import.h \
461 Include/abstract.h \
462 Include/pyfpe.h
463
Neil Schemenauerf65e5002001-01-25 20:07:50 +0000464$(LIBRARY_OBJS) $(MODOBJS) $(MAINOBJ): $(PYTHON_HEADERS)
465
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000466
467######################################################################
468
469# Test the interpreter (twice, once without .pyc files, once with)
470TESTOPTS= -l
471TESTPROG= $(srcdir)/Lib/test/regrtest.py
472TESTPYTHON= ./$(PYTHON) -tt
473test: all platform
474 -rm -f $(srcdir)/Lib/test/*.py[co]
475 -PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
476 PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
477
Jeremy Hylton2a850d92001-02-01 19:51:28 +0000478QUICKTESTOPTS= $(TESTOPTS) -x test_thread test_signal test_strftime \
Fred Drake042f3132001-02-02 03:03:33 +0000479 test_unicodedata test_re test_sre test_select test_poll \
Jeremy Hylton26d1f142001-02-02 18:12:16 +0000480 test_linuxaudiodev test_sunaudiodev
Jeremy Hylton2a850d92001-02-01 19:51:28 +0000481quicktest: all platform
482 -rm -f $(srcdir)/Lib/test/*.py[co]
483 -PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
484 PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
485
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000486# Install everything
487install: altinstall bininstall maninstall
488
489# Install almost everything without disturbing previous versions
Andrew M. Kuchlingbddd8782001-01-29 20:18:59 +0000490altinstall: altbininstall libinstall inclinstall libainstall \
491 sharedinstall oldsharedinstall
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000492
493# Install shared libraries enabled by Setup
494DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
495
496oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
497 @for i in X $(SHAREDMODS); do \
Neil Schemenauerac959772001-02-06 14:50:27 +0000498 if test $$i != X; then \
499 echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
500 $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
501 fi; \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000502 done
503
504$(DESTSHARED):
505 @for i in $(DESTDIRS); \
506 do \
507 if test ! -d $$i; then \
508 echo "Creating directory $$i"; \
Neil Schemenauer8d3274e2001-02-10 20:07:38 +0000509 $(INSTALL) -d -m $(DIRMODE) $$i; \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000510 else true; \
511 fi; \
512 done
513
514
515# Install the interpreter (by creating a hard link to python$(VERSION))
516bininstall: altbininstall
517 -if test -f $(BINDIR)/$(PYTHON); \
518 then rm -f $(BINDIR)/$(PYTHON); \
519 else true; \
520 fi
521 (cd $(BINDIR); $(LN) python$(VERSION)$(EXEEXT) python$(EXEEXT))
522
523# Install the interpreter with $(VERSION) affixed
524# This goes into $(exec_prefix)
525altbininstall: $(PYTHON)
526 @for i in $(BINDIR); \
527 do \
528 if test ! -d $$i; then \
529 echo "Creating directory $$i"; \
Neil Schemenauer8d3274e2001-02-10 20:07:38 +0000530 $(INSTALL) -d -m $(DIRMODE) $$i; \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000531 else true; \
532 fi; \
533 done
534 $(INSTALL_PROGRAM) $(PYTHON) $(BINDIR)/python$(VERSION)$(EXEEXT)
535 if test -f libpython$(VERSION).so; then \
536 $(INSTALL_DATA) libpython$(VERSION).so $(LIBDIR); \
537 else true; \
538 fi
539 if test -f "$(DLLLIBRARY)"; then \
540 $(INSTALL_DATA) $(DLLLIBRARY) $(BINDIR); \
541 else true; \
542 fi
543
544# Install the manual page
545maninstall:
546 @for i in $(MANDIR) $(MANDIR)/man1; \
547 do \
548 if test ! -d $$i; then \
549 echo "Creating directory $$i"; \
Neil Schemenauer8d3274e2001-02-10 20:07:38 +0000550 $(INSTALL) -d -m $(DIRMODE) $$i; \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000551 else true; \
552 fi; \
553 done
554 $(INSTALL_DATA) $(srcdir)/Misc/python.man \
555 $(MANDIR)/man1/python.1
556
557# Install the library
558PLATDIR= plat-$(MACHDEP)
559MACHDEPS= $(PLATDIR)
560XMLLIBSUBDIRS= xml xml/dom xml/parsers xml/sax
561LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \
562 distutils distutils/command $(XMLLIBSUBDIRS) curses $(MACHDEPS)
563libinstall: python $(srcdir)/Lib/$(PLATDIR)
564 @for i in $(SCRIPTDIR) $(LIBDEST); \
565 do \
566 if test ! -d $$i; then \
567 echo "Creating directory $$i"; \
Neil Schemenauer8d3274e2001-02-10 20:07:38 +0000568 $(INSTALL) -d -m $(DIRMODE) $$i; \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000569 else true; \
570 fi; \
571 done
572 @for d in $(LIBSUBDIRS); \
573 do \
574 a=$(srcdir)/Lib/$$d; \
575 if test ! -d $$a; then continue; else true; fi; \
576 b=$(LIBDEST)/$$d; \
577 if test ! -d $$b; then \
578 echo "Creating directory $$b"; \
Neil Schemenauer8d3274e2001-02-10 20:07:38 +0000579 $(INSTALL) -d -m $(DIRMODE) $$b; \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000580 else true; \
581 fi; \
582 done
583 @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc; \
584 do \
585 if test -x $$i; then \
586 $(INSTALL_PROGRAM) $$i $(LIBDEST); \
587 echo $(INSTALL_PROGRAM) $$i $(LIBDEST); \
588 else \
589 $(INSTALL_DATA) $$i $(LIBDEST); \
590 echo $(INSTALL_DATA) $$i $(LIBDEST); \
591 fi; \
592 done
593 @for d in $(LIBSUBDIRS); \
594 do \
595 a=$(srcdir)/Lib/$$d; \
596 if test ! -d $$a; then continue; else true; fi; \
597 b=$(LIBDEST)/$$d; \
598 for i in $$a/*; \
599 do \
600 case $$i in \
601 *CVS) ;; \
602 *.py[co]) ;; \
603 *.orig) ;; \
604 *~) ;; \
605 *) \
606 if test -d $$i; then continue; fi; \
607 if test -x $$i; then \
608 echo $(INSTALL_PROGRAM) $$i $$b; \
609 $(INSTALL_PROGRAM) $$i $$b; \
610 else \
611 echo $(INSTALL_DATA) $$i $$b; \
612 $(INSTALL_DATA) $$i $$b; \
613 fi;; \
614 esac; \
615 done; \
616 done
617 $(INSTALL_DATA) $(srcdir)/LICENSE $(LIBDEST)/LICENSE.txt
618 PYTHONPATH=$(LIBDEST) \
619 ./$(PYTHON) -tt $(LIBDEST)/compileall.py $(LIBDEST)
620 PYTHONPATH=$(LIBDEST) \
621 ./$(PYTHON) -O $(LIBDEST)/compileall.py $(LIBDEST)
622
623# Create the PLATDIR source directory, if one wasn't distributed..
624$(srcdir)/Lib/$(PLATDIR):
625 mkdir $(srcdir)/Lib/$(PLATDIR)
626 cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
627 export PATH; PATH="`pwd`:$$PATH"; \
628 export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
629 export EXEEXT; EXEEXT="$(EXEEXT)"; \
630 cd $(srcdir)/Lib/$(PLATDIR); ./regen
631
632# Install the include files
633INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
634inclinstall:
635 @for i in $(INCLDIRSTOMAKE); \
636 do \
637 if test ! -d $$i; then \
638 echo "Creating directory $$i"; \
Neil Schemenauer8d3274e2001-02-10 20:07:38 +0000639 $(INSTALL) -d -m $(DIRMODE) $$i; \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000640 else true; \
641 fi; \
642 done
643 @for i in $(srcdir)/Include/*.h; \
644 do \
645 echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
646 $(INSTALL_DATA) $$i $(INCLUDEPY); \
647 done
648 $(INSTALL_DATA) config.h $(CONFINCLUDEPY)/config.h
649
650# Install the library and miscellaneous stuff needed for extending/embedding
651# This goes into $(exec_prefix)
652LIBPL= $(LIBP)/config
653libainstall: all
654 @for i in $(LIBDIR) $(LIBP) $(LIBPL); \
655 do \
656 if test ! -d $$i; then \
657 echo "Creating directory $$i"; \
Neil Schemenauer8d3274e2001-02-10 20:07:38 +0000658 $(INSTALL) -d -m $(DIRMODE) $$i; \
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000659 else true; \
660 fi; \
661 done
662 @if test -d $(LDLIBRARY); then :; else \
663 $(INSTALL_DATA) $(LDLIBRARY) $(LIBPL)/$(LDLIBRARY) ; \
664 $(RANLIB) $(LIBPL)/$(LDLIBRARY) ; \
665 fi
666 $(INSTALL_DATA) Modules/config.c $(LIBPL)/config.c
667 $(INSTALL_DATA) Modules/python.o $(LIBPL)/python.o
668 $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(LIBPL)/config.c.in
669 $(INSTALL_DATA) Makefile $(LIBPL)/Makefile
670 $(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup
671 $(INSTALL_DATA) Modules/Setup.local $(LIBPL)/Setup.local
672 $(INSTALL_DATA) Modules/Setup.config $(LIBPL)/Setup.config
673 $(INSTALL_PROGRAM) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup
674 $(INSTALL_PROGRAM) $(srcdir)/install-sh $(LIBPL)/install-sh
675 $(INSTALL_DATA) $(srcdir)/Misc/Makefile.pre.in $(LIBPL)/Makefile.pre.in
676 @if [ -s Modules/python.exp -a \
677 "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
678 echo; echo "Installing support files for building shared extension modules on AIX:"; \
679 $(INSTALL_DATA) Modules/python.exp \
680 $(LIBPL)/python.exp; \
681 echo; echo "$(LIBPL)/python.exp"; \
682 $(INSTALL_PROGRAM) $(srcdir)/Modules/makexp_aix \
683 $(LIBPL)/makexp_aix; \
684 echo "$(LIBPL)/makexp_aix"; \
685 $(INSTALL_PROGRAM) $(srcdir)/Modules/ld_so_aix \
686 $(LIBPL)/ld_so_aix; \
687 echo "$(LIBPL)/ld_so_aix"; \
688 echo; echo "See Misc/AIX-NOTES for details."; \
689 else true; \
690 fi
691 @case "$(MACHDEP)" in beos*) \
692 echo; echo "Installing support files for building shared extension modules on BeOS:"; \
693 $(INSTALL_DATA) BeOS/README $(LIBPL)/README; \
694 echo; echo "$(LIBPL)/README"; \
695 $(INSTALL_DATA) BeOS/README.readline-2.2 $(LIBPL)/README.readline-2.2; \
696 echo "$(LIBPL)/README.readline-2.2"; \
697 $(INSTALL_PROGRAM) BeOS/ar-fake $(LIBPL)/ar-fake; \
698 echo "$(LIBPL)/ar-fake"; \
699 $(INSTALL_PROGRAM) BeOS/linkmodule $(LIBPL)/linkmodule; \
700 echo "$(LIBPL)/linkmodule"; \
701 echo; echo "See BeOS/README for details."; \
702 ;; \
703 esac
704
705# Install the dynamically loadable modules
706# This goes into $(exec_prefix)
707sharedinstall:
Neil Schemenauer18821822001-01-27 21:42:38 +0000708 ./python$(EXEEXT) $(srcdir)/setup.py install \
Andrew M. Kuchling03184e22001-01-26 22:52:45 +0000709 --install-platlib=$(DESTSHARED)
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000710
711# Build the toplevel Makefile
712Makefile.pre: Makefile.pre.in config.status
713 CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
714 $(MAKE) -f Makefile.pre Makefile
715
716# Run the configure script. If config.status already exists,
717# call it with the --recheck argument, which reruns configure with the
718# same options as it was run last time; otherwise run the configure
719# script with options taken from the $(WITH) variable
720config.status: $(srcdir)/configure
721 if test -f config.status; \
722 then $(SHELL) config.status --recheck; \
723 $(SHELL) config.status; \
724 else $(SHELL) $(srcdir)/configure $(WITH); \
725 fi
726
727.PRECIOUS: config.status $(PYTHON) Makefile Makefile.pre
728
729# Some make's put the object file in the current directory
730.c.o:
Neil Schemenauer7ac954b2001-01-26 16:14:41 +0000731 $(CC) -c $(PY_CFLAGS) -o $@ $<
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000732
733# Rerun configure with the same options as it was run last time,
734# provided the config.status script exists
735recheck:
736 $(SHELL) config.status --recheck
737 $(SHELL) config.status
738
739# Rebuild the configure script from configure.in; also rebuild config.h.in
740autoconf:
741 (cd $(srcdir); autoconf)
742 (cd $(srcdir); autoheader)
743
744# Create a tags file for vi
745tags::
746 cd $(srcdir); \
747 ctags -w -t Include/*.h; \
748 for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \
749 done; \
750 sort tags -o tags
751
752# Create a tags file for GNU Emacs
753TAGS::
754 cd $(srcdir); \
755 etags Include/*.h; \
756 for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
757
758# Sanitation targets -- clean leaves libraries, executables and tags
759# files, which clobber removes those as well
760
761clean:
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000762 # avoid long command lines, same as LIBRARY_OBJS MAINOBJ PGOBJS
763 -rm -f $(PARSER_OBJS)
764 -rm -f $(OBJECT_OBJS)
765 -rm -f $(PYTHON_OBJS)
Neil Schemenauere0d43572001-02-03 17:16:29 +0000766 -rm -f $(MODULE_OBJS) $(SIGNAL_OBJS) Modules/getbuildinfo.o
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000767 -rm -f $(MODOBJS) $(MAINOBJ) $(PGOBJS)
Neil Schemenauere0d43572001-02-03 17:16:29 +0000768 if test -f build; then find build -name '*.o' -exec rm -f {} ';' ; fi
769 find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000770
771clobber: clean
Neil Schemenauer7ac954b2001-01-26 16:14:41 +0000772 -rm -f tags TAGS $(PYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
Neil Schemenauere0d43572001-02-03 17:16:29 +0000773 Modules/*.so Modules/*.sl Parser/pgen
774 -rm -rf build
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000775
776# Make things extra clean, before making a distribution:
777# remove all generated files, even Makefile[.pre]
778distclean: clobber
Neil Schemenauere0d43572001-02-03 17:16:29 +0000779 -rm -f core Makefile Makefile.pre buildno config.status \
780 config.log config.cache config.h Modules/config.c \
Neil Schemenauer7ac954b2001-01-26 16:14:41 +0000781 Modules/Setup Modules/Setup.local Modules/Setup.config
Neil Schemenauere0d43572001-02-03 17:16:29 +0000782 find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
783 -o -name '[@,#]*' -o -name '*.old' \
784 -o -name '*.orig' -o -name '*.rej' \
785 -o -name '*.bak' ')' \
786 -exec rm -f {} ';'
Neil Schemenauer85515ad2001-01-24 17:11:43 +0000787
788# Check for smelly exported symbols (not starting with Py/_Py)
789smelly: all
790 nm -p $(LIBRARY) | \
791 sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
792
793# Find files with funny names
794funny:
795 find $(DISTDIRS) -type d \
796 -o -name '*.[chs]' \
797 -o -name '*.py' \
798 -o -name '*.doc' \
799 -o -name '*.sty' \
800 -o -name '*.bib' \
801 -o -name '*.dat' \
802 -o -name '*.el' \
803 -o -name '*.fd' \
804 -o -name '*.in' \
805 -o -name '*.tex' \
806 -o -name '*,[vpt]' \
807 -o -name 'Setup' \
808 -o -name 'Setup.*' \
809 -o -name README \
810 -o -name Makefile \
811 -o -name ChangeLog \
812 -o -name Repository \
813 -o -name Root \
814 -o -name Entries \
815 -o -name Tag \
816 -o -name tags \
817 -o -name TAGS \
818 -o -name .cvsignore \
819 -o -name MANIFEST \
820 -o -print
821
822# IF YOU PUT ANYTHING HERE IT WILL GO AWAY