]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/distrib/build.py
fixed some typos
[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.14'
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 self.CRTFLAG = ''
267
268
269 else:
270 self.MAKE = 'make'
271 self.PYLIB = '$(EXECPREFIX)/lib/python$(PYVERSION)'
272 self.LIBPL = '$(PYLIB)/config'
273 self.PYTHONLIB = '$(LIBPL)/libpython$(PYVERSION).a'
274 self.TARGETDIR = '$(EXECPREFIX)/lib/python$(PYVERSION)/site-packages/wxPython'
275 self.TARGET = '$(MODULE)module$(SO)'
276 self.OBJEXT = '.o'
277 self.HELPERLIB = 'wxPyHelpers'
278 self.HELPERLIBDIR = '/usr/local/lib'
279 self.CFLAGS = '-DSWIG_GLOBAL -DHAVE_CONFIG_H $(THREAD) -I. '\
280 '`$(WXCONFIG) --cflags` -I$(PYINCLUDE) -I$(EXECINCLUDE) '\
281 '-I$(WXPSRCDIR)'
282 self.LFLAGS = '-L$(WXPSRCDIR) `$(WXCONFIG) --libs`'
283 self.LIBS = '-l$(HELPERLIB)'
284 self.RMCMD = '-rm -f '
285 self.WXCONFIG = 'wx-config'
286
287
288 # **** What to do when I start supporting Motif, etc.???
289 self.GENCODEDIR = 'gtk'
290 self.SWIGTOOLKITFLAG = '-D__WXGTK__'
291
292 # Extract a few things from Python's Makefile...
293 try:
294 filename = os.path.join(self.EXECPREFIX,
295 'lib/python'+self.PYVERSION,
296 'config/Makefile')
297 mfText = string.split(open(filename, 'r').read(), '\n')
298 except IOError:
299 raise SystemExit, "Python development files not found"
300
301 self.CCC = self.findMFValue(mfText, 'CCC')
302 self.CC = self.findMFValue(mfText, 'CC')
303 self.OPT = self.findMFValue(mfText, 'OPT')
304 self.SO = self.findMFValue(mfText, 'SO')
305 self.LDSHARED = self.findMFValue(mfText, 'LDSHARED')
306 self.CCSHARED = self.findMFValue(mfText, 'CCSHARED')
307 #self.LINKFORSHARED = self.findMFValue(mfText, 'LINKFORSHARED')
308 #self. = self.findMFValue(mfText, '')
309 #self. = self.findMFValue(mfText, '')
310
311
312 # The majority of cases will require LDSHARED to be
313 # modified to use the C++ driver instead of the C driver
314 # for linking. We'll try to do it here and if we goof up
315 # then the user can correct it in their build.local file.
316 self.LDSHARED = string.join(['$(CCC)'] +
317 string.split(self.LDSHARED, ' ')[1:],
318 ' ')
319
320
321 #------------------------------------------------------------
322 def doFixups(self):
323 # This is called after the config files have been evaluated
324 # so we can do some sanity checking...
325 if sys.platform != 'win32':
326 if not self.CCC:
327 self.CCC = os.popen('%(WXCONFIG)s --cxx' % self.__dict__, 'r').read()[:-1]
328 if not self.CCC:
329 print "Warning: C++ compiler not specified (CCC). Assuming c++"
330 self.CCC = 'c++'
331 if not self.CC:
332 self.CCC = os.popen('%(WXCONFIG)s --cc' % self.__dict__, 'r').read()[:-1]
333 if not self.CC:
334 print "Warning: C compiler not specified (CC). Assuming cc"
335 self.CC = 'cc'
336
337 #------------------------------------------------------------
338 def findMFValue(self, mfText, st):
339 # Find line begining with st= and return the value
340 # Regex would probably be to cooler way to do this, but
341 # I think this is the most understandable.
342 for line in mfText:
343 if string.find(line, st+'=') == 0:
344 st = string.strip(line[len(st)+1:])
345 return st
346 return None
347
348 #------------------------------------------------------------
349 def makeMakefile(self):
350
351 # make a list of object file names
352 objects = ""
353 for name in self.SWIGFILES:
354 objects = objects + os.path.splitext(name)[0] + self.OBJEXT + ' '
355 for name in self.SOURCES:
356 obj = os.path.basename(name)
357 objects = objects + os.path.splitext(obj)[0] + self.OBJEXT + ' '
358 self.OBJECTS = splitlines(objects)
359
360
361 # now build the text for the dependencies
362 depends = ""
363 for name in self.SWIGFILES:
364 rootname = os.path.splitext(name)[0]
365 text = '$(GENCODEDIR)/%s.cpp $(GENCODEDIR)/%s.py : %s.i %s\n' \
366 '$(TARGETDIR)\\%s.py : $(GENCODEDIR)\\%s.py\n' % \
367 (rootname, rootname, rootname, self.SWIGDEPS, rootname, rootname)
368 depends = depends + text
369 if self.OTHERDEPS:
370 text = '%s%s : %s\n' % \
371 (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS)
372 depends = depends + text
373 for name in self.PYFILES:
374 text = '$(TARGETDIR)\\%s.py : %s.py\n' % \
375 tuple([os.path.splitext(name)[0]] * 2)
376 depends = depends + text
377 if self.OTHERDEPS:
378 for name in self.SOURCES:
379 name = os.path.basename(name)
380 text = '%s%s : %s\n' % \
381 (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS)
382 depends = depends + text
383
384 self.DEPENDS = swapslash(depends)
385
386
387 # and the list of .py files
388 pymodules = ""
389 for name in self.SWIGFILES:
390 pymodules = pymodules + '$(TARGETDIR)\\%s.py ' % os.path.splitext(name)[0]
391 for name in self.PYFILES:
392 pymodules = pymodules + '$(TARGETDIR)\\%s.py ' % os.path.splitext(name)[0]
393 self.PYMODULES = splitlines(swapslash(pymodules))
394
395
396 # now make a list of the python files that would need uninstalled
397 pycleanup = ""
398 for name in self.SWIGFILES:
399 pycleanup = pycleanup + self.makeCleanupList(name)
400 for name in self.PYFILES:
401 pycleanup = pycleanup + self.makeCleanupList(name)
402 self.PYCLEANUP = swapslash(pycleanup)
403
404
405 # finally, build the makefile
406 if sys.platform == 'win32':
407 if self.RESFILE:
408 self.RESFILE = '$(MODULE).res'
409 self.RESRULE = '$(MODULE).res : $(MODULE).rc $(WXDIR)\\include\\wx\\msw\\wx.rc\n\t'\
410 '$(rc) -r /i$(WXDIR)\\include -fo$@ $(MODULE).rc'
411 text = win32Template % self.__dict__
412 else:
413 text = unixTemplate % self.__dict__
414 f = open(self.MAKEFILE, 'w')
415 f.write(text)
416 f.close()
417
418 print "Makefile created: ", self.MAKEFILE
419
420
421
422 #------------------------------------------------------------
423 def makeCleanupList(self, name):
424 st = ""
425 st = st + '\t%s$(TARGETDIR)\\%s.py\n' % (self.RMCMD, os.path.splitext(name)[0])
426 st = st + '\t%s$(TARGETDIR)\\%s.pyc\n' % (self.RMCMD, os.path.splitext(name)[0])
427 st = st + '\t%s$(TARGETDIR)\\%s.pyo\n' % (self.RMCMD, os.path.splitext(name)[0])
428 return st
429
430
431 #------------------------------------------------------------
432 def readConfigFiles(self, args):
433 return self.processFile(self.bldCfg, 1) and \
434 self.processFile(os.path.join('../..', self.bldCfgLocal)) and \
435 self.processFile(os.path.join('..', self.bldCfgLocal)) and \
436 self.processFile(os.path.join('.', self.bldCfgLocal)) and \
437 self.processArgs(args)
438
439 #------------------------------------------------------------
440 def processFile(self, filename, required=0):
441 try:
442 text = open(filename, 'r').read()
443 except IOError:
444 if required:
445 print "Unable to open %s" % filename
446 return 0
447 else:
448 return 1
449
450 try:
451 exec(text, self.__dict__)
452 except:
453 print "Error evaluating %s" % filename
454 import traceback
455 traceback.print_exc()
456 return 0
457 return 1
458
459
460 #------------------------------------------------------------
461 def processArgs(self, args):
462 try:
463 for st in args:
464 pair = string.split(st, '=')
465 name = pair[0]
466 value = pair[1]
467 self.__dict__[name] = value
468 except:
469 print "Error parsing command-line: %s" % st
470 return 0
471
472 return 1
473
474
475 #------------------------------------------------------------
476
477
478
479
480
481 #----------------------------------------------------------------------------
482 #----------------------------------------------------------------------------
483 #----------------------------------------------------------------------------
484
485 win32Template = '''
486 #----------------------------------------------------------------------
487 # This makefile was autogenerated from build.py. Your changes will be
488 # lost if the generator is run again. You have been warned.
489 #----------------------------------------------------------------------
490
491 WXDIR = %(WXDIR)s
492 VERSION = %(VERSION)s
493 MODULE = %(MODULE)s
494 SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s
495 CFLAGS = %(CFLAGS)s
496 LFLAGS = %(LFLAGS)s
497 PYVERSION = %(PYVERSION)s
498 PYPREFIX = %(PYPREFIX)s
499 EXECPREFIX = %(EXECPREFIX)s
500 PYTHONLIB = %(PYTHONLIB)s
501 FINAL = %(FINAL)s
502 WXP_USE_THREAD = %(WXP_USE_THREAD)s
503 WXUSINGDLL = %(WXUSINGDLL)s
504 GENCODEDIR = %(GENCODEDIR)s
505 RESFILE = %(RESFILE)s
506 WXPSRCDIR = %(WXPSRCDIR)s
507
508
509 TARGETDIR = %(TARGETDIR)s
510
511 OBJECTS = %(OBJECTS)s
512 PYMODULES = %(PYMODULES)s
513 TARGET = %(TARGET)s
514
515
516
517
518 !if "$(FINAL)" == "0"
519 DEBUGLFLAGS = /DEBUG /INCREMENTAL:YES
520 !else
521 DEBUGLFLAGS = /INCREMENTAL:NO
522 !endif
523 !if "$(WXP_USE_THREAD)" == "1"
524 THREAD=-DWXP_USE_THREAD=1
525 !endif
526
527
528
529
530 NOPCH=1
531 OVERRIDEFLAGS=%(OVERRIDEFLAGS)s
532 EXTRAFLAGS = $(CFLAGS) %(OTHERCFLAGS)s
533
534 LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
535 EXTRALIBS = %(LIBS)s %(OTHERLIBS)s
536
537 CRTFLAG=%(CRTFLAG)s
538
539 #----------------------------------------------------------------------
540
541 !include $(WXDIR)\\src\\makevc.env
542
543 #----------------------------------------------------------------------
544
545 %(DEFAULTRULE)s %(OTHERTARGETS)s
546
547
548
549 install: $(TARGETDIR) $(TARGETDIR)\\$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s
550
551 clean:
552 -erase *.obj
553 -erase *.exe
554 -erase *.res
555 -erase *.map
556 -erase *.sbr
557 -erase *.pdb
558 -erase *.pch
559 -erase $(MODULE).exp
560 -erase $(MODULE).lib
561 -erase $(MODULE).ilk
562 -erase $(TARGET)
563
564
565 uninstall: %(OTHERUNINSTALLTARGETS)s
566 -erase $(TARGETDIR)\\$(TARGET)
567 %(PYCLEANUP)s
568
569
570 #----------------------------------------------------------------------
571 # implicit rule for compiling .cpp and .c files
572 {}.cpp{}.obj:
573 $(cc) @<<
574 $(CPPFLAGS) /c /Tp $<
575 <<
576
577 {$(GENCODEDIR)}.cpp{}.obj:
578 $(cc) @<<
579 $(CPPFLAGS) /c /Tp $<
580 <<
581
582 {}.c{}.obj:
583 $(cc) @<<
584 $(CPPFLAGS) /c $<
585 <<
586
587 .SUFFIXES : .i .py
588
589 # Implicit rules to run SWIG
590 {}.i{$(GENCODEDIR)}.cpp:
591 swig $(SWIGFLAGS) -c -o $@ $<
592
593 {}.i{$(GENCODEDIR)}.py:
594 swig $(SWIGFLAGS) -c -o $(GENCODEDIR)\\tmp_wrap.cpp $<
595 -erase $(GENCODEDIR)\\tmp_wrap.cpp
596
597
598 {$(GENCODEDIR)}.py{$(TARGETDIR)}.py:
599 copy $< $@
600
601 {}.py{$(TARGETDIR)}.py:
602 copy $< $@
603
604 #----------------------------------------------------------------------
605
606 $(TARGET) : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(RESFILE)
607 $(link) @<<
608 /out:$@
609 $(LFLAGS) /export:init$(MODULE) /implib:./$(MODULE).lib
610 $(DUMMYOBJ) $(OBJECTS) $(RESFILE)
611 $(LIBS)
612 <<
613
614
615 %(RESRULE)s
616
617
618 $(TARGETDIR)\\$(TARGET) : $(TARGET)
619 copy $(TARGET) $@
620
621
622 pycfiles : $(PYMODULES)
623 $(EXECPREFIX)\\python $(PYPREFIX)\\Lib\\compileall.py -l $(TARGETDIR)
624 $(EXECPREFIX)\\python -O $(PYPREFIX)\Lib\\compileall.py -l $(TARGETDIR)
625
626
627 $(TARGETDIR) :
628 mkdir $(TARGETDIR)
629
630 $(GENCODEDIR):
631 mkdir $(GENCODEDIR)
632
633 #----------------------------------------------------------------------
634
635 %(DEPENDS)s
636
637 #----------------------------------------------------------------------
638
639 showflags:
640 @echo CPPFLAGS:
641 @echo $(CPPFLAGS)
642 @echo LFLAGS:
643 @echo $(LFLAGS)
644
645
646
647 %(OTHERRULES)s
648 '''
649
650 #----------------------------------------------------------------------------
651 #----------------------------------------------------------------------------
652 #----------------------------------------------------------------------------
653
654 unixTemplate = '''
655 #----------------------------------------------------------------------
656 # This makefile was autogenerated from build.py. Your changes will be
657 # lost if the generator is run again. You have been warned.
658 #----------------------------------------------------------------------
659
660
661
662 WXDIR = %(WXDIR)s
663 VERSION = %(VERSION)s
664 MODULE = %(MODULE)s
665 SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s
666 CFLAGS = %(CFLAGS)s $(OPT) %(OTHERCFLAGS)s
667 LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s
668 LIBS = %(LIBS)s %(OTHERLIBS)s
669 PYVERSION = %(PYVERSION)s
670 PYPREFIX = %(PYPREFIX)s
671 EXECPREFIX = %(EXECPREFIX)s
672 PYINCLUDE = $(PYPREFIX)/include/python$(PYVERSION)
673 EXECINCLUDE = $(EXECPREFIX)/include/python$(PYVERSION)
674 PYLIB = %(PYLIB)s
675 LIBPL = %(LIBPL)s
676 PYTHONLIB = %(PYTHONLIB)s
677 FINAL = %(FINAL)s
678 WXP_USE_THREAD = %(WXP_USE_THREAD)s
679 GENCODEDIR = %(GENCODEDIR)s
680 WXPSRCDIR = %(WXPSRCDIR)s
681 HELPERLIB = %(HELPERLIB)s
682 HELPERLIBDIR = %(HELPERLIBDIR)s
683 WXCONFIG=%(WXCONFIG)s
684 TARGETDIR = %(TARGETDIR)s
685
686
687 CCC = %(CCC)s
688 CC = %(CC)s
689 OPT = %(OPT)s
690 SO = %(SO)s
691 LDSHARED = %(LDSHARED)s
692 CCSHARED = %(CCSHARED)s
693
694
695 OBJECTS = %(OBJECTS)s
696 PYMODULES = %(PYMODULES)s
697 TARGET = %(TARGET)s
698
699
700 ifeq ($(WXP_USE_THREAD), 1)
701 THREAD=-DWXP_USE_THREAD
702 endif
703
704 #----------------------------------------------------------------------
705
706 %(DEFAULTRULE)s %(OTHERTARGETS)s
707
708 install: $(TARGETDIR) $(TARGETDIR)/$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s
709
710 clean:
711 -rm -f *.o *$(SO) *~
712 -rm -f $(TARGET)
713
714 uninstall: %(OTHERUNINSTALLTARGETS)s
715 -rm -f $(TARGETDIR)/$(TARGET)
716 %(PYCLEANUP)s
717
718
719 #----------------------------------------------------------------------
720
721 %%.o : %%.cpp
722 $(CCC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
723
724 %%.o : $(GENCODEDIR)/%%.cpp
725 $(CCC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
726
727 %%.o : %%.c
728 $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
729
730 %%.o : $(GENCODEDIR)/%%.c
731 $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $<
732
733 ifndef NOSWIG
734 $(GENCODEDIR)/%%.cpp : %%.i
735 swig $(SWIGFLAGS) -c -o $@ $<
736
737 $(GENCODEDIR)/%%.py : %%.i
738 swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $<
739 rm $(GENCODEDIR)/tmp_wrap.cpp
740 endif
741
742
743 $(TARGETDIR)/%% : %%
744 cp -f $< $@
745
746 $(TARGETDIR)/%% : $(GENCODEDIR)/%%
747 cp -f $< $@
748
749 #----------------------------------------------------------------------
750
751 %(DEPENDS)s
752
753 #----------------------------------------------------------------------
754
755 $(TARGET) : $(OBJECTS)
756 $(LDSHARED) $(OBJECTS) $(LFLAGS) $(LIBS) $(OTHERLIBS) -o $(TARGET)
757
758
759
760 pycfiles : $(PYMODULES)
761 $(EXECPREFIX)/bin/python $(PYLIB)/compileall.py -l $(TARGETDIR)
762 $(EXECPREFIX)/bin/python -O $(PYLIB)/compileall.py -l $(TARGETDIR)
763
764
765 $(TARGETDIR) :
766 mkdir -p $(TARGETDIR)
767
768 $(GENCODEDIR):
769 mkdir $(GENCODEDIR)
770
771 #----------------------------------------------------------------------
772
773
774 %(OTHERRULES)s
775
776
777
778 '''
779
780
781 #----------------------------------------------------------------------------
782
783 if __name__ == '__main__':
784 err = main(sys.argv)
785 sys.exit(err)
786
787 #----------------------------------------------------------------------------
788
789
790
791
792
793
794
795