blob: 787a3f421be42cf5b9af9aff4270206e059f1d37 [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 MacIntyred4c9b162003-04-21 14:28:01 +0000267 Modules/threadmodule.c
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000268SRC.PARSE1= $(addprefix $(TOP), \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000269 Parser/acceler.c \
270 Parser/grammar1.c \
271 Parser/listnode.c \
272 Parser/node.c \
273 Parser/parser.c \
274 Parser/parsetok.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000275 Parser/bitset.c \
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000276 Parser/metagrammar.c)
277SRC.PARSE2= $(addprefix $(TOP), \
278 Parser/tokenizer.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000279 Parser/myreadline.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000280SRC.PARSER= $(SRC.PARSE1) \
281 $(SRC.PARSE2)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000282SRC.PYTHON= $(addprefix $(TOP), \
283 Python/bltinmodule.c \
284 Python/exceptions.c \
285 Python/ceval.c \
286 Python/compile.c \
287 Python/codecs.c \
288 Python/errors.c \
289 Python/frozen.c \
290 Python/frozenmain.c \
291 Python/future.c \
292 Python/getargs.c \
293 Python/getcompiler.c \
294 Python/getcopyright.c \
295 Python/getmtime.c \
296 Python/getplatform.c \
297 Python/getversion.c \
298 Python/graminit.c \
299 Python/import.c \
300 Python/importdl.c \
301 Python/marshal.c \
302 Python/modsupport.c \
303 Python/mysnprintf.c \
304 Python/mystrtoul.c \
305 Python/pyfpe.c \
306 Python/pystate.c \
307 Python/pythonrun.c \
308 Python/structmember.c \
309 Python/symtable.c \
310 Python/sysmodule.c \
311 Python/traceback.c \
312 Python/getopt.c \
313 Python/dynload_shlib.c \
314 Python/thread.c)
315SRC.OBJECT= $(addprefix $(TOP), \
316 Objects/abstract.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000317 Objects/boolobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000318 Objects/bufferobject.c \
319 Objects/cellobject.c \
320 Objects/classobject.c \
321 Objects/cobject.c \
322 Objects/complexobject.c \
323 Objects/descrobject.c \
324 Objects/dictobject.c \
Andrew MacIntyre07c639f2002-04-30 13:06:32 +0000325 Objects/enumobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000326 Objects/fileobject.c \
327 Objects/floatobject.c \
328 Objects/frameobject.c \
329 Objects/funcobject.c \
330 Objects/intobject.c \
331 Objects/iterobject.c \
332 Objects/listobject.c \
333 Objects/longobject.c \
334 Objects/methodobject.c \
335 Objects/moduleobject.c \
336 Objects/object.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000337 Objects/obmalloc.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000338 Objects/rangeobject.c \
339 Objects/sliceobject.c \
340 Objects/stringobject.c \
341 Objects/structseq.c \
342 Objects/tupleobject.c \
343 Objects/typeobject.c \
344 Objects/unicodeobject.c \
345 Objects/unicodectype.c \
346 Objects/weakrefobject.c)
347
348SRC.LIB= $(SRC.OS2EMX) \
349 $(SRC.MAIN) \
350 $(SRC.PARSER) \
351 $(SRC.OBJECT) \
352 $(SRC.PYTHON) \
353 $(SRC.MODULES)
354OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
355
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000356SRC.PGEN= $(SRC.PARSE1) \
357 $(addprefix $(TOP), \
358 Objects/obmalloc.c) \
359 $(addprefix $(TOP), \
360 Python/mysnprintf.c) \
361 $(addprefix $(TOP), \
362 Parser/tokenizer_pgen.c \
363 Parser/pgenmain.c \
364 Parser/pgen.c \
365 Parser/printgrammar.c \
366 Parser/grammar.c \
367 Parser/firstsets.c) \
368
369OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
370
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000371SRC.EXE= $(TOP)Modules/python.c
372SRC.PMEXE= pythonpm.c
373
374# Python modules to be dynamically loaded that:
375# 1) have only single source file and require no extra libs
376# 2) use the standard module naming convention
377# (the 'module' in ?????module.c is assumed)
378# - these can be built with implicit rules
379EASYEXTMODULES= array \
380 cmath \
381 _codecs \
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000382 datetime \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000383 dl \
384 errno \
385 fcntl \
386 fpectl \
387 fpetest \
388 _locale \
389 math \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000390 parser \
391 pwd \
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000392 _random \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000393 rgbimg \
394 rotor \
395 select \
396 sha \
397 strop \
398 struct \
399 time \
400 timing
401
402# Python modules to be dynamically loaded that need explicit build rules
403# (either multiple source files and/or non-standard module naming)
404# (NOTE: use shortened names for modules affected by 8 char name limit)
405HARDEXTMODULES= binascii \
406 cPickle \
407 cStringI \
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000408 _csv \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000409 _hotshot \
410 imageop \
Andrew MacIntyre4f28c4d2003-02-19 12:42:36 +0000411 itertool \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000412 md5 \
413 operator \
414 pcre \
415 regex \
416 _socket \
Andrew MacIntyre4a79e362002-06-10 08:04:29 +0000417 _sre \
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000418 _symtabl \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000419 termios \
420 _testcap \
421 unicoded \
422 _weakref \
Andrew MacIntyre4a79e362002-06-10 08:04:29 +0000423 xreadlin \
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000424 xxsubtyp \
425 zipimpor
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000426
427# Python external ($(MODULE.EXT)) modules - can be EASY or HARD
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000428ifeq ($(HAVE_ZLIB),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000429 HARDEXTMODULES+= zlib
430endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000431ifeq ($(HAVE_UFC),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000432 HARDEXTMODULES+= crypt
433endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000434ifeq ($(HAVE_TCLTK),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000435 HARDEXTMODULES+= _tkinter
436 CFLAGS+= -DHAS_DIRENT -I/TclTk80/include
437 TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80
438endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000439ifeq ($(HAVE_GMPZ),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000440 HARDEXTMODULES+= mpz
441endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000442ifeq ($(HAVE_GREADLINE),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000443 HARDEXTMODULES+= readline
444endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000445ifeq ($(HAVE_BSDDB),yes)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000446 HARDEXTMODULES+= bsddb185
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000447endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000448ifeq ($(HAVE_NCURSES),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000449 HARDEXTMODULES+= _curses _curses_
450endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000451ifeq ($(HAVE_GDBM),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000452 HARDEXTMODULES+= gdbm dbm
453endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000454ifeq ($(HAVE_BZ2),yes)
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000455 HARDEXTMODULES+= bz2
456endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000457
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000458# Expat is now distributed with the Python source
459HARDEXTMODULES+= pyexpat
460EXPAT.INC= -I../../Modules/expat
461EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \
462 -DXML_CONTENT_BYTES=1024
463EXPAT.SRC= $(addprefix ../../Modules/expat/, \
464 xmlparse.c \
465 xmlrole.c \
466 xmltok.c)
467
468# all the external modules
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000469EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES)))
470EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
471
472# Targets
473all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
474 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
475
476clean:
477 rm -f $(OUT)*
478 rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
479 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT)
480
481lx:
482 @echo Packing everything with lxLite...
483 lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
484
485depend: $(OUTBASE)
486 makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
487 -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
488
489$(OUT): $(OUTBASE)
490
491$(OUT) $(OUTBASE):
492 mkdir.exe $@
493
494$(PYTHON.LIB): $(OBJ.LIB)
495 rm.exe -f $@
496 $(AR) $(ARFLAGS) $@ $^
497
498$(PYTHON.DEF): $(PYTHON.LIB)
499 @echo Creating .DEF file: $@
500 @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
501 @echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
502 @echo PROTMODE >>$@
503 @echo DATA MULTIPLE NONSHARED >>$@
504 @echo EXPORTS >>$@
505 $(EXPLIB) -u $(PYTHON.LIB) >>$@
506
507$(PYTHON.IMPLIB): $(PYTHON.DEF)
508 $(IMPLIB) -o $@ $^
509
510$(PYTHON.EXEIMP): $(PYTHON.DEF)
511 $(IMPLIB) -o $@ $^
512
513$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF)
514
515# Explicit make targets for the .EXEs to be able to use LD to link
516# (so that fork() will work if required)
517
518$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
519 $(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 +0000520 $(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000521
522$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def
523 $(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 +0000524 $(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000525
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000526$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000527
528# Explicit building instructions for those external modules that require
529# awkward handling (due e.g. to non-std naming, or multiple source files)
530# - standard modules
531binascii$(MODULE.EXT): $(OUT)binascii$O $(OUT)binascii_m.def $(PYTHON.IMPLIB)
532 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
533
534cPickle$(MODULE.EXT): $(OUT)cPickle$O $(OUT)cPickle_m.def $(PYTHON.IMPLIB)
535 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
536
537# cStringIO needs to be renamed to be useful (8 char DLL name limit)
538cStringIO$(MODULE.EXT): $(OUT)cStringIO$O $(OUT)cStringIO_m.def $(PYTHON.IMPLIB)
539 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
540
541cStringI$(MODULE.EXT): cStringIO$(MODULE.EXT)
542 cp $^ $@
543
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000544_csv$(MODULE.EXT): $(OUT)_csv$O $(OUT)_csv_m.def $(PYTHON.IMPLIB)
545 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
546
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000547_hotshot$(MODULE.EXT): $(OUT)_hotshot$O $(OUT)_hotshot_m.def $(PYTHON.IMPLIB)
548 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
549
550imageop$(MODULE.EXT): $(OUT)imageop$O $(OUT)imageop_m.def $(PYTHON.IMPLIB)
551 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
552
Andrew MacIntyre4f28c4d2003-02-19 12:42:36 +0000553# itertools needs to be renamed to be useful
554itertools$(MODULE.EXT): $(OUT)itertoolsmodule$O $(OUT)itertools_m.def $(PYTHON.IMPLIB)
555 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
556
557itertool$(MODULE.EXT): itertools$(MODULE.EXT)
558 cp $^ $@
559
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000560md5$(MODULE.EXT): $(OUT)md5module$O $(OUT)md5c$O $(OUT)md5_m.def $(PYTHON.IMPLIB)
561 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
562
563operator$(MODULE.EXT): $(OUT)operator$O $(OUT)operator_m.def $(PYTHON.IMPLIB)
564 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
565
566pcre$(MODULE.EXT): $(OUT)pcremodule$O $(OUT)pypcre$O $(OUT)pcre_m.def $(PYTHON.IMPLIB)
567 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
568
569regex$(MODULE.EXT): $(OUT)regexmodule$O $(OUT)regexpr$O $(OUT)regex_m.def $(PYTHON.IMPLIB)
570 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
571
572_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
573 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
574
Andrew MacIntyre4a79e362002-06-10 08:04:29 +0000575_sre$(MODULE.EXT): $(OUT)_sre$O $(OUT)_sre_m.def $(PYTHON.IMPLIB)
576 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
577
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000578# _symtable needs to be renamed to be useful
579_symtable$(MODULE.EXT): $(OUT)symtablemodule$O $(OUT)_symtable_m.def $(PYTHON.IMPLIB)
580 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
581
582_symtabl$(MODULE.EXT): _symtable$(MODULE.EXT)
583 cp $^ $@
584
585termios$(MODULE.EXT): $(OUT)termios$O $(OUT)termios_m.def $(PYTHON.IMPLIB)
586 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
587
588# _testcapi needs to be renamed to be useful
589_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB)
590 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
591
592_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT)
593 cp $^ $@
594
595# unicodedata needs to be renamed to be useful
596unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB)
597 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS)
598
599unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT)
600 cp $^ $@
601
602_weakref$(MODULE.EXT): $(OUT)_weakref$O $(OUT)_weakref_m.def $(PYTHON.IMPLIB)
603 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
604
605# xreadlines needs to be renamed to be useful
606xreadlines$(MODULE.EXT): $(OUT)xreadlinesmodule$O $(OUT)xreadlines_m.def $(PYTHON.IMPLIB)
607 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
608
609xreadlin$(MODULE.EXT): xreadlines$(MODULE.EXT)
610 cp $^ $@
611
Andrew MacIntyre4a79e362002-06-10 08:04:29 +0000612# xxsubtype needs to be renamed to be useful
613xxsubtype$(MODULE.EXT): $(OUT)xxsubtype$O $(OUT)xxsubtype_m.def $(PYTHON.IMPLIB)
614 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
615
616xxsubtyp$(MODULE.EXT): xxsubtype$(MODULE.EXT)
617 cp $^ $@
618
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000619# zipimport needs to be renamed to be useful
620zipimport$(MODULE.EXT): $(OUT)zipimport$O $(OUT)zipimport_m.def $(PYTHON.IMPLIB)
621 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
622
623zipimpor$(MODULE.EXT): zipimport$(MODULE.EXT)
624 cp $^ $@
625
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000626# - optional modules (requiring other software to be installed)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000627bsddb185$(MODULE.EXT): $(OUT)bsddbmodule$O $(OUT)bsddb185_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000628 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -ldb $(LIBS)
629
630crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
631 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS)
632
633# The _curses_panel module requires a couple of ncurses library entry
634# points, which are best exposed as exports from the _curses module DLL
635$(OUT)_curses_m.def:
636 @echo Creating .DEF file: $@
637 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
638 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
639 @echo DATA MULTIPLE NONSHARED >>$@
640 @echo EXPORTS >>$@
641 @echo init_curses >>$@
642 @echo wnoutrefresh >>$@
643 @echo _nc_panelhook >>$@
644 @echo is_linetouched >>$@
645 @echo mvwin >>$@
646 @echo stdscr >>$@
647 @echo wtouchln >>$@
648
649$(OUT)_curses_panel_m.def:
650 @echo Creating .DEF file: $@
651 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
652 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
653 @echo DATA MULTIPLE NONSHARED >>$@
654 @echo IMPORTS >>$@
655 @echo _curses.wnoutrefresh >>$@
656 @echo _curses._nc_panelhook >>$@
657 @echo _curses.is_linetouched >>$@
658 @echo _curses.mvwin >>$@
659 @echo _curses.stdscr >>$@
660 @echo _curses.wtouchln >>$@
661 @echo EXPORTS >>$@
662 @echo init_curses_panel >>$@
663
664_curses$(MODULE.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB)
665 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses
666
667# curses_panel needs to be renamed to be useful
668_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB)
669 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel
670
671_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT)
672 cp $^ $@
673
674dbm$(MODULE.EXT): $(OUT)dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB)
675 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
676
677gdbm$(MODULE.EXT): $(OUT)gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB)
678 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
679
680mpz$(MODULE.EXT): $(OUT)mpzmodule$O $(OUT)mpz_m.def $(PYTHON.IMPLIB)
681 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgmp
682
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000683# Expat is now distributed with Python, so use the included version
684$(OUT)pyexpat$O: ../../Modules/pyexpat.c
685 $(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^
686$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c
687 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
688$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c
689 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
690$(OUT)xmltok$O: ../../Modules/expat/xmltok.c
691 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
692pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \
693 $(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB)
694 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000695
696readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
697 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses
698
699#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
700_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
701 $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
702 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
703
704zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
705 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz
706
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000707bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB)
708 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2
709
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000710# the test target
711test:
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000712 -find ../../Lib -name "*.py[co]" -exec rm {} ";"
713 -./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000714 ./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000715
716-include $(OUTBASE)python.dep