home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pytho152.zip / emx / src / Python / PC / os2emx / Makefile < prev   
Encoding:
Makefile  |  2000-08-10  |  8.7 KB  |  281 lines

  1. #####################==================----------------·············
  2. #
  3. # Top-Level Makefile for Building Python for OS/2 using GCC/EMX
  4. # Written by Andrew Zabolotny, <bit@eltech.ru>
  5. #
  6. # This makefile was developed for use with [P]GCC/EMX compiler any
  7. # version and GNU Make.
  8. #
  9. # The output of the build is a largish Python15.DLL containing the
  10. # essential modules of Python and a small Python.exe program to start
  11. # the interpreter. When embedding Python within another program, only
  12. # Python15.DLL is needed. We also build python_s.a static library (which
  13. # can be converted into OMF (.lib) format using emxomf tool) and an
  14. # python.a import library.
  15. #
  16. # Recommended build order:
  17. #   make depend        (if you have makedep)
  18. #   make all
  19. #   make lx        (if you have lxlite)
  20. #   make test        (optional)
  21. #
  22. #####################==================----------------·············
  23.  
  24. # Compilation mode: debug or release
  25. MODE = optimize
  26.  
  27. # Do you have the InfoZip compression library installed?
  28. ZLIB = yes
  29. # Do you have the Ultra Fast Crypt (UFC) library installed?
  30. UFC = yes
  31. # Do you have the Tcl/Tk library installed?
  32. TCLTK = no
  33. # Do you have the GNU multiprecision library installed?
  34. GMPZ = no
  35. # Do you have the GNU readline library installed?
  36. # NOTE: I'm using my own port of GNU readline library
  37. # that is a part of my port of GNU Bash to OS/2. If you're using
  38. # Kai Uwe Rommel's port (gnureadl.zip) you will have to add several
  39. # functions to his .def file since not all functions that Python
  40. # module requires are exported.
  41. GREADLINE = yes
  42.  
  43. # The Tools
  44. CC = gcc
  45. CFLAGS = -Zmt -Wall $(INCLUDE)
  46. LD = gcc
  47. LDFLAGS = -Zmt -Zcrtdll -L. -lgcc
  48. LDFLAGS.EXE = $(LDFLAGS)
  49. LDFLAGS.DLL = $(LDFLAGS) -Zdll $(LIBS)
  50. ARFLAGS = crs
  51. IMPLIB = emximp
  52.  
  53. ifeq ($(MODE),debug)
  54.   CFLAGS += -g
  55.   LDFLAGS += -g
  56. else
  57.   CFLAGS += -s -O6 -fomit-frame-pointer -funroll-loops
  58.   LDFLAGS += -s
  59. endif
  60.  
  61. # We're using the OMF format since EMX's ld has a obscure bug
  62. # because of which it sometimes fails to build relocations
  63. # in .data segment that point to another .data locations
  64. OMF = yes
  65.  
  66. # File extensions
  67. ifeq ($(OMF),yes)
  68.   O = .obj
  69.   A = .lib
  70.   AR = emxomfar
  71.   CFLAGS += -Zomf
  72.   LDFLAGS += -Zomf
  73.   ifeq ($(MODE),debug)
  74.     ARFLAGS = -p32 crs
  75.   endif
  76. else
  77.   O = .o
  78.   A = .a
  79.   AR = ar
  80. endif
  81.  
  82. # Source file paths
  83. SRCPATH = .;../../Python;../../Parser;../../Objects;../../Include;../../Modules
  84. # Python contains the central core, containing the builtins and interpreter.
  85. # Parser contains Python's Internal Parser and
  86. # Standalone Parser Generator Program (Shares Some of Python's Modules)
  87. # Objects contains Python Object Types
  88. # Modules contains extension Modules (Built-In or as Separate DLLs)
  89.  
  90. # Unix shells tend to use "$" as delimiter for variable names.
  91. # Test for this behaviour and set $(BUCK) variable correspondigly ...
  92. __TMP__:=$(shell echo $$$$)
  93. ifeq ($(__TMP__),$$$$)
  94.   BUCK = $$
  95.   BRO = (
  96.   BRC = )
  97. else
  98.   BUCK = \$$
  99.   BRO = \(
  100.   BRC = \)
  101. endif
  102. # Compute the "double quote" variable
  103. __TMP__:=$(shell echo "")
  104. ifeq ($(__TMP__),"")
  105.   DQUOTE = "
  106. else
  107.   DQUOTE = \"
  108. endif
  109.  
  110. # Include paths
  111. INCLUDE = -I$(subst ;, -I, $(SRCPATH))
  112.  
  113. # Path to search for .c files
  114. vpath %.c .;..;$(SRCPATH)
  115.  
  116. # Directory for output files
  117. OUTBASE = out/
  118. OUT = $(OUTBASE)$(MODE)/
  119.  
  120. # Additional libraries
  121. LIBS = -lsocket
  122.  
  123. # Build rules
  124. $(OUT)%$O: %.c
  125.     $(CC) $(CFLAGS) -c $< -o $@
  126.  
  127. %.dll:
  128.     $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^)
  129.  
  130. %.exe:
  131.     $(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^)
  132.  
  133. %_m.def:
  134.     @echo Creating .DEF file: $@
  135.     @echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
  136.     @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).dll)$(DQUOTE) >>$@
  137.     @echo EXPORTS >>$@
  138.     @echo     init$(notdir $*) >>$@
  139.  
  140. %.def:
  141.     @echo Creating .DEF file: $@
  142.     @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@
  143.     @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@
  144.     @echo STACKSIZE 1048576 >>$@
  145.  
  146. # Output file names
  147. PYTHON.LIB = python_s$A
  148. PYTHON.IMPLIB = python$A
  149. PYTHON.DLL = python15.dll
  150. PYTHON.EXE = python.exe
  151. PYTHONPM.EXE = pythonpm.exe
  152. PGEN.EXE = pgen.exe
  153.  
  154. # Additional executable parameters
  155. EXETYPE.$(PYTHON.EXE) = WINDOWCOMPAT
  156. EXETYPE.$(PYTHONPM.EXE) = WINDOWAPI
  157. EXETYPE.$(PGEN.EXE) = WINDOWCOMPAT
  158. DESCRIPTION.$(PYTHON.EXE) = Python object-oriented programming language interpreter for OS/2
  159. DESCRIPTION.$(PYTHONPM.EXE) = $(DESCRIPTION.$(PYTHON.EXE))
  160. DESCRIPTION.$(PGEN.EXE) = Python object-oriented programming language parser generator for OS/2
  161.  
  162. # Module descriptions
  163. DESCRIPTION.zlib.dll = Python Extension DLL for accessing the InfoZip compression library
  164. DESCRIPTION.crypt.dll = Python Extension DLL implementing the crypt$(BRO)$(BRC) function
  165. DESCRIPTION._tkinter.dll = Python Extension DLL for access to Tcl/Tk Environment
  166. DESCRIPTION.mpz.dll = Python Extension DLL for access to GNU multi-precision library
  167. DESCRIPTION.readline.dll = Python Extension DLL for access to GNU ReadLine library
  168.  
  169. # Utility macro: replacement for $^
  170. ^^ = $(filter-out %$A,$^)
  171. # Use $(L^) to link with all libraries specified as dependencies
  172. L^=$(addprefix -l,$(basename $(notdir $(filter %$A,$+))))
  173.  
  174. # Source files
  175. SRC.PGEN = $(addprefix ../../Parser/,pgenmain.c pgen.c printgrammar.c \
  176.   listnode.c grammar.c bitset.c firstsets.c metagrammar.c)
  177. OBJ.PGEN = $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
  178.  
  179. SRC.NOTLIB = sigcheck.c intrcheck.c dup2.c fmod.c atof.c hypot.c \
  180.   memmove.c strdup.c strerror.c strtod.c
  181. SRC.LIB = $(filter-out $(addprefix %,$(SRC.NOTLIB)) $(SRC.PGEN) \
  182.   ../../Modules/%, $(wildcard $(subst ;,/*.c ,$(SRCPATH))/*.c)) \
  183.   $(addsuffix .c,$(addprefix ../../Modules/,$(BUILTINMODULES))) \
  184.   dlfcn.c config.c ../getpathp.c
  185. OBJ.LIB = $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
  186.  
  187. # Python built-in modules to build (the first line are support modules)
  188. BUILTINMODULES = main getbuildinfo cgensupport pypcre regexpr yuvconvert md5c \
  189.   _localemodule arraymodule binascii cPickle cStringIO cmathmodule dlmodule \
  190.   errnomodule fpectlmodule fpetestmodule imageop mathmodule md5module \
  191.   newmodule operator parsermodule pcremodule posixmodule pwdmodule \
  192.   regexmodule rgbimgmodule rotormodule selectmodule shamodule signalmodule \
  193.   socketmodule soundex stropmodule structmodule termios threadmodule \
  194.   timemodule timingmodule
  195.  
  196. # Python external (.dll) modules
  197. ifeq ($(ZLIB),yes)
  198.   EXTERNMODULES += zlibmodule
  199.   LIBS += -lz
  200. endif
  201. ifeq ($(UFC),yes)
  202.   EXTERNMODULES += cryptmodule
  203.   LIBS += -lufc
  204. endif
  205. ifeq ($(TCLTK),yes)
  206.   EXTERNMODULES += _tkinter
  207.   LIBS += -ltcl -ltk
  208. endif
  209. ifeq ($(GMPZ),yes)
  210.   EXTERNMODULES += mpzmodule
  211.   LIBS += ????
  212. endif
  213. ifeq ($(GREADLINE),yes)
  214.   EXTERNMODULES += readline
  215.   LIBS += -lreadline -ltermcap
  216. endif
  217.  
  218. EXTERNDLLS = $(addsuffix .dll,$(patsubst %module,%,$(EXTERNMODULES)))
  219.  
  220. # The following modules won't build either because I didn't had installed
  221. # required libraries (such as Tcl/Tk or GDBM)
  222. # or because they were designed for a different OS.
  223. BADMODULES = \
  224.   gdbmmodule getpath glmodule almodule audioop bsddbmodule cdmodule clmodule \
  225.   cursesmodule dbmmodule fcntlmodule flmodule fmmodule grpmodule imgfile \
  226.   nismodule resource puremodule sgimodule stdwinmodule sunaudiodev svmodule \
  227.   syslogmodule
  228.  
  229. # The following modules are still possible to build but you will require either
  230. # a specific library or some OS/2-specific changes (such as to OpenGL module)
  231. # gdbmmodule (GNU database manager, should be either available or easily portable)
  232. # glmodule (OS/2 - specific changes for OS/2 OpenGL)
  233.  
  234. # Targets
  235. all:  $(OUT) $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
  236.   $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
  237.  
  238. clean:
  239.     rm -rf $(OUT)
  240.  
  241. lx:
  242.     @echo Packing everything with lxLite...
  243.     lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
  244.  
  245. depend: $(OUTBASE)
  246.     makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
  247.       -r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
  248.  
  249. $(OUT): $(OUTBASE)
  250.  
  251. $(OUT) $(OUTBASE):
  252.     mkdir $@
  253.  
  254. $(PYTHON.LIB): $(OBJ.LIB)
  255.     rm -f $@
  256.     $(AR) $(ARFLAGS) $@ $^
  257.  
  258. $(PYTHON.IMPLIB): ../os2vacpp/Python.def
  259.     $(IMPLIB) -o $@ $^
  260.  
  261. $(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) ../os2vacpp/Python.def
  262.  
  263. $(PYTHON.EXE): $(OUT)python$O $(PYTHON.IMPLIB) $(OUT)python.def
  264.  
  265. $(PYTHONPM.EXE): $(OUT)python$O $(PYTHON.IMPLIB) $(OUT)pythonpm.def
  266.  
  267. $(PGEN.EXE): $(OBJ.PGEN) $(PYTHON.LIB) $(OUT)pgen.def
  268.  
  269. # External modules
  270. zlib.dll: $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
  271. crypt.dll: $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
  272. _tkinter.dll: $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O \
  273.   $(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
  274. mpz.dll: $(OUT)mpzmodule$O $(OUT)mpz_m.def $(PYTHON.IMPLIB)
  275. readline.dll: $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
  276.  
  277. test:
  278.     ./python ../../lib/test/regrtest.py
  279.  
  280. -include $(OUTBASE)python.dep
  281.