blob: 800610e53e35c90dc73b12f6fa489e87a575fee1 [file] [log] [blame]
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +00001#####################==================----------------
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00002#
Christian Heimes292d3512008-02-03 16:51:08 +00003# Top-Level Makefile for Building Python 2.6 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
Christian Heimes292d3512008-02-03 16:51:08 +00005# Modified by Andrew MacIntyre, <andymac@pcug.org.au> for Python 2.6
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#
Christian Heimes292d3512008-02-03 16:51:08 +000010# The output of the build is a largish Python26.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
Christian Heimes292d3512008-02-03 16:51:08 +000013# Python26.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
Andrew MacIntyre744b3132005-02-17 12:44:51 +000062# Do you have the OpenSSL libraries installed
63HAVE_OPENSSL= no
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000064
65# === install locations ===
66# default value of PYTHONHOME
Christian Heimes292d3512008-02-03 16:51:08 +000067LIB_DIR=C:/Python26
Andrew MacIntyred4c9b162003-04-21 14:28:01 +000068# default is to have everything in or under PYTHONHOME
69EXE_DIR=$(LIB_DIR)
70DLL_DIR=$(EXE_DIR)
71
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000072
73# === The Tools ===
74CC= gcc
75CFLAGS= -Zmt -Wall $(INCLUDE)
76CFLAGS.LIB= $(CFLAGS)
77LD= gcc
78LDFLAGS= -Zmt -Zcrtdll -L. -lgcc
79LDFLAGS.EXE= $(LDFLAGS)
80LDFLAGS.DLL= $(LDFLAGS) -Zdll
81LDFLAGS.A= $(LDFLAGS) $(LIBS)
82ARFLAGS= crs
83IMPLIB= emximp
84EXPLIB= emxexp
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +000085EXEOPT= emxbind
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +000086PY_DEF= -DPy_BUILD_CORE
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +000087
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000088
89# adjust C compiler settings based on build options
90ifeq ($(MODE),debug)
91 CFLAGS+= -g -O
92 LDFLAGS+= -g
93else
Andrew MacIntyre51578ae2003-12-02 12:21:20 +000094 CFLAGS+= -s -O3 -fomit-frame-pointer -mprobe
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000095 LDFLAGS+= -s
96endif
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +000097CFLAGS+= $(PY_DEF)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +000098ifeq ($(ASSERTIONS),no)
99 CFLAGS+= -DNDEBUG
100endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000101ifeq ($(FIXED_PYHOME),yes)
102 CFLAGS+= -DPREFIX=$(DQUOTE)$(LIB_DIR)$(DQUOTE)
103endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000104
105# We're using the OMF format since EMX's ld has a obscure bug
106# because of which it sometimes fails to build relocations
107# in .data segment that point to another .data locations
108# (except for the final linking if the .EXEs)
109OMF= yes
110
111# if fork() support is required, the main executable must be linked with ld
112EXEOMF= no
113
114# File extensions
115MODULE.EXT= .pyd
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000116MODLIB.EXT= .dll
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000117ifeq ($(OMF),yes)
118 O= .obj
119 A= .lib
120 AR= emxomfar
121 CFLAGS+= -Zomf
122 LDFLAGS+= -Zomf
123 ifeq ($(MODE),debug)
124 ARFLAGS= -p64 crs
125 else
126 ARFLAGS= -p32 crs
127 endif
128else
129 O= .o
130 A= .a
131 AR= ar
132endif
133
Andrew MacIntyreff59f3c2005-01-17 12:18:12 +0000134
135# === Build time resource settings ===
136
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000137# EMX's default number of file handles is 40, which is sometimes insufficient
138# (the tempfile regression test tries to create 100 temporary files)
139NFILES=250
140
Andrew MacIntyreff59f3c2005-01-17 12:18:12 +0000141# The default stack size for child threads is 64k bytes, which is
142# insufficient for some applications which do a lot of work in threads
143# (such as Zope, especially in conjunction with Plone).
144# Note that this setting is distinct from the stack size for the main
145# thread, which is set via the %.def rule below.
146# EMX documents that the thread stack size should be at least 32768 bytes;
147# for Zope/Plone at least 128k bytes is recommended.
148# Uncomment & adjust the next line to override the default stack size:
149#CFLAGS+= -DTHREAD_STACK_SIZE=0x20000
150
151
152# === The environment ===
153
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000154# Source file paths
155SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules
156# Python contains the central core, containing the builtins and interpreter.
157# Parser contains Python's Internal Parser and
158# Standalone Parser Generator Program (Shares Some of Python's Modules)
159# Objects contains Python Object Types
160# Modules contains extension Modules (Built-In or as Separate DLLs)
161
162# Unix shells tend to use "$" as delimiter for variable names.
163# Test for this behaviour and set $(BUCK) variable correspondigly ...
164__TMP__:=$(shell echo $$$$)
165ifeq ($(__TMP__),$$$$)
166 BUCK= $$
167 BRO= (
168 BRC= )
169else
170 BUCK= \$$
171 BRO= \(
172 BRC= \)
173endif
174# Compute the "double quote" variable
175__TMP__:=$(shell echo "")
176ifeq ($(__TMP__),"")
177 DQUOTE= "
178else
179 DQUOTE= \"
180endif
181
182# Include paths
183#INCLUDE= -I$(subst ;, -I, $(SRCPATH))
184INCLUDE= -I. -I../../Include
185
186# Path to search for .c files
187vpath %.c .;..;$(SRCPATH)
188
189# Top of the package tree
190TOP= ../../
191
192# Directory for output files
193OUTBASE= out/
194OUT= $(OUTBASE)$(MODE)/
195
196# Additional libraries
197LIBS= -lsocket
198
199# Utility macro: replacement for $^
200^^= $(filter-out %$A,$^)
201# Use $(L^) to link with all libraries specified as dependencies
202L^= $(addprefix -l,$(basename $(notdir $(filter %$A,$+))))
203
204# Build rules
205$(OUT)%$O: %.c
206 $(CC) $(CFLAGS.LIB) -c $< -o $@
207
208%.a:
209 $(LD) $(LDFLAGS.A) -o $@ $(^^) $(L^)
210
211%.dll:
212 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
213
214%.pyd: $(OUT)%module$O $(OUT)%_m.def
215 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(PYTHON.IMPLIB) $(LIBS)
216
217%.exe:
218 $(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^)
219
220%_m.def:
221 @echo Creating .DEF file: $@
222 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
223 ifeq ($(DESCRIPTION.$(notdir $*)$(MODULE.EXT)),)
224 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
225 else
226 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
227 endif
228 @echo DATA MULTIPLE NONSHARED >>$@
229 @echo EXPORTS >>$@
230 @echo init$(notdir $*) >>$@
231
232%.def:
233 @echo Creating .DEF file: $@
234 @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@
235 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@
Andrew MacIntyreff59f3c2005-01-17 12:18:12 +0000236 @echo STACKSIZE 2097152 >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000237
238# Output file names
Christian Heimes292d3512008-02-03 16:51:08 +0000239PYTHON_VER= 2.6
Georg Brandlfa2c61a2011-02-20 10:41:31 +0000240PYTHON_LIB= python33
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000241PYTHON.LIB= $(PYTHON_LIB)_s$A
242PYTHON.IMPLIB= $(PYTHON_LIB)$A
243ifeq ($(EXEOMF),yes)
244 PYTHON.EXEIMP= $(PYTHON.IMPLIB)
245 LDMODE.EXE= -Zomf
246else
247 PYTHON.EXEIMP= $(PYTHON_LIB).a
248 LDMODE.EXE =
249endif
250PYTHON.DLL= $(PYTHON_LIB).dll
251PYTHON.DEF= $(PYTHON_LIB).def
252PYTHON.EXE= python.exe
253PYTHONPM.EXE= pythonpm.exe
254PGEN.EXE= pgen.exe
255LIBRARY= $(PYTHON.LIB)
256LD_LIBRARY= $(PYTHON.IMPLIB)
257
258# Additional executable parameters
259EXETYPE.$(PYTHON.EXE)= WINDOWCOMPAT
260EXETYPE.$(PYTHONPM.EXE)= WINDOWAPI
261EXETYPE.$(PGEN.EXE)= WINDOWCOMPAT
262DESCRIPTION.$(PYTHON.EXE)= Python object-oriented programming language interpreter for OS/2
263DESCRIPTION.$(PYTHONPM.EXE)= $(DESCRIPTION.$(PYTHON.EXE))
264DESCRIPTION.$(PGEN.EXE)= Python object-oriented programming language parser generator for OS/2
265
266# Module descriptions
267DESCRIPTION.zlib$(MODULE.EXT)= Python Extension DLL for accessing the InfoZip compression library
268DESCRIPTION.crypt$(MODULE.EXT)= Python Extension DLL implementing the crypt$(BRO)$(BRC) function
269DESCRIPTION._tkinter$(MODULE.EXT)= Python Extension DLL for access to Tcl/Tk Environment
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000270DESCRIPTION.readline$(MODULE.EXT)= Python Extension DLL for access to GNU ReadLine library
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000271DESCRIPTION._curses$(MODLIB.EXT)= Python Extension DLL for access to ncurses library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000272DESCRIPTION.pyexpat$(MODULE.EXT)= Python Extension DLL for access to expat library
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000273DESCRIPTION.bz2$(MODULE.EXT)= Python Extension DLL for accessing the bz2 compression library
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000274
275# Source files
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000276SRC.OS2EMX= config.c dlfcn.c getpathp.c
277SRC.MAIN= $(addprefix $(TOP), \
278 Modules/getbuildinfo.c \
279 Modules/main.c)
280SRC.MODULES= $(addprefix $(TOP), \
281 Modules/gcmodule.c \
282 Modules/signalmodule.c \
283 Modules/posixmodule.c \
Georg Brandl2067bfd2008-05-25 13:05:15 +0000284 Modules/_threadmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000285 Modules/arraymodule.c \
286 Modules/binascii.c \
287 Modules/cmathmodule.c \
288 Modules/_codecsmodule.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000289 Modules/collectionsmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000290 Modules/_csv.c \
291 Modules/datetimemodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000292 Modules/errnomodule.c \
293 Modules/fcntlmodule.c \
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000294 Modules/_functoolsmodule.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000295 Modules/_heapqmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000296 Modules/imageop.c \
297 Modules/itertoolsmodule.c \
298 Modules/_localemodule.c \
299 Modules/mathmodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000300 Modules/operator.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000301 Modules/_randommodule.c \
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000302 Modules/sha256module.c \
303 Modules/sha512module.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000304 Modules/_sre.c \
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000305 Modules/_struct.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000306 Modules/symtablemodule.c \
307 Modules/termios.c \
308 Modules/timemodule.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000309 Modules/_weakref.c \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000310 Modules/xxsubtype.c \
311 Modules/zipimport.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000312SRC.PARSE1= $(addprefix $(TOP), \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000313 Parser/acceler.c \
314 Parser/grammar1.c \
315 Parser/listnode.c \
316 Parser/node.c \
317 Parser/parser.c \
318 Parser/parsetok.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000319 Parser/bitset.c \
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000320 Parser/metagrammar.c)
321SRC.PARSE2= $(addprefix $(TOP), \
322 Parser/tokenizer.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000323 Parser/myreadline.c)
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000324SRC.PARSER= $(SRC.PARSE1) \
325 $(SRC.PARSE2)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000326SRC.PYTHON= $(addprefix $(TOP), \
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000327 Python/Python-ast.c \
328 Python/asdl.c \
329 Python/ast.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000330 Python/bltinmodule.c \
331 Python/exceptions.c \
332 Python/ceval.c \
333 Python/compile.c \
334 Python/codecs.c \
Jeffrey Yasskin39370832010-05-03 19:29:34 +0000335 Python/dynamic_annotations.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000336 Python/errors.c \
337 Python/frozen.c \
338 Python/frozenmain.c \
339 Python/future.c \
340 Python/getargs.c \
341 Python/getcompiler.c \
342 Python/getcopyright.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000343 Python/getplatform.c \
344 Python/getversion.c \
345 Python/graminit.c \
346 Python/import.c \
347 Python/importdl.c \
348 Python/marshal.c \
349 Python/modsupport.c \
350 Python/mysnprintf.c \
351 Python/mystrtoul.c \
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000352 Python/pyarena.c \
Eric Smith6dc46f52009-04-27 20:39:49 +0000353 Python/pyctype.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000354 Python/pyfpe.c \
355 Python/pystate.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000356 Python/pystrtod.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000357 Python/pythonrun.c \
358 Python/structmember.c \
359 Python/symtable.c \
360 Python/sysmodule.c \
361 Python/traceback.c \
362 Python/getopt.c \
363 Python/dynload_shlib.c \
364 Python/thread.c)
365SRC.OBJECT= $(addprefix $(TOP), \
366 Objects/abstract.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000367 Objects/boolobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000368 Objects/cellobject.c \
369 Objects/classobject.c \
370 Objects/cobject.c \
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000371 Objects/codeobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000372 Objects/complexobject.c \
373 Objects/descrobject.c \
374 Objects/dictobject.c \
Andrew MacIntyre07c639f2002-04-30 13:06:32 +0000375 Objects/enumobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000376 Objects/fileobject.c \
377 Objects/floatobject.c \
378 Objects/frameobject.c \
379 Objects/funcobject.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000380 Objects/genobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000381 Objects/iterobject.c \
382 Objects/listobject.c \
383 Objects/longobject.c \
384 Objects/methodobject.c \
385 Objects/moduleobject.c \
386 Objects/object.c \
Andrew MacIntyre6c655312002-04-15 12:09:45 +0000387 Objects/obmalloc.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000388 Objects/rangeobject.c \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000389 Objects/setobject.c \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000390 Objects/sliceobject.c \
391 Objects/stringobject.c \
392 Objects/structseq.c \
393 Objects/tupleobject.c \
394 Objects/typeobject.c \
395 Objects/unicodeobject.c \
396 Objects/unicodectype.c \
397 Objects/weakrefobject.c)
398
399SRC.LIB= $(SRC.OS2EMX) \
400 $(SRC.MAIN) \
401 $(SRC.PARSER) \
402 $(SRC.OBJECT) \
403 $(SRC.PYTHON) \
404 $(SRC.MODULES)
405OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
406
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000407SRC.PGEN= $(SRC.PARSE1) \
408 $(addprefix $(TOP), \
409 Objects/obmalloc.c) \
410 $(addprefix $(TOP), \
411 Python/mysnprintf.c) \
412 $(addprefix $(TOP), \
413 Parser/tokenizer_pgen.c \
414 Parser/pgenmain.c \
415 Parser/pgen.c \
416 Parser/printgrammar.c \
417 Parser/grammar.c \
418 Parser/firstsets.c) \
Guido van Rossum0cb85a92007-08-07 22:09:52 +0000419
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000420OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
421
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000422SRC.EXE= $(TOP)Modules/python.c
423SRC.PMEXE= pythonpm.c
424
425# Python modules to be dynamically loaded that:
426# 1) have only single source file and require no extra libs
427# 2) use the standard module naming convention
428# (the 'module' in ?????module.c is assumed)
429# - these can be built with implicit rules
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000430EASYEXTMODULES= fpectl \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000431 fpetest \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000432 parser \
433 pwd \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000434 select
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000435
436# Python modules to be dynamically loaded that need explicit build rules
437# (either multiple source files and/or non-standard module naming)
438# (NOTE: use shortened names for modules affected by 8 char name limit)
Neal Norwitzc05d3842007-10-13 18:56:00 +0000439HARDEXTMODULES= _socket \
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000440 _testcap \
Andrew MacIntyre631e87f2003-04-21 14:33:04 +0000441 unicoded
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000442
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000443# Python modules that are used as libraries and therefore must use
444# a .DLL extension
445LIBEXTMODULES=
446
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000447# Python external ($(MODULE.EXT)) modules - can be EASY or HARD
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000448ifeq ($(HAVE_ZLIB),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000449 HARDEXTMODULES+= zlib
450endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000451ifeq ($(HAVE_UFC),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000452 HARDEXTMODULES+= crypt
453endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000454ifeq ($(HAVE_TCLTK),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000455 HARDEXTMODULES+= _tkinter
456 CFLAGS+= -DHAS_DIRENT -I/TclTk80/include
457 TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80
458endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000459ifeq ($(HAVE_GREADLINE),yes)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000460 HARDEXTMODULES+= readline
461endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000462ifeq ($(HAVE_NCURSES),yes)
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000463 LIBEXTMODULES+= _curses
464 HARDEXTMODULES+= _curses_
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000465endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000466ifeq ($(HAVE_GDBM),yes)
Georg Brandl0a7ac7d2008-05-26 10:29:35 +0000467 HARDEXTMODULES+= _gdbm _dbm
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000468endif
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000469ifeq ($(HAVE_BZ2),yes)
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000470 HARDEXTMODULES+= bz2
471endif
Andrew MacIntyre744b3132005-02-17 12:44:51 +0000472ifeq ($(HAVE_OPENSSL),yes)
473 HARDEXTMODULES+= _ssl
474endif
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000475
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000476# Expat is now distributed with the Python source
477HARDEXTMODULES+= pyexpat
478EXPAT.INC= -I../../Modules/expat
479EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \
Andrew MacIntyre4d046392003-12-25 13:25:20 +0000480 -DXML_CONTENT_BYTES=1024 -DHAVE_MEMMOVE=1 -DHAVE_BCOPY=1
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000481EXPAT.SRC= $(addprefix ../../Modules/expat/, \
482 xmlparse.c \
483 xmlrole.c \
484 xmltok.c)
485
486# all the external modules
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000487EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES)))
488EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000489EXTERNDLLS+= $(addsuffix $(MODLIB.EXT),$(patsubst %module,%,$(LIBEXTMODULES)))
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000490
491# Targets
492all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000493 python_noncore
494
495python_noncore:
496 make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000497
498clean:
499 rm -f $(OUT)*
500 rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
Andrew MacIntyre378d3c02004-07-07 13:55:25 +0000501 $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) *.dll
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000502 find ../../Lib -name "*.py[co]" -exec rm {} ";"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000503
504lx:
505 @echo Packing everything with lxLite...
506 lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
507
508depend: $(OUTBASE)
509 makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
510 -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
511
512$(OUT): $(OUTBASE)
513
514$(OUT) $(OUTBASE):
515 mkdir.exe $@
516
517$(PYTHON.LIB): $(OBJ.LIB)
518 rm.exe -f $@
519 $(AR) $(ARFLAGS) $@ $^
520
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000521# the Python core DLL .def file needs to have a number of non-static
522# symbols that aren't part of the Python C API removed (commented out)
523# from the DLL export list.
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000524$(PYTHON.DEF): $(PYTHON.LIB)
525 @echo Creating .DEF file: $@
526 @echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
527 @echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
528 @echo PROTMODE >>$@
529 @echo DATA MULTIPLE NONSHARED >>$@
530 @echo EXPORTS >>$@
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000531 $(EXPLIB) -u $(PYTHON.LIB) |\
Andrew MacIntyrebac1ea92003-07-16 13:31:11 +0000532 sed -e "/^ .init.*/s/^ /; /" \
533 -e "/^ .pcre_.*/s/^ /; /" \
534 -e "/^ .array_methods/s/^ /; /" \
535 -e "/^ .fast_save_leave/s/^ /; /" \
536 -e "/^ .dlopen/s/^ /; /" \
537 -e "/^ .dlsym/s/^ /; /" \
538 -e "/^ .dlclose/s/^ /; /" \
539 -e "/^ .dlerror/s/^ /; /" \
540 -e "/^ ._Py_re_.*/s/^ /; /" \
541 -e "/^ ._Py_MD5.*/s/^ /; /" >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000542
543$(PYTHON.IMPLIB): $(PYTHON.DEF)
544 $(IMPLIB) -o $@ $^
545
546$(PYTHON.EXEIMP): $(PYTHON.DEF)
547 $(IMPLIB) -o $@ $^
548
549$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF)
550
551# Explicit make targets for the .EXEs to be able to use LD to link
552# (so that fork() will work if required)
553
554$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
555 $(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 +0000556 $(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000557
558$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def
559 $(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 +0000560 $(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000561
Andrew MacIntyre4fffdff2002-08-18 06:26:33 +0000562$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000563
564# Explicit building instructions for those external modules that require
565# awkward handling (due e.g. to non-std naming, or multiple source files)
566# - standard modules
Andrew MacIntyred4c9b162003-04-21 14:28:01 +0000567
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000568_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
569 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
570
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000571# _testcapi needs to be renamed to be useful
572_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB)
573 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
574
575_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT)
576 cp $^ $@
577
578# unicodedata needs to be renamed to be useful
579unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB)
580 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS)
581
582unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT)
583 cp $^ $@
584
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000585crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
586 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS)
587
588# The _curses_panel module requires a couple of ncurses library entry
589# points, which are best exposed as exports from the _curses module DLL
590$(OUT)_curses_m.def:
591 @echo Creating .DEF file: $@
592 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000593 @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODLIB.EXT))$(DQUOTE) >>$@
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000594 @echo DATA MULTIPLE NONSHARED >>$@
595 @echo EXPORTS >>$@
596 @echo init_curses >>$@
597 @echo wnoutrefresh >>$@
598 @echo _nc_panelhook >>$@
599 @echo is_linetouched >>$@
600 @echo mvwin >>$@
601 @echo stdscr >>$@
602 @echo wtouchln >>$@
603
604$(OUT)_curses_panel_m.def:
605 @echo Creating .DEF file: $@
606 @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
607 @echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
608 @echo DATA MULTIPLE NONSHARED >>$@
609 @echo IMPORTS >>$@
610 @echo _curses.wnoutrefresh >>$@
611 @echo _curses._nc_panelhook >>$@
612 @echo _curses.is_linetouched >>$@
613 @echo _curses.mvwin >>$@
614 @echo _curses.stdscr >>$@
615 @echo _curses.wtouchln >>$@
616 @echo EXPORTS >>$@
617 @echo init_curses_panel >>$@
618
Andrew MacIntyre51578ae2003-12-02 12:21:20 +0000619_curses$(MODLIB.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000620 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses
621
622# curses_panel needs to be renamed to be useful
623_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB)
624 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel
625
626_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT)
627 cp $^ $@
628
Georg Brandl0a7ac7d2008-05-26 10:29:35 +0000629_dbm$(MODULE.EXT): $(OUT)_dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000630 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
631
Georg Brandl0a7ac7d2008-05-26 10:29:35 +0000632_gdbm$(MODULE.EXT): $(OUT)_gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000633 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
634
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000635
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000636# Expat is now distributed with Python, so use the included version
637$(OUT)pyexpat$O: ../../Modules/pyexpat.c
638 $(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^
639$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c
640 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
641$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c
642 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
643$(OUT)xmltok$O: ../../Modules/expat/xmltok.c
644 $(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
645pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \
646 $(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB)
647 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000648
649readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
650 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses
651
652#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
653_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
Andrew MacIntyre4ee893f2003-07-13 13:41:59 +0000654 $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000655 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
656
657zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
658 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz
659
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000660bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB)
661 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2
662
Andrew MacIntyre744b3132005-02-17 12:44:51 +0000663_ssl$(MODULE.EXT): $(OUT)_ssl$O $(OUT)_ssl_m.def $(PYTHON.IMPLIB)
664 $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lssl -lcrypto
665
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000666# the test target
667test:
Andrew MacIntyre978697b2002-12-31 11:18:08 +0000668 -find ../../Lib -name "*.py[co]" -exec rm {} ";"
Georg Brandle1b5ac62008-06-04 13:06:58 +0000669 -./python -E ../../lib/test/regrtest.py -l -u "network"
670 ./python -E ../../lib/test/regrtest.py -l -u "network"
Andrew MacIntyre41d97d62002-02-17 05:23:30 +0000671
672-include $(OUTBASE)python.dep