blob: 296200b6e0827b8b152a28caac2a07a5665e46b6 [file] [log] [blame]
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +00001#####################==================----------------
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00002#
3# Top-Level Makefile for Building Python 2.3 for OS/2 using GCC/EMX
4# Originally written by Andrew Zabolotny, <bit@eltech.ru> for Python 1.5.2
5# Modified by Andrew MacIntyre, <andymac@pcug.org.au> for Python 2.3
6#
7# This makefile was developed for use with [P]GCC/EMX compiler any
8# version and GNU Make.
9#
10# The output of the build is a largish Python23.DLL containing the
11# essential modules of Python and a small Python.exe program to start
12# the interpreter. When embedding Python within another program, only
13# Python23.DLL is needed. We also build python_s.a static library (which
14# can be converted into OMF (.lib) format using emxomf tool) and both
15# python.a and python.lib import libraries. Then the optional
16# extension modules, which are OS/2 DLLs renamed with a PYD file extension.
17#
18# Recommended build order:
19# make depend (if you have makedep)
20# make all
21# make lx (if you have lxlite)
22# make test (optional)
23#
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +000024#####################==================----------------
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000025
26# === Compilation mode: debug or release ===
27MODE= optimize
28#MODE= debug
29# === Assert() enabled ===
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000030ASSERTIONS=no
31#ASSERTIONS=yes
32# === Hard-wire installation location ===
33FIXED_PYHOME=no
34#FIXED_PYHOME=yes
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000035
36# === Optional modules ===
37# Do you have the InfoZip compression library installed?
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000038HAVE_ZLIB= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000039# Do you have the Ultra Fast Crypt (UFC) library installed?
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000040HAVE_UFC= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000041# Do you have the Tcl/Tk library installed?
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000042HAVE_TCLTK= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000043# Do you have the GNU multiprecision library installed?
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000044HAVE_GMPZ= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000045# Do you have the GNU readline library installed?
46# NOTE: I'm using a modified version of Kai Uwe Rommel's port that
47# - is compiled with multithreading enabled
48# - is linked statically
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000049# I have had no success trying to use a DLL version, even when
50# compiled with multithreading enabled.
51HAVE_GREADLINE= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000052# Do you have the BSD DB library (v1.85) as included in the EMXBSD package?
53# NOTE: this library needs to be recompiled with a structure member
54# renamed to avoid problems with the multithreaded errno support
55# (there is a structure member called errno, used for shadowing the
56# real errno, which conflicts with the errno redefinition of -Zmt)
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000057HAVE_BSDDB= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000058# Do you have the ncurses library installed? EMX's BSD curses aren't enough!
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000059HAVE_NCURSES= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000060# Do you have the GDBM library installed?
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000061HAVE_GDBM= no
Andrew MacIntyre978697b2002-12-31 11:18:08 +000062# Do you have the BZ2 compression library installed?
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000063HAVE_BZ2= no
64
65# === install locations ===
66# default value of PYTHONHOME
67LIB_DIR=C:/Python23
68# default is to have everything in or under PYTHONHOME
69EXE_DIR=$(LIB_DIR)
70DLL_DIR=$(EXE_DIR)
71
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000072
73# === The Tools ===
74CC= gcc
75CFLAGS= -Zmt -Wall $(INCLUDE)
76CFLAGS.LIB= $(CFLAGS)
77LD= gcc
78LDFLAGS= -Zmt -Zcrtdll -L. -lgcc
79LDFLAGS.EXE= $(LDFLAGS)
80LDFLAGS.DLL= $(LDFLAGS) -Zdll
81LDFLAGS.A= $(LDFLAGS) $(LIBS)
82ARFLAGS= crs
83IMPLIB= emximp
84EXPLIB= emxexp
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +000085EXEOPT= emxbind
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +000086PY_DEF= -DPy_BUILD_CORE
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +000087
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000088
89# adjust C compiler settings based on build options
90ifeq ($(MODE),debug)
91 CFLAGS+= -g -O
92 LDFLAGS+= -g
93else
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +000094 CFLAGS+= -s -O2 -fomit-frame-pointer
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000095 LDFLAGS+= -s
96endif
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +000097CFLAGS+= $(PY_DEF)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000098ifeq ($(ASSERTIONS),no)
99 CFLAGS+= -DNDEBUG
100endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000101ifeq ($(FIXED_PYHOME),yes)
102 CFLAGS+= -DPREFIX=$(DQUOTE)$(LIB_DIR)$(DQUOTE)
103endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000104
105# We're using the OMF format since EMX's ld has a obscure bug
106# because of which it sometimes fails to build relocations
107# in .data segment that point to another .data locations
108# (except for the final linking if the .EXEs)
109OMF= yes
110
111# if fork() support is required, the main executable must be linked with ld
112EXEOMF= no
113
114# File extensions
115MODULE.EXT= .pyd
116ifeq ($(OMF),yes)
117 O= .obj
118 A= .lib
119 AR= emxomfar
120 CFLAGS+= -Zomf
121 LDFLAGS+= -Zomf
122 ifeq ($(MODE),debug)
123 ARFLAGS= -p64 crs
124 else
125 ARFLAGS= -p32 crs
126 endif
127else
128 O= .o
129 A= .a
130 AR= ar
131endif
132
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000133# EMX's default number of file handles is 40, which is sometimes insufficient
134# (the tempfile regression test tries to create 100 temporary files)
135NFILES=250
136
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000137# Source file paths
138SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules
139# Python contains the central core, containing the builtins and interpreter.
140# Parser contains Python's Internal Parser and
141# Standalone Parser Generator Program (Shares Some of Python's Modules)
142# Objects contains Python Object Types
143# Modules contains extension Modules (Built-In or as Separate DLLs)
144
145# Unix shells tend to use "$" as delimiter for variable names.
146# Test for this behaviour and set $(BUCK) variable correspondigly ...
147__TMP__:=$(shell echo $$$$)
148ifeq ($(__TMP__),$$$$)
149 BUCK= $$
150 BRO= (
151 BRC= )
152else
153 BUCK= \$$
154 BRO= \(
155 BRC= \)
156endif
157# Compute the "double quote" variable
158__TMP__:=$(shell echo "")
159ifeq ($(__TMP__),"")
160 DQUOTE= "
161else
162 DQUOTE= \"
163endif
164
165# Include paths
166#INCLUDE= -I$(subst ;, -I, $(SRCPATH))
167INCLUDE= -I. -I../../Include
168
169# Path to search for .c files
170vpath %.c .;..;$(SRCPATH)
171
172# Top of the package tree
173TOP= ../../
174
175# Directory for output files
176OUTBASE= out/
177OUT= $(OUTBASE)$(MODE)/
178
179# Additional libraries
180LIBS= -lsocket
181
182# Utility macro: replacement for $^
183^^= $(filter-out %$A,$^)
184# Use $(L^) to link with all libraries specified as dependencies
185L^= $(addprefix -l,$(basename $(notdir $(filter %$A,$+))))
186
187# Build rules
188$(OUT)%$O: %.c
189 $(CC) $(CFLAGS.LIB) -c $< -o $@
190
191%.a:
192 $(LD) $(LDFLAGS.A) -o $@ $(^^) $(L^)
193
194%.dll:
195 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
196
197%.pyd: $(OUT)%module$O $(OUT)%_m.def
198 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(PYTHON.IMPLIB) $(LIBS)
199
200%.exe:
201 $(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^)
202
203%_m.def:
204 @echo Creating .DEF file: $@
205 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
206 ifeq ($(DESCRIPTION.$(notdir $*)$(MODULE.EXT)),)
207 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
208 else
209 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
210 endif
211 @echo DATA MULTIPLE NONSHARED >>$@
212 @echo EXPORTS >>$@
213 @echo init$(notdir $*) >>$@
214
215%.def:
216 @echo Creating .DEF file: $@
217 @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@
218 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@
Andrew MacIntyre23ec1dc2003-06-09 08:14:03 +0000219 @echo STACKSIZE 1572864 >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000220
221# Output file names
222PYTHON_VER= 2.3
223PYTHON_LIB= python23
224PYTHON.LIB= $(PYTHON_LIB)_s$A
225PYTHON.IMPLIB= $(PYTHON_LIB)$A
226ifeq ($(EXEOMF),yes)
227 PYTHON.EXEIMP= $(PYTHON.IMPLIB)
228 LDMODE.EXE= -Zomf
229else
230 PYTHON.EXEIMP= $(PYTHON_LIB).a
231 LDMODE.EXE =
232endif
233PYTHON.DLL= $(PYTHON_LIB).dll
234PYTHON.DEF= $(PYTHON_LIB).def
235PYTHON.EXE= python.exe
236PYTHONPM.EXE= pythonpm.exe
237PGEN.EXE= pgen.exe
238LIBRARY= $(PYTHON.LIB)
239LD_LIBRARY= $(PYTHON.IMPLIB)
240
241# Additional executable parameters
242EXETYPE.$(PYTHON.EXE)= WINDOWCOMPAT
243EXETYPE.$(PYTHONPM.EXE)= WINDOWAPI
244EXETYPE.$(PGEN.EXE)= WINDOWCOMPAT
245DESCRIPTION.$(PYTHON.EXE)= Python object-oriented programming language interpreter for OS/2
246DESCRIPTION.$(PYTHONPM.EXE)= $(DESCRIPTION.$(PYTHON.EXE))
247DESCRIPTION.$(PGEN.EXE)= Python object-oriented programming language parser generator for OS/2
248
249# Module descriptions
250DESCRIPTION.zlib$(MODULE.EXT)= Python Extension DLL for accessing the InfoZip compression library
251DESCRIPTION.crypt$(MODULE.EXT)= Python Extension DLL implementing the crypt$(BRO)$(BRC) function
252DESCRIPTION._tkinter$(MODULE.EXT)= Python Extension DLL for access to Tcl/Tk Environment
253DESCRIPTION.mpz$(MODULE.EXT)= Python Extension DLL for access to GNU multi-precision library
254DESCRIPTION.readline$(MODULE.EXT)= Python Extension DLL for access to GNU ReadLine library
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000255DESCRIPTION.bsddb185$(MODULE.EXT)= Python Extension DLL for access to BSD DB (v1.85) library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000256DESCRIPTION._curses$(MODULE.EXT)= Python Extension DLL for access to ncurses library
257DESCRIPTION.pyexpat$(MODULE.EXT)= Python Extension DLL for access to expat library
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000258DESCRIPTION.bz2$(MODULE.EXT)= Python Extension DLL for accessing the bz2 compression library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000259
260# Source files
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000261SRC.OS2EMX= config.c dlfcn.c getpathp.c
262SRC.MAIN= $(addprefix $(TOP), \
263 Modules/getbuildinfo.c \
264 Modules/main.c)
265SRC.MODULES= $(addprefix $(TOP), \
266 Modules/gcmodule.c \
267 Modules/signalmodule.c \
268 Modules/posixmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000269 Modules/threadmodule.c \
270 Modules/arraymodule.c \
271 Modules/binascii.c \
272 Modules/cmathmodule.c \
273 Modules/_codecsmodule.c \
274 Modules/cPickle.c \
275 Modules/cStringIO.c \
276 Modules/_csv.c \
277 Modules/datetimemodule.c \
278 Modules/dlmodule.c \
279 Modules/errnomodule.c \
280 Modules/fcntlmodule.c \
281 Modules/imageop.c \
282 Modules/itertoolsmodule.c \
283 Modules/_localemodule.c \
284 Modules/mathmodule.c \
285 Modules/md5c.c \
286 Modules/md5module.c \
287 Modules/operator.c \
288 Modules/pcremodule.c \
289 Modules/pypcre.c \
290 Modules/_randommodule.c \
291 Modules/regexmodule.c \
292 Modules/regexpr.c \
293 Modules/rgbimgmodule.c \
294 Modules/shamodule.c \
295 Modules/_sre.c \
296 Modules/stropmodule.c \
297 Modules/structmodule.c \
298 Modules/symtablemodule.c \
299 Modules/termios.c \
300 Modules/timemodule.c \
301 Modules/timingmodule.c \
302 Modules/_weakref.c \
303 Modules/xreadlinesmodule.c \
304 Modules/xxsubtype.c \
305 Modules/zipimport.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000306SRC.PARSE1= $(addprefix $(TOP), \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000307 Parser/acceler.c \
308 Parser/grammar1.c \
309 Parser/listnode.c \
310 Parser/node.c \
311 Parser/parser.c \
312 Parser/parsetok.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000313 Parser/bitset.c \
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000314 Parser/metagrammar.c)
315SRC.PARSE2= $(addprefix $(TOP), \
316 Parser/tokenizer.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000317 Parser/myreadline.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000318SRC.PARSER= $(SRC.PARSE1) \
319 $(SRC.PARSE2)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000320SRC.PYTHON= $(addprefix $(TOP), \
321 Python/bltinmodule.c \
322 Python/exceptions.c \
323 Python/ceval.c \
324 Python/compile.c \
325 Python/codecs.c \
326 Python/errors.c \
327 Python/frozen.c \
328 Python/frozenmain.c \
329 Python/future.c \
330 Python/getargs.c \
331 Python/getcompiler.c \
332 Python/getcopyright.c \
333 Python/getmtime.c \
334 Python/getplatform.c \
335 Python/getversion.c \
336 Python/graminit.c \
337 Python/import.c \
338 Python/importdl.c \
339 Python/marshal.c \
340 Python/modsupport.c \
341 Python/mysnprintf.c \
342 Python/mystrtoul.c \
343 Python/pyfpe.c \
344 Python/pystate.c \
345 Python/pythonrun.c \
346 Python/structmember.c \
347 Python/symtable.c \
348 Python/sysmodule.c \
349 Python/traceback.c \
350 Python/getopt.c \
351 Python/dynload_shlib.c \
352 Python/thread.c)
353SRC.OBJECT= $(addprefix $(TOP), \
354 Objects/abstract.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000355 Objects/boolobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000356 Objects/bufferobject.c \
357 Objects/cellobject.c \
358 Objects/classobject.c \
359 Objects/cobject.c \
360 Objects/complexobject.c \
361 Objects/descrobject.c \
362 Objects/dictobject.c \
Andrew MacIntyre07c639f2002-04-30 13:06:32 +0000363 Objects/enumobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000364 Objects/fileobject.c \
365 Objects/floatobject.c \
366 Objects/frameobject.c \
367 Objects/funcobject.c \
368 Objects/intobject.c \
369 Objects/iterobject.c \
370 Objects/listobject.c \
371 Objects/longobject.c \
372 Objects/methodobject.c \
373 Objects/moduleobject.c \
374 Objects/object.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000375 Objects/obmalloc.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000376 Objects/rangeobject.c \
377 Objects/sliceobject.c \
378 Objects/stringobject.c \
379 Objects/structseq.c \
380 Objects/tupleobject.c \
381 Objects/typeobject.c \
382 Objects/unicodeobject.c \
383 Objects/unicodectype.c \
384 Objects/weakrefobject.c)
385
386SRC.LIB= $(SRC.OS2EMX) \
387 $(SRC.MAIN) \
388 $(SRC.PARSER) \
389 $(SRC.OBJECT) \
390 $(SRC.PYTHON) \
391 $(SRC.MODULES)
392OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
393
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000394SRC.PGEN= $(SRC.PARSE1) \
395 $(addprefix $(TOP), \
396 Objects/obmalloc.c) \
397 $(addprefix $(TOP), \
398 Python/mysnprintf.c) \
399 $(addprefix $(TOP), \
400 Parser/tokenizer_pgen.c \
401 Parser/pgenmain.c \
402 Parser/pgen.c \
403 Parser/printgrammar.c \
404 Parser/grammar.c \
405 Parser/firstsets.c) \
406
407OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
408
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000409SRC.EXE= $(TOP)Modules/python.c
410SRC.PMEXE= pythonpm.c
411
412# Python modules to be dynamically loaded that:
413# 1) have only single source file and require no extra libs
414# 2) use the standard module naming convention
415# (the 'module' in ?????module.c is assumed)
416# - these can be built with implicit rules
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000417EASYEXTMODULES= fpectl \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000418 fpetest \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000419 parser \
420 pwd \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000421 rotor \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000422 select
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000423
424# Python modules to be dynamically loaded that need explicit build rules
425# (either multiple source files and/or non-standard module naming)
426# (NOTE: use shortened names for modules affected by 8 char name limit)
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000427HARDEXTMODULES= _hotshot \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000428 _socket \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000429 _testcap \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000430 unicoded
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000431
432# Python external ($(MODULE.EXT)) modules - can be EASY or HARD
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000433ifeq ($(HAVE_ZLIB),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000434 HARDEXTMODULES+= zlib
435endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000436ifeq ($(HAVE_UFC),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000437 HARDEXTMODULES+= crypt
438endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000439ifeq ($(HAVE_TCLTK),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000440 HARDEXTMODULES+= _tkinter
441 CFLAGS+= -DHAS_DIRENT -I/TclTk80/include
442 TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80
443endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000444ifeq ($(HAVE_GMPZ),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000445 HARDEXTMODULES+= mpz
446endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000447ifeq ($(HAVE_GREADLINE),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000448 HARDEXTMODULES+= readline
449endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000450ifeq ($(HAVE_BSDDB),yes)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000451 HARDEXTMODULES+= bsddb185
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000452endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000453ifeq ($(HAVE_NCURSES),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000454 HARDEXTMODULES+= _curses _curses_
455endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000456ifeq ($(HAVE_GDBM),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000457 HARDEXTMODULES+= gdbm dbm
458endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000459ifeq ($(HAVE_BZ2),yes)
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000460 HARDEXTMODULES+= bz2
461endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000462
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000463# Expat is now distributed with the Python source
464HARDEXTMODULES+= pyexpat
465EXPAT.INC= -I../../Modules/expat
466EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \
467 -DXML_CONTENT_BYTES=1024
468EXPAT.SRC= $(addprefix ../../Modules/expat/, \
469 xmlparse.c \
470 xmlrole.c \
471 xmltok.c)
472
473# all the external modules
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000474EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES)))
475EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
476
477# Targets
478all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000479 python_noncore
480
481python_noncore:
482 make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000483
484clean:
485 rm -f $(OUT)*
486 rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
487 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT)
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000488 find ../../Lib -name "*.py[co]" -exec rm {} ";"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000489
490lx:
491 @echo Packing everything with lxLite...
492 lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
493
494depend: $(OUTBASE)
495 makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
496 -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
497
498$(OUT): $(OUTBASE)
499
500$(OUT) $(OUTBASE):
501 mkdir.exe $@
502
503$(PYTHON.LIB): $(OBJ.LIB)
504 rm.exe -f $@
505 $(AR) $(ARFLAGS) $@ $^
506
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000507# the Python core DLL .def file needs to have a number of non-static
508# symbols that aren't part of the Python C API removed (commented out)
509# from the DLL export list.
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000510$(PYTHON.DEF): $(PYTHON.LIB)
511 @echo Creating .DEF file: $@
512 @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
513 @echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
514 @echo PROTMODE >>$@
515 @echo DATA MULTIPLE NONSHARED >>$@
516 @echo EXPORTS >>$@
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000517 $(EXPLIB) -u $(PYTHON.LIB) |\
518 sed -e "/ .init.*/s/^ /; /" \
519 -e "/ .pcre_.*/s/^ /; /" \
520 -e "/ .array_methods/s/^ /; /" \
521 -e "/ .fast_save_leave/s/^ /; /" \
522 -e "/ .dlopen/s/^ /; /" \
523 -e "/ .dlsym/s/^ /; /" \
524 -e "/ .dlclose/s/^ /; /" \
525 -e "/ .dlerror/s/^ /; /" \
526 -e "/ .cycle_type/s/^ /; /" \
527 -e "/ .dropwhile_type/s/^ /; /" \
528 -e "/ .takewhile_type/s/^ /; /" \
529 -e "/ .islice_type/s/^ /; /" \
530 -e "/ .starmap_type/s/^ /; /" \
531 -e "/ .imap_type/s/^ /; /" \
532 -e "/ .chain_type/s/^ /; /" \
533 -e "/ .ifilter_type/s/^ /; /" \
534 -e "/ .ifilterfalse_type/s/^ /; /" \
535 -e "/ .count_type/s/^ /; /" \
536 -e "/ .izip_type/s/^ /; /" \
537 -e "/ .repeat_type/s/^ /; /" \
538 -e "/ ._Py_re_.*/s/^ /; /" \
539 -e "/ ._Py_MD5.*/s/^ /; /" >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000540
541$(PYTHON.IMPLIB): $(PYTHON.DEF)
542 $(IMPLIB) -o $@ $^
543
544$(PYTHON.EXEIMP): $(PYTHON.DEF)
545 $(IMPLIB) -o $@ $^
546
547$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF)
548
549# Explicit make targets for the .EXEs to be able to use LD to link
550# (so that fork() will work if required)
551
552$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
553 $(CC) -Zmt $(LDMODE.EXE) -Zcrtdll -Wall $(INCLUDE) -L. -lgcc -o $@ $(SRC.EXE) $(PYTHON.EXEIMP) $(LIBS) $(OUT)python.def
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000554 $(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000555
556$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def
557 $(CC) -Zmt $(LDMODE.EXE) -Zcrtdll -Wall $(INCLUDE) -L. -lgcc -o $@ $(SRC.PMEXE) $(PYTHON.EXEIMP) $(LIBS) $(OUT)pythonpm.def
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000558 $(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000559
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000560$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000561
562# Explicit building instructions for those external modules that require
563# awkward handling (due e.g. to non-std naming, or multiple source files)
564# - standard modules
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000565
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000566_hotshot$(MODULE.EXT): $(OUT)_hotshot$O $(OUT)_hotshot_m.def $(PYTHON.IMPLIB)
567 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
568
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000569_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
570 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
571
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000572# _testcapi needs to be renamed to be useful
573_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB)
574 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
575
576_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT)
577 cp $^ $@
578
579# unicodedata needs to be renamed to be useful
580unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB)
581 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS)
582
583unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT)
584 cp $^ $@
585
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000586# - optional modules (requiring other software to be installed)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000587bsddb185$(MODULE.EXT): $(OUT)bsddbmodule$O $(OUT)bsddb185_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000588 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -ldb $(LIBS)
589
590crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
591 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS)
592
593# The _curses_panel module requires a couple of ncurses library entry
594# points, which are best exposed as exports from the _curses module DLL
595$(OUT)_curses_m.def:
596 @echo Creating .DEF file: $@
597 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
598 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
599 @echo DATA MULTIPLE NONSHARED >>$@
600 @echo EXPORTS >>$@
601 @echo init_curses >>$@
602 @echo wnoutrefresh >>$@
603 @echo _nc_panelhook >>$@
604 @echo is_linetouched >>$@
605 @echo mvwin >>$@
606 @echo stdscr >>$@
607 @echo wtouchln >>$@
608
609$(OUT)_curses_panel_m.def:
610 @echo Creating .DEF file: $@
611 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
612 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
613 @echo DATA MULTIPLE NONSHARED >>$@
614 @echo IMPORTS >>$@
615 @echo _curses.wnoutrefresh >>$@
616 @echo _curses._nc_panelhook >>$@
617 @echo _curses.is_linetouched >>$@
618 @echo _curses.mvwin >>$@
619 @echo _curses.stdscr >>$@
620 @echo _curses.wtouchln >>$@
621 @echo EXPORTS >>$@
622 @echo init_curses_panel >>$@
623
624_curses$(MODULE.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB)
625 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses
626
627# curses_panel needs to be renamed to be useful
628_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB)
629 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel
630
631_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT)
632 cp $^ $@
633
634dbm$(MODULE.EXT): $(OUT)dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB)
635 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
636
637gdbm$(MODULE.EXT): $(OUT)gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB)
638 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
639
640mpz$(MODULE.EXT): $(OUT)mpzmodule$O $(OUT)mpz_m.def $(PYTHON.IMPLIB)
641 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgmp
642
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000643# Expat is now distributed with Python, so use the included version
644$(OUT)pyexpat$O: ../../Modules/pyexpat.c
645 $(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^
646$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c
647 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
648$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c
649 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
650$(OUT)xmltok$O: ../../Modules/expat/xmltok.c
651 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
652pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \
653 $(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB)
654 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000655
656readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
657 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses
658
659#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
660_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000661 $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000662 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
663
664zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
665 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz
666
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000667bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB)
668 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2
669
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000670# the test target
671test:
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000672 -find ../../Lib -name "*.py[co]" -exec rm {} ";"
673 -./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000674 ./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000675
676-include $(OUTBASE)python.dep