blob: 140749f8704a8e4599493e4bfc2286d62a98dfb8 [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 MacIntyre51578ae2003-12-02 12:21:20 +000094 CFLAGS+= -s -O3 -fomit-frame-pointer -mprobe
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
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000116MODLIB.EXT= .dll
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000117ifeq ($(OMF),yes)
118 O= .obj
119 A= .lib
120 AR= emxomfar
121 CFLAGS+= -Zomf
122 LDFLAGS+= -Zomf
123 ifeq ($(MODE),debug)
124 ARFLAGS= -p64 crs
125 else
126 ARFLAGS= -p32 crs
127 endif
128else
129 O= .o
130 A= .a
131 AR= ar
132endif
133
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000134# EMX's default number of file handles is 40, which is sometimes insufficient
135# (the tempfile regression test tries to create 100 temporary files)
136NFILES=250
137
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000138# Source file paths
139SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules
140# Python contains the central core, containing the builtins and interpreter.
141# Parser contains Python's Internal Parser and
142# Standalone Parser Generator Program (Shares Some of Python's Modules)
143# Objects contains Python Object Types
144# Modules contains extension Modules (Built-In or as Separate DLLs)
145
146# Unix shells tend to use "$" as delimiter for variable names.
147# Test for this behaviour and set $(BUCK) variable correspondigly ...
148__TMP__:=$(shell echo $$$$)
149ifeq ($(__TMP__),$$$$)
150 BUCK= $$
151 BRO= (
152 BRC= )
153else
154 BUCK= \$$
155 BRO= \(
156 BRC= \)
157endif
158# Compute the "double quote" variable
159__TMP__:=$(shell echo "")
160ifeq ($(__TMP__),"")
161 DQUOTE= "
162else
163 DQUOTE= \"
164endif
165
166# Include paths
167#INCLUDE= -I$(subst ;, -I, $(SRCPATH))
168INCLUDE= -I. -I../../Include
169
170# Path to search for .c files
171vpath %.c .;..;$(SRCPATH)
172
173# Top of the package tree
174TOP= ../../
175
176# Directory for output files
177OUTBASE= out/
178OUT= $(OUTBASE)$(MODE)/
179
180# Additional libraries
181LIBS= -lsocket
182
183# Utility macro: replacement for $^
184^^= $(filter-out %$A,$^)
185# Use $(L^) to link with all libraries specified as dependencies
186L^= $(addprefix -l,$(basename $(notdir $(filter %$A,$+))))
187
188# Build rules
189$(OUT)%$O: %.c
190 $(CC) $(CFLAGS.LIB) -c $< -o $@
191
192%.a:
193 $(LD) $(LDFLAGS.A) -o $@ $(^^) $(L^)
194
195%.dll:
196 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
197
198%.pyd: $(OUT)%module$O $(OUT)%_m.def
199 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(PYTHON.IMPLIB) $(LIBS)
200
201%.exe:
202 $(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^)
203
204%_m.def:
205 @echo Creating .DEF file: $@
206 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
207 ifeq ($(DESCRIPTION.$(notdir $*)$(MODULE.EXT)),)
208 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
209 else
210 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
211 endif
212 @echo DATA MULTIPLE NONSHARED >>$@
213 @echo EXPORTS >>$@
214 @echo init$(notdir $*) >>$@
215
216%.def:
217 @echo Creating .DEF file: $@
218 @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@
219 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@
Andrew MacIntyre23ec1dc2003-06-09 08:14:03 +0000220 @echo STACKSIZE 1572864 >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000221
222# Output file names
223PYTHON_VER= 2.3
224PYTHON_LIB= python23
225PYTHON.LIB= $(PYTHON_LIB)_s$A
226PYTHON.IMPLIB= $(PYTHON_LIB)$A
227ifeq ($(EXEOMF),yes)
228 PYTHON.EXEIMP= $(PYTHON.IMPLIB)
229 LDMODE.EXE= -Zomf
230else
231 PYTHON.EXEIMP= $(PYTHON_LIB).a
232 LDMODE.EXE =
233endif
234PYTHON.DLL= $(PYTHON_LIB).dll
235PYTHON.DEF= $(PYTHON_LIB).def
236PYTHON.EXE= python.exe
237PYTHONPM.EXE= pythonpm.exe
238PGEN.EXE= pgen.exe
239LIBRARY= $(PYTHON.LIB)
240LD_LIBRARY= $(PYTHON.IMPLIB)
241
242# Additional executable parameters
243EXETYPE.$(PYTHON.EXE)= WINDOWCOMPAT
244EXETYPE.$(PYTHONPM.EXE)= WINDOWAPI
245EXETYPE.$(PGEN.EXE)= WINDOWCOMPAT
246DESCRIPTION.$(PYTHON.EXE)= Python object-oriented programming language interpreter for OS/2
247DESCRIPTION.$(PYTHONPM.EXE)= $(DESCRIPTION.$(PYTHON.EXE))
248DESCRIPTION.$(PGEN.EXE)= Python object-oriented programming language parser generator for OS/2
249
250# Module descriptions
251DESCRIPTION.zlib$(MODULE.EXT)= Python Extension DLL for accessing the InfoZip compression library
252DESCRIPTION.crypt$(MODULE.EXT)= Python Extension DLL implementing the crypt$(BRO)$(BRC) function
253DESCRIPTION._tkinter$(MODULE.EXT)= Python Extension DLL for access to Tcl/Tk Environment
254DESCRIPTION.mpz$(MODULE.EXT)= Python Extension DLL for access to GNU multi-precision library
255DESCRIPTION.readline$(MODULE.EXT)= Python Extension DLL for access to GNU ReadLine library
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000256DESCRIPTION.bsddb185$(MODULE.EXT)= Python Extension DLL for access to BSD DB (v1.85) library
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000257DESCRIPTION._curses$(MODLIB.EXT)= Python Extension DLL for access to ncurses library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000258DESCRIPTION.pyexpat$(MODULE.EXT)= Python Extension DLL for access to expat library
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000259DESCRIPTION.bz2$(MODULE.EXT)= Python Extension DLL for accessing the bz2 compression library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000260
261# Source files
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000262SRC.OS2EMX= config.c dlfcn.c getpathp.c
263SRC.MAIN= $(addprefix $(TOP), \
264 Modules/getbuildinfo.c \
265 Modules/main.c)
266SRC.MODULES= $(addprefix $(TOP), \
267 Modules/gcmodule.c \
268 Modules/signalmodule.c \
269 Modules/posixmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000270 Modules/threadmodule.c \
271 Modules/arraymodule.c \
272 Modules/binascii.c \
273 Modules/cmathmodule.c \
274 Modules/_codecsmodule.c \
275 Modules/cPickle.c \
276 Modules/cStringIO.c \
277 Modules/_csv.c \
278 Modules/datetimemodule.c \
279 Modules/dlmodule.c \
280 Modules/errnomodule.c \
281 Modules/fcntlmodule.c \
282 Modules/imageop.c \
283 Modules/itertoolsmodule.c \
284 Modules/_localemodule.c \
285 Modules/mathmodule.c \
286 Modules/md5c.c \
287 Modules/md5module.c \
288 Modules/operator.c \
289 Modules/pcremodule.c \
290 Modules/pypcre.c \
291 Modules/_randommodule.c \
292 Modules/regexmodule.c \
293 Modules/regexpr.c \
294 Modules/rgbimgmodule.c \
295 Modules/shamodule.c \
296 Modules/_sre.c \
297 Modules/stropmodule.c \
298 Modules/structmodule.c \
299 Modules/symtablemodule.c \
300 Modules/termios.c \
301 Modules/timemodule.c \
302 Modules/timingmodule.c \
303 Modules/_weakref.c \
304 Modules/xreadlinesmodule.c \
305 Modules/xxsubtype.c \
306 Modules/zipimport.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000307SRC.PARSE1= $(addprefix $(TOP), \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000308 Parser/acceler.c \
309 Parser/grammar1.c \
310 Parser/listnode.c \
311 Parser/node.c \
312 Parser/parser.c \
313 Parser/parsetok.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000314 Parser/bitset.c \
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000315 Parser/metagrammar.c)
316SRC.PARSE2= $(addprefix $(TOP), \
317 Parser/tokenizer.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000318 Parser/myreadline.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000319SRC.PARSER= $(SRC.PARSE1) \
320 $(SRC.PARSE2)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000321SRC.PYTHON= $(addprefix $(TOP), \
322 Python/bltinmodule.c \
323 Python/exceptions.c \
324 Python/ceval.c \
325 Python/compile.c \
326 Python/codecs.c \
327 Python/errors.c \
328 Python/frozen.c \
329 Python/frozenmain.c \
330 Python/future.c \
331 Python/getargs.c \
332 Python/getcompiler.c \
333 Python/getcopyright.c \
334 Python/getmtime.c \
335 Python/getplatform.c \
336 Python/getversion.c \
337 Python/graminit.c \
338 Python/import.c \
339 Python/importdl.c \
340 Python/marshal.c \
341 Python/modsupport.c \
342 Python/mysnprintf.c \
343 Python/mystrtoul.c \
344 Python/pyfpe.c \
345 Python/pystate.c \
346 Python/pythonrun.c \
347 Python/structmember.c \
348 Python/symtable.c \
349 Python/sysmodule.c \
350 Python/traceback.c \
351 Python/getopt.c \
352 Python/dynload_shlib.c \
353 Python/thread.c)
354SRC.OBJECT= $(addprefix $(TOP), \
355 Objects/abstract.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000356 Objects/boolobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000357 Objects/bufferobject.c \
358 Objects/cellobject.c \
359 Objects/classobject.c \
360 Objects/cobject.c \
361 Objects/complexobject.c \
362 Objects/descrobject.c \
363 Objects/dictobject.c \
Andrew MacIntyre07c639f2002-04-30 13:06:32 +0000364 Objects/enumobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000365 Objects/fileobject.c \
366 Objects/floatobject.c \
367 Objects/frameobject.c \
368 Objects/funcobject.c \
369 Objects/intobject.c \
370 Objects/iterobject.c \
371 Objects/listobject.c \
372 Objects/longobject.c \
373 Objects/methodobject.c \
374 Objects/moduleobject.c \
375 Objects/object.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000376 Objects/obmalloc.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000377 Objects/rangeobject.c \
378 Objects/sliceobject.c \
379 Objects/stringobject.c \
380 Objects/structseq.c \
381 Objects/tupleobject.c \
382 Objects/typeobject.c \
383 Objects/unicodeobject.c \
384 Objects/unicodectype.c \
385 Objects/weakrefobject.c)
386
387SRC.LIB= $(SRC.OS2EMX) \
388 $(SRC.MAIN) \
389 $(SRC.PARSER) \
390 $(SRC.OBJECT) \
391 $(SRC.PYTHON) \
392 $(SRC.MODULES)
393OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
394
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000395SRC.PGEN= $(SRC.PARSE1) \
396 $(addprefix $(TOP), \
397 Objects/obmalloc.c) \
398 $(addprefix $(TOP), \
399 Python/mysnprintf.c) \
400 $(addprefix $(TOP), \
401 Parser/tokenizer_pgen.c \
402 Parser/pgenmain.c \
403 Parser/pgen.c \
404 Parser/printgrammar.c \
405 Parser/grammar.c \
406 Parser/firstsets.c) \
407
408OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
409
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000410SRC.EXE= $(TOP)Modules/python.c
411SRC.PMEXE= pythonpm.c
412
413# Python modules to be dynamically loaded that:
414# 1) have only single source file and require no extra libs
415# 2) use the standard module naming convention
416# (the 'module' in ?????module.c is assumed)
417# - these can be built with implicit rules
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000418EASYEXTMODULES= fpectl \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000419 fpetest \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000420 parser \
421 pwd \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000422 rotor \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000423 select
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000424
425# Python modules to be dynamically loaded that need explicit build rules
426# (either multiple source files and/or non-standard module naming)
427# (NOTE: use shortened names for modules affected by 8 char name limit)
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000428HARDEXTMODULES= _hotshot \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000429 _socket \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000430 _testcap \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000431 unicoded
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000432
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000433# Python modules that are used as libraries and therefore must use
434# a .DLL extension
435LIBEXTMODULES=
436
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000437# Python external ($(MODULE.EXT)) modules - can be EASY or HARD
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000438ifeq ($(HAVE_ZLIB),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000439 HARDEXTMODULES+= zlib
440endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000441ifeq ($(HAVE_UFC),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000442 HARDEXTMODULES+= crypt
443endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000444ifeq ($(HAVE_TCLTK),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000445 HARDEXTMODULES+= _tkinter
446 CFLAGS+= -DHAS_DIRENT -I/TclTk80/include
447 TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80
448endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000449ifeq ($(HAVE_GMPZ),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000450 HARDEXTMODULES+= mpz
451endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000452ifeq ($(HAVE_GREADLINE),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000453 HARDEXTMODULES+= readline
454endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000455ifeq ($(HAVE_BSDDB),yes)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000456 HARDEXTMODULES+= bsddb185
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000457endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000458ifeq ($(HAVE_NCURSES),yes)
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000459 LIBEXTMODULES+= _curses
460 HARDEXTMODULES+= _curses_
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000461endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000462ifeq ($(HAVE_GDBM),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000463 HARDEXTMODULES+= gdbm dbm
464endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000465ifeq ($(HAVE_BZ2),yes)
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000466 HARDEXTMODULES+= bz2
467endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000468
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000469# Expat is now distributed with the Python source
470HARDEXTMODULES+= pyexpat
471EXPAT.INC= -I../../Modules/expat
472EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \
Andrew MacIntyre4d046392003-12-25 13:25:20 +0000473 -DXML_CONTENT_BYTES=1024 -DHAVE_MEMMOVE=1 -DHAVE_BCOPY=1
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000474EXPAT.SRC= $(addprefix ../../Modules/expat/, \
475 xmlparse.c \
476 xmlrole.c \
477 xmltok.c)
478
479# all the external modules
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000480EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES)))
481EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000482EXTERNDLLS+= $(addsuffix $(MODLIB.EXT),$(patsubst %module,%,$(LIBEXTMODULES)))
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000483
484# Targets
485all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000486 python_noncore
487
488python_noncore:
489 make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000490
491clean:
492 rm -f $(OUT)*
493 rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
494 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT)
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000495 find ../../Lib -name "*.py[co]" -exec rm {} ";"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000496
497lx:
498 @echo Packing everything with lxLite...
499 lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
500
501depend: $(OUTBASE)
502 makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
503 -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
504
505$(OUT): $(OUTBASE)
506
507$(OUT) $(OUTBASE):
508 mkdir.exe $@
509
510$(PYTHON.LIB): $(OBJ.LIB)
511 rm.exe -f $@
512 $(AR) $(ARFLAGS) $@ $^
513
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000514# the Python core DLL .def file needs to have a number of non-static
515# symbols that aren't part of the Python C API removed (commented out)
516# from the DLL export list.
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000517$(PYTHON.DEF): $(PYTHON.LIB)
518 @echo Creating .DEF file: $@
519 @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
520 @echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
521 @echo PROTMODE >>$@
522 @echo DATA MULTIPLE NONSHARED >>$@
523 @echo EXPORTS >>$@
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000524 $(EXPLIB) -u $(PYTHON.LIB) |\
Andrew MacIntyrebac1ea92003-07-16 13:31:11 +0000525 sed -e "/^ .init.*/s/^ /; /" \
526 -e "/^ .pcre_.*/s/^ /; /" \
527 -e "/^ .array_methods/s/^ /; /" \
528 -e "/^ .fast_save_leave/s/^ /; /" \
529 -e "/^ .dlopen/s/^ /; /" \
530 -e "/^ .dlsym/s/^ /; /" \
531 -e "/^ .dlclose/s/^ /; /" \
532 -e "/^ .dlerror/s/^ /; /" \
533 -e "/^ ._Py_re_.*/s/^ /; /" \
534 -e "/^ ._Py_MD5.*/s/^ /; /" >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000535
536$(PYTHON.IMPLIB): $(PYTHON.DEF)
537 $(IMPLIB) -o $@ $^
538
539$(PYTHON.EXEIMP): $(PYTHON.DEF)
540 $(IMPLIB) -o $@ $^
541
542$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF)
543
544# Explicit make targets for the .EXEs to be able to use LD to link
545# (so that fork() will work if required)
546
547$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
548 $(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 +0000549 $(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000550
551$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def
552 $(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 +0000553 $(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000554
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000555$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000556
557# Explicit building instructions for those external modules that require
558# awkward handling (due e.g. to non-std naming, or multiple source files)
559# - standard modules
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000560
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000561_hotshot$(MODULE.EXT): $(OUT)_hotshot$O $(OUT)_hotshot_m.def $(PYTHON.IMPLIB)
562 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
563
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000564_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
565 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
566
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000567# _testcapi needs to be renamed to be useful
568_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB)
569 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
570
571_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT)
572 cp $^ $@
573
574# unicodedata needs to be renamed to be useful
575unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB)
576 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS)
577
578unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT)
579 cp $^ $@
580
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000581# - optional modules (requiring other software to be installed)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000582bsddb185$(MODULE.EXT): $(OUT)bsddbmodule$O $(OUT)bsddb185_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000583 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -ldb $(LIBS)
584
585crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
586 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS)
587
588# The _curses_panel module requires a couple of ncurses library entry
589# points, which are best exposed as exports from the _curses module DLL
590$(OUT)_curses_m.def:
591 @echo Creating .DEF file: $@
592 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000593 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODLIB.EXT))$(DQUOTE) >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000594 @echo DATA MULTIPLE NONSHARED >>$@
595 @echo EXPORTS >>$@
596 @echo init_curses >>$@
597 @echo wnoutrefresh >>$@
598 @echo _nc_panelhook >>$@
599 @echo is_linetouched >>$@
600 @echo mvwin >>$@
601 @echo stdscr >>$@
602 @echo wtouchln >>$@
603
604$(OUT)_curses_panel_m.def:
605 @echo Creating .DEF file: $@
606 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
607 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
608 @echo DATA MULTIPLE NONSHARED >>$@
609 @echo IMPORTS >>$@
610 @echo _curses.wnoutrefresh >>$@
611 @echo _curses._nc_panelhook >>$@
612 @echo _curses.is_linetouched >>$@
613 @echo _curses.mvwin >>$@
614 @echo _curses.stdscr >>$@
615 @echo _curses.wtouchln >>$@
616 @echo EXPORTS >>$@
617 @echo init_curses_panel >>$@
618
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000619_curses$(MODLIB.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000620 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses
621
622# curses_panel needs to be renamed to be useful
623_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB)
624 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel
625
626_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT)
627 cp $^ $@
628
629dbm$(MODULE.EXT): $(OUT)dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB)
630 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
631
632gdbm$(MODULE.EXT): $(OUT)gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB)
633 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
634
635mpz$(MODULE.EXT): $(OUT)mpzmodule$O $(OUT)mpz_m.def $(PYTHON.IMPLIB)
636 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgmp
637
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000638# Expat is now distributed with Python, so use the included version
639$(OUT)pyexpat$O: ../../Modules/pyexpat.c
640 $(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^
641$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c
642 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
643$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c
644 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
645$(OUT)xmltok$O: ../../Modules/expat/xmltok.c
646 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
647pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \
648 $(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB)
649 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000650
651readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
652 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses
653
654#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
655_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000656 $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000657 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
658
659zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
660 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz
661
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000662bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB)
663 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2
664
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000665# the test target
666test:
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000667 -find ../../Lib -name "*.py[co]" -exec rm {} ";"
668 -./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000669 ./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000670
671-include $(OUTBASE)python.dep