]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/Makefile.pre.in
fixes for GetReturnCode/SetReturnCode
[wxWidgets.git] / utils / wxPython / src / Makefile.pre.in
CommitLineData
7bf85405
RD
1# Universal Unix Makefile for Python extensions
2# =============================================
3
4# Short Instructions
5# ------------------
6
7# 1. Build and install Python (1.5 or newer).
8# 2. "make -f Makefile.pre.in boot"
9# 3. "make"
10# You should now have a shared library.
11
12# Long Instructions
13# -----------------
14
15# Build *and install* the basic Python 1.5 distribution. See the
16# Python README for instructions. (This version of Makefile.pre.in
17# only withs with Python 1.5, alpha 3 or newer.)
18
19# Create a file Setup.in for your extension. This file follows the
20# format of the Modules/Setup.in file; see the instructions there.
21# For a simple module called "spam" on file "spammodule.c", it can
22# contain a single line:
23# spam spammodule.c
24# You can build as many modules as you want in the same directory --
25# just have a separate line for each of them in the Setup.in file.
26
27# If you want to build your extension as a shared library, insert a
28# line containing just the string
29# *shared*
30# at the top of your Setup.in file.
31
32# Note that the build process copies Setup.in to Setup, and then works
33# with Setup. It doesn't overwrite Setup when Setup.in is changed, so
34# while you're in the process of debugging your Setup.in file, you may
35# want to edit Setup instead, and copy it back to Setup.in later.
36# (All this is done so you can distribute your extension easily and
37# someone else can select the modules they actually want to build by
38# commenting out lines in the Setup file, without editing the
39# original. Editing Setup is also used to specify nonstandard
40# locations for include or library files.)
41
42# Copy this file (Misc/Makefile.pre.in) to the directory containing
43# your extension.
44
45# Run "make -f Makefile.pre.in boot". This creates Makefile
46# (producing Makefile.pre and sedscript as intermediate files) and
47# config.c, incorporating the values for sys.prefix, sys.exec_prefix
48# and sys.version from the installed Python binary. For this to work,
49# the python binary must be on your path. If this fails, try
50# make -f Makefile.pre.in Makefile VERSION=1.5 installdir=<prefix>
51# where <prefix> is the prefix used to install Python for installdir
52# (and possibly similar for exec_installdir=<exec_prefix>).
53
54# Note: "make boot" implies "make clobber" -- it assumes that when you
55# bootstrap you may have changed platforms so it removes all previous
56# output files.
57
58# If you are building your extension as a shared library (your
59# Setup.in file starts with *shared*), run "make" or "make sharedmods"
60# to build the shared library files. If you are building a statically
61# linked Python binary (the only solution of your platform doesn't
62# support shared libraries, and sometimes handy if you want to
63# distribute or install the resulting Python binary), run "make
64# python".
65
66# Note: Each time you edit Makefile.pre.in or Setup, you must run
67# "make Makefile" before running "make".
68
69# Hint: if you want to use VPATH, you can start in an empty
70# subdirectory and say (e.g.):
71# make -f ../Makefile.pre.in boot srcdir=.. VPATH=..
72
73
74# === Bootstrap variables (edited through "make boot") ===
75
76# The prefix used by "make inclinstall libainstall" of core python
77installdir= /usr/local
78
79# The exec_prefix used by the same
80exec_installdir=$(installdir)
81
82# Source directory and VPATH in case you want to use VPATH.
83# (You will have to edit these two lines yourself -- there is no
84# automatic support as the Makefile is not generated by
85# config.status.)
86srcdir= .
87VPATH= .
88
89# === Variables that you may want to customize (rarely) ===
90
91# (Static) build target
92TARGET= python
93
94# Installed python binary (used only by boot target)
95PYTHON= python
96
97# Add more -I and -D options here
98CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(EXECINCLUDEPY) $(DEFS)
99
100# These two variables can be set in Setup to merge extensions.
101# See example[23].
102BASELIB=
103BASESETUP=
104
105# === Variables set by makesetup ===
106
107MODOBJS= _MODOBJS_
108MODLIBS= _MODLIBS_
109
110# === Definitions added by makesetup ===
111
112# === Variables from configure (through sedscript) ===
113
114VERSION= @VERSION@
115CC= @CC@
116LINKCC= @LINKCC@
117SGI_ABI= @SGI_ABI@
118OPT= @OPT@
119LDFLAGS= @LDFLAGS@
120LDLAST= @LDLAST@
121DEFS= @DEFS@
122LIBS= @LIBS@
123LIBM= @LIBM@
124LIBC= @LIBC@
125RANLIB= @RANLIB@
126MACHDEP= @MACHDEP@
127SO= @SO@
128LDSHARED= @LDSHARED@
129CCSHARED= @CCSHARED@
130LINKFORSHARED= @LINKFORSHARED@
131#@SET_CCC@
132
133# Install prefix for architecture-independent files
134prefix= /usr/local
135
136# Install prefix for architecture-dependent files
137exec_prefix= $(prefix)
138
139# === Fixed definitions ===
140
141# Shell used by make (some versions default to the login shell, which is bad)
142SHELL= /bin/sh
143
144# Expanded directories
145BINDIR= $(exec_installdir)/bin
146LIBDIR= $(exec_prefix)/lib
147MANDIR= $(installdir)/man
148INCLUDEDIR= $(installdir)/include
149SCRIPTDIR= $(prefix)/lib
150
151# Detailed destination directories
152BINLIBDEST= $(LIBDIR)/python$(VERSION)
153LIBDEST= $(SCRIPTDIR)/python$(VERSION)
154INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
155EXECINCLUDEPY= $(exec_installdir)/include/python$(VERSION)
156LIBP= $(exec_installdir)/lib/python$(VERSION)
157DESTSHARED= $(BINLIBDEST)/site-packages
158
159LIBPL= $(LIBP)/config
160
161PYTHONLIBS= $(LIBPL)/libpython$(VERSION).a
162
163MAKESETUP= $(LIBPL)/makesetup
164MAKEFILE= $(LIBPL)/Makefile
165CONFIGC= $(LIBPL)/config.c
166CONFIGCIN= $(LIBPL)/config.c.in
167SETUP= $(LIBPL)/Setup
168
169SYSLIBS= $(LIBM) $(LIBC)
170
171ADDOBJS= $(LIBPL)/python.o config.o
172
173# Portable install script (configure doesn't always guess right)
174INSTALL= $(LIBPL)/install-sh -c
175# Shared libraries must be installed with executable mode on some systems;
176# rather than figuring out exactly which, we always give them executable mode.
177# Also, making them read-only seems to be a good idea...
178INSTALL_SHARED= ${INSTALL} -m 555
179
f57d7932
RD
180#---------------------------------------------------
181# Possibly change some definintions for C++
182ifdef MY_LDSHARED
183LDSHARED=$(MY_LDSHARED)
184endif
185ifdef MY_LINKCC
186LINKCC=$(MY_LINKCC)
187endif
188
189
7bf85405
RD
190# === Fixed rules ===
191
192# Default target. This builds shared libraries only
193default: sharedmods
194
195# Build everything
196all: static sharedmods
197
198# Build shared libraries from our extension modules
199sharedmods: $(SHAREDMODS)
200
201# Build a static Python binary containing our extension modules
202static: $(TARGET)
203$(TARGET): $(ADDOBJS) lib.a $(PYTHONLIBS) Makefile $(BASELIB)
204 $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) \
205 $(ADDOBJS) lib.a $(PYTHONLIBS) \
206 $(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) \
207 -o $(TARGET) $(LDLAST)
208
209#------------------------------------------------------------------------
210#------------------------------------------------------------------------
f57d7932 211# This is a default version of the install target for wxPython. It just
7bf85405
RD
212# redirects to wxInstall below...
213
214install: wxInstall
215
216#install: sharedmods
217# if test ! -d $(DESTSHARED) ; then \
218# mkdir $(DESTSHARED) ; else true ; fi
219# -for i in X $(SHAREDMODS); do \
220# if test $$i != X; \
221# then $(INSTALL_SHARED) $$i $(DESTSHARED)/$$i; \
222# fi; \
223# done
224
225
226# Build the library containing our extension modules
227lib.a: $(MODOBJS)
228 -rm -f lib.a
229 ar cr lib.a $(MODOBJS)
230 -$(RANLIB) lib.a
231
232# This runs makesetup *twice* to use the BASESETUP definition from Setup
233config.c Makefile: Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
234 $(MAKESETUP) \
235 -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
236 $(MAKE) -f Makefile do-it-again
237
238# Internal target to run makesetup for the second time
239do-it-again:
240 $(MAKESETUP) \
241 -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
242
243# Make config.o from the config.c created by makesetup
244config.o: config.c
245 $(CC) $(CFLAGS) -c config.c
246
247# Setup is copied from Setup.in *only* if it doesn't yet exist
248Setup:
9d358552 249 cp Setup.in Setup
7bf85405
RD
250
251# Make the intermediate Makefile.pre from Makefile.pre.in
252Makefile.pre: Makefile.pre.in sedscript
9d358552 253 sed -f sedscript Makefile.pre.in >Makefile.pre
7bf85405
RD
254
255# Shortcuts to make the sed arguments on one line
256P=prefix
257E=exec_prefix
258H=Generated automatically from Makefile.pre.in by sedscript.
259L=LINKFORSHARED
260
261# Make the sed script used to create Makefile.pre from Makefile.pre.in
262sedscript: $(MAKEFILE)
263 sed -n \
264 -e '1s/.*/1i\\/p' \
265 -e '2s%.*%# $H%p' \
266 -e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \
267 -e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \
268 -e '/^CCC=/s/^CCC=[ ]*\(.*\)/s%#@SET_CCC[@]%CCC=\1%/p' \
269 -e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \
270 -e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \
271 -e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \
272 -e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \
273 -e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \
274 -e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \
275 -e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \
276 -e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
277 -e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
278 -e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \
279 -e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
280 -e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
281 -e '/^$L=/s/^$L=[ ]*\(.*\)/s%@$L[@]%\1%/p' \
282 -e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
283 -e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
284 $(MAKEFILE) >sedscript
285 echo "/^#@SET_CCC@/d" >>sedscript
286 echo "/^installdir=/s%=.*%= $(installdir)%" >>sedscript
287 echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%" >>sedscript
288 echo "/^srcdir=/s%=.*%= $(srcdir)%" >>sedscript
289 echo "/^VPATH=/s%=.*%= $(VPATH)%" >>sedscript
290 echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%" >>sedscript
291 echo "/^BASELIB=/s%=.*%= $(BASELIB)%" >>sedscript
292 echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%" >>sedscript
293
294# Bootstrap target
295boot: clobber
296 VERSION=`$(PYTHON) -c "import sys; print sys.version[:3]"`; \
297 installdir=`$(PYTHON) -c "import sys; print sys.prefix"`; \
298 exec_installdir=`$(PYTHON) -c "import sys; print sys.exec_prefix"`; \
9d358552 299 $(MAKE) -f Makefile.pre.in VPATH=$(VPATH) srcdir=$(srcdir) \
7bf85405
RD
300 VERSION=$$VERSION \
301 installdir=$$installdir \
302 exec_installdir=$$exec_installdir \
303 Makefile
304
305# Handy target to remove intermediate files and backups
306clean:
307 -rm -f *.o *~
308
309# Handy target to remove everything that is easily regenerated
310clobber: clean
311 -rm -f *.a tags TAGS config.c Makefile.pre $(TARGET) sedscript
312 -rm -f *.so *.sl so_locations
313
314
315# Handy target to remove everything you don't want to distribute
316distclean: clobber
317 -rm -f Makefile Setup
318
319
320
321
322#------------------------------------------------------------------------
323#------------------------------------------------------------------------
324# Custom rules and dependencies added for wxPython
325#
326
e6c95f27 327WXP_VERSION=2.0b9
9d358552 328
cf694132 329SWIGFLAGS=-c++ -shadow -python -dnone -D__WXGTK__ $(SEPARATE)
7bf85405 330
7bf85405 331
105e45b9 332PYMODULES = $(GENCODEDIR)/wx.py $(GENCODEDIR)/events.py \
b62bdb48
RD
333 $(GENCODEDIR)/windows.py $(GENCODEDIR)/misc.py \
334 $(GENCODEDIR)/gdi.py $(GENCODEDIR)/mdi.py \
335 $(GENCODEDIR)/controls.py $(GENCODEDIR)/controls2.py \
336 $(GENCODEDIR)/windows2.py $(GENCODEDIR)/cmndlgs.py \
9c039d08 337 $(GENCODEDIR)/frames.py $(GENCODEDIR)/stattool.py \
08127323 338 $(GENCODEDIR)/utils.py $(GENCODEDIR)/windows3.py \
ab9bc19b 339 $(GENCODEDIR)/image.py $(GENCODEDIR)/glcanvas.py \
b62bdb48 340 __init__.py
7bf85405
RD
341
342
343# Implicit rules to run SWIG
b62bdb48
RD
344$(GENCODEDIR)/%.cpp : %.i
345 swig $(SWIGFLAGS) -c -o $@ $<
7bf85405 346
b62bdb48
RD
347$(GENCODEDIR)/%.py : %.i
348 swig $(SWIGFLAGS) -c -o $@ $<
7bf85405
RD
349
350
351# This one must leave out the -c flag so we define the whole rule
b8b8dda7
RD
352$(GENCODEDIR)/wx.cpp $(GENCODEDIR)/wx.py : wx.i my_typemaps.i _defs.i _extras.py
353 swig $(SWIGFLAGS) -o $(GENCODEDIR)/wx.cpp wx.i
7bf85405
RD
354
355
356# define some dependencies
b62bdb48
RD
357$(GENCODEDIR)/windows.cpp $(GENCODEDIR)/windows.py : windows.i my_typemaps.i _defs.i
358$(GENCODEDIR)/windows2.cpp $(GENCODEDIR)/windows2.py : windows2.i my_typemaps.i _defs.i
08127323 359$(GENCODEDIR)/windows3.cpp $(GENCODEDIR)/windows3.py : windows3.i my_typemaps.i _defs.i
b62bdb48
RD
360$(GENCODEDIR)/events.cpp $(GENCODEDIR)/events.py : events.i my_typemaps.i _defs.i
361$(GENCODEDIR)/misc.cpp $(GENCODEDIR)/misc.py : misc.i my_typemaps.i _defs.i
362$(GENCODEDIR)/gdi.cpp $(GENCODEDIR)/gdi.py : gdi.i my_typemaps.i _defs.i
363$(GENCODEDIR)/mdi.cpp $(GENCODEDIR)/mdi.py : mdi.i my_typemaps.i _defs.i
364$(GENCODEDIR)/controls.cpp $(GENCODEDIR)/controls.py : controls.i my_typemaps.i _defs.i
365$(GENCODEDIR)/controls2.cpp $(GENCODEDIR)/controls2.py : controls2.i my_typemaps.i _defs.i
366$(GENCODEDIR)/cmndlgs.cpp $(GENCODEDIR)/cmndlgs.py : cmndlgs.i my_typemaps.i _defs.i
9c039d08
RD
367$(GENCODEDIR)/frames.cpp $(GENCODEDIR)/frames.py : frames.i my_typemaps.i _defs.i
368$(GENCODEDIR)/stattool.cpp $(GENCODEDIR)/stattool.py : stattool.i my_typemaps.i _defs.i
ab9bc19b 369$(GENCODEDIR)/image.cpp $(GENCODEDIR)/image.py : image.i my_typemaps.i _defs.i
b8b8dda7 370$(GENCODEDIR)/utils.cpp $(GENCODEDIR)/utils.py : utils.i my_typemaps.i _defs.i
ab9bc19b 371$(GENCODEDIR)/glcanvas.cpp $(GENCODEDIR)/glcanvas.py : glcanvas.i my_typemaps.i _defs.i
7bf85405 372
9d358552
RD
373$(GENCODEDIR)/helpers.cpp:
374 ln -s `pwd`/helpers.cpp $@
7bf85405 375
ab9bc19b
RD
376$(GENCODEDIR)/_glcanvas.cpp:
377 -cp $(WXWIN)/utils/glcanvas/$(GENCODEDIR)/glcanvas.cpp $@
378 -cp $(WXWIN)/utils/glcanvas/$(GENCODEDIR)/glcanvas.h ./glcanvas.h
379
7bf85405
RD
380
381wxInstall : sharedmods $(PYMODULES)
382 if test ! -d $(TARGETDIR) ; then \
383 mkdir $(TARGETDIR) ; else true ; fi
b26e2dc4 384 if [ "$(SHAREDMODS)" != "" ]; then \
08127323 385 chmod 755 $(SHAREDMODS); \
b26e2dc4 386 cp $(SHAREDMODS) $(TARGETDIR); fi
7bf85405 387 -for i in $(PYMODULES); do \
9d358552 388 cp $$i $(TARGETDIR); \
7bf85405 389 done
e6c95f27
RD
390 if [ "$(TARGETDIR)" != ".." ]; then \
391 mkdir $(TARGETDIR)/lib; \
392 mkdir $(TARGETDIR)/demo; \
393 cp ../lib/*.py $(TARGETDIR)/lib; \
394 cp ../demo/*.py $(TARGETDIR)/demo; \
395 cp ../lib/*.txt $(TARGETDIR)/lib; \
396 cp ../demo/*.txt $(TARGETDIR)/demo;\
397 fi
398 if [ "$(TARGETDIR)" != ".." ]; then \
399 python $(LIBDEST)/compileall.py $(TARGETDIR); \
400 python -O $(LIBDEST)/compileall.py $(TARGETDIR); \
401 else \
402 python $(LIBDEST)/compileall.py -l $(TARGETDIR); \
403 python -O $(LIBDEST)/compileall.py -l $(TARGETDIR);\
404 fi
405
406
7bf85405
RD
407
408
b0f1bdde
RD
409lib : libwxPython.a
410
411libwxPython.a : lib.a
412 cp $< $@
e6c95f27
RD
413
414dist: tgz rpm
415
416tgz:
417 cd ../..; wxPython/distrib/maketgz $(WXP_VERSION)
418
419rpm:
420 cd ../distrib; ./makerpm $(WXP_VERSION)
421