blob: cb726dfc2cdca51e868ef2ffc30529e4f233d6e0 [file] [log] [blame]
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001########################################################################
2# Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
3# Amsterdam, The Netherlands.
4#
5# All Rights Reserved
6#
7# Permission to use, copy, modify, and distribute this software and its
8# documentation for any purpose and without fee is hereby granted,
9# provided that the above copyright notice appear in all copies and that
10# both that copyright notice and this permission notice appear in
11# 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.
14#
15# 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 Rossum433c8ad1994-08-01 12:07:07 +000024# Toplevel Makefile for Python
25# Note -- if recursive makes fail, try adding MAKE=make
Guido van Rossum627b2d71993-12-24 10:39:16 +000026
Guido van Rossum433c8ad1994-08-01 12:07:07 +000027# Substitutions by configure
28srcdir= @srcdir@
29VPATH= @srcdir@
30INSTALL= @INSTALL@
Guido van Rossum4a91df41994-10-10 17:58:27 +000031RANLIB= @RANLIB@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000032
Guido van Rossumac405f61994-09-12 10:56:06 +000033# Machine-dependent subdirectories
34MACHDEP= @MACHDEP@
35
Guido van Rossum433c8ad1994-08-01 12:07:07 +000036# Install prefix for architecture-independent files
Guido van Rossum76be6ed1995-01-02 18:33:54 +000037prefix= @prefix@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000038
39# Install prefix for architecture-dependent files
Guido van Rossum76be6ed1995-01-02 18:33:54 +000040exec_prefix= @exec_prefix@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000041
Guido van Rossum90412791994-10-20 22:04:30 +000042# Expanded directories
43MANDIR=$(prefix)/man
44BINDIR=$(exec_prefix)/bin
45LIBDIR=$(exec_prefix)/lib
46INCLUDEDIR=$(prefix)/include
47SCRIPTDIR=$(prefix)/lib
48
Guido van Rossumac405f61994-09-12 10:56:06 +000049# Symbols used for using shared libraries
50SO= @SO@
51LDSHARED= @LDSHARED@
52CCSHARED= @CCSHARED@
53LINKFORSHARED= @LINKFORSHARED@
Guido van Rossum90412791994-10-20 22:04:30 +000054DESTSHARED= $(SCRIPTDIR)/python/$(MACHDEP)
Guido van Rossumac405f61994-09-12 10:56:06 +000055
Guido van Rossum433c8ad1994-08-01 12:07:07 +000056# Programs
57SHELL= /bin/sh
58
59# --with-PACKAGE options for configure script
60# e.g. --with-readline --with-svr5 --with-solaris --with-thread
61# (see README for an explanation)
62WITH=
63
64# Compiler options passed to subordinate makes
Guido van Rossum4e8af441994-08-19 15:33:54 +000065OPT= @OPT@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000066
67# Subdirectories where to run make recursively
68SUBDIRS= Parser Objects Python Modules
69
70# Other subdirectories
71SUBDIRSTOO= Include Lib Doc Misc Demo readline Grammar
72
73# Files and directories to be distributed
74CONFIGFILES= configure configure.in acconfig.h config.h.in Makefile.in
75DISTFILES= README ChangeLog $(CONFIGFILES)
76DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
77DIST= $(DISTFILES) $(DISTDIRS)
78
79# Default target
80all: python
81
82# Build the interpreter
83python: Makefiles
Guido van Rossum810a92f1993-12-28 19:39:56 +000084 for i in $(SUBDIRS); do \
Guido van Rossum433c8ad1994-08-01 12:07:07 +000085 (echo $$i; cd $$i; $(MAKE) OPT="$(OPT)" all); \
Guido van Rossum810a92f1993-12-28 19:39:56 +000086 done
87
Guido van Rossum433c8ad1994-08-01 12:07:07 +000088# Test the interpreter (twice, once without .pyc files, once with)
Guido van Rossum76be6ed1995-01-02 18:33:54 +000089TESTPATH= $(srcdir)/Lib:$(srcdir)/Lib/test:./Modules
Guido van Rossum433c8ad1994-08-01 12:07:07 +000090test: python
91 -rm -f $(srcdir)/Lib/test/*.pyc
92 PYTHONPATH=$(TESTPATH) ./python -c 'import autotest'
93 PYTHONPATH=$(TESTPATH) ./python -c 'import autotest'
Guido van Rossum810a92f1993-12-28 19:39:56 +000094
Guido van Rossum433c8ad1994-08-01 12:07:07 +000095# Install the interpreter
96install: python
Guido van Rossum90412791994-10-20 22:04:30 +000097 $(INSTALL) python $(BINDIR)/python
Guido van Rossum433c8ad1994-08-01 12:07:07 +000098 @echo If this is your first time, consider make libinstall...
Guido van Rossum810a92f1993-12-28 19:39:56 +000099
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000100# Install the library.
101# If your system does not support "cp -r", try "copy -r" or perhaps
Guido van Rossum7522f031994-08-30 12:42:01 +0000102# something like find Lib -print | cpio -pacvdmu $(LIBDEST)
Guido van Rossum90412791994-10-20 22:04:30 +0000103LIBDEST= $(SCRIPTDIR)/python
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000104libinstall:
Guido van Rossum7522f031994-08-30 12:42:01 +0000105 -if test ! -d $(LIBDEST); \
106 then mkdir $(LIBDEST); \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000107 fi
Guido van Rossum7522f031994-08-30 12:42:01 +0000108 cp -r $(srcdir)/Lib/* $(LIBDEST)
109 PYTHONPATH=$(LIBDEST) \
110 ./python $(LIBDEST)/compileall.py $(LIBDEST)
Guido van Rossum90412791994-10-20 22:04:30 +0000111 cd Modules; make sharedinstall
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000112
113# install the manual page
114maninstall:
115 $(INSTALL) $(srcdir)/Misc/python.man \
Guido van Rossum90412791994-10-20 22:04:30 +0000116 $(MANDIR)/man1/python.1
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000117
118# install the include files
Guido van Rossum90412791994-10-20 22:04:30 +0000119INCLUDEPY= $(INCLUDEDIR)/Py
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000120inclinstall:
121 -if test ! -d $(INCLUDEPY); \
122 then mkdir $(INCLUDEPY); \
123 fi
124 cp $(srcdir)/Include/*.h $(INCLUDEPY)
125
126# install the lib*.a files and miscellaneous stuff needed by extensions
Guido van Rossum90412791994-10-20 22:04:30 +0000127LIBP= $(LIBDIR)/python
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000128LIBPL= $(LIBP)/lib
129libainstall: all
130 -if test ! -d $(LIBP); \
131 then mkdir $(LIBP); \
132 fi
133 -if test ! -d $(LIBPL); \
134 then mkdir $(LIBPL); \
135 fi
136 for i in $(SUBDIRS); do \
137 echo $$i; $(INSTALL) $$i/lib$$i.a $(LIBPL)/lib$$i.a; \
Guido van Rossum4a91df41994-10-10 17:58:27 +0000138 $(RANLIB) $(LIBPL)/lib$$i.a; \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000139 done
140 $(INSTALL) Modules/config.c $(LIBPL)/config.c
141 $(INSTALL) $(srcdir)/Modules/config.c.in $(LIBPL)/config.c.in
142 $(INSTALL) Modules/Makefile $(LIBPL)/Makefile
143 $(INSTALL) Modules/Setup $(LIBPL)/Setup
144 $(INSTALL) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup
145 $(INSTALL) config.h $(LIBPL)/config.h
146 $(INSTALL) $(srcdir)/Python/frozenmain.c $(LIBPL)/frozenmain.c
147
Guido van Rossumac405f61994-09-12 10:56:06 +0000148# install the dynamically loadable modules
149sharedinstall:
150 cd Modules; $(MAKE) \
151 OPT="$(OPT)" \
152 SO="$(SO)" \
153 LDSHARED="$(LDSHARED)" \
154 CCSHARED="$(CCSHARED)" \
155 LINKFORSHARED="$(LINKFORSHARED)" \
156 DESTSHARED="$(DESTSHARED)" \
157 sharedinstall
158
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000159# Build the sub-Makefiles
160Makefiles: config.status
161 (cd Modules; $(MAKE) -f Makefile.pre Makefile)
162 for i in . $(SUBDIRS); do \
163 (echo $$i; cd $$i; $(MAKE) Makefile); \
164 done
165
166# Build the toplevel Makefile
167Makefile: Makefile.in config.status
168 CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) config.status
169
170# Run the configure script. If config.status already exists,
171# call it with the --recheck argument, which reruns configure with the
172# same options as it was run last time; otherwise run the configure
173# script with options taken from the $(WITH) variable
174config.status: $(srcdir)/configure
175 if test -f config.status; \
176 then $(SHELL) config.status --recheck; \
177 else $(SHELL) $(srcdir)/configure $(WITH); \
178 fi
179
180.PRECIOUS: config.status python
181
182# Rerun configure with the same options as it was run last time,
183# provided the config.status script exists
184recheck:
185 $(SHELL) config.status --recheck
186
187# Rebuild the configure script from configure.in; also rebuild config.h.in
188autoconf:
189 (cd $(srcdir); autoconf; autoheader)
190
191# Create a tags file for vi
192tags::
193 ctags -w -t Include/*.h
194 for i in $(SUBDIRS); do ctags -w -t -a $$i/*.[ch]; done
195 sort tags -o tags
196
197# Create a tags file for GNU Emacs
198TAGS::
Guido van Rossum5552eb71994-08-05 15:51:00 +0000199 etags Include/*.h
200 for i in $(SUBDIRS); do etags -a $$i/*.[ch]; done
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000201
202# Add dependencies to sub-Makefiles
Guido van Rossum810a92f1993-12-28 19:39:56 +0000203depend:
204 for i in $(SUBDIRS); do \
205 (echo $$i; cd $$i; $(MAKE) depend); \
206 done
Guido van Rossum627b2d71993-12-24 10:39:16 +0000207
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000208# Sanitation targets -- clean leaves libraries, executables and tags
209# files, which clobber removes those as well
210
Guido van Rossum627b2d71993-12-24 10:39:16 +0000211localclean:
212 -rm -f core *~ [@,#]* *.old *.orig *.rej
Guido van Rossum627b2d71993-12-24 10:39:16 +0000213
214clean: localclean
215 -for i in $(SUBDIRS); do \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000216 (echo $$i; cd $$i; \
217 if test -f Makefile; \
218 then $(MAKE) clean; \
219 else $(MAKE) -f Makefile.*in clean; \
220 fi); \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000221 done
222
Guido van Rossum810a92f1993-12-28 19:39:56 +0000223localclobber: localclean
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000224 -rm -f tags TAGS python
Guido van Rossum810a92f1993-12-28 19:39:56 +0000225
226clobber: localclobber
Guido van Rossum627b2d71993-12-24 10:39:16 +0000227 -for i in $(SUBDIRS); do \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000228 (echo $$i; cd $$i; \
229 if test -f Makefile; \
230 then $(MAKE) clobber; \
231 else $(MAKE) -f Makefile.in clobber; \
232 fi); \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000233 done
234
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000235# Make things extra clean, before making a distribution
Guido van Rossum627b2d71993-12-24 10:39:16 +0000236distclean: clobber
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000237 -$(MAKE) SUBDIRS="$(SUBDIRSTOO)" clobber
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000238 -rm -f config.status config.log config.cache config.h Makefile
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000239 -for i in $(SUBDIRS) $(SUBDIRSTOO); do \
240 for f in $$i/*.in; do \
241 f=`basename "$$f" .in`; \
242 if test "$$f" != "*"; then \
243 echo rm -f "$$i/$$f"; \
244 rm -f "$$i/$$f"; \
245 fi; \
246 done; \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000247 done
Guido van Rossum627b2d71993-12-24 10:39:16 +0000248
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000249# Find files with funny names
250find:
251 find $(DISTDIRS) -type d \
252 -o -name '*.[chs]' \
253 -o -name '*.py' \
254 -o -name '*.doc' \
255 -o -name '*.sty' \
256 -o -name '*.bib' \
257 -o -name '*.dat' \
258 -o -name '*.el' \
259 -o -name '*.fd' \
260 -o -name '*.in' \
261 -o -name '*.tex' \
262 -o -name '*,[vpt]' \
263 -o -name 'Setup' \
264 -o -name 'Setup.*' \
265 -o -name README \
266 -o -name Makefile \
267 -o -name ChangeLog \
268 -o -name RCS \
269 -o -name Repository \
270 -o -name Entries \
271 -o -name Tag \
272 -o -name tags \
273 -o -name TAGS \
274 -o -name .cvsignore \
275 -o -name MANIFEST \
276 -o -print
Guido van Rossum627b2d71993-12-24 10:39:16 +0000277
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000278# Build a distribution tar file (run make distclean first)
279# (This leaves the RCS and CVS directories in :-( )
280tar:
Guido van Rossum5552eb71994-08-05 15:51:00 +0000281 tar cf - $(DIST) | gzip --best >dist.tar.gz