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