blob: ead811808c28c9ef9725e767f696c64a473085d7 [file] [log] [blame]
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001########################################################################
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00002# Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3# The Netherlands.
4#
Guido van Rossum433c8ad1994-08-01 12:07:07 +00005# All Rights Reserved
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00006#
7# Permission to use, copy, modify, and distribute this software and its
8# documentation for any purpose and without fee is hereby granted,
Guido van Rossum433c8ad1994-08-01 12:07:07 +00009# provided that the above copyright notice appear in all copies and that
Guido van Rossumaf5b83e1995-01-04 19:02:35 +000010# both that copyright notice and this permission notice appear in
Guido van Rossum433c8ad1994-08-01 12:07:07 +000011# supporting documentation, and that the names of Stichting Mathematisch
12# Centrum or CWI not be used in advertising or publicity pertaining to
13# distribution of the software without specific, written prior permission.
Guido van Rossumaf5b83e1995-01-04 19:02:35 +000014#
Guido van Rossum433c8ad1994-08-01 12:07:07 +000015# STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17# FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18# FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22########################################################################
Guido van Rossum627b2d71993-12-24 10:39:16 +000023
Guido van Rossum586480b1996-05-28 22:49:08 +000024# Top-level Makefile for Python
25#
26# As distributed, this file is called Makefile.in; it is processed
27# into the real Makefile by running the script ./configure, which
28# replaces things like @spam@ with values appropriate for your system.
29# This means that if you edit Makefile, your changes get lost the next
30# time you run the configure script. Ideally, you can do:
31#
32# ./configure
33# make
34# make test
35# make install
36#
37# The top-level Makefile invokes make recursively in a number of
38# subdirectories (see the SUBDIRS variable below). If you want to,
39# you can invoke make in individual subdirectories. However, the
40# sub-Makefiles are also generated by configure, and the quickest way
41# to make sure they are up to date is by running make (or "make
42# Makefiles") at the top level. This is particularly important for
43# Modules/Makefile, which has to be regenerated every time you edit
44# Modules/Setup. The python executable is built in the Modules
45# directory and then moved to the top-level directory. The recursive
46# makes pass three options to subordinate makes: OPT (a quick way to
47# change some compiler options; it defaults to -O), prefix and
48# exec_prefix (the installation paths).
49#
50# If recursive makes fail, try invoking make as "make MAKE=make".
51#
52# See also the section "Build instructions" in the README file.
Guido van Rossum627b2d71993-12-24 10:39:16 +000053
Guido van Rossum433c8ad1994-08-01 12:07:07 +000054# Substitutions by configure
55srcdir= @srcdir@
56VPATH= @srcdir@
Guido van Rossum4a91df41994-10-10 17:58:27 +000057RANLIB= @RANLIB@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000058
Guido van Rossumac405f61994-09-12 10:56:06 +000059# Machine-dependent subdirectories
60MACHDEP= @MACHDEP@
61
Guido van Rossum433c8ad1994-08-01 12:07:07 +000062# Install prefix for architecture-independent files
Guido van Rossum76be6ed1995-01-02 18:33:54 +000063prefix= @prefix@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000064
65# Install prefix for architecture-dependent files
Guido van Rossum76be6ed1995-01-02 18:33:54 +000066exec_prefix= @exec_prefix@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000067
Guido van Rossum90412791994-10-20 22:04:30 +000068# Expanded directories
69MANDIR=$(prefix)/man
70BINDIR=$(exec_prefix)/bin
71LIBDIR=$(exec_prefix)/lib
72INCLUDEDIR=$(prefix)/include
73SCRIPTDIR=$(prefix)/lib
74
Guido van Rossumac405f61994-09-12 10:56:06 +000075# Symbols used for using shared libraries
76SO= @SO@
77LDSHARED= @LDSHARED@
78CCSHARED= @CCSHARED@
79LINKFORSHARED= @LINKFORSHARED@
Guido van Rossum90412791994-10-20 22:04:30 +000080DESTSHARED= $(SCRIPTDIR)/python/$(MACHDEP)
Guido van Rossumac405f61994-09-12 10:56:06 +000081
Guido van Rossum586480b1996-05-28 22:49:08 +000082# Shell used by make (some versions default to the login shell, which is bad)
Guido van Rossum433c8ad1994-08-01 12:07:07 +000083SHELL= /bin/sh
84
Guido van Rossum586480b1996-05-28 22:49:08 +000085# Portable install script (configure doesn't always guess right)
86INSTALL= @srcdir@/install-sh -c
87INSTALL_PROGRAM=${INSTALL}
88INSTALL_DATA= ${INSTALL} -m 644
89
Guido van Rossum433c8ad1994-08-01 12:07:07 +000090# --with-PACKAGE options for configure script
91# e.g. --with-readline --with-svr5 --with-solaris --with-thread
92# (see README for an explanation)
93WITH=
94
95# Compiler options passed to subordinate makes
Guido van Rossum4e8af441994-08-19 15:33:54 +000096OPT= @OPT@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000097
98# Subdirectories where to run make recursively
99SUBDIRS= Parser Objects Python Modules
100
101# Other subdirectories
102SUBDIRSTOO= Include Lib Doc Misc Demo readline Grammar
103
104# Files and directories to be distributed
105CONFIGFILES= configure configure.in acconfig.h config.h.in Makefile.in
106DISTFILES= README ChangeLog $(CONFIGFILES)
107DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
108DIST= $(DISTFILES) $(DISTDIRS)
109
110# Default target
111all: python
112
113# Build the interpreter
114python: Makefiles
Guido van Rossum810a92f1993-12-28 19:39:56 +0000115 for i in $(SUBDIRS); do \
Guido van Rossum6d47d0d1995-08-07 21:58:40 +0000116 (echo $$i; cd $$i; \
117 $(MAKE) OPT="$(OPT)" \
118 prefix="$(prefix)" \
119 exec_prefix="$(exec_prefix)" \
120 all); \
Guido van Rossum810a92f1993-12-28 19:39:56 +0000121 done
122
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000123# Test the interpreter (twice, once without .pyc files, once with)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000124TESTPATH= $(srcdir)/Lib:$(srcdir)/Lib/test:./Modules
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000125test: python
126 -rm -f $(srcdir)/Lib/test/*.pyc
127 PYTHONPATH=$(TESTPATH) ./python -c 'import autotest'
128 PYTHONPATH=$(TESTPATH) ./python -c 'import autotest'
Guido van Rossum810a92f1993-12-28 19:39:56 +0000129
Guido van Rossum586480b1996-05-28 22:49:08 +0000130# Install everything
131install: bininstall libinstall maninstall inclinstall \
132 libainstall sharedinstall
133
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000134# Install the interpreter
Guido van Rossum586480b1996-05-28 22:49:08 +0000135bininstall: python
136 for i in $(BINDIR); \
137 do \
138 if test ! -d $$i; then \
139 echo "Creating directory $$i"; \
140 mkdir $$i; \
141 chmod 755 $$i; \
142 else true; \
143 fi; \
144 done
Guido van Rossum6403d281995-01-20 16:51:32 +0000145 $(INSTALL_PROGRAM) python $(BINDIR)/python
Guido van Rossum810a92f1993-12-28 19:39:56 +0000146
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000147# Install the library.
148# If your system does not support "cp -r", try "copy -r" or perhaps
Guido van Rossum7522f031994-08-30 12:42:01 +0000149# something like find Lib -print | cpio -pacvdmu $(LIBDEST)
Guido van Rossum90412791994-10-20 22:04:30 +0000150LIBDEST= $(SCRIPTDIR)/python
Guido van Rossum586480b1996-05-28 22:49:08 +0000151libinstall: python
152 for i in $(SCRIPTDIR) $(LIBDEST); \
153 do \
154 if test ! -d $$i; then \
155 echo "Creating directory $$i"; \
156 mkdir $$i; \
157 chmod 755 $$i; \
158 else true; \
159 fi; \
160 done
Guido van Rossum7522f031994-08-30 12:42:01 +0000161 cp -r $(srcdir)/Lib/* $(LIBDEST)
162 PYTHONPATH=$(LIBDEST) \
163 ./python $(LIBDEST)/compileall.py $(LIBDEST)
Guido van Rossum6d47d0d1995-08-07 21:58:40 +0000164 $(MAKE) \
165 OPT="$(OPT)" \
166 SO="$(SO)" \
167 LDSHARED="$(LDSHARED)" \
168 CCSHARED="$(CCSHARED)" \
169 LINKFORSHARED="$(LINKFORSHARED)" \
170 DESTSHARED="$(DESTSHARED)" \
171 sharedinstall
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000172
Guido van Rossum586480b1996-05-28 22:49:08 +0000173# Install the manual page
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000174maninstall:
Guido van Rossum586480b1996-05-28 22:49:08 +0000175 for i in $(MANDIR) $(MANDIR)/man1; \
176 do \
177 if test ! -d $$i; then \
178 echo "Creating directory $$i"; \
179 mkdir $$i; \
180 chmod 755 $$i; \
181 else true; \
182 fi; \
183 done
Guido van Rossum6403d281995-01-20 16:51:32 +0000184 $(INSTALL_DATA) $(srcdir)/Misc/python.man \
Guido van Rossum90412791994-10-20 22:04:30 +0000185 $(MANDIR)/man1/python.1
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000186
Guido van Rossum586480b1996-05-28 22:49:08 +0000187# Install the include files
Guido van Rossum90412791994-10-20 22:04:30 +0000188INCLUDEPY= $(INCLUDEDIR)/Py
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000189inclinstall:
Guido van Rossum586480b1996-05-28 22:49:08 +0000190 for i in $(INCLUDEDIR) $(INCLUDEPY); \
191 do \
192 if test ! -d $$i; then \
193 echo "Creating directory $$i"; \
194 mkdir $$i; \
195 chmod 755 $$i; \
196 else true; \
197 fi; \
198 done
Guido van Rossum6403d281995-01-20 16:51:32 +0000199 $(INSTALL_DATA) $(srcdir)/Include/*.h $(INCLUDEPY)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000200
Guido van Rossum586480b1996-05-28 22:49:08 +0000201# Install the lib*.a files and miscellaneous stuff needed by extensions
Guido van Rossum90412791994-10-20 22:04:30 +0000202LIBP= $(LIBDIR)/python
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000203LIBPL= $(LIBP)/lib
204libainstall: all
Guido van Rossum586480b1996-05-28 22:49:08 +0000205 for i in $(LIBDIR) $(LIBP) $(LIBPL); \
206 do \
207 if test ! -d $$i; then \
208 echo "Creating directory $$i"; \
209 mkdir $$i; \
210 chmod 755 $$i; \
211 else true; \
212 fi; \
213 done
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000214 for i in $(SUBDIRS); do \
Guido van Rossum586480b1996-05-28 22:49:08 +0000215 echo $$i; \
216 $(INSTALL_DATA) $$i/lib$$i.a $(LIBPL)/lib$$i.a; \
Guido van Rossum4a91df41994-10-10 17:58:27 +0000217 $(RANLIB) $(LIBPL)/lib$$i.a; \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000218 done
Guido van Rossum6403d281995-01-20 16:51:32 +0000219 $(INSTALL_DATA) Modules/config.c $(LIBPL)/config.c
Guido van Rossum6d47d0d1995-08-07 21:58:40 +0000220 $(INSTALL_DATA) $(srcdir)/Modules/getpath.c $(LIBPL)/getpath.c
Guido van Rossum6403d281995-01-20 16:51:32 +0000221 $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(LIBPL)/config.c.in
222 $(INSTALL_DATA) Modules/Makefile $(LIBPL)/Makefile
223 $(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup
224 $(INSTALL_DATA) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup
225 $(INSTALL_DATA) config.h $(LIBPL)/config.h
226 $(INSTALL_DATA) $(srcdir)/Python/frozenmain.c $(LIBPL)/frozenmain.c
Sjoerd Mullenderad5d2cf1995-08-09 09:18:20 +0000227 $(INSTALL_DATA) Modules/main.o $(LIBPL)/main.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000228
Guido van Rossum586480b1996-05-28 22:49:08 +0000229# Install the dynamically loadable modules
Guido van Rossumac405f61994-09-12 10:56:06 +0000230sharedinstall:
231 cd Modules; $(MAKE) \
232 OPT="$(OPT)" \
233 SO="$(SO)" \
234 LDSHARED="$(LDSHARED)" \
235 CCSHARED="$(CCSHARED)" \
236 LINKFORSHARED="$(LINKFORSHARED)" \
237 DESTSHARED="$(DESTSHARED)" \
238 sharedinstall
239
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000240# Build the sub-Makefiles
Guido van Rossumd09119e1995-01-17 16:45:08 +0000241Makefiles: config.status Modules/Makefile.pre
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000242 (cd Modules; $(MAKE) -f Makefile.pre Makefile)
243 for i in . $(SUBDIRS); do \
244 (echo $$i; cd $$i; $(MAKE) Makefile); \
245 done
246
Guido van Rossumd09119e1995-01-17 16:45:08 +0000247# Build the intermediate Makefile in Modules
248Modules/Makefile.pre: config.status
249 $(SHELL) config.status
250
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000251# Build the toplevel Makefile
252Makefile: Makefile.in config.status
253 CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) config.status
254
255# Run the configure script. If config.status already exists,
256# call it with the --recheck argument, which reruns configure with the
257# same options as it was run last time; otherwise run the configure
258# script with options taken from the $(WITH) variable
259config.status: $(srcdir)/configure
260 if test -f config.status; \
261 then $(SHELL) config.status --recheck; \
Guido van Rossumfb00a991995-01-12 12:26:50 +0000262 $(SHELL) config.status; \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000263 else $(SHELL) $(srcdir)/configure $(WITH); \
264 fi
265
266.PRECIOUS: config.status python
267
268# Rerun configure with the same options as it was run last time,
269# provided the config.status script exists
270recheck:
271 $(SHELL) config.status --recheck
Guido van Rossumaf5b83e1995-01-04 19:02:35 +0000272 $(SHELL) config.status
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000273
274# Rebuild the configure script from configure.in; also rebuild config.h.in
275autoconf:
276 (cd $(srcdir); autoconf; autoheader)
277
278# Create a tags file for vi
279tags::
280 ctags -w -t Include/*.h
281 for i in $(SUBDIRS); do ctags -w -t -a $$i/*.[ch]; done
282 sort tags -o tags
283
284# Create a tags file for GNU Emacs
285TAGS::
Guido van Rossum5552eb71994-08-05 15:51:00 +0000286 etags Include/*.h
287 for i in $(SUBDIRS); do etags -a $$i/*.[ch]; done
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000288
289# Add dependencies to sub-Makefiles
Guido van Rossum810a92f1993-12-28 19:39:56 +0000290depend:
291 for i in $(SUBDIRS); do \
292 (echo $$i; cd $$i; $(MAKE) depend); \
293 done
Guido van Rossum627b2d71993-12-24 10:39:16 +0000294
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000295# Sanitation targets -- clean leaves libraries, executables and tags
296# files, which clobber removes those as well
297
Guido van Rossum627b2d71993-12-24 10:39:16 +0000298localclean:
299 -rm -f core *~ [@,#]* *.old *.orig *.rej
Guido van Rossum627b2d71993-12-24 10:39:16 +0000300
301clean: localclean
302 -for i in $(SUBDIRS); do \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000303 (echo $$i; cd $$i; \
304 if test -f Makefile; \
305 then $(MAKE) clean; \
306 else $(MAKE) -f Makefile.*in clean; \
307 fi); \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000308 done
309
Guido van Rossum810a92f1993-12-28 19:39:56 +0000310localclobber: localclean
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000311 -rm -f tags TAGS python
Guido van Rossumaf07a441995-02-13 19:45:27 +0000312 -rm -f config.log config.cache config.h Makefile
Guido van Rossum810a92f1993-12-28 19:39:56 +0000313
314clobber: localclobber
Guido van Rossum627b2d71993-12-24 10:39:16 +0000315 -for i in $(SUBDIRS); do \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000316 (echo $$i; cd $$i; \
317 if test -f Makefile; \
318 then $(MAKE) clobber; \
Guido van Rossum7b4d4601995-03-22 12:27:16 +0000319 else $(MAKE) -f $(srcdir)/Makefile.in clobber; \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000320 fi); \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000321 done
322
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000323# Make things extra clean, before making a distribution
Guido van Rossum627b2d71993-12-24 10:39:16 +0000324distclean: clobber
Guido van Rossum7b4d4601995-03-22 12:27:16 +0000325 -$(MAKE) -f $(srcdir)/Makefile.in \
326 SUBDIRS="$(SUBDIRSTOO)" clobber
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000327 -rm -f config.status config.log config.cache config.h Makefile
Guido van Rossume7abf4e1995-09-18 22:12:20 +0000328 -rm -f Modules/Makefile
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000329 -for i in $(SUBDIRS) $(SUBDIRSTOO); do \
330 for f in $$i/*.in; do \
331 f=`basename "$$f" .in`; \
332 if test "$$f" != "*"; then \
333 echo rm -f "$$i/$$f"; \
334 rm -f "$$i/$$f"; \
335 fi; \
336 done; \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000337 done
Guido van Rossum627b2d71993-12-24 10:39:16 +0000338
Guido van Rossum586480b1996-05-28 22:49:08 +0000339# Check for smelly exported symbols (not starting with Py/_Py)
340smelly: all
341 for i in $(SUBDIRS); do \
342 echo --- $$i ---; \
343 nm -p $$i/lib$$i.a | \
344 sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
345 done
346
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000347# Find files with funny names
348find:
349 find $(DISTDIRS) -type d \
350 -o -name '*.[chs]' \
351 -o -name '*.py' \
352 -o -name '*.doc' \
353 -o -name '*.sty' \
354 -o -name '*.bib' \
355 -o -name '*.dat' \
356 -o -name '*.el' \
357 -o -name '*.fd' \
358 -o -name '*.in' \
359 -o -name '*.tex' \
360 -o -name '*,[vpt]' \
361 -o -name 'Setup' \
362 -o -name 'Setup.*' \
363 -o -name README \
364 -o -name Makefile \
365 -o -name ChangeLog \
366 -o -name RCS \
367 -o -name Repository \
368 -o -name Entries \
369 -o -name Tag \
370 -o -name tags \
371 -o -name TAGS \
372 -o -name .cvsignore \
373 -o -name MANIFEST \
374 -o -print
Guido van Rossum627b2d71993-12-24 10:39:16 +0000375
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000376# Build a distribution tar file (run make distclean first)
377# (This leaves the RCS and CVS directories in :-( )
378tar:
Guido van Rossum5552eb71994-08-05 15:51:00 +0000379 tar cf - $(DIST) | gzip --best >dist.tar.gz