summaryrefslogtreecommitdiffstats
path: root/Makefile.in
blob: 0a26902ad4ebc56b1b284d8109374d576e56ae73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
########################################################################
# Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
# The Netherlands.
#
#                         All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the names of Stichting Mathematisch
# Centrum or CWI or Corporation for National Research Initiatives or
# CNRI not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission.
# 
# While CWI is the initial source for this software, a modified version
# is made available by the Corporation for National Research Initiatives
# (CNRI) at the Internet address ftp://ftp.python.org.
# 
# STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
# CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
########################################################################

# Top-level Makefile for Python
# 
# As distributed, this file is called Makefile.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:
# 
#	./configure
#	make
#	make test
#	make install
# 
# The top-level Makefile invokes make recursively in a number of
# subdirectories (see the SUBDIRS variable below).  If you want to,
# you can invoke make in individual subdirectories.  However, the
# sub-Makefiles are also generated by configure, and the quickest way
# to make sure they are up to date is by running make (or "make
# Makefiles") at the top level.  This is particularly important for
# Modules/Makefile, which has to be regenerated every time you edit
# Modules/Setup.  The python executable is built in the Modules
# directory and then moved to the top-level directory.  The recursive
# makes pass three options to subordinate makes: OPT (a quick way to
# change some compiler options; it usually defaults to -O), prefix and
# exec_prefix (the installation paths).
# 
# If you have a previous version of Python installed that you don't
# want to overwrite, you can use "make altinstall" instead of "make
# install".  This changes the install procedure so it installs the
# Python binary as "python<version>".  The libraries and include files
# are always installed in a subdirectory called "python<version>".
# "make altinstall" does not install the manual page.  If you want to
# make this installation the "official" installation but want to keep
# the old binary around "just in case", rename the installed python
# binary to "python<oldversion>" before running "make install".
# (This only works between different versions, e.g. 1.3 and 1.4 --
# different betas of the same version will overwrite each other in
# installation unless you override the VERSION Make variable.)
# 
# In fact, "make install" or "make bininstall" installs the binary
# as python<version> and makes a hard link to python, so when
# installing a new version in the future, nothing of the current
# version will be lost (except for the man page).
# 
# If recursive makes fail, try invoking make as "make MAKE=make".
# 
# See also the section "Build instructions" in the README file.

# Substitutions by configure
VERSION=	@VERSION@
srcdir=		@srcdir@
VPATH=		@srcdir@
CC=		@CC@
AR=		@AR@
RANLIB=		@RANLIB@
DEFS=		@DEFS@

# 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
MANDIR=		$(prefix)/man
INCLUDEDIR=	$(prefix)/include
SCRIPTDIR=	$(prefix)/lib

# Detailed destination directories
BINLIBDEST=	$(LIBDIR)/python$(VERSION)
LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)
LIBP=		$(LIBDIR)/python$(VERSION)

# Symbols used for using shared libraries
SO=		@SO@
LDSHARED=	@LDSHARED@
CCSHARED=	@CCSHARED@
LINKFORSHARED=	@LINKFORSHARED@
DESTSHARED=	$(BINLIBDEST)/sharedmodules

# Shell used by make (some versions default to the login shell, which is bad)
SHELL=		/bin/sh

# Portable install script (configure doesn't always guess right)
INSTALL=	@srcdir@/install-sh -c
INSTALL_PROGRAM=${INSTALL} -m 755
INSTALL_DATA=	${INSTALL} -m 644

# --with-PACKAGE options for configure script
# e.g. --with-readline --with-svr5 --with-solaris --with-thread
# (see README for an explanation)
WITH=		

# Compiler options passed to subordinate makes
OPT=		@OPT@

# Subdirectories where to run make recursively
SUBDIRS=	Parser Objects Python Modules

# Other subdirectories
SUBDIRSTOO=	Include Lib Doc Misc Demo Grammar

