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