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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
|
# /***********************************************************
# Copyright 1991 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 not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior permission.
#
# STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM 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.
#
# ******************************************************************/
# Makefile for Python
# ===================
#
# If you are in a hurry, you can just edit this Makefile to choose the
# correct settings for SYSV and RANLIB below, and type "make" in this
# directory. If you are using a recent version of SunOS (or Ultrix?)
# you don't even have to edit: the Makefile comes pre-configured for
# such systems with all configurable options turned off, building the
# minimal portable version of the Python interpreter.
#
# If have more time, read the section on configurable options below.
# It may still be wise to begin building the minimal portable Python,
# to see if it works at all, and select options later. You don't have
# to rebuild all objects when you turn on options; all dependencies
# are concentrated in the file "config.c" which is rebuilt whenever
# the Makefile changes. (Except if you turn on the GNU Readline option
# you may have to toss out the tokenizer.o object.)
# Operating System Defines (ALWAYS READ THIS)
# ===========================================
# Uncomment the following line if you are using a System V derivative.
# This must be used, for instance, on an SGI IRIS. Don't use it for
# SunOS. (This is only needed by posixmodule.c...)
#SYSVDEF= -DSYSV
# Choose one of the following two lines depending on whether your system
# requires the use of 'ranlib' after creating a library, or not.
#RANLIB = true # For System V
RANLIB = ranlib # For BSD
# If your system doesn't have symbolic links, uncomment the following
# line.
#NOSYMLINKDEF= -DNO_LSTAT
# Installation Options
# ====================
# You may want to change DEFPYTHONPATH to reflect where you install the
# Python module library. The default contains "../lib" so running
# the interpreter from the source/build directory as distributed will
# find the library (admittedly a hack).
# patched by Arslaan Pathan, 2026-01-21
# change DEFPYTHONPATH to the default INSTALL_DIR
# used in the make install target I added at the
# end of the file.
INSTALL_DIR= /opt/python091
DEFPYTHONPATH= .:$(INSTALL_DIR)/lib:../lib
# For "Pure" BSD Systems
# ======================
#
# "Pure" BSD systems (as opposed to enhanced BSD derivatives like SunOS)
# often miss certain standard library functions. Source for
# these is provided, you just have to turn it on. This may work for
# other systems as well, where these things are needed.
# If your system does not have a strerror() function in the library,
# uncomment the following two lines to use one I wrote. (Actually, this
# is missing in most systems I have encountered, so it is turned on
# in the Makefile. Turn it off if your system doesn't have sys_errlist.)
# STRERROR_SRC= strerror.c
# STRERROR_OBJ= strerror.o
# If your BSD system does not have a fmod() function in the library,
# uncomment the following two lines to use one I wrote.
#FMOD_SRC= fmod.c
#FMOD_OBJ= fmod.o
# If your BSD system does not have a strtol() function in the library,
# uncomment the following two lines to use one I wrote.
#STRTOL_SRC= strtol.c
#STRTOL_OBJ= strtol.o
# If your BSD system does not have a getcwd() function in the library,
# but it does have a getwd() function, uncomment the following two lines
# to use one I wrote. (If you don't have getwd() either, turn on the
# NO_GETWD #define in getcwd.c.)
#GETCWD_SRC= getcwd.c
#GETCWD_OBJ= getcwd.o
# If your signal() function believes signal handlers return int,
# uncomment the following line.
#SIGTYPEDEF= -DSIGTYPE=int
# Further porting hints
# =====================
#
# If you don't have the header file <string.h>, but you do have
# <strings.h>, create a file "string.h" in this directory which contains
# the single line "#include <strings.h>", and add "-I." to CFLAGS.
# If you don't have the functions strchr and strrchr, add definitions
# "-Dstrchr=index -Dstrrchr=rindex" to CFLAGS. (NB: CFLAGS is not
# defined in this Makefile.)
# Configurable Options
# ====================
#
# Python can be configured to interface to various system libraries that
# are not available on all systems. It is also possible to configure
# the input module to use the GNU Readline library for interactive
# input. For each configuration choice you must uncomment the relevant
# section of the Makefile below. Note: you may also have to change a
# pathname and/or an architecture identifier that is hardcoded in the
# Makefile.
#
# Read the comments to determine if you can use the option. (You can
# always leave all options off and build a minimal portable version of
# Python.)
# BSD Time Option
# ===============
#
# This option does not add a new module but adds two functions to
# an existing module.
#
# It implements time.millisleep() and time.millitimer()
# using the BSD system calls select() and gettimeofday().
#
# Uncomment the following line to select this option.
#BSDTIMEDEF= -DBSD_TIME
# GNU Readline Option
# ===================
#
# If you have the sources of the GNU Readline library you can have
# full interactive command line editing and history in Python.
# The GNU Readline library is distributed with the BASH shell
# (I only know of version 1.05). You must build the GNU Readline
# library and the alloca routine it needs in their own source
# directories (which are subdirectories of the basg source directory),
# and plant a pointer to the BASH source directory in this Makefile.
#
# Uncomment and edit the following block to use the GNU Readline option.
# - Edit the definition of BASHDIR to point to the bash source tree.
# You may have to fix the definition of LIBTERMCAP; leave the LIBALLOCA
# definition commented if alloca() is in your C library.
#BASHDIR= ../../bash-1.05
#LIBREADLINE= $(BASHDIR)/readline/libreadline.a
#LIBALLOCA= $(BASHDIR)/alloc-files/alloca.o
#LIBTERMCAP= -ltermcap
#RL_USE = -DUSE_READLINE
#RL_LIBS= $(LIBREADLINE) $(LIBALLOCA) $(LIBTERMCAP)
#RL_LIBDEPS= $(LIBREADLINE) $(LIBALLOCA)
# STDWIN Option
# =============
#
# If you have the sources of STDWIN (by the same author) you can
# configure Python to incorporate the built-in module 'stdwin'.
# This requires a fairly recent version of STDWIN (dated late 1990).
#
# Uncomment and edit the following block to use the STDWIN option.
# - Edit the STDWINDIR defition to reflect the top of the STDWIN source
# tree.
# - Edit the ARCH definition to reflect your system's architecture
# (usually the program 'arch' or 'machine' returns this).
# You may have to edit the LIBX11 defition to reflect the location of
# the X11 runtime library if it is non-standard.
#STDWINDIR= ../../stdwin
#ARCH= sgi
#LIBSTDWIN= $(STDWINDIR)/Build/$(ARCH)/x11/lib/lib.a
#LIBX11 = -lX11
#STDW_INCL= -I$(STDWINDIR)/H
#STDW_USE= -DUSE_STDWIN
#STDW_LIBS= $(LIBSTDWIN) $(LIBX11)
#STDW_LIBDEPS= $(LIBSTDWIN)
#STDW_SRC= stdwinmodule.c
#STDW_OBJ= stdwinmodule.o
# Amoeba Option
# =============
#
# If you have the Amoeba 4.0 distribution (Beta or otherwise) you can
# configure Python to incorporate the built-in module 'amoeba'.
# (Python can also be built for native Amoeba, but it requires more
# work and thought. Contact the author.)
#
# Uncomment and edit the following block to use the Amoeba option.
# - Edit the AMOEBADIR defition to reflect the top of the Amoeba source
# tree.
# - Edit the AM_CONF definition to reflect the machine/operating system
# configuration needed by Amoeba (this is the name of a subdirectory
# of $(AMOEBADIR)/conf/unix, e.g., vax.ultrix).
#AMOEBADIR= /usr/amoeba
#AM_CONF= mipseb.irix
#LIBAMUNIX= $(AMOEBADIR)/conf/unix/$(AM_CONF)/lib/amunix/libamunix.a
#AM_INCL= -I$(AMOEBADIR)/src/h
#AM_USE = -DUSE_AMOEBA
#AM_LIBDEPS= $(LIBAMUNIX)
#AM_LIBS= $(LIBAMUNIX)
#AM_SRC = amoebamodule.c sc_interpr.c sc_errors.c
#AM_OBJ = amoebamodule.o sc_interpr.o sc_errors.o
# Silicon Graphics IRIS Options
# =============================
#
# The following three options are only relevant if you are using a
# Silicon Graphics IRIS machine. These have been tested with IRIX 3.3.1
# on a 4D/25.
# GL Option
# =========
#
# This option incorporates the built-in module 'gl', which provides a
# complete interface to the Silicon Graphics GL library. It adds
# about 70K to the Python text size and about 260K to the unstripped
# binary size.
#
# NOTE WHEN BUILDING FOR THE FIRST TIME:
# There is a circular dependency in the build process: you need to have
# a working Python interpreter before you can build a Python interpreter
# that incorporates the 'gl' module -- the source file 'glmodule.c' is
# not distributed (it's about 140K!) and a Python script is used to
# create it. Thus, you first have to build python without the the GL
# and Panel options, then edit the Makefile to turn them (or at least GL)
# on and rebuild. You may also have to set PYTHONPATH to point to
# the place where the module library is for the generation script to
# work.
#
# Uncomment the following block to use the GL option.
#GL_USE = -DUSE_GL
#GL_LIBDEPS=
#GL_LIBS= -lgl_s
#GL_SRC = glmodule.c cgensupport.c
#GL_OBJ = glmodule.o cgensupport.o
# Panel Option
# ============
#
# If you have source to the NASA Ames Panel Library, you can configure
# Python to incorporate the built-in module 'pnl', which is used byu
# the standard module 'panel' to provide an interface to most features
# of the Panel Library. This option requires that you also turn on the
# GL option. It adds about 100K to the Python text size and about 160K
# to the unstripped binary size. This requires Panel Library version 9.7
# (for lower versions you may have to remove some functionality -- send
# me the patches if you bothered to do this).
#
# Uncomment and edit the following block to use the Panel option.
# - Edit the PANELDIR definition to point to the top-level directory
# of the Panel distribution tree.
#PANELDIR= /usr/people/guido/src/pl
#PANELLIBDIR= $(PANELDIR)/library
#LIBPANEL= $(PANELLIBDIR)/lib/libpanel.a
#PANEL_USE= -DUSE_PANEL
#PANEL_INCL= -I$(PANELLIBDIR)/include
#PANEL_LIBDEPS= $(LIBPANEL)
#PANEL_LIBS= $(LIBPANEL)
#PANEL_SRC= panelmodule.c
#PANEL_OBJ= panelmodule.o
# Audio Option
# ============
#
# This option lets you play with /dev/audio on the IRIS 4D/25.
# It incorporates the built-in module 'audio'.
# Warning: using the asynchronous I/O facilities of this module can
# create a second 'thread', which looks in the listings of 'ps' like a
# forked child. However, it shares its address space with the parent.
#
# Uncomment the following block to use the Audio option.
#AUDIO_USE= -DUSE_AUDIO
#AUDIO_SRC= audiomodule.c asa.c
#AUDIO_OBJ= audiomodule.o asa.o
# Major Definitions
# =================
STANDARD_OBJ= acceler.o bltinmodule.o ceval.o classobject.o \
compile.o dictobject.o errors.o fgetsintr.o \
fileobject.o floatobject.o $(FMOD_OBJ) frameobject.o \
funcobject.o $(GETCWD_OBJ) \
graminit.o grammar1.o import.o \
intobject.o intrcheck.o listnode.o listobject.o \
mathmodule.o methodobject.o modsupport.o \
moduleobject.o node.o object.o parser.o \
parsetok.o posixmodule.o regexp.o regexpmodule.o \
strdup.o $(STRERROR_OBJ) \
stringobject.o $(STRTOL_OBJ) structmember.o \
sysmodule.o timemodule.o tokenizer.o traceback.o \
tupleobject.o typeobject.o
STANDARD_SRC= acceler.c bltinmodule.c ceval.c classobject.c \
compile.c dictobject.c errors.c fgetsintr.c \
fileobject.c floatobject.c $(FMOD_SRC) frameobject.c \
funcobject.c $(GETCWD_SRC) \
graminit.c grammar1.c import.c \
intobject.c intrcheck.c listnode.c listobject.c \
mathmodule.c methodobject.c modsupport.c \
moduleobject.c node.c object.c parser.c \
parsetok.c posixmodule.c regexp.c regexpmodule.c \
strdup.c $(STRERROR_SRC) \
stringobject.c $(STRTOL_SRC) structmember.c \
sysmodule.c timemodule.c tokenizer.c traceback.c \
tupleobject.c typeobject.c
CONFIGDEFS= $(STDW_USE) $(AM_USE) $(AUDIO_USE) $(GL_USE) $(PANEL_USE) \
'-DPYTHONPATH="$(DEFPYTHONPATH)"'
CONFIGINCLS= $(STDW_INCL)
LIBDEPS= libpython.a $(STDW_LIBDEPS) $(AM_LIBDEPS) \
$(GL_LIBDEPS) $(PANEL_LIBSDEP) $(RL_LIBDEPS)
# NB: the ordering of items in LIBS is significant!
LIBS= libpython.a $(STDW_LIBS) $(AM_LIBS) \
$(PANEL_LIBS) $(GL_LIBS) $(RL_LIBS) -lm
LIBOBJECTS= $(STANDARD_OBJ) $(STDW_OBJ) $(AM_OBJ) $(AUDIO_OBJ) \
$(GL_OBJ) $(PANEL_OBJ)
LIBSOURCES= $(STANDARD_SRC) $(STDW_SRC) $(AM_SRC) $(AUDIO_SRC) \
$(GL_SRC) $(PANEL_SRC)
OBJECTS= pythonmain.o config.o
SOURCES= $(LIBSOURCES) pythonmain.c config.c
GENOBJECTS= acceler.o fgetsintr.o grammar1.o \
intrcheck.o listnode.o node.o parser.o \
parsetok.o strdup.o tokenizer.o bitset.o \
firstsets.o grammar.o metagrammar.o pgen.o \
pgenmain.o printgrammar.o
GENSOURCES= acceler.c fgetsintr.c grammar1.c \
intrcheck.c listnode.c node.c parser.c \
parsetok.c strdup.c tokenizer.c bitset.c \
firstsets.c grammar.c metagrammar.c pgen.c \
pgenmain.c printgrammar.c
# patched by Arslaan Pathan 2026-01-21
# use -std=c89 so it compiles with modern cc/gcc
CFLAGS="-std=c89"
# Main Targets
# ============
python: libpython.a $(OBJECTS) $(LIBDEPS) Makefile
$(CC) $(CFLAGS) $(OBJECTS) $(LIBS) -o python
libpython.a: $(LIBOBJECTS)
-rm -f @lib
ar cr @lib $(LIBOBJECTS)
$(RANLIB) @lib
mv @lib libpython.a
python_gen: $(GENOBJECTS) $(RL_LIBDEPS)
$(CC) $(CFLAGS) $(GENOBJECTS) $(RL_LIBS) -o python_gen
# Utility Targets
# ===============
# Don't take the output from lint too seriously. I have not attempted
# to make Python lint-free. But I use function prototypes.
LINTFLAGS= -h
LINTCPPFLAGS= $(CONFIGDEFS) $(CONFIGINCLS) $(SYSVDEF) \
$(AM_INCL) $(PANEL_INCL)
LINT= lint
lint:: $(SOURCES)
$(LINT) $(LINTFLAGS) $(LINTCPPFLAGS) $(SOURCES)
lint:: $(GENSOURCES)
$(LINT) $(LINTFLAGS) $(GENSOURCES)
# Generating dependencies is only necessary if you intend to hack Python.
# You may change $(MKDEP) to your favorite dependency generator (it should
# edit the Makefile in place).
MKDEP= mkdep
depend::
$(MKDEP) $(LINTCPPFLAGS) $(SOURCES) $(GENSOURCES)
# You may change $(CTAGS) to suit your taste...
CTAGS= ctags -t -w
HEADERS= *.h
tags: $(SOURCES) $(GENSOURCES) $(HEADERS)
$(CTAGS) $(SOURCES) $(GENSOURCES) $(HEADERS)
clean::
-rm -f *.o core [,#@]*
clobber:: clean
-rm -f python python_gen libpython.a tags
# Build Special Objects
# =====================
# You may change $(COMPILE) to reflect the default .c.o rule...
COMPILE= $(CC) -c $(CFLAGS)
amoebamodule.o: amoebamodule.c
$(COMPILE) $(AM_INCL) $*.c
config.o: config.c Makefile
$(COMPILE) $(CONFIGDEFS) $(CONFIGINCLS) $*.c
fgetsintr.o: fgetsintr.c
$(COMPILE) $(SIGTYPEDEF) $*.c
intrcheck.o: intrcheck.c
$(COMPILE) $(SIGTYPEDEF) $*.c
panelmodule.o: panelmodule.c
$(COMPILE) $(PANEL_INCL) $*.c
posixmodule.o: posixmodule.c
$(COMPILE) $(SYSVDEF) $(NOSYMLINKDEF) $*.c
sc_interpr.o: sc_interpr.c
$(COMPILE) $(AM_INCL) $*.c
sc_error.o: sc_error.c
$(COMPILE) $(AM_INCL) $*.c
stdwinmodule.o: stdwinmodule.c
$(COMPILE) $(STDW_INCL) $*.c
timemodule.o: timemodule.c
$(COMPILE) $(SIGTYPEDEF) $(BSDTIMEDEF) $*.c
tokenizer.o: tokenizer.c
$(COMPILE) $(RL_USE) $*.c
.PRECIOUS: python libpython.a glmodule.c graminit.c graminit.h
# Generated Sources
# =================
#
# Some source files are (or may be) generated.
# The rules for doing so are given here.
# Build "glmodule.c", the GL interface.
# See important note at "GL Option" above.
# You may have to set and export PYTHONPATH for this to work.
# Ignore the messages emitted by the cgen script as long as its exit
# status is zero.
# Also ignore the warnings emitted while compiling glmodule.c; it works.
glmodule.c: cstubs cgen
python cgen <cstubs >@glmodule.c
mv @glmodule.c glmodule.c
# The dependencies for graminit.[ch] are not turned on in the
# distributed Makefile because the files themselves are distributed.
# Turn them on if you want to hack the grammar.
#graminit.c graminit.h: Grammar python_gen
# python_gen Grammar
# ALL CODE PAST HERE IS NOT WRITTEN NOR ENDORSED
# BY THE PYTHON SOFTWARE FOUNDATION,
# THE STICHTING MATHEMATISCH CENTRUM,
# THE CWI,
# OR ANY OF IT'S/THEIR SUBSIDIARIES
# make install target added by Arslaan Pathan
# 2026-01-21
# installs into /opt/python091 by default
# INSTALL_DIR is defined above, next to DEFPYTHONPATH
install: python
install -d $(INSTALL_DIR)
install -d $(INSTALL_DIR)/bin
install -d $(INSTALL_DIR)/lib
install -m 755 python $(INSTALL_DIR)/bin/py091
install -m 644 ../lib/* $(INSTALL_DIR)/lib
@echo
@echo "----- Python 0.9.1 (patched, QoL improvements) -----"
@echo "----- by Arslaan Pathan -----"
@echo "Installed python 0.9.1 to $(INSTALL_DIR)"
@echo "Note: you may need to add $(INSTALL_DIR)/bin to your PATH"
@echo "Run the py091 command to get started!"
|