blob: 7bbf57b9de07677fcbdbd7fb95ebd78868ce6977 [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 prefixes are treated specially by the configure script:
37# it only changes these lines if it has received a --prefix=... or
Guido van Rossuma0e9a771994-08-12 13:18:25 +000038# --exec-prefix=... command line option. Note that $(prefix) is
Guido van Rossum433c8ad1994-08-01 12:07:07 +000039# also used when compiling config.c in Modules to set the default
40# module search path, so if you change it later be sure to change it
41# there too and rebuild.
42
43# Install prefix for architecture-independent files
44prefix= /usr/local
45
46# Install prefix for architecture-dependent files
47exec_prefix= $(prefix)
48
Guido van Rossum90412791994-10-20 22:04:30 +000049# Expanded directories
50MANDIR=$(prefix)/man
51BINDIR=$(exec_prefix)/bin
52LIBDIR=$(exec_prefix)/lib
53INCLUDEDIR=$(prefix)/include
54SCRIPTDIR=$(prefix)/lib
55
Guido van Rossumac405f61994-09-12 10:56:06 +000056# Symbols used for using shared libraries
57SO= @SO@
58LDSHARED= @LDSHARED@
59CCSHARED= @CCSHARED@
60LINKFORSHARED= @LINKFORSHARED@
Guido van Rossum90412791994-10-20 22:04:30 +000061DESTSHARED= $(SCRIPTDIR)/python/$(MACHDEP)
Guido van Rossumac405f61994-09-12 10:56:06 +000062
Guido van Rossum433c8ad1994-08-01 12:07:07 +000063# Programs
64SHELL= /bin/sh
65
66# --with-PACKAGE options for configure script
67# e.g. --with-readline --with-svr5 --with-solaris --with-thread
68# (see README for an explanation)
69WITH=
70
71# Compiler options passed to subordinate makes
Guido van Rossum4e8af441994-08-19 15:33:54 +000072OPT= @OPT@
Guido van Rossum433c8ad1994-08-01 12:07:07 +000073
74# Subdirectories where to run make recursively
75SUBDIRS= Parser Objects Python Modules
76
77# Other subdirectories
78SUBDIRSTOO= Include Lib Doc Misc Demo readline Grammar
79
80# Files and directories to be distributed
81CONFIGFILES= configure configure.in acconfig.h config.h.in Makefile.in
82DISTFILES= README ChangeLog $(CONFIGFILES)
83DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
84DIST= $(DISTFILES) $(DISTDIRS)
85
86# Default target
87all: python
88
89# Build the interpreter
90python: Makefiles
Guido van Rossum810a92f1993-12-28 19:39:56 +000091 for i in $(SUBDIRS); do \
Guido van Rossum433c8ad1994-08-01 12:07:07 +000092 (echo $$i; cd $$i; $(MAKE) OPT="$(OPT)" all); \
Guido van Rossum810a92f1993-12-28 19:39:56 +000093 done
94
Guido van Rossum433c8ad1994-08-01 12:07:07 +000095# Test the interpreter (twice, once without .pyc files, once with)
96TESTPATH= $(srcdir)/Lib:$(srcdir)/Lib/test
97test: python
98 -rm -f $(srcdir)/Lib/test/*.pyc
99 PYTHONPATH=$(TESTPATH) ./python -c 'import autotest'
100 PYTHONPATH=$(TESTPATH) ./python -c 'import autotest'
Guido van Rossum810a92f1993-12-28 19:39:56 +0000101
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000102# Install the interpreter
103install: python
Guido van Rossum90412791994-10-20 22:04:30 +0000104 $(INSTALL) python $(BINDIR)/python
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000105 @echo If this is your first time, consider make libinstall...
Guido van Rossum810a92f1993-12-28 19:39:56 +0000106
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000107# Install the library.
108# If your system does not support "cp -r", try "copy -r" or perhaps
Guido van Rossum7522f031994-08-30 12:42:01 +0000109# something like find Lib -print | cpio -pacvdmu $(LIBDEST)
Guido van Rossum90412791994-10-20 22:04:30 +0000110LIBDEST= $(SCRIPTDIR)/python
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000111libinstall:
Guido van Rossum7522f031994-08-30 12:42:01 +0000112 -if test ! -d $(LIBDEST); \
113 then mkdir $(LIBDEST); \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000114 fi
Guido van Rossum7522f031994-08-30 12:42:01 +0000115 cp -r $(srcdir)/Lib/* $(LIBDEST)
116 PYTHONPATH=$(LIBDEST) \
117 ./python $(LIBDEST)/compileall.py $(LIBDEST)
Guido van Rossum90412791994-10-20 22:04:30 +0000118 cd Modules; make sharedinstall
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000119
120# install the manual page
121maninstall:
122 $(INSTALL) $(srcdir)/Misc/python.man \
Guido van Rossum90412791994-10-20 22:04:30 +0000123 $(MANDIR)/man1/python.1
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000124
125# install the include files
Guido van Rossum90412791994-10-20 22:04:30 +0000126INCLUDEPY= $(INCLUDEDIR)/Py
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000127inclinstall:
128 -if test ! -d $(INCLUDEPY); \
129 then mkdir $(INCLUDEPY); \
130 fi
131 cp $(srcdir)/Include/*.h $(INCLUDEPY)
132
133# install the lib*.a files and miscellaneous stuff needed by extensions
Guido van Rossum90412791994-10-20 22:04:30 +0000134LIBP= $(LIBDIR)/python
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000135LIBPL= $(LIBP)/lib
136libainstall: all
137 -if test ! -d $(LIBP); \
138 then mkdir $(LIBP); \
139 fi
140 -if test ! -d $(LIBPL); \
141 then mkdir $(LIBPL); \
142 fi
143 for i in $(SUBDIRS); do \
144 echo $$i; $(INSTALL) $$i/lib$$i.a $(LIBPL)/lib$$i.a; \
Guido van Rossum4a91df41994-10-10 17:58:27 +0000145 $(RANLIB) $(LIBPL)/lib$$i.a; \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000146 done
147 $(INSTALL) Modules/config.c $(LIBPL)/config.c
148 $(INSTALL) $(srcdir)/Modules/config.c.in $(LIBPL)/config.c.in
149 $(INSTALL) Modules/Makefile $(LIBPL)/Makefile
150 $(INSTALL) Modules/Setup $(LIBPL)/Setup
151 $(INSTALL) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup
152 $(INSTALL) config.h $(LIBPL)/config.h
153 $(INSTALL) $(srcdir)/Python/frozenmain.c $(LIBPL)/frozenmain.c
154
Guido van Rossumac405f61994-09-12 10:56:06 +0000155# install the dynamically loadable modules
156sharedinstall:
157 cd Modules; $(MAKE) \
158 OPT="$(OPT)" \
159 SO="$(SO)" \
160 LDSHARED="$(LDSHARED)" \
161 CCSHARED="$(CCSHARED)" \
162 LINKFORSHARED="$(LINKFORSHARED)" \
163 DESTSHARED="$(DESTSHARED)" \
164 sharedinstall
165
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000166# Build the sub-Makefiles
167Makefiles: config.status
168 (cd Modules; $(MAKE) -f Makefile.pre Makefile)
169 for i in . $(SUBDIRS); do \
170 (echo $$i; cd $$i; $(MAKE) Makefile); \
171 done
172
173# Build the toplevel Makefile
174Makefile: Makefile.in config.status
175 CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) config.status
176
177# Run the configure script. If config.status already exists,
178# call it with the --recheck argument, which reruns configure with the
179# same options as it was run last time; otherwise run the configure
180# script with options taken from the $(WITH) variable
181config.status: $(srcdir)/configure
182 if test -f config.status; \
183 then $(SHELL) config.status --recheck; \
184 else $(SHELL) $(srcdir)/configure $(WITH); \
185 fi
186
187.PRECIOUS: config.status python
188
189# Rerun configure with the same options as it was run last time,
190# provided the config.status script exists
191recheck:
192 $(SHELL) config.status --recheck
193
194# Rebuild the configure script from configure.in; also rebuild config.h.in
195autoconf:
196 (cd $(srcdir); autoconf; autoheader)
197
198# Create a tags file for vi
199tags::
200 ctags -w -t Include/*.h
201 for i in $(SUBDIRS); do ctags -w -t -a $$i/*.[ch]; done
202 sort tags -o tags
203
204# Create a tags file for GNU Emacs
205TAGS::
Guido van Rossum5552eb71994-08-05 15:51:00 +0000206 etags Include/*.h
207 for i in $(SUBDIRS); do etags -a $$i/*.[ch]; done
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000208
209# Add dependencies to sub-Makefiles
Guido van Rossum810a92f1993-12-28 19:39:56 +0000210depend:
211 for i in $(SUBDIRS); do \
212 (echo $$i; cd $$i; $(MAKE) depend); \
213 done
Guido van Rossum627b2d71993-12-24 10:39:16 +0000214
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000215# Sanitation targets -- clean leaves libraries, executables and tags
216# files, which clobber removes those as well
217
Guido van Rossum627b2d71993-12-24 10:39:16 +0000218localclean:
219 -rm -f core *~ [@,#]* *.old *.orig *.rej
Guido van Rossum627b2d71993-12-24 10:39:16 +0000220
221clean: localclean
222 -for i in $(SUBDIRS); do \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000223 (echo $$i; cd $$i; \
224 if test -f Makefile; \
225 then $(MAKE) clean; \
226 else $(MAKE) -f Makefile.*in clean; \
227 fi); \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000228 done
229
Guido van Rossum810a92f1993-12-28 19:39:56 +0000230localclobber: localclean
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000231 -rm -f tags TAGS python
Guido van Rossum810a92f1993-12-28 19:39:56 +0000232
233clobber: localclobber
Guido van Rossum627b2d71993-12-24 10:39:16 +0000234 -for i in $(SUBDIRS); do \
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000235 (echo $$i; cd $$i; \
236 if test -f Makefile; \
237 then $(MAKE) clobber; \
238 else $(MAKE) -f Makefile.in clobber; \
239 fi); \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000240 done
241
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000242# Make things extra clean, before making a distribution
Guido van Rossum627b2d71993-12-24 10:39:16 +0000243distclean: clobber
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000244 -$(MAKE) SUBDIRS="$(SUBDIRSTOO)" clobber
245 -rm -f config.status config.h Makefile
246 -for i in $(SUBDIRS) $(SUBDIRSTOO); do \
247 for f in $$i/*.in; do \
248 f=`basename "$$f" .in`; \
249 if test "$$f" != "*"; then \
250 echo rm -f "$$i/$$f"; \
251 rm -f "$$i/$$f"; \
252 fi; \
253 done; \
Guido van Rossum627b2d71993-12-24 10:39:16 +0000254 done
Guido van Rossum627b2d71993-12-24 10:39:16 +0000255
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000256# Find files with funny names
257find:
258 find $(DISTDIRS) -type d \
259 -o -name '*.[chs]' \
260 -o -name '*.py' \
261 -o -name '*.doc' \
262 -o -name '*.sty' \
263 -o -name '*.bib' \
264 -o -name '*.dat' \
265 -o -name '*.el' \
266 -o -name '*.fd' \
267 -o -name '*.in' \
268 -o -name '*.tex' \
269 -o -name '*,[vpt]' \
270 -o -name 'Setup' \
271 -o -name 'Setup.*' \
272 -o -name README \
273 -o -name Makefile \
274 -o -name ChangeLog \
275 -o -name RCS \
276 -o -name Repository \
277 -o -name Entries \
278 -o -name Tag \
279 -o -name tags \
280 -o -name TAGS \
281 -o -name .cvsignore \
282 -o -name MANIFEST \
283 -o -print
Guido van Rossum627b2d71993-12-24 10:39:16 +0000284
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000285# Build a distribution tar file (run make distclean first)
286# (This leaves the RCS and CVS directories in :-( )
287tar:
Guido van Rossum5552eb71994-08-05 15:51:00 +0000288 tar cf - $(DIST) | gzip --best >dist.tar.gz