blob: 8ee63712006455ee396c6ac9be4bf4df64ea2f98 [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 MacIntyre4fffdff2002-08-18 06:26:33 +0000132# EMX's default number of file handles is 40, which is sometimes insufficient
133# (the tempfile regression test tries to create 100 temporary files)
134NFILES=250
135
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000136# Source file paths
137SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules
138# Python contains the central core, containing the builtins and interpreter.
139# Parser contains Python's Internal Parser and
140# Standalone Parser Generator Program (Shares Some of Python's Modules)
141# Objects contains Python Object Types
142# Modules contains extension Modules (Built-In or as Separate DLLs)
143
144# Unix shells tend to use "$" as delimiter for variable names.
145# Test for this behaviour and set $(BUCK) variable correspondigly ...
146__TMP__:=$(shell echo $$$$)
147ifeq ($(__TMP__),$$$$)
148 BUCK= $$
149 BRO= (
150 BRC= )
151else
152 BUCK= \$$
153 BRO= \(
154 BRC= \)
155endif
156# Compute the "double quote" variable
157__TMP__:=$(shell echo "")
158ifeq ($(__TMP__),"")
159 DQUOTE= "
160else
161 DQUOTE= \"
162endif
163
164# Include paths
165#INCLUDE= -I$(subst ;, -I, $(SRCPATH))
166INCLUDE= -I. -I../../Include
167
168# Path to search for .c files
169vpath %.c .;..;$(SRCPATH)
170
171# Top of the package tree
172TOP= ../../
173
174# Directory for output files
175OUTBASE= out/
176OUT= $(OUTBASE)$(MODE)/
177
178# Additional libraries
179LIBS= -lsocket
180
181# Utility macro: replacement for $^
182^^= $(filter-out %$A,$^)
183# Use $(L^) to link with all libraries specified as dependencies
184L^= $(addprefix -l,$(basename $(notdir $(filter %$A,$+))))
185
186# Build rules
187$(OUT)%$O: %.c
188 $(CC) $(CFLAGS.LIB) -c $< -o $@
189
190%.a:
191 $(LD) $(LDFLAGS.A) -o $@ $(^^) $(L^)
192
193%.dll:
194 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
195
196%.pyd: $(OUT)%module$O $(OUT)%_m.def
197 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(PYTHON.IMPLIB) $(LIBS)
198
199%.exe:
200 $(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^)
201
202%_m.def:
203 @echo Creating .DEF file: $@
204 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
205 ifeq ($(DESCRIPTION.$(notdir $*)$(MODULE.EXT)),)
206 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
207 else
208 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
209 endif
210 @echo DATA MULTIPLE NONSHARED >>$@
211 @echo EXPORTS >>$@
212 @echo init$(notdir $*) >>$@
213
214%.def:
215 @echo Creating .DEF file: $@
216 @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@
217 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@
Andrew MacIntyre23ec1dc2003-06-09 08:14:03 +0000218 @echo STACKSIZE 1572864 >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000219
220# Output file names
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000221PYTHON_VER= 2.4
222PYTHON_LIB= python24
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000223PYTHON.LIB= $(PYTHON_LIB)_s$A
224PYTHON.IMPLIB= $(PYTHON_LIB)$A
225ifeq ($(EXEOMF),yes)
226 PYTHON.EXEIMP= $(PYTHON.IMPLIB)
227 LDMODE.EXE= -Zomf
228else
229 PYTHON.EXEIMP= $(PYTHON_LIB).a
230 LDMODE.EXE =
231endif
232PYTHON.DLL= $(PYTHON_LIB).dll
233PYTHON.DEF= $(PYTHON_LIB).def
234PYTHON.EXE= python.exe
235PYTHONPM.EXE= pythonpm.exe
236PGEN.EXE= pgen.exe
237LIBRARY= $(PYTHON.LIB)
238LD_LIBRARY= $(PYTHON.IMPLIB)
239
240# Additional executable parameters
241EXETYPE.$(PYTHON.EXE)= WINDOWCOMPAT
242EXETYPE.$(PYTHONPM.EXE)= WINDOWAPI
243EXETYPE.$(PGEN.EXE)= WINDOWCOMPAT
244DESCRIPTION.$(PYTHON.EXE)= Python object-oriented programming language interpreter for OS/2
245DESCRIPTION.$(PYTHONPM.EXE)= $(DESCRIPTION.$(PYTHON.EXE))
246DESCRIPTION.$(PGEN.EXE)= Python object-oriented programming language parser generator for OS/2
247
248# Module descriptions
249DESCRIPTION.zlib$(MODULE.EXT)= Python Extension DLL for accessing the InfoZip compression library
250DESCRIPTION.crypt$(MODULE.EXT)= Python Extension DLL implementing the crypt$(BRO)$(BRC) function
251DESCRIPTION._tkinter$(MODULE.EXT)= Python Extension DLL for access to Tcl/Tk Environment
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000252DESCRIPTION.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 MacIntyre51578ae2003-12-02 12:21:20 +0000254DESCRIPTION._curses$(MODLIB.EXT)= Python Extension DLL for access to ncurses library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000255DESCRIPTION.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 \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000272 Modules/collectionsmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000273 Modules/cPickle.c \
274 Modules/cStringIO.c \
275 Modules/_csv.c \
276 Modules/datetimemodule.c \
277 Modules/dlmodule.c \
278 Modules/errnomodule.c \
279 Modules/fcntlmodule.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000280 Modules/_heapqmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000281 Modules/imageop.c \
282 Modules/itertoolsmodule.c \
283 Modules/_localemodule.c \
284 Modules/mathmodule.c \
285 Modules/md5c.c \
286 Modules/md5module.c \
287 Modules/operator.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000288 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 \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000301 Modules/xxsubtype.c \
302 Modules/zipimport.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000303SRC.PARSE1= $(addprefix $(TOP), \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000304 Parser/acceler.c \
305 Parser/grammar1.c \
306 Parser/listnode.c \
307 Parser/node.c \
308 Parser/parser.c \
309 Parser/parsetok.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000310 Parser/bitset.c \
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000311 Parser/metagrammar.c)
312SRC.PARSE2= $(addprefix $(TOP), \
313 Parser/tokenizer.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000314 Parser/myreadline.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000315SRC.PARSER= $(SRC.PARSE1) \
316 $(SRC.PARSE2)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000317SRC.PYTHON= $(addprefix $(TOP), \
318 Python/bltinmodule.c \
319 Python/exceptions.c \
320 Python/ceval.c \
321 Python/compile.c \
322 Python/codecs.c \
323 Python/errors.c \
324 Python/frozen.c \
325 Python/frozenmain.c \
326 Python/future.c \
327 Python/getargs.c \
328 Python/getcompiler.c \
329 Python/getcopyright.c \
330 Python/getmtime.c \
331 Python/getplatform.c \
332 Python/getversion.c \
333 Python/graminit.c \
334 Python/import.c \
335 Python/importdl.c \
336 Python/marshal.c \
337 Python/modsupport.c \
338 Python/mysnprintf.c \
339 Python/mystrtoul.c \
340 Python/pyfpe.c \
341 Python/pystate.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000342 Python/pystrtod.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000343 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 \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000366 Objects/genobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000367 Objects/intobject.c \
368 Objects/iterobject.c \
369 Objects/listobject.c \
370 Objects/longobject.c \
371 Objects/methodobject.c \
372 Objects/moduleobject.c \
373 Objects/object.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000374 Objects/obmalloc.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000375 Objects/rangeobject.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000376 Objects/setobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000377 Objects/sliceobject.c \
378 Objects/stringobject.c \
379 Objects/structseq.c \
380 Objects/tupleobject.c \
381 Objects/typeobject.c \
382 Objects/unicodeobject.c \
383 Objects/unicodectype.c \
384 Objects/weakrefobject.c)
385
386SRC.LIB= $(SRC.OS2EMX) \
387 $(SRC.MAIN) \
388 $(SRC.PARSER) \
389 $(SRC.OBJECT) \
390 $(SRC.PYTHON) \
391 $(SRC.MODULES)
392OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
393
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000394SRC.PGEN= $(SRC.PARSE1) \
395 $(addprefix $(TOP), \
396 Objects/obmalloc.c) \
397 $(addprefix $(TOP), \
398 Python/mysnprintf.c) \
399 $(addprefix $(TOP), \
400 Parser/tokenizer_pgen.c \
401 Parser/pgenmain.c \
402 Parser/pgen.c \
403 Parser/printgrammar.c \
404 Parser/grammar.c \
405 Parser/firstsets.c) \
406
407OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
408
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000409SRC.EXE= $(TOP)Modules/python.c
410SRC.PMEXE= pythonpm.c
411
412# Python modules to be dynamically loaded that:
413# 1) have only single source file and require no extra libs
414# 2) use the standard module naming convention
415# (the 'module' in ?????module.c is assumed)
416# - these can be built with implicit rules
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000417EASYEXTMODULES= fpectl \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000418 fpetest \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000419 parser \
420 pwd \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000421 select
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000422
423# Python modules to be dynamically loaded that need explicit build rules
424# (either multiple source files and/or non-standard module naming)
425# (NOTE: use shortened names for modules affected by 8 char name limit)
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000426HARDEXTMODULES= _hotshot \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000427 _socket \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000428 _testcap \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000429 unicoded
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000430
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000431# Python modules that are used as libraries and therefore must use
432# a .DLL extension
433LIBEXTMODULES=
434
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000435# Python external ($(MODULE.EXT)) modules - can be EASY or HARD
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000436ifeq ($(HAVE_ZLIB),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000437 HARDEXTMODULES+= zlib
438endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000439ifeq ($(HAVE_UFC),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000440 HARDEXTMODULES+= crypt
441endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000442ifeq ($(HAVE_TCLTK),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000443 HARDEXTMODULES+= _tkinter
444 CFLAGS+= -DHAS_DIRENT -I/TclTk80/include
445 TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80
446endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000447ifeq ($(HAVE_GREADLINE),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000448 HARDEXTMODULES+= readline
449endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000450ifeq ($(HAVE_BSDDB),yes)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000451 HARDEXTMODULES+= bsddb185
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000452endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000453ifeq ($(HAVE_NCURSES),yes)
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000454 LIBEXTMODULES+= _curses
455 HARDEXTMODULES+= _curses_
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000456endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000457ifeq ($(HAVE_GDBM),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000458 HARDEXTMODULES+= gdbm dbm
459endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000460ifeq ($(HAVE_BZ2),yes)
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000461 HARDEXTMODULES+= bz2
462endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000463
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000464# Expat is now distributed with the Python source
465HARDEXTMODULES+= pyexpat
466EXPAT.INC= -I../../Modules/expat
467EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \
Andrew MacIntyre4d046392003-12-25 13:25:20 +0000468 -DXML_CONTENT_BYTES=1024 -DHAVE_MEMMOVE=1 -DHAVE_BCOPY=1
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000469EXPAT.SRC= $(addprefix ../../Modules/expat/, \
470 xmlparse.c \
471 xmlrole.c \
472 xmltok.c)
473
474# all the external modules
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000475EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES)))
476EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000477EXTERNDLLS+= $(addsuffix $(MODLIB.EXT),$(patsubst %module,%,$(LIBEXTMODULES)))
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000478
479# Targets
480all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000481 python_noncore
482
483python_noncore:
484 make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000485
486clean:
487 rm -f $(OUT)*
488 rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000489 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) *.dll
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000490 find ../../Lib -name "*.py[co]" -exec rm {} ";"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000491
492lx:
493 @echo Packing everything with lxLite...
494 lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
495
496depend: $(OUTBASE)
497 makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
498 -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
499
500$(OUT): $(OUTBASE)
501
502$(OUT) $(OUTBASE):
503 mkdir.exe $@
504
505$(PYTHON.LIB): $(OBJ.LIB)
506 rm.exe -f $@
507 $(AR) $(ARFLAGS) $@ $^
508
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000509# the Python core DLL .def file needs to have a number of non-static
510# symbols that aren't part of the Python C API removed (commented out)
511# from the DLL export list.
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000512$(PYTHON.DEF): $(PYTHON.LIB)
513 @echo Creating .DEF file: $@
514 @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
515 @echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
516 @echo PROTMODE >>$@
517 @echo DATA MULTIPLE NONSHARED >>$@
518 @echo EXPORTS >>$@
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000519 $(EXPLIB) -u $(PYTHON.LIB) |\
Andrew MacIntyrebac1ea92003-07-16 13:31:11 +0000520 sed -e "/^ .init.*/s/^ /; /" \
521 -e "/^ .pcre_.*/s/^ /; /" \
522 -e "/^ .array_methods/s/^ /; /" \
523 -e "/^ .fast_save_leave/s/^ /; /" \
524 -e "/^ .dlopen/s/^ /; /" \
525 -e "/^ .dlsym/s/^ /; /" \
526 -e "/^ .dlclose/s/^ /; /" \
527 -e "/^ .dlerror/s/^ /; /" \
528 -e "/^ ._Py_re_.*/s/^ /; /" \
529 -e "/^ ._Py_MD5.*/s/^ /; /" >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000530
531$(PYTHON.IMPLIB): $(PYTHON.DEF)
532 $(IMPLIB) -o $@ $^
533
534$(PYTHON.EXEIMP): $(PYTHON.DEF)
535 $(IMPLIB) -o $@ $^
536
537$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF)
538
539# Explicit make targets for the .EXEs to be able to use LD to link
540# (so that fork() will work if required)
541
542$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
543 $(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 +0000544 $(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000545
546$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def
547 $(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 +0000548 $(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000549
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000550$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000551
552# Explicit building instructions for those external modules that require
553# awkward handling (due e.g. to non-std naming, or multiple source files)
554# - standard modules
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000555
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000556_hotshot$(MODULE.EXT): $(OUT)_hotshot$O $(OUT)_hotshot_m.def $(PYTHON.IMPLIB)
557 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
558
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000559_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
560 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
561
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000562# _testcapi needs to be renamed to be useful
563_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB)
564 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
565
566_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT)
567 cp $^ $@
568
569# unicodedata needs to be renamed to be useful
570unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB)
571 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS)
572
573unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT)
574 cp $^ $@
575
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000576# - optional modules (requiring other software to be installed)
Andrew MacIntyree7a8cad2002-12-04 12:37:17 +0000577bsddb185$(MODULE.EXT): $(OUT)bsddbmodule$O $(OUT)bsddb185_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000578 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -ldb $(LIBS)
579
580crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
581 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS)
582
583# The _curses_panel module requires a couple of ncurses library entry
584# points, which are best exposed as exports from the _curses module DLL
585$(OUT)_curses_m.def:
586 @echo Creating .DEF file: $@
587 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000588 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODLIB.EXT))$(DQUOTE) >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000589 @echo DATA MULTIPLE NONSHARED >>$@
590 @echo EXPORTS >>$@
591 @echo init_curses >>$@
592 @echo wnoutrefresh >>$@
593 @echo _nc_panelhook >>$@
594 @echo is_linetouched >>$@
595 @echo mvwin >>$@
596 @echo stdscr >>$@
597 @echo wtouchln >>$@
598
599$(OUT)_curses_panel_m.def:
600 @echo Creating .DEF file: $@
601 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
602 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
603 @echo DATA MULTIPLE NONSHARED >>$@
604 @echo IMPORTS >>$@
605 @echo _curses.wnoutrefresh >>$@
606 @echo _curses._nc_panelhook >>$@
607 @echo _curses.is_linetouched >>$@
608 @echo _curses.mvwin >>$@
609 @echo _curses.stdscr >>$@
610 @echo _curses.wtouchln >>$@
611 @echo EXPORTS >>$@
612 @echo init_curses_panel >>$@
613
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000614_curses$(MODLIB.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000615 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses
616
617# curses_panel needs to be renamed to be useful
618_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB)
619 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel
620
621_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT)
622 cp $^ $@
623
624dbm$(MODULE.EXT): $(OUT)dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB)
625 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
626
627gdbm$(MODULE.EXT): $(OUT)gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB)
628 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
629
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000630
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000631# Expat is now distributed with Python, so use the included version
632$(OUT)pyexpat$O: ../../Modules/pyexpat.c
633 $(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^
634$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c
635 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
636$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c
637 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
638$(OUT)xmltok$O: ../../Modules/expat/xmltok.c
639 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
640pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \
641 $(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB)
642 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000643
644readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
645 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses
646
647#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
648_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000649 $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000650 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
651
652zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
653 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz
654
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000655bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB)
656 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2
657
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000658# the test target
659test:
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000660 -find ../../Lib -name "*.py[co]" -exec rm {} ";"
661 -./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000662 ./python -E -tt ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000663
664-include $(OUTBASE)python.dep