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