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