]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/distrib/build.py
1. wxHtmlHelpController and related classes
[wxWidgets.git] / utils / wxPython / distrib / build.py
1 #!/usr/bin/env python
2 #----------------------------------------------------------------------------
3 # Name: build.py
4 # Purpose: This script is used to build wxPython. It reads a build
5 # configuration file in the requested project directory and
6 # based on the contents of the file can build Makefiles for
7 # unix or win32, and can execute make with various options
8 # potentially automating the entire build/install/clean process
9 # from a single command.
10 #
11 # Author: Robin Dunn
12 #
13 # Created: 18-Aug-1999
14 # RCS-ID: $Id$
15 # Copyright: (c) 1999 by Total Control Software
16 # Licence: wxWindows license
17 #----------------------------------------------------------------------------
18 """
19 build.py
20
21 This script is used to build wxPython. It reads a build configuration
22 file in the requested project directory and based on the contents of
23 the file can build Makefiles for unix or win32, and can execute make
24 with various options potentially automating the entire
25 build/install/clean process from a single command.
26
27 The default action is to build the Makefile and exit.
28
29 Options
30 -C dir CD to dir before doing anything
31 -B file Use file as the build configuration (default ./build.cfg)
32 -M file Use file as the name of the makefile to create
33 (default Makefile)
34
35 -b Build the module (runs make)
36 -i Install the module (runs make install)
37 -c Cleanup (runs make clean)
38 -u Uninstall (runs make uninstall)
39
40 -h Show help and exit
41
42
43 Configuration Files
44
45 The build configuration file lists targets, source files and options
46 for the the build process. The contents of the build.cfg are used to
47 dynamically generate the Makefile.
48
49 To prevent you from getting screwed when the default build.cfg is
50 updated, you can override the values in build.cfg by putting your
51 custom definitions in a file named build.local. You can also place a
52 build.local file in the parent directory, or even in the grandparent
53 directory for project-wide overrides. Finally, command-line arguments
54 of the form NAME=VALUE can also be used to override simple configuration
55 values. The order of evaluation is:
56
57 0. comman-line flags (-M, -b, etc.)
58 1. ./build.cfg
59 2. ../../build.local (if present)
60 3. ../build.local (if present)
61 4. ./build.local (if present)
62 5. command-line NAME=VALUEs
63
64 The config files are actually just Python files that get exec'ed in a
65 separate namespace which is then used later as a configuration object.
66 This keeps the build script simple in that it doesn't have to parse
67 anything, and the config files can be much more than just names and
68 values as pretty much any python code can be executed. The global
69 variables set in the config namespace are what are used later as
70 configuation values.
71
72
73 Configuration Options
74
75 The following variables can be set in the config files. Only a few are
76 required, the rest will either have suitable defaults or will be
77 calculated from your current Python runtime environment.
78
79 MODULE The name of the extension module to produce
80 SWIGFILES A list of files that should be run through SWIG
81 SWIGFLAGS Flags for SWIG
82 SOURCES Other C/C++ sources that should be part of the module
83 PYFILES Other Python files that should be installed with the module
84 CFLAGS Flags to be used by the compiler
85 LFLAGS Flags to be used at the link step
86 LIBS Libraries to be linked with
87
88 OTHERCFLAGS Extra flags to append to CFLAGS
89 OTHERLFLAGS Extra flags to append to LFLAGS
90 OTHERSWIGFLAGS Extra flags to append to SWIGFLAGS
91 OTHERLIBS Other libraries to be linked with, in addition to LIBS
92 OTHERTARGETS Other targets to be placed on the default rule line
93 OTHERINSTALLTARGETS
94 Other targets to be placed on the install rule line
95 OTHERRULES This text is placed at the end of the makefile and
96 will typically be used for adding rules and such
97 DEFAULTRULE Text to be used for the default rule in the makefile
98
99 TARGETDIR Destination for the install step
100
101 MAKE The make program to use
102 MAKEFILE The name of the makefile
103
104 runBuild Setting this to 1 is eqivalent to the -b flag
105 runInstall Setting this to 1 is eqivalent to the -i flag
106 runClean Setting this to 1 is eqivalent to the -c flag
107 runUninstall Setting this to 1 is eqivalent to the -u flag
108
109 PYVERSION Version number of Python used in pathnames
110 PYPREFIX The root of the Python install
111 EXECPREFIX The root of the Python install for binary files
112 PYTHONLIB The Python link library
113
114 """
115
116 import sys, os, string, getopt
117
118 #----------------------------------------------------------------------------
119 # This is really the wxPython version number, and will be placed in the
120 # Makefiles for use with the distribution related targets.
121
122 __version__ = '2.1.4'
123
124 #----------------------------------------------------------------------------
125
126 def main(args):
127 try:
128 opts, args = getopt.getopt(args[1:], 'C:B:M:bicu')
129 except getopt.error:
130 usage()
131 sys.exit(1)
132
133 if not os.environ.has_key('WXWIN'):
134 print "WARNING: WXWIN is not set in the environment. WXDIR may not\n"\
135 " be set properly in the makefile, you will have to \n"\
136 " set the environment variable or override in build.local."
137
138 bldCfg = 'build.cfg'
139 bldCfgLocal = 'build.local'
140 MAKEFILE = 'Makefile'
141 runBuild = 0
142 runInstall = 0
143 runClean = 0
144 runUninstall = 0
145
146 for flag, value in opts:
147 if flag == '-C': os.chdir(value)
148 elif flag == '-B': bldCfgFile = value
149 elif flag == '-M': makefile = value
150 elif flag == '-b': runBuild = 1
151 elif flag == '-c': runClean = 1
152 elif flag == '-i': runInstall = 1
153 elif flag == '-u': runUninstall = 1
154
155 elif flag == '-h': usage(); sys.exit(1)
156 else: usage(); sys.exit(1)
157
158 config = BuildConfig(bldCfg = bldCfg,
159 bldCfgLocal = bldCfgLocal,
160 MAKEFILE = MAKEFILE,
161 runBuild = runBuild,
162 runInstall = runInstall,
163 runClean = runClean,
164 runUninstall = runUninstall)
165
166 err = 0
167 if config.readConfigFiles(args):
168 config.doFixups()
169 config.makeMakefile()
170
171 if config.runBuild:
172 cmd = "%s -f %s" % (config.MAKE, config.MAKEFILE)
173 print "Running:", cmd
174 err = os.system(cmd)
175
176 if not err and config.runInstall:
177 cmd = "%s -f %s install" % (config.MAKE, config.MAKEFILE)
178 print "Running:", cmd
179 err = os.system(cmd)
180
181
182 if not err and config.runClean:
183 cmd = "%s -f %s clean" % (config.MAKE, config.MAKEFILE)
184 print "Running:", cmd
185 err = os.system(cmd)
186
187 if not err and config.runUninstall:
188 cmd = "%s -f %s uninstall" % (config.MAKE, config.MAKEFILE)
189 print "Running:", cmd
190 err = os.system(cmd)
191
192 return err
193
194
195 #----------------------------------------------------------------------------
196
197 def usage():
198 print __doc__
199
200 #----------------------------------------------------------------------------
201
202 def swapslash(st):
203 if sys.platform != 'win32':
204 st = string.join(string.split(st, '\\'), '/')
205 return st
206
207 #----------------------------------------------------------------------------
208
209 def splitlines(st):
210 return string.join(string.split(string.strip(st), ' '), ' \\\n\t')
211
212 #----------------------------------------------------------------------------
213
214 class BuildConfig:
215 def __init__(self, **kw):
216 self.__dict__.update(kw)
217 self.setDefaults()
218
219 #------------------------------------------------------------
220 def setDefaults(self):
221 self.VERSION = __version__
222 self.MODULE = ''
223 self.SWIGFILES = []
224 self.SWIGFLAGS = '-c++ -shadow -python -keyword -dnone -I$(WXPSRCDIR)'
225 self.SOURCES = []
226 self.PYFILES = []
227 self.LFLAGS = ''
228 self.OTHERCFLAGS = ''
229 self.OTHERLFLAGS = ''
230 self.OTHERSWIGFLAGS = ''
231 self.OTHERLIBS = ''
232 self.OTHERTARGETS = ''
233 self.OTHERINSTALLTARGETS = ''
234 self.OTHERUNINSTALLTARGETS = ''
235 self.OTHERRULES = ''
236 self.DEFAULTRULE = 'default: $(GENCODEDIR) $(TARGET)'
237 self.PYVERSION = sys.version[:3]
238 self.PYPREFIX = sys.prefix
239 self.EXECPREFIX = sys.exec_prefix
240 self.WXDIR = '$(WXWIN)'
241 self.FINAL = '0'
242 self.WXP_USE_THREAD = '1'
243 self.WXUSINGDLL = '1'
244 self.OTHERDEP = ''
245 self.WXPSRCDIR = '$(WXDIR)/utils/wxPython/src'
246 self.SWIGDEPS = ''
247 self.OTHERDEPS = ''
248
249
250 if sys.platform == 'win32':
251 self.MAKE = 'nmake'
252 self.PYTHONLIB = '$(PYPREFIX)\\libs\\python15.lib'
253 self.TARGETDIR = '$(PYPREFIX)\\wxPython'
254 self.LIBS = '$(PYTHONLIB) $(WXPSRCDIR)\wxc.lib'
255 self.GENCODEDIR = 'msw'
256 self.SWIGTOOLKITFLAG = '-D__WXMSW__'
257 self.OBJEXT = '.obj'
258 self.TARGET = '$(MODULE).pyd'
259 self.CFLAGS = '-I$(PYPREFIX)\include -I$(WXPSRCDIR) -I. /Fp$(MODULE).pch /YXhelpers.h -DSWIG_GLOBAL -DHAVE_CONFIG_H $(THREAD) '
260 self.LFLAGS = '$(DEBUGLFLAGS) /DLL /subsystem:windows,3.50 /machine:I386 /nologo'
261 self.RESFILE = ''
262 self.RESRULE = ''
263 self.OVERRIDEFLAGS = '/GX-'
264 self.RMCMD = '-erase '
265 self.WXPSRCDIR = os.path.normpath(self.WXPSRCDIR)
266
267
268 else:
269 self.MAKE = 'make'
270 self.PYLIB = '$(EXECPREFIX)/lib/python$(PYVERSION)'
271 self.LIBPL = '$(PYLIB)/config'
272 self.PYTHONLIB = '$(LIBPL)/libpython$(PYVERSION).a'
273 self.TARGETDIR = '$(EXECPREFIX)/lib/python$(PYVERSION)/site-packages/wxPython'
274 self.TARGET = '$(MODULE)module$(SO)'
275 self.OBJEXT = '.o'
276 self.HELPERLIB = 'wxPyHelpers'
277 self.HELPERLIBDIR = '/usr/local/lib'
278 self.CFLAGS = '-DSWIG_GLOBAL -DHAVE_CONFIG_H $(THREAD) -I. '\
279 '`wx-config --cflags` -I$(PYINCLUDE) -I$(EXECINCLUDE) '\
280 '-I$(WXPSRCDIR)'
281 self.LFLAGS = '-L$(WXPSRCDIR) `wx-config --libs`'
282 self.LIBS = '-l$(HELPERLIB)'
283 self.RMCMD = '-rm -f '
284
285 # **** What to do when I start supporting Motif, etc.???
286 self.GENCODEDIR = 'gtk'
287 self.SWIGTOOLKITFLAG = '-D__WXGTK__'
288
289 # Extract a few things from Python's Makefile...
290 try:
291 filename = os.path.join(self.EXECPREFIX,
292 'lib/python'+self.PYVERSION,
293 'config/Makefile')
294 mfText = string.split(open(filename, 'r').read(), '\n')
295 except IOError:
296 raise SystemExit, "Python development files not found"
297
298 self.CCC = self.findMFValue(mfText, 'CCC')
299 self.CC = self.findMFValue(mfText, 'CC')
300 self.OPT = self.findMFValue(mfText, 'OPT')
301 self.SO = self.findMFValue(mfText, 'SO')
302 self.LDSHARED = self.findMFValue(mfText, 'LDSHARED')
303 self.CCSHARED = self.findMFValue(mfText, 'CCSHARED')
304 #self.LINKFORSHARED = self.findMFValue(mfText, 'LINKFORSHARED')
305 #self. = self.findMFValue(mfText, '')
306 #self. = self.findMFValue(mfText, '')
307
308
309 # The majority of cases will require LDSHARED to be
310 # modified to use the C++ driver instead of the C driver
311 # for linking. We'll try to do it here and if we goof up
312 # then the user can correct it in their build.local file.
313 self.LDSHARED = string.join(['$(CCC)'] +
314 string.split(self.LDSHARED, ' ')[1:],
315 ' ')
316
317
318 #------------------------------------------------------------
319 def doFixups(self):
320 # This is called after the config files have been evaluated
321 # so we can do some sanity checking...
322 if sys.platform != 'win32':
323 if not self.CCC:
324 print "Warning: C++ compiler not specified (CCC). Assuming c++"
325 self.CCC = 'c++'
326 if not self.CC:
327 print "Warning: C compiler not specified (CC). Assuming cc"
328 self.CC = 'cc'
329
330 #------------------------------------------------------------
331 def findMFValue(self, mfText, st):
332 # Find line begining with st= and return the value
333 # Regex would probably be to cooler way to do this, but
334 # I think this is the most understandable.
335 for line in mfText:
336 if string.find(line, st+'=') == 0:
337 st = string.strip(line[len(st)+1:])
338 return st
339 return None
340
341 #------------------------------------------------------------
342 def makeMakefile(self):
343
344 # make a list of object file names
345 objects = ""
346 for name in self.SWIGFILES:
347 objects = objects + os.path.splitext(name)[0] + self.OBJEXT + ' '
348 for name in self.SOURCES:
349 obj = os.path.basename(name)
350 objects = objects + os.path.splitext(obj)[0] + self.OBJEXT + ' '
351 self.OBJECTS = splitlines(objects)
352
353
354 # now build the text for the dependencies
355 depends = ""
356 for name in self.SWIGFILES:
357 rootname = os.path.splitext(name)[0]
358 text = '$(GENCODEDIR)/%s.cpp $(GENCODEDIR)/%s.py : %s.i %s\n' \
359 '$(TARGETDIR)\\%s.py : $(GENCODEDIR)\\%s.py\n' % \
360 (rootname, rootname, rootname, self.SWIGDEPS, rootname, rootname)
361 depends = depends + text
362 if self.OTHERDEPS:
363 text = '%s%s : %s\n' % \
364 (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS)
365 depends = depends + text
366 for name in self.PYFILES:
367 text = '$(TARGETDIR)\\%s.py : %s.py\n' % \
368 tuple([os.path.splitext(name)[0]] * 2)
369 depends = depends + text
370 if self.OTHERDEPS:
371 for name in self.SOURCES:
372 name = os.path.basename(name)
373 text = '%s%s : %s\n' % \
374 (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS)
375 depends = depends + text
376
377 self.DEPENDS = swapslash(depends)
378
379
380 # and the list of .py files
381 pymodules = ""
382 for name in self.SWIGFILES:
383 pymodules = pymodules + '$(TARGETDIR)\\%s.py ' % os.path.splitext(name)[0]
384 for name in self.PYFILES:
385 pymodules = pymodules + '$(TARGETDIR)\\%s.py ' % os.path.splitext(name)[0]
386 self.PYMODULES = splitlines(swapslash(pymodules))
387
388
389 # now make a list of the python files that would need uninstalled
390 pycleanup = ""
391 for name in self.SWIGFILES:
392 pycleanup = pycleanup + self.makeCleanupList(name)
393 for name in self.PYFILES:
394 pycleanup = pycleanup + self.makeCleanupList(name)
395 self.PYCLEANUP = swapslash(pycleanup)
396
397
398 # finally, build the makefile
399 if sys.platform == 'win32':
400 if self.RESFILE:
401 self.RESFILE = '$(MODULE).res'
402 self.RESRULE = '$(MODULE).res : $(MODULE).rc $(WXDIR)\\include\\wx\\msw\\wx.rc\n\t'\
403 '$(rc) -r /i$(WXDIR)\\include -fo$@ $(MODULE).rc'
404 text = win32Template % self.__dict__
405 else:
406 text = unixTemplate % self.__dict__
407 f = open(self.MAKEFILE, 'w')
408 f.write(text)
409 f.close()
410
411 print "Makefile created: ", self.MAKEFILE
412
413
414
415 #------------------------------------------------------------
416 def makeCleanupList(self, name):
417 st = ""
418 st = st + '\t%s$(TARGETDIR)\\%s.py\n' % (self.RMCMD, os.path.splitext(name)[0])
419 st = st + '\t%s$(TARGETDIR)\\%s.pyc\n' % (self.RMCMD, os.path.splitext(name)[0])
420 st = st + '\t%s$(TARGETDIR)\\%s.pyo\n' % (self.RMCMD, os.path.splitext(name)[0])
421 return st
422
423
424 #------------------------------------------------------------
425 def readConfigFiles(self, args):
426 return self.processFile(self.bldCfg, 1) and \
427 self.processFile(os.path.join('../..', self.bldCfgLocal)) and \
428 self.processFile(os.path.join('..', self.bldCfgLocal)) and \
429 self.processFile(os.path.join('.', self.bldCfgLocal)) and \
430 self.processArgs(args)
431
432 #------------------------------------------------------------
433 def processFile(self, filename, required=0):
434 try:
435 text = open(filename, 'r').read()
436 except IOError:
437 if required:
438 print "Unable to open %s" % filename
439 return 0
440 else:
441 return 1
442
443 try:
444 exec(text, self.__dict__)
445 except:
446 print "Error evaluating %s" % filename
447 import traceback
448 traceback.print_exc()
449 return 0
450 return 1
451
452
453 #------------------------------------------------------------
454 def processArgs(self, args):
455 try:
456 for st in args:
457 pair = string.split(st, '=')
458 name = pair[0]
459 value = pair[1]
460 self.__dict__[name] = value
461 except:
462 print "Error parsing command-line: %s" % st
463 return 0
464
465 return 1
466
467
468 #------------------------------------------------------------
469
470
471
472
473
474 #----------------------------------------------------------------------------
475 #----------------------------------------------------------------------------
476 #----------------------------------------------------------------------------
477
478 win32Template = '''
479 #----------------------------------------------------------------------
480 # This makefile was autogenerated from build.py. Your changes will be
481 # lost if the generator is run again. You have been warned.
482 #----------------------------------------------------------------------
483
484 WXDIR = %(WXDIR)s
485 VERSION = %(VERSION)s
486 MODULE = %(MODULE)s
487 SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s
488 CFLAGS = %(CFLAGS)s
489 LFLAGS = %(LFLAGS)s
490 PYVERSION = %(PYVERSION)s
491 PYPREFIX = %(PYPREFIX)s
492 EXECPREFIX = %(EXECPREFIX)s
493 PYTHONLIB = %(PYTHONLIB)s
494 FINAL = %(FINAL)s
495 WXP_USE_THREAD = %(WXP_USE_THREAD)s
496 WXUSINGDLL = %(WXUSINGDLL)s
497 GENCODEDIR = %(GENCODEDIR)s
498 RESFILE = %(RESFILE)s
499 WXPSRCDIR = %(WXPSRCDIR)s
500
501
502 TARGETDIR = %(TARGETDIR)s
503
504 OBJECTS = %(OBJECTS)s
505 PYMODULES = %(PYMODULES)s
506 TARGET = %(TARGET)s
507
508
509
510
511 !if "$(FINAL)" == "0"
512 DEBUGLFLAGS = /DEBUG /INCREMENTAL:YES
513 !else
514 DEBUGLFLAGS = /INCREMENTAL:NO
515 !endif
516 !if "$(WXP_USE_THREAD)" == "1"
517 THREAD=-DWXP_USE_THREAD=1
518 !endif
519
520
521
522
523 NOPCH=1
524 OVERRIDEFLAGS=%(OVERRIDEFLAGS)s
525 EXTRAFLAGS = $(CFLAGS) %(OTHERCFLAGS)s
526
527 LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
528 EXTRALIBS = %(LIBS)s %(OTHERLIBS)s
529
530 #----------------------------------------------------------------------
531
532 !include $(WXDIR)\\src\\makevc.env
533
534 #----------------------------------------------------------------------
535
536 %(DEFAULTRULE)s %(OTHERTARGETS)s
537
538
539
540 install: $(TARGETDIR) $(TARGETDIR)\\$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s
541
542 clean:
543 -erase *.obj
544 -erase *.exe
545 -erase *.res
546 -erase *.map
547 -erase *.sbr
548 -erase *.pdb
549 -erase *.pch
550 -erase $(MODULE).exp
551 -erase $(MODULE).lib
552 -erase $(MODULE).ilk
553 -erase $(TARGET)
554
555
556 uninstall: %(OTHERUNINSTALLTARGETS)s
557 -erase $(TARGETDIR)\\$(TARGET)
558 %(PYCLEANUP)s
559
560
561 #----------------------------------------------------------------------
562 # implicit rule for compiling .cpp and .c files
563 {}.cpp{}.obj:
564 $(cc) @<<
565 $(CPPFLAGS) /c /Tp $<
566 <<
567
568 {$(GENCODEDIR)}.cpp{}.obj:
569 $(cc) @<<
570 $(CPPFLAGS) /c /Tp $<
571 <<
572
573 {}.c{}.obj:
574 $(cc) @<<
575 $(CPPFLAGS) /c $<
576 <<
577
578 .SUFFIXES : .i .py
579
580 # Implicit rules to run SWIG
581 {}.i{$(GENCODEDIR)}.cpp:
582 swig $(SWIGFLAGS) -c -o $@ $<
583
584 {}.i{$(GENCODEDIR)}.py:
585 swig $(SWIGFLAGS) -c -o $(GENCODEDIR)\\tmp_wrap.cpp $<
586 -erase $(GENCODEDIR)\\tmp_wrap.cpp
587
588
589 {$(GENCODEDIR)}.py{$(TARGETDIR)}.py:
590 copy $< $@
591
592 {}.py{$(TARGETDIR)}.py:
593 copy $< $@
594
595 #----------------------------------------------------------------------
596
597 $(TARGET) : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(RESFILE)
598 $(link) @<<
599 /out:$@
600 $(LFLAGS) /def:$(MODULE).def /implib:./$(MODULE).lib
601 $(DUMMYOBJ) $(OBJECTS) $(RESFILE)
602 $(LIBS)
603 <<
604
605
606 %(RESRULE)s
607
608
609 $(TARGETDIR)\\$(TARGET) : $(TARGET)
610 copy $(TARGET) $@
611
612
613 pycfiles : $(PYMODULES)
614 $(EXECPREFIX)\\python $(PYPREFIX)\\Lib\\compileall.py -l $(TARGETDIR)
615 $(EXECPREFIX)\\python -O $(PYPREFIX)\Lib\\compileall.py -l $(TARGETDIR)
616
617
618 $(TARGETDIR) :
619 mkdir $(TARGETDIR)
620
621 $(GENCODEDIR):
622 mkdir $(GENCODEDIR)
623
624 #----------------------------------------------------------------------
625
626 %(DEPENDS)s
627
628 #----------------------------------------------------------------------
629
630 showflags:
631 @echo CPPFLAGS:
632 @echo $(CPPFLAGS)
633 @echo LFLAGS:
634 @echo $(LFLAGS)
635
636
637
638 %(OTHERRULES)s
639 '''
640
641 #----------------------------------------------------------------------------
642 #----------------------------------------------------------------------------
643 #----------------------------------------------------------------------------
644
645 unixTemplate = '''
646 #----------------------------------------------------------------------
647 # This makefile was autogenerated from build.py. Your changes will be
648 # lost if the generator is run again. You have been warned.
649 #----------------------------------------------------------------------
650
651
652
653 WXDIR = %(WXDIR)s
654 VERSION = %(VERSION)s
655 MODULE = %(MODULE)s
656 SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s
657 CFLAGS = %(CFLAGS)s $(OPT) %(OTHERCFLAGS)s
658 LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
659 LIBS = %(LIBS)s %(OTHERLIBS)s
660 PYVERSION = %(PYVERSION)s
661 PYPREFIX = %(PYPREFIX)s
662 EXECPREFIX = %(EXECPREFIX)s
663 PYINCLUDE = $(PYPREFIX)/include/python$(PYVERSION)
664 EXECINCLUDE = $(EXECPREFIX)/include/python$(PYVERSION)
665 PYLIB = %(PYLIB)s
666 LIBPL = %(LIBPL)s
667 PYTHONLIB = %(PYTHONLIB)s
668 FINAL = %(FINAL)s
669 WXP_USE_THREAD = %(WXP_USE_THREAD)s
670 GENCODEDIR = %(GENCODEDIR)s
671 WXPSRCDIR = %(WXPSRCDIR)s
672 HELPERLIB = %(HELPERLIB)s
673 HELPERLIBDIR = %(HELPERLIBDIR)s
674
675 TARGETDIR = %(TARGETDIR)s
676
677
678 CCC = %(CCC)s
679 CC = %(CC)s
680 OPT = %(OPT)s
681 SO = %(SO)s
682 LDSHARED = %(LDSHARED)s
683 CCSHARED = %(CCSHARED)s
684
685
686 OBJECTS = %(OBJECTS)s
687 PYMODULES = %(PYMODULES)s
688 TARGET = %(TARGET)s
689
690
691 ifeq ($(WXP_USE_THREAD), 1)
692 THREAD=-DWXP_USE_THREAD
693 endif
694
695 #----------------------------------------------------------------------
696
697 %(DEFAULTRULE)s %(OTHERTARGETS)s
698
699 install: $(TARGETDIR) $(TARGETDIR)/$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s
700
701 clean:
702 -rm -f *.o *$(SO) *~
703 -rm -f $(TARGET)
704
705 uninstall: %(OTHERUNINSTALLTARGETS)s
706 -rm -f $(TARGETDIR)/$(TARGET)
707 %(PYCLEANUP)s
708
709
710 #----------------------------------------------------------------------
711
712 %%.o : %%.cpp
713 $(CCC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
714
715 %%.o : $(GENCODEDIR)/%%.cpp
716 $(CCC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
717
718 %%.o : %%.c
719 $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
720
721 %%.o : $(GENCODEDIR)/%%.c
722 $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
723
724 $(GENCODEDIR)/%%.cpp : %%.i
725 swig $(SWIGFLAGS) -c -o $@ $<
726
727 $(GENCODEDIR)/%%.py : %%.i
728 swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $<
729 rm $(GENCODEDIR)/tmp_wrap.cpp
730
731 $(TARGETDIR)/%% : %%
732 cp -f $< $@
733
734 $(TARGETDIR)/%% : $(GENCODEDIR)/%%
735 cp -f $< $@
736
737 #----------------------------------------------------------------------
738
739 %(DEPENDS)s
740
741 #----------------------------------------------------------------------
742
743 $(TARGET) : $(OBJECTS)
744 $(LDSHARED) $(OBJECTS) $(LFLAGS) $(LIBS) $(OTHERLIBS) -o $(TARGET)
745
746
747
748 pycfiles : $(PYMODULES)
749 $(EXECPREFIX)/bin/python $(PYLIB)/compileall.py -l $(TARGETDIR)
750 $(EXECPREFIX)/bin/python -O $(PYLIB)/compileall.py -l $(TARGETDIR)
751
752
753 $(TARGETDIR) :
754 mkdir $(TARGETDIR)
755
756 $(GENCODEDIR):
757 mkdir $(GENCODEDIR)
758
759 #----------------------------------------------------------------------
760
761
762 %(OTHERRULES)s
763
764
765
766 '''
767
768
769 #----------------------------------------------------------------------------
770
771 if __name__ == '__main__':
772 main(sys.argv)
773
774 #----------------------------------------------------------------------------
775
776
777
778
779
780
781
782