# Files and directories to be distributed
CONFIGFILES=	configure configure.in acconfig.h config.h.in Makefile.in
DISTFILES=	README ChangeLog $(CONFIGFILES)
DISTDIRS=	$(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
DIST=		$(DISTFILES) $(DISTDIRS)

# Compilation flags for getbuildinfo.c only
CFLAGS=		$(OPT) -I. $(DEFS)

LIBRARY=	libpython$(VERSION).a

# Default target
all:		$(LIBRARY) python sharedmods

# Build the interpreter
python:		$(LIBRARY) buildno
		expr `cat buildno` + 1 >buildno1
		mv -f buildno1 buildno
		$(CC) -c $(CFLAGS) -DBUILD=`cat buildno` \
		      $(srcdir)/Modules/getbuildinfo.c
		$(AR) cr $(LIBRARY) getbuildinfo.o
		$(RANLIB) $(LIBRARY)
		cd Modules;  $(MAKE) OPT="$(OPT)" VERSION="$(VERSION)" \
			prefix="$(prefix)" exec_prefix="$(exec_prefix)" \
			LIBRARY=../$(LIBRARY) link

buildno:
		echo 0 >buildno

# Build the shared modules
sharedmods: 	python
		cd Modules;  $(MAKE) OPT="$(OPT)" VERSION="$(VERSION)" \
			prefix="$(prefix)" exec_prefix="$(exec_prefix)" \
			sharedmods

# Build the library
$(LIBRARY):	$(SUBDIRS)
		if test ! -f $(LIBRARY); \
		then for i in $(SUBDIRS); do rm -f $$i/add2lib; done; true; \
		else true; fi
		for i in $(SUBDIRS); do \
			(cd $$i; $(MAKE) VERSION="$(VERSION)" add2lib); done

$(SUBDIRS):	Makefiles

Parser:
		cd Parser ; $(MAKE) OPT="$(OPT)" VERSION="$(VERSION)" \
			prefix="$(prefix)" exec_prefix="$(exec_prefix)" all

Python:
		cd Python ; $(MAKE) OPT="$(OPT)" VERSION="$(VERSION)" \
			prefix="$(prefix)" exec_prefix="$(exec_prefix)" all

Objects:
		cd Objects ; $(MAKE) OPT="$(OPT)" VERSION="$(VERSION)" \
			prefix="$(prefix)" exec_prefix="$(exec_prefix)" all

Modules:	Parser Python Objects
		cd Modules ; $(MAKE) OPT="$(OPT)" VERSION="$(VERSION)" \
			prefix="$(prefix)" exec_prefix="$(exec_prefix)" all

# Test the interpreter (twice, once without .pyc files, once with)
TESTOPTS=	
TESTPROG=	$(srcdir)/Lib/test/regrtest.py
TESTPYTHON=	./python
test:		python
		-rm -f $(srcdir)/Lib/test/*.pyc
		-PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
		PYTHONPATH= $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)

# Install everything
install:	altinstall bininstall maninstall

# Install almost everything without disturbing previous versions
altinstall:	altbininstall libinstall inclinstall libainstall sharedinstall

# 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
		(cd $(BINDIR); ln python$(VERSION) python)

# Install the interpreter with $(VERSION) affixed
# This goes into $(exec_prefix)
altbininstall:	python
		@for i in $(BINDIR); \
		do \
			if test ! -d $$i; then \
				echo "Creating directory $$i"; \
				mkdir $$i; \
				chmod 755 $$i; \
			else	true; \
			fi; \
		done
		$(INSTALL_PROGRAM) python $(BINDIR)/python$(VERSION)

# Install the manual page
maninstall:
		@for i in $(MANDIR) $(MANDIR)/man1; \
		do \
			if test ! -d $$i; then \
				echo "Creating directory $$i"; \
				mkdir $$i; \
				chmod 755 $$i; \
			else	true; \
			fi; \
		done
		$(INSTALL_DATA) $(srcdir)/Misc/python.man \
			$(MANDIR)/man1/python.1

# Install the library
MACHDEPS=	$(MACHDEP)
LIBSUBDIRS=	stdwin tkinter test $(MACHDEPS)
libinstall:	python $(srcdir)/Lib/$(MACHDEP)
		@for i in $(SCRIPTDIR) $(LIBDEST); \
		do \
			if test ! -d $$i; then \
				echo "Creating directory $$i"; \
				mkdir $$i; \
				chmod 755 $$i; \
			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"; \
				mkdir $$b; \
				chmod 755 $$b; \
			else	true; \
			fi; \
		done
		@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc; \
		do \
			if test -x $$i; then \
				$(INSTALL_PROGRAM) $$i $(LIBDEST); \
				echo $(INSTALL_PROGRAM) $$i $(LIBDEST); \
			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) ;; \
				*.pyc) ;; \
				*~) ;; \
				*) \
					if test -x $$i; then \
					    echo $(INSTALL_PROGRAM) $$i $$b; \
					    $(INSTALL_PROGRAM) $$i $$b; \
					else \
					    echo $(INSTALL_DATA) $$i $$b; \
					    $(INSTALL_DATA) $$i $$b; \
					fi;; \
				esac; \
			done; \
		done
		PYTHONPATH=$(LIBDEST) \
			./python $(LIBDEST)/compileall.py $(LIBDEST)
		PYTHONPATH=$(LIBDEST) \
			./python -O $(LIBDEST)/compileall.py $(LIBDEST)

# Create the MACHDEP source directory, if one wasn't distributed..
$(srcdir)/Lib/$(MACHDEP):
		mkdir $(srcdir)/Lib/$(MACHDEP)
		cp $(srcdir)/Lib/generic/regen $(srcdir)/Lib/$(MACHDEP)/regen
		export PATH; PATH="`pwd`:$$PATH"; \
		export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
		cd $(srcdir)/Lib/$(MACHDEP); ./regen

# Install the include files
inclinstall:
		@for i in $(INCLUDEDIR) $(INCLUDEPY); \
		do \
			if test ! -d $$i; then \
				echo "Creating directory $$i"; \
				mkdir $$i; \
				chmod 755 $$i; \
			else	true; \
			fi; \
		done
		@for i in $(srcdir)/Include/*.h; \
		do \
			echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
			$(INSTALL_DATA) $$i $(INCLUDEPY); \
		done

# 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"; \
				mkdir $$i; \
				chmod 755 $$i; \
			else	true; \
			fi; \
		done
		$(INSTALL_DATA) $(LIBRARY) $(LIBPL)/$(LIBRARY)
		$(RANLIB) $(LIBPL)/$(LIBRARY)
		$(INSTALL_DATA) Modules/config.c $(LIBPL)/config.c
		$(INSTALL_DATA) Modules/python.o $(LIBPL)/python.o
		$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(LIBPL)/config.c.in
		$(INSTALL_DATA) Modules/Makefile $(LIBPL)/Makefile
		$(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup
		$(INSTALL_DATA) Modules/Setup.local $(LIBPL)/Setup.local
		$(INSTALL_PROGRAM) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup
		$(INSTALL_DATA) config.h $(LIBPL)/config.h

# Install the dynamically loadable modules
# This goes into $(exec_prefix)
sharedinstall:
		cd Modules; $(MAKE) \
			OPT="$(OPT)" \
			VERSION="$(VERSION)" \
			SO="$(SO)" \
			LDSHARED="$(LDSHARED)" \
			CCSHARED="$(CCSHARED)" \
			LINKFORSHARED="$(LINKFORSHARED)" \
			DESTSHARED="$(DESTSHARED)" \
			prefix="$(prefix)" \
			exec_prefix="$(exec_prefix)" \
			sharedinstall

# Build the sub-Makefiles
Makefiles:	config.status Modules/Makefile.pre
		(cd Modules; $(MAKE) -f Makefile.pre Makefile)
		@for i in . $(SUBDIRS); do \
			(echo making Makefile in subdirectory $$i; cd $$i; \
			 $(MAKE) Makefile); \
		done

# Build the intermediate Makefile in Modules
Modules/Makefile.pre: config.status
		$(SHELL) config.status

# Build the toplevel Makefile
Makefile:	Makefile.in config.status
		CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) config.status

# Run the configure script.  If config.status already exists,
# call it with the --recheck argument, which reruns configure with the
# same options as it was run last time; otherwise run the configure
# script with options taken from the $(WITH) variable
config.status:	$(srcdir)/configure
		if test -f config.status; \
		then $(SHELL) config.status --recheck; \
		     $(SHELL) config.status; \
		else $(SHELL) $(srcdir)/configure $(WITH); \
		fi

.PRECIOUS:	config.status python

# 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

# Rebuild the configure script from configure.in; also rebuild config.h.in
autoconf:
		(cd $(srcdir); autoconf)
		(cd $(srcdir); autoheader)

# Create a tags file for vi
tags::
		ctags -w -t Include/*.h
		for i in $(SUBDIRS); do ctags -w -t -a $$i/*.[ch]; done
		sort tags -o tags

# Create a tags file for GNU Emacs
TAGS::
		etags Include/*.h
		for i in $(SUBDIRS); do etags -a $$i/*.[ch]; done

# Add dependencies to sub-Makefiles
depend:
		@for i in $(SUBDIRS); do \
			(echo making depend in subdirectory $$i; cd $$i; \
			 $(MAKE) depend); \
		done

# Sanitation targets -- clean leaves libraries, executables and tags
# files, which clobber removes those as well

localclean:
		-rm -f core *~ [@,#]* *.old *.orig *.rej

clean:		localclean
		-for i in $(SUBDIRS); do \
			(echo making clean in subdirectory $$i; cd $$i; \
			 if test -f Makefile; \
			 then $(MAKE) clean; \
			 else $(MAKE) -f Makefile.*in clean; \
			 fi); \
		done

localclobber:	localclean
		-rm -f tags TAGS python $(LIBRARY) *.o
		-rm -f config.log config.cache config.h

clobber:	localclobber
		-for i in $(SUBDIRS); do \
			(echo clobbering subdirectory $$i; cd $$i; \
			 if test -f Makefile; \
			 then $(MAKE) clobber; \
			 else $(MAKE) -f $(srcdir)/Makefile.in clobber; \
			 fi); \
		done

# Make things extra clean, before making a distribution:
# remove all generated files, even Makefile[.pre]
distclean:	clobber
		-$(MAKE) -f $(srcdir)/Makefile.in \
			SUBDIRS="$(SUBDIRSTOO)" clobber
		-rm -f config.status config.log config.cache config.h Makefile
		-rm -f buildno
		-rm -f Modules/Makefile
		-for i in $(SUBDIRS) $(SUBDIRSTOO); do \
			 for f in $$i/*.in; do \
				f=`basename "$$f" .in`; \
			 	if test "$$f" != "*"; then \
					echo rm -f "$$i/$$f"; \
				 	rm -f "$$i/$$f"; \
				fi; \
			 done; \
		done

# Check for smelly exported symbols (not starting with Py/_Py)
smelly: all
	for i in $(SUBDIRS); do \
		echo --- $$i ---; \
		nm -p $$i/lib$$i.a | \
		sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
	done

# 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