blob: 677605f2ffa185dd8bdc50edbb68ec9bdca36ec0 [file] [log] [blame]
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +00001#####################==================----------------
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00002#
Andrew MacIntyre378d3c02004-07-07 13:55:25 +00003# Top-Level Makefile for Building Python 2.4 for OS/2 using GCC/EMX
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00004# Originally written by Andrew Zabolotny, <bit@eltech.ru> for Python 1.5.2
Andrew MacIntyre378d3c02004-07-07 13:55:25 +00005# Modified by Andrew MacIntyre, <andymac@pcug.org.au> for Python 2.4
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00006#
7# This makefile was developed for use with [P]GCC/EMX compiler any
8# version and GNU Make.
9#
Andrew MacIntyre378d3c02004-07-07 13:55:25 +000010# The output of the build is a largish Python24.DLL containing the
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000011# essential modules of Python and a small Python.exe program to start
12# the interpreter. When embedding Python within another program, only
Andrew MacIntyre378d3c02004-07-07 13:55:25 +000013# Python24.DLL is needed. We also build python_s.a static library (which
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000014# 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 readline library installed?
44# NOTE: I'm using a modified version of Kai Uwe Rommel's port that
45# - is compiled with multithreading enabled
46# - is linked statically
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000047# I have had no success trying to use a DLL version, even when
48# compiled with multithreading enabled.
49HAVE_GREADLINE= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000050# Do you have the BSD DB library (v1.85) as included in the EMXBSD package?
51# NOTE: this library needs to be recompiled with a structure member
52# renamed to avoid problems with the multithreaded errno support
53# (there is a structure member called errno, used for shadowing the
54# real errno, which conflicts with the errno redefinition of -Zmt)
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000055HAVE_BSDDB= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000056# Do you have the ncurses library installed? EMX's BSD curses aren't enough!
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000057HAVE_NCURSES= no
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000058# Do you have the GDBM library installed?
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000059HAVE_GDBM= no
Andrew MacIntyre978697b2002-12-31 11:18:08 +000060# Do you have the BZ2 compression library installed?
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000061HAVE_BZ2= no
62
63# === install locations ===
64# default value of PYTHONHOME
Andrew MacIntyre378d3c02004-07-07 13:55:25 +000065LIB_DIR=C:/Python24
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000066# default is to have everything in or under PYTHONHOME
67EXE_DIR=$(LIB_DIR)
68DLL_DIR=$(EXE_DIR)
69
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000070
71# === The Tools ===
72CC= gcc
73CFLAGS= -Zmt -Wall $(INCLUDE)
74CFLAGS.LIB= $(CFLAGS)
75LD= gcc
76LDFLAGS= -Zmt -Zcrtdll -L. -lgcc
77LDFLAGS.EXE= $(LDFLAGS)
78LDFLAGS.DLL= $(LDFLAGS) -Zdll
79LDFLAGS.A= $(LDFLAGS) $(LIBS)
80ARFLAGS= crs
81IMPLIB= emximp
82EXPLIB= emxexp
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +000083EXEOPT= emxbind
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +000084PY_DEF= -DPy_BUILD_CORE
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +000085
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000086
87# adjust C compiler settings based on build options
88ifeq ($(MODE),debug)
89 CFLAGS+= -g -O
90 LDFLAGS+= -g
91else
Andrew MacIntyre51578ae2003-12-02 12:21:20 +000092 CFLAGS+= -s -O3 -fomit-frame-pointer -mprobe
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000093 LDFLAGS+= -s
94endif
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +000095CFLAGS+= $(PY_DEF)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000096ifeq ($(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
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000114MODLIB.EXT= .dll
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000115ifeq ($(OMF),yes)
116 O= .obj
117 A= .lib
118 AR= emxomfar
119 CFLAGS+= -Zomf
120 LDFLAGS+= -Zomf
121 ifeq ($(MODE),debug)
122 ARFLAGS= -p64 crs
123 else
124 ARFLAGS= -p32 crs
125 endif
126else
127 O= .o
128 A= .a
129 AR= ar
130endif
131
Andrew MacIntyreff59f3c2005-01-17 12:18:12 +0000132
133# === Build time resource settings ===
134
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000135# EMX's default number of file handles is 40, which is sometimes insufficient
136# (the tempfile regression test tries to create 100 temporary files)
137NFILES=250
138
Andrew MacIntyreff59f3c2005-01-17 12:18:12 +0000139# The default stack size for child threads is 64k bytes, which is
140# insufficient for some applications which do a lot of work in threads
141# (such as Zope, especially in conjunction with Plone).
142# Note that this setting is distinct from the stack size for the main
143# thread, which is set via the %.def rule below.
144# EMX documents that the thread stack size should be at least 32768 bytes;
145# for Zope/Plone at least 128k bytes is recommended.
146# Uncomment & adjust the next line to override the default stack size:
147#CFLAGS+= -DTHREAD_STACK_SIZE=0x20000
148
149
150# === The environment ===
151
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000152# Source file paths
153SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules
154# Python contains the central core, containing the builtins and interpreter.
155# Parser contains Python's Internal Parser and
156# Standalone Parser Generator Program (Shares Some of Python's Modules)
157# Objects contains Python Object Types
158# Modules contains extension Modules (Built-In or as Separate DLLs)
159
160# Unix shells tend to use "$" as delimiter for variable names.
161# Test for this behaviour and set $(BUCK) variable correspondigly ...
162__TMP__:=$(shell echo $$$$)
163ifeq ($(__TMP__),$$$$)
164 BUCK= $$
165 BRO= (
166 BRC= )
167else
168 BUCK= \$$
169 BRO= \(
170 BRC= \)
171endif
172# Compute the "double quote" variable
173__TMP__:=$(shell echo "")
174ifeq ($(__TMP__),"")
175 DQUOTE= "
176else
177 DQUOTE= \"
178endif
179
180# Include paths
181#INCLUDE= -I$(subst ;, -I, $(SRCPATH))
182INCLUDE= -I. -I../../Include
183
184# Path to search for .c files
185vpath %.c .;..;$(SRCPATH)
186
187# Top of the package tree
188TOP= ../../
189
190# Directory for output files
191OUTBASE= out/
192OUT= $(OUTBASE)$(MODE)/
193
194# Additional libraries
195LIBS= -lsocket
196
197# Utility macro: replacement for $^
198^^= $(filter-out %$A,$^)
199# Use $(L^) to link with all libraries specified as dependencies
200L^= $(addprefix -l,$(basename $(notdir $(filter %$A,$+))))
201
202# Build rules
203$(OUT)%$O: %.c
204 $(CC) $(CFLAGS.LIB) -c $< -o $@
205
206%.a:
207 $(LD) $(LDFLAGS.A) -o $@ $(^^) $(L^)
208
209%.dll:
210 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
211
212%.pyd: $(OUT)%module$O $(OUT)%_m.def
213 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(PYTHON.IMPLIB) $(LIBS)
214
215%.exe:
216 $(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^)
217
218%_m.def:
219 @echo Creating .DEF file: $@
220 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
221 ifeq ($(DESCRIPTION.$(notdir $*)$(MODULE.EXT)),)
222 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
223 else
224 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
225 endif
226 @echo DATA MULTIPLE NONSHARED >>$@
227 @echo EXPORTS >>$@
228 @echo init$(notdir $*) >>$@
229
230%.def:
231 @echo Creating .DEF file: $@
232 @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@
233 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@
Andrew MacIntyreff59f3c2005-01-17 12:18:12 +0000234 @echo STACKSIZE 2097152 >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000235
236# Output file names
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000237PYTHON_VER= 2.4
238PYTHON_LIB= python24
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000239PYTHON.LIB= $(PYTHON_LIB)_s$A
240PYTHON.IMPLIB= $(PYTHON_LIB)$A
241ifeq ($(EXEOMF),yes)
242 PYTHON.EXEIMP= $(PYTHON.IMPLIB)
243 LDMODE.EXE= -Zomf
244else
245 PYTHON.EXEIMP= $(PYTHON_LIB).a
246 LDMODE.EXE =
247endif
248PYTHON.DLL= $(PYTHON_LIB).dll
249PYTHON.DEF= $(PYTHON_LIB).def
250PYTHON.EXE= python.exe
251PYTHONPM.EXE= pythonpm.exe
252PGEN.EXE= pgen.exe
253LIBRARY= $(PYTHON.LIB)
254LD_LIBRARY= $(PYTHON.IMPLIB)
255
256# Additional executable parameters
257EXETYPE.$(PYTHON.EXE)= WINDOWCOMPAT
258EXETYPE.$(PYTHONPM.EXE)= WINDOWAPI
259EXETYPE.$(PGEN.EXE)= WINDOWCOMPAT
260DESCRIPTION.$(PYTHON.EXE)= Python object-oriented programming language interpreter for OS/2
261DESCRIPTION.$(PYTHONPM.EXE)= $(DESCRIPTION.$(PYTHON.EXE))
262DESCRIPTION.$(PGEN.EXE)= Python object-oriented programming language parser generator for OS/2
263
264# Module descriptions
265DESCRIPTION.zlib$(MODULE.EXT)= Python Extension DLL for accessing the InfoZip compression library
266DESCRIPTION.crypt$(MODULE.EXT)= Python Extension DLL implementing the crypt$(BRO)$(BRC) function
267DESCRIPTION._tkinter$(MODULE.EXT)= Python Extension DLL for access to Tcl/Tk Environment
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000268DESCRIPTION.readline$(MODULE.EXT)= Python Extension DLL for access to GNU ReadLine library
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000269DESCRIPTION.bsddb185$(MODULE.EXT)= Python Extension DLL for access to BSD DB (v1.85) library
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000270DESCRIPTION._curses$(MODLIB.EXT)= Python Extension DLL for access to ncurses library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000271DESCRIPTION.pyexpat$(MODULE.EXT)= Python Extension DLL for access to expat library
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000272DESCRIPTION.bz2$(MODULE.EXT)= Python Extension DLL for accessing the bz2 compression library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000273
274# Source files
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000275SRC.OS2EMX= config.c dlfcn.c getpathp.c
276SRC.MAIN= $(addprefix $(TOP), \
277 Modules/getbuildinfo.c \
278 Modules/main.c)
279SRC.MODULES= $(addprefix $(TOP), \
280 Modules/gcmodule.c \
281 Modules/signalmodule.c \
282 Modules/posixmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000283 Modules/threadmodule.c \
284 Modules/arraymodule.c \
285 Modules/binascii.c \
286 Modules/cmathmodule.c \
287 Modules/_codecsmodule.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000288 Modules/collectionsmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000289 Modules/cPickle.c \
290 Modules/cStringIO.c \
291 Modules/_csv.c \
292 Modules/datetimemodule.c \
293 Modules/dlmodule.c \
294 Modules/errnomodule.c \
295 Modules/fcntlmodule.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000296 Modules/_heapqmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000297 Modules/imageop.c \
298 Modules/itertoolsmodule.c \
299 Modules/_localemodule.c \
300 Modules/mathmodule.c \
301 Modules/md5c.c \
302 Modules/md5module.c \
303 Modules/operator.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000304 Modules/_randommodule.c \
305 Modules/regexmodule.c \
306 Modules/regexpr.c \
307 Modules/rgbimgmodule.c \
308 Modules/shamodule.c \
309 Modules/_sre.c \
310 Modules/stropmodule.c \
311 Modules/structmodule.c \
312 Modules/symtablemodule.c \
313 Modules/termios.c \
314 Modules/timemodule.c \
315 Modules/timingmodule.c \
316 Modules/_weakref.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000317 Modules/xxsubtype.c \
318 Modules/zipimport.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000319SRC.PARSE1= $(addprefix $(TOP), \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000320 Parser/acceler.c \
321 Parser/grammar1.c \
322 Parser/listnode.c \
323 Parser/node.c \
324 Parser/parser.c \
325 Parser/parsetok.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000326 Parser/bitset.c \
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000327 Parser/metagrammar.c)
328SRC.PARSE2= $(addprefix $(TOP), \
329 Parser/tokenizer.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000330 Parser/myreadline.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000331SRC.PARSER= $(SRC.PARSE1) \
332 $(SRC.PARSE2)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000333SRC.PYTHON= $(addprefix $(TOP), \
334 Python/bltinmodule.c \
335 Python/exceptions.c \
336 Python/ceval.c \
337 Python/compile.c \
338 Python/codecs.c \
339 Python/errors.c \
340 Python/frozen.c \
341 Python/frozenmain.c \
342 Python/future.c \
343 Python/getargs.c \
344 Python/getcompiler.c \
345 Python/getcopyright.c \
346 Python/getmtime.c \
347 Python/getplatform.c \
348 Python/getversion.c \
349 Python/graminit.c \
350 Python/import.c \
351 Python/importdl.c \
352 Python/marshal.c \
353 Python/modsupport.c \
354 Python/mysnprintf.c \
355 Python/mystrtoul.c \
356 Python/pyfpe.c \
357 Python/pystate.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000358 Python/pystrtod.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000359 Python/pythonrun.c \
360 Python/structmember.c \
361 Python/symtable.c \
362 Python/sysmodule.c \
363 Python/traceback.c \
364 Python/getopt.c \
365 Python/dynload_shlib.c \
366 Python/thread.c)
367SRC.OBJECT= $(addprefix $(TOP), \
368 Objects/abstract.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000369 Objects/boolobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000370 Objects/bufferobject.c \
371 Objects/cellobject.c \
372 Objects/classobject.c \
373 Objects/cobject.c \
374 Objects/complexobject.c \
375 Objects/descrobject.c \
376 Objects/dictobject.c \
Andrew MacIntyre07c639f2002-04-30 13:06:32 +0000377 Objects/enumobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000378 Objects/fileobject.c \
379 Objects/floatobject.c \
380 Objects/frameobject.c \
381 Objects/funcobject.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000382 Objects/genobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000383 Objects/intobject.c \
384 Objects/iterobject.c \
385 Objects/listobject.c \
386 Objects/longobject.c \
387 Objects/methodobject.c \
388 Objects/moduleobject.c \
389 Objects/object.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000390 Objects/obmalloc.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000391 Objects/rangeobject.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000392 Objects/setobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000393 Objects/sliceobject.c \
394 Objects/stringobject.c \
395 Objects/structseq.c \
396 Objects/tupleobject.c \
397 Objects/typeobject.c \
398 Objects/unicodeobject.c \
399 Objects/unicodectype.c \
400 Objects/weakrefobject.c)
401
402SRC.LIB= $(SRC.OS2EMX) \
403 $(SRC.MAIN) \
404 $(SRC.PARSER) \
405 $(SRC.OBJECT) \
406 $(SRC.PYTHON) \
407 $(SRC.MODULES)
408OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
409
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000410SRC.PGEN= $(SRC.PARSE1) \
411 $(addprefix $(TOP), \
412 Objects/obmalloc.c) \
413 $(addprefix $(TOP), \
414 Python/mysnprintf.c) \
415 $(addprefix $(TOP), \
416 Parser/tokenizer_pgen.c \
417 Parser/pgenmain.c \
418 Parser/pgen.c \
419 Parser/printgrammar.c \
420 Parser/grammar.c \
421 Parser/firstsets.c) \
422
423OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
424
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000425SRC.EXE= $(TOP)Modules/python.c
426SRC.PMEXE= pythonpm.c
427
428# Python modules to be dynamically loaded that:
429# 1) have only single source file and require no extra libs
430# 2) use the standard module naming convention
431# (the 'module' in ?????module.c is assumed)
432# - these can be built with implicit rules
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000433EASYEXTMODULES= fpectl \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000434 fpetest \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000435 parser \
436 pwd \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000437 select
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000438
439# Python modules to be dynamically loaded that need explicit build rules
440# (either multiple source files and/or non-standard module naming)
441# (NOTE: use shortened names for modules affected by 8 char name limit)
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000442HARDEXTMODULES= _hotshot \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000443 _socket \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000444 _testcap \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000445 unicoded
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000446
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000447# Python modules that are used as libraries and therefore must use
448# a .DLL extension
449LIBEXTMODULES=
450
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000451# Python external ($(MODULE.EXT)) modules - can be EASY or HARD
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000452ifeq ($(HAVE_ZLIB),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000453 HARDEXTMODULES+= zlib
454endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000455ifeq ($(HAVE_UFC),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000456 HARDEXTMODULES+= crypt
457endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000458ifeq ($(HAVE_TCLTK),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000459 HARDEXTMODULES+= _tkinter
460 CFLAGS+= -DHAS_DIRENT -I/TclTk80/include
461 TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80
462endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000463ifeq ($(HAVE_GREADLINE),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000464 HARDEXTMODULES+= readline
465endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000466ifeq ($(HAVE_BSDDB),yes)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000467 HARDEXTMODULES+= bsddb185
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000468endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000469ifeq ($(HAVE_NCURSES),yes)
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000470 LIBEXTMODULES+= _curses
471 HARDEXTMODULES+= _curses_
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000472endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000473ifeq ($(HAVE_GDBM),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000474 HARDEXTMODULES+= gdbm dbm
475endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000476ifeq ($(HAVE_BZ2),yes)
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000477 HARDEXTMODULES+= bz2
478endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000479
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000480# Expat is now distributed with the Python source
481HARDEXTMODULES+= pyexpat
482EXPAT.INC= -I../../Modules/expat
483EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \
Andrew MacIntyre4d046392003-12-25 13:25:20 +0000484 -DXML_CONTENT_BYTES=1024 -DHAVE_MEMMOVE=1 -DHAVE_BCOPY=1
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000485EXPAT.SRC= $(addprefix ../../Modules/expat/, \
486 xmlparse.c \
487 xmlrole.c \
488 xmltok.c)
489
490# all the external modules
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000491EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES)))
492EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000493EXTERNDLLS+= $(addsuffix $(MODLIB.EXT),$(patsubst %module,%,$(LIBEXTMODULES)))
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000494
495# Targets
496all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000497 python_noncore
498
499python_noncore:
500 make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000501
502clean:
503 rm -f $(OUT)*
504 rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000505 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) *.dll
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000506 find ../../Lib -name "*.py[co]" -exec rm {} ";"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000507
508lx:
509 @echo Packing everything with lxLite...
510 lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
511
512depend: $(OUTBASE)
513 makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
514 -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
515
516$(OUT): $(OUTBASE)
517
518$(OUT) $(OUTBASE):
519 mkdir.exe $@
520
521$(PYTHON.LIB): $(OBJ.LIB)
522 rm.exe -f $@
523 $(AR) $(ARFLAGS) $@ $^
524
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000525# the Python core DLL .def file needs to have a number of non-static
526# symbols that aren't part of the Python C API removed (commented out)
527# from the DLL export list.
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000528$(PYTHON.DEF): $(PYTHON.LIB)
529 @echo Creating .DEF file: $@
530 @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
531 @echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
532 @echo PROTMODE >>$@
533 @echo DATA MULTIPLE NONSHARED >>$@
534 @echo EXPORTS >>$@
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000535 $(EXPLIB) -u $(PYTHON.LIB) |\
Andrew MacIntyrebac1ea92003-07-16 13:31:11 +0000536 sed -e "/^ .init.*/s/^ /; /" \
537 -e "/^ .pcre_.*/s/^ /; /" \
538 -e "/^ .array_methods/s/^ /; /" \
539 -e "/^ .fast_save_leave/s/^ /; /" \
540 -e "/^ .dlopen/s/^ /; /" \
541 -e "/^ .dlsym/s/^ /; /" \
542 -e "/^ .dlclose/s/^ /; /" \
543 -e "/^ .dlerror/s/^ /; /" \
544 -e "/^ ._Py_re_.*/s/^ /; /" \
545 -e "/^ ._Py_MD5.*/s/^ /; /" >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000546
547$(PYTHON.IMPLIB): $(PYTHON.DEF)
548 $(IMPLIB) -o $@ $^
549
550$(PYTHON.EXEIMP): $(PYTHON.DEF)
551 $(IMPLIB) -o $@ $^
552
553$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF)
554
555# Explicit make targets for the .EXEs to be able to use LD to link
556# (so that fork() will work if required)
557
558$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
559 $(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 +0000560 $(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000561
562$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def
563 $(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 +0000564 $(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000565
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000566$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000567
568# Explicit building instructions for those external modules that require
569# awkward handling (due e.g. to non-std naming, or multiple source files)
570# - standard modules
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000571
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000572_hotshot$(MODULE.EXT): $(OUT)_hotshot$O $(OUT)_hotshot_m.def $(PYTHON.IMPLIB)
573 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
574
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000575_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
576 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
577
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000578# _testcapi needs to be renamed to be useful
579_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB)
580 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
581
582_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT)
583 cp $^ $@
584
585# unicodedata needs to be renamed to be useful
586unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB)
587 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS)
588
589unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT)
590 cp $^ $@
591
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000592# - optional modules (requiring other software to be installed)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000593bsddb185$(MODULE.EXT): $(OUT)bsddbmodule$O $(OUT)bsddb185_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000594 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -ldb $(LIBS)
595
596crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
597 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS)
598
599# The _curses_panel module requires a couple of ncurses library entry
600# points, which are best exposed as exports from the _curses module DLL
601$(OUT)_curses_m.def:
602 @echo Creating .DEF file: $@
603 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000604 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODLIB.EXT))$(DQUOTE) >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000605 @echo DATA MULTIPLE NONSHARED >>$@
606 @echo EXPORTS >>$@
607 @echo init_curses >>$@
608 @echo wnoutrefresh >>$@
609 @echo _nc_panelhook >>$@
610 @echo is_linetouched >>$@
611 @echo mvwin >>$@
612 @echo stdscr >>$@
613 @echo wtouchln >>$@
614
615$(OUT)_curses_panel_m.def:
616 @echo Creating .DEF file: $@
617 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
618 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
619 @echo DATA MULTIPLE NONSHARED >>$@
620 @echo IMPORTS >>$@
621 @echo _curses.wnoutrefresh >>$@
622 @echo _curses._nc_panelhook >>$@
623 @echo _curses.is_linetouched >>$@
624 @echo _curses.mvwin >>$@
625 @echo _curses.stdscr >>$@
626 @echo _curses.wtouchln >>$@
627 @echo EXPORTS >>$@
628 @echo init_curses_panel >>$@
629
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000630_curses$(MODLIB.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000631 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses
632
633# curses_panel needs to be renamed to be useful
634_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB)
635 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel
636
637_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT)
638 cp $^ $@
639
640dbm$(MODULE.EXT): $(OUT)dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB)
641 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
642
643gdbm$(MODULE.EXT): $(OUT)gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB)
644 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
645
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000646
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000647# Expat is now distributed with Python, so use the included version
648$(OUT)pyexpat$O: ../../Modules/pyexpat.c
649 $(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^
650$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c
651 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
652$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c
653 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
654$(OUT)xmltok$O: ../../Modules/expat/xmltok.c
655 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
656pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \
657 $(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB)
658 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000659
660readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
661 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses
662
663#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
664_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000665 $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000666 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
667
668zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
669 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz
670
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000671bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB)
672 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2
673
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000674# the test target
675test:
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000676 -find ../../Lib -name "*.py[co]" -exec rm {} ";"
677 -./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000678 ./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000679
680-include $(OUTBASE)python.dep