blob: 265ff0bcc560e6da49404e36975ee4de4685a324 [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
86
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000087
88# adjust C compiler settings based on build options
89ifeq ($(MODE),debug)
90 CFLAGS+= -g -O
91 LDFLAGS+= -g
92else
93 CFLAGS+= -s -O2
94 LDFLAGS+= -s
95endif
96ifeq ($(ASSERTIONS),no)
97 CFLAGS+= -DNDEBUG
98endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000099ifeq ($(FIXED_PYHOME),yes)
100 CFLAGS+= -DPREFIX=$(DQUOTE)$(LIB_DIR)$(DQUOTE)
101endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000102
103# We're using the OMF format since EMX's ld has a obscure bug
104# because of which it sometimes fails to build relocations
105# in .data segment that point to another .data locations
106# (except for the final linking if the .EXEs)
107OMF= yes
108
109# if fork() support is required, the main executable must be linked with ld
110EXEOMF= no
111
112# File extensions
113MODULE.EXT= .pyd
114ifeq ($(OMF),yes)
115 O= .obj
116 A= .lib
117 AR= emxomfar
118 CFLAGS+= -Zomf
119 LDFLAGS+= -Zomf
120 ifeq ($(MODE),debug)
121 ARFLAGS= -p64 crs
122 else
123 ARFLAGS= -p32 crs
124 endif
125else
126 O= .o
127 A= .a
128 AR= ar
129endif
130
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000131# EMX's default number of file handles is 40, which is sometimes insufficient
132# (the tempfile regression test tries to create 100 temporary files)
133NFILES=250
134
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000135# Source file paths
136SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules
137# Python contains the central core, containing the builtins and interpreter.
138# Parser contains Python's Internal Parser and
139# Standalone Parser Generator Program (Shares Some of Python's Modules)
140# Objects contains Python Object Types
141# Modules contains extension Modules (Built-In or as Separate DLLs)
142
143# Unix shells tend to use "$" as delimiter for variable names.
144# Test for this behaviour and set $(BUCK) variable correspondigly ...
145__TMP__:=$(shell echo $$$$)
146ifeq ($(__TMP__),$$$$)
147 BUCK= $$
148 BRO= (
149 BRC= )
150else
151 BUCK= \$$
152 BRO= \(
153 BRC= \)
154endif
155# Compute the "double quote" variable
156__TMP__:=$(shell echo "")
157ifeq ($(__TMP__),"")
158 DQUOTE= "
159else
160 DQUOTE= \"
161endif
162
163# Include paths
164#INCLUDE= -I$(subst ;, -I, $(SRCPATH))
165INCLUDE= -I. -I../../Include
166
167# Path to search for .c files
168vpath %.c .;..;$(SRCPATH)
169
170# Top of the package tree
171TOP= ../../
172
173# Directory for output files
174OUTBASE= out/
175OUT= $(OUTBASE)$(MODE)/
176
177# Additional libraries
178LIBS= -lsocket
179
180# Utility macro: replacement for $^
181^^= $(filter-out %$A,$^)
182# Use $(L^) to link with all libraries specified as dependencies
183L^= $(addprefix -l,$(basename $(notdir $(filter %$A,$+))))
184
185# Build rules
186$(OUT)%$O: %.c
187 $(CC) $(CFLAGS.LIB) -c $< -o $@
188
189%.a:
190 $(LD) $(LDFLAGS.A) -o $@ $(^^) $(L^)
191
192%.dll:
193 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
194
195%.pyd: $(OUT)%module$O $(OUT)%_m.def
196 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(PYTHON.IMPLIB) $(LIBS)
197
198%.exe:
199 $(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^)
200
201%_m.def:
202 @echo Creating .DEF file: $@
203 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
204 ifeq ($(DESCRIPTION.$(notdir $*)$(MODULE.EXT)),)
205 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
206 else
207 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
208 endif
209 @echo DATA MULTIPLE NONSHARED >>$@
210 @echo EXPORTS >>$@
211 @echo init$(notdir $*) >>$@
212
213%.def:
214 @echo Creating .DEF file: $@
215 @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@
216 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@
217 @echo STACKSIZE 1048576 >>$@
218
219# Output file names
220PYTHON_VER= 2.3
221PYTHON_LIB= python23
222PYTHON.LIB= $(PYTHON_LIB)_s$A
223PYTHON.IMPLIB= $(PYTHON_LIB)$A
224ifeq ($(EXEOMF),yes)
225 PYTHON.EXEIMP= $(PYTHON.IMPLIB)
226 LDMODE.EXE= -Zomf
227else
228 PYTHON.EXEIMP= $(PYTHON_LIB).a
229 LDMODE.EXE =
230endif
231PYTHON.DLL= $(PYTHON_LIB).dll
232PYTHON.DEF= $(PYTHON_LIB).def
233PYTHON.EXE= python.exe
234PYTHONPM.EXE= pythonpm.exe
235PGEN.EXE= pgen.exe
236LIBRARY= $(PYTHON.LIB)
237LD_LIBRARY= $(PYTHON.IMPLIB)
238
239# Additional executable parameters
240EXETYPE.$(PYTHON.EXE)= WINDOWCOMPAT
241EXETYPE.$(PYTHONPM.EXE)= WINDOWAPI
242EXETYPE.$(PGEN.EXE)= WINDOWCOMPAT
243DESCRIPTION.$(PYTHON.EXE)= Python object-oriented programming language interpreter for OS/2
244DESCRIPTION.$(PYTHONPM.EXE)= $(DESCRIPTION.$(PYTHON.EXE))
245DESCRIPTION.$(PGEN.EXE)= Python object-oriented programming language parser generator for OS/2
246
247# Module descriptions
248DESCRIPTION.zlib$(MODULE.EXT)= Python Extension DLL for accessing the InfoZip compression library
249DESCRIPTION.crypt$(MODULE.EXT)= Python Extension DLL implementing the crypt$(BRO)$(BRC) function
250DESCRIPTION._tkinter$(MODULE.EXT)= Python Extension DLL for access to Tcl/Tk Environment
251DESCRIPTION.mpz$(MODULE.EXT)= Python Extension DLL for access to GNU multi-precision library
252DESCRIPTION.readline$(MODULE.EXT)= Python Extension DLL for access to GNU ReadLine library
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000253DESCRIPTION.bsddb185$(MODULE.EXT)= Python Extension DLL for access to BSD DB (v1.85) library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000254DESCRIPTION._curses$(MODULE.EXT)= Python Extension DLL for access to ncurses library
255DESCRIPTION.pyexpat$(MODULE.EXT)= Python Extension DLL for access to expat library
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000256DESCRIPTION.bz2$(MODULE.EXT)= Python Extension DLL for accessing the bz2 compression library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000257
258# Source files
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000259SRC.OS2EMX= config.c dlfcn.c getpathp.c
260SRC.MAIN= $(addprefix $(TOP), \
261 Modules/getbuildinfo.c \
262 Modules/main.c)
263SRC.MODULES= $(addprefix $(TOP), \
264 Modules/gcmodule.c \
265 Modules/signalmodule.c \
266 Modules/posixmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000267 Modules/threadmodule.c \
268 Modules/arraymodule.c \
269 Modules/binascii.c \
270 Modules/cmathmodule.c \
271 Modules/_codecsmodule.c \
272 Modules/cPickle.c \
273 Modules/cStringIO.c \
274 Modules/_csv.c \
275 Modules/datetimemodule.c \
276 Modules/dlmodule.c \
277 Modules/errnomodule.c \
278 Modules/fcntlmodule.c \
279 Modules/imageop.c \
280 Modules/itertoolsmodule.c \
281 Modules/_localemodule.c \
282 Modules/mathmodule.c \
283 Modules/md5c.c \
284 Modules/md5module.c \
285 Modules/operator.c \
286 Modules/pcremodule.c \
287 Modules/pypcre.c \
288 Modules/_randommodule.c \
289 Modules/regexmodule.c \
290 Modules/regexpr.c \
291 Modules/rgbimgmodule.c \
292 Modules/shamodule.c \
293 Modules/_sre.c \
294 Modules/stropmodule.c \
295 Modules/structmodule.c \
296 Modules/symtablemodule.c \
297 Modules/termios.c \
298 Modules/timemodule.c \
299 Modules/timingmodule.c \
300 Modules/_weakref.c \
301 Modules/xreadlinesmodule.c \
302 Modules/xxsubtype.c \
303 Modules/zipimport.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000304SRC.PARSE1= $(addprefix $(TOP), \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000305 Parser/acceler.c \
306 Parser/grammar1.c \
307 Parser/listnode.c \
308 Parser/node.c \
309 Parser/parser.c \
310 Parser/parsetok.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000311 Parser/bitset.c \
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000312 Parser/metagrammar.c)
313SRC.PARSE2= $(addprefix $(TOP), \
314 Parser/tokenizer.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000315 Parser/myreadline.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000316SRC.PARSER= $(SRC.PARSE1) \
317 $(SRC.PARSE2)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000318SRC.PYTHON= $(addprefix $(TOP), \
319 Python/bltinmodule.c \
320 Python/exceptions.c \
321 Python/ceval.c \
322 Python/compile.c \
323 Python/codecs.c \
324 Python/errors.c \
325 Python/frozen.c \
326 Python/frozenmain.c \
327 Python/future.c \
328 Python/getargs.c \
329 Python/getcompiler.c \
330 Python/getcopyright.c \
331 Python/getmtime.c \
332 Python/getplatform.c \
333 Python/getversion.c \
334 Python/graminit.c \
335 Python/import.c \
336 Python/importdl.c \
337 Python/marshal.c \
338 Python/modsupport.c \
339 Python/mysnprintf.c \
340 Python/mystrtoul.c \
341 Python/pyfpe.c \
342 Python/pystate.c \
343 Python/pythonrun.c \
344 Python/structmember.c \
345 Python/symtable.c \
346 Python/sysmodule.c \
347 Python/traceback.c \
348 Python/getopt.c \
349 Python/dynload_shlib.c \
350 Python/thread.c)
351SRC.OBJECT= $(addprefix $(TOP), \
352 Objects/abstract.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000353 Objects/boolobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000354 Objects/bufferobject.c \
355 Objects/cellobject.c \
356 Objects/classobject.c \
357 Objects/cobject.c \
358 Objects/complexobject.c \
359 Objects/descrobject.c \
360 Objects/dictobject.c \
Andrew MacIntyre07c639f2002-04-30 13:06:32 +0000361 Objects/enumobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000362 Objects/fileobject.c \
363 Objects/floatobject.c \
364 Objects/frameobject.c \
365 Objects/funcobject.c \
366 Objects/intobject.c \
367 Objects/iterobject.c \
368 Objects/listobject.c \
369 Objects/longobject.c \
370 Objects/methodobject.c \
371 Objects/moduleobject.c \
372 Objects/object.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000373 Objects/obmalloc.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000374 Objects/rangeobject.c \
375 Objects/sliceobject.c \
376 Objects/stringobject.c \
377 Objects/structseq.c \
378 Objects/tupleobject.c \
379 Objects/typeobject.c \
380 Objects/unicodeobject.c \
381 Objects/unicodectype.c \
382 Objects/weakrefobject.c)
383
384SRC.LIB= $(SRC.OS2EMX) \
385 $(SRC.MAIN) \
386 $(SRC.PARSER) \
387 $(SRC.OBJECT) \
388 $(SRC.PYTHON) \
389 $(SRC.MODULES)
390OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
391
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000392SRC.PGEN= $(SRC.PARSE1) \
393 $(addprefix $(TOP), \
394 Objects/obmalloc.c) \
395 $(addprefix $(TOP), \
396 Python/mysnprintf.c) \
397 $(addprefix $(TOP), \
398 Parser/tokenizer_pgen.c \
399 Parser/pgenmain.c \
400 Parser/pgen.c \
401 Parser/printgrammar.c \
402 Parser/grammar.c \
403 Parser/firstsets.c) \
404
405OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
406
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000407SRC.EXE= $(TOP)Modules/python.c
408SRC.PMEXE= pythonpm.c
409
410# Python modules to be dynamically loaded that:
411# 1) have only single source file and require no extra libs
412# 2) use the standard module naming convention
413# (the 'module' in ?????module.c is assumed)
414# - these can be built with implicit rules
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000415EASYEXTMODULES= fpectl \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000416 fpetest \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000417 parser \
418 pwd \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000419 rotor \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000420 select
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000421
422# Python modules to be dynamically loaded that need explicit build rules
423# (either multiple source files and/or non-standard module naming)
424# (NOTE: use shortened names for modules affected by 8 char name limit)
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000425HARDEXTMODULES= _hotshot \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000426 _socket \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000427 _testcap \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000428 unicoded
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000429
430# Python external ($(MODULE.EXT)) modules - can be EASY or HARD
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000431ifeq ($(HAVE_ZLIB),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000432 HARDEXTMODULES+= zlib
433endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000434ifeq ($(HAVE_UFC),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000435 HARDEXTMODULES+= crypt
436endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000437ifeq ($(HAVE_TCLTK),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000438 HARDEXTMODULES+= _tkinter
439 CFLAGS+= -DHAS_DIRENT -I/TclTk80/include
440 TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80
441endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000442ifeq ($(HAVE_GMPZ),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000443 HARDEXTMODULES+= mpz
444endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000445ifeq ($(HAVE_GREADLINE),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000446 HARDEXTMODULES+= readline
447endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000448ifeq ($(HAVE_BSDDB),yes)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000449 HARDEXTMODULES+= bsddb185
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000450endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000451ifeq ($(HAVE_NCURSES),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000452 HARDEXTMODULES+= _curses _curses_
453endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000454ifeq ($(HAVE_GDBM),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000455 HARDEXTMODULES+= gdbm dbm
456endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000457ifeq ($(HAVE_BZ2),yes)
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000458 HARDEXTMODULES+= bz2
459endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000460
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000461# Expat is now distributed with the Python source
462HARDEXTMODULES+= pyexpat
463EXPAT.INC= -I../../Modules/expat
464EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \
465 -DXML_CONTENT_BYTES=1024
466EXPAT.SRC= $(addprefix ../../Modules/expat/, \
467 xmlparse.c \
468 xmlrole.c \
469 xmltok.c)
470
471# all the external modules
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000472EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES)))
473EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
474
475# Targets
476all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
477 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
478
479clean:
480 rm -f $(OUT)*
481 rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
482 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT)
483
484lx:
485 @echo Packing everything with lxLite...
486 lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
487
488depend: $(OUTBASE)
489 makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
490 -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
491
492$(OUT): $(OUTBASE)
493
494$(OUT) $(OUTBASE):
495 mkdir.exe $@
496
497$(PYTHON.LIB): $(OBJ.LIB)
498 rm.exe -f $@
499 $(AR) $(ARFLAGS) $@ $^
500
501$(PYTHON.DEF): $(PYTHON.LIB)
502 @echo Creating .DEF file: $@
503 @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
504 @echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
505 @echo PROTMODE >>$@
506 @echo DATA MULTIPLE NONSHARED >>$@
507 @echo EXPORTS >>$@
508 $(EXPLIB) -u $(PYTHON.LIB) >>$@
509
510$(PYTHON.IMPLIB): $(PYTHON.DEF)
511 $(IMPLIB) -o $@ $^
512
513$(PYTHON.EXEIMP): $(PYTHON.DEF)
514 $(IMPLIB) -o $@ $^
515
516$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF)
517
518# Explicit make targets for the .EXEs to be able to use LD to link
519# (so that fork() will work if required)
520
521$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
522 $(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 +0000523 $(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000524
525$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def
526 $(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 +0000527 $(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000528
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000529$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000530
531# Explicit building instructions for those external modules that require
532# awkward handling (due e.g. to non-std naming, or multiple source files)
533# - standard modules
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000534
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000535_hotshot$(MODULE.EXT): $(OUT)_hotshot$O $(OUT)_hotshot_m.def $(PYTHON.IMPLIB)
536 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
537
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000538_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
539 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
540
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000541# _testcapi needs to be renamed to be useful
542_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB)
543 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
544
545_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT)
546 cp $^ $@
547
548# unicodedata needs to be renamed to be useful
549unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB)
550 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS)
551
552unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT)
553 cp $^ $@
554
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000555# - optional modules (requiring other software to be installed)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000556bsddb185$(MODULE.EXT): $(OUT)bsddbmodule$O $(OUT)bsddb185_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000557 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -ldb $(LIBS)
558
559crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
560 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS)
561
562# The _curses_panel module requires a couple of ncurses library entry
563# points, which are best exposed as exports from the _curses module DLL
564$(OUT)_curses_m.def:
565 @echo Creating .DEF file: $@
566 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
567 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
568 @echo DATA MULTIPLE NONSHARED >>$@
569 @echo EXPORTS >>$@
570 @echo init_curses >>$@
571 @echo wnoutrefresh >>$@
572 @echo _nc_panelhook >>$@
573 @echo is_linetouched >>$@
574 @echo mvwin >>$@
575 @echo stdscr >>$@
576 @echo wtouchln >>$@
577
578$(OUT)_curses_panel_m.def:
579 @echo Creating .DEF file: $@
580 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
581 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
582 @echo DATA MULTIPLE NONSHARED >>$@
583 @echo IMPORTS >>$@
584 @echo _curses.wnoutrefresh >>$@
585 @echo _curses._nc_panelhook >>$@
586 @echo _curses.is_linetouched >>$@
587 @echo _curses.mvwin >>$@
588 @echo _curses.stdscr >>$@
589 @echo _curses.wtouchln >>$@
590 @echo EXPORTS >>$@
591 @echo init_curses_panel >>$@
592
593_curses$(MODULE.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB)
594 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses
595
596# curses_panel needs to be renamed to be useful
597_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB)
598 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel
599
600_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT)
601 cp $^ $@
602
603dbm$(MODULE.EXT): $(OUT)dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB)
604 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
605
606gdbm$(MODULE.EXT): $(OUT)gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB)
607 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
608
609mpz$(MODULE.EXT): $(OUT)mpzmodule$O $(OUT)mpz_m.def $(PYTHON.IMPLIB)
610 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgmp
611
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000612# Expat is now distributed with Python, so use the included version
613$(OUT)pyexpat$O: ../../Modules/pyexpat.c
614 $(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^
615$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c
616 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
617$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c
618 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
619$(OUT)xmltok$O: ../../Modules/expat/xmltok.c
620 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
621pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \
622 $(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB)
623 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000624
625readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
626 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses
627
628#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
629_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
630 $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
631 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
632
633zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
634 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz
635
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000636bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB)
637 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2
638
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000639# the test target
640test:
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000641 -find ../../Lib -name "*.py[co]" -exec rm {} ";"
642 -./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000643 ./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000644
645-include $(OUTBASE)python.dep