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