]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env python | |
2 | #---------------------------------------------------------------------------- | |
3 | # Name: build.py | |
4 | # Purpose: This script is used to build wxPython. It reads a build | |
5 | # configuration file in the requested project directory and | |
6 | # based on the contents of the file can build Makefiles for | |
7 | # unix or win32, and can execute make with various options | |
8 | # potentially automating the entire build/install/clean process | |
9 | # from a single command. | |
10 | # | |
11 | # Author: Robin Dunn | |
12 | # | |
13 | # Created: 18-Aug-1999 | |
14 | # RCS-ID: $Id$ | |
15 | # Copyright: (c) 1999 by Total Control Software | |
16 | # Licence: wxWindows license | |
17 | #---------------------------------------------------------------------------- | |
18 | """ | |
19 | build.py | |
20 | ||
21 | This script is used to build wxPython. It reads a build configuration | |
22 | file in the requested project directory and based on the contents of | |
23 | the file can build Makefiles for unix or win32, and can execute make | |
24 | with various options potentially automating the entire | |
25 | build/install/clean process from a single command. | |
26 | ||
27 | The default action is to build the Makefile and exit. | |
28 | ||
29 | Options | |
30 | -C dir CD to dir before doing anything | |
31 | -B file Use file as the build configuration (default ./build.cfg) | |
32 | -M file Use file as the name of the makefile to create | |
33 | (default Makefile) | |
34 | ||
35 | -b Build the module (runs make) | |
36 | -i Install the module (runs make install) | |
37 | -c Cleanup (runs make clean) | |
38 | -u Uninstall (runs make uninstall) | |
39 | ||
40 | -h Show help and exit | |
41 | ||
42 | ||
43 | Configuration Files | |
44 | ||
45 | The build configuration file lists targets, source files and options | |
46 | for the the build process. The contents of the build.cfg are used to | |
47 | dynamically generate the Makefile. | |
48 | ||
49 | To prevent you from getting screwed when the default build.cfg is | |
50 | updated, you can override the values in build.cfg by putting your | |
51 | custom definitions in a file named build.local. You can also place a | |
52 | build.local file in the parent directory, or even in the grandparent | |
53 | directory for project-wide overrides. Finally, command-line arguments | |
54 | of the form NAME=VALUE can also be used to override simple configuration | |
55 | values. The order of evaluation is: | |
56 | ||
57 | 0. comman-line flags (-M, -b, etc.) | |
58 | 1. ./build.cfg | |
59 | 2. ../../build.local (if present) | |
60 | 3. ../build.local (if present) | |
61 | 4. ./build.local (if present) | |
62 | 5. command-line NAME=VALUEs | |
63 | ||
64 | The config files are actually just Python files that get exec'ed in a | |
65 | separate namespace which is then used later as a configuration object. | |
66 | This keeps the build script simple in that it doesn't have to parse | |
67 | anything, and the config files can be much more than just names and | |
68 | values as pretty much any python code can be executed. The global | |
69 | variables set in the config namespace are what are used later as | |
70 | configuation values. | |
71 | ||
72 | ||
73 | Configuration Options | |
74 | ||
75 | The following variables can be set in the config files. Only a few are | |
76 | required, the rest will either have suitable defaults or will be | |
77 | calculated from your current Python runtime environment. | |
78 | ||
79 | MODULE The name of the extension module to produce | |
80 | SWIGFILES A list of files that should be run through SWIG | |
81 | SWIGFLAGS Flags for SWIG | |
82 | SOURCES Other C/C++ sources that should be part of the module | |
83 | PYFILES Other Python files that should be installed with the module | |
84 | CFLAGS Flags to be used by the compiler | |
85 | LFLAGS Flags to be used at the link step | |
86 | LIBS Libraries to be linked with | |
87 | ||
88 | OTHERCFLAGS Extra flags to append to CFLAGS | |
89 | OTHERLFLAGS Extra flags to append to LFLAGS | |
90 | OTHERSWIGFLAGS Extra flags to append to SWIGFLAGS | |
91 | OTHERLIBS Other libraries to be linked with, in addition to LIBS | |
92 | OTHERTARGETS Other targets to be placed on the default rule line | |
93 | OTHERINSTALLTARGETS | |
94 | Other targets to be placed on the install rule line | |
95 | OTHERRULES This text is placed at the end of the makefile and | |
96 | will typically be used for adding rules and such | |
97 | DEFAULTRULE Text to be used for the default rule in the makefile | |
98 | ||
99 | TARGETDIR Destination for the install step | |
100 | ||
101 | MAKE The make program to use | |
102 | MAKEFILE The name of the makefile | |
103 | ||
104 | runBuild Setting this to 1 is eqivalent to the -b flag | |
105 | runInstall Setting this to 1 is eqivalent to the -i flag | |
106 | runClean Setting this to 1 is eqivalent to the -c flag | |
107 | runUninstall Setting this to 1 is eqivalent to the -u flag | |
108 | ||
109 | PYVERSION Version number of Python used in pathnames | |
110 | PYPREFIX The root of the Python install | |
111 | EXECPREFIX The root of the Python install for binary files | |
112 | PYTHONLIB The Python link library | |
113 | ||
114 | """ | |
115 | ||
116 | import sys, os, string, getopt | |
117 | ||
118 | #---------------------------------------------------------------------------- | |
119 | # This is really the wxPython version number, and will be placed in the | |
120 | # Makefiles for use with the distribution related targets. | |
121 | ||
122 | __version__ = '2.1.11' | |
123 | ||
124 | #---------------------------------------------------------------------------- | |
125 | ||
126 | def main(args): | |
127 | try: | |
128 | opts, args = getopt.getopt(args[1:], 'C:B:M:bicu') | |
129 | except getopt.error: | |
130 | usage() | |
131 | sys.exit(1) | |
132 | ||
133 | if not os.environ.has_key('WXWIN'): | |
134 | print "WARNING: WXWIN is not set in the environment. WXDIR may not\n"\ | |
135 | " be set properly in the makefile, you will have to \n"\ | |
136 | " set the environment variable or override in build.local." | |
137 | ||
138 | bldCfg = 'build.cfg' | |
139 | bldCfgLocal = 'build.local' | |
140 | MAKEFILE = 'Makefile' | |
141 | runBuild = 0 | |
142 | runInstall = 0 | |
143 | runClean = 0 | |
144 | runUninstall = 0 | |
145 | ||
146 | for flag, value in opts: | |
147 | if flag == '-C': os.chdir(value) | |
148 | elif flag == '-B': bldCfgFile = value | |
149 | elif flag == '-M': makefile = value | |
150 | elif flag == '-b': runBuild = 1 | |
151 | elif flag == '-c': runClean = 1 | |
152 | elif flag == '-i': runInstall = 1 | |
153 | elif flag == '-u': runUninstall = 1 | |
154 | ||
155 | elif flag == '-h': usage(); sys.exit(1) | |
156 | else: usage(); sys.exit(1) | |
157 | ||
158 | config = BuildConfig(bldCfg = bldCfg, | |
159 | bldCfgLocal = bldCfgLocal, | |
160 | MAKEFILE = MAKEFILE, | |
161 | runBuild = runBuild, | |
162 | runInstall = runInstall, | |
163 | runClean = runClean, | |
164 | runUninstall = runUninstall) | |
165 | ||
166 | err = 0 | |
167 | if config.readConfigFiles(args): | |
168 | config.doFixups() | |
169 | config.makeMakefile() | |
170 | ||
171 | if config.runBuild: | |
172 | cmd = "%s -f %s" % (config.MAKE, config.MAKEFILE) | |
173 | print "Running:", cmd | |
174 | err = os.system(cmd) | |
175 | ||
176 | if not err and config.runInstall: | |
177 | cmd = "%s -f %s install" % (config.MAKE, config.MAKEFILE) | |
178 | print "Running:", cmd | |
179 | err = os.system(cmd) | |
180 | ||
181 | ||
182 | if not err and config.runClean: | |
183 | cmd = "%s -f %s clean" % (config.MAKE, config.MAKEFILE) | |
184 | print "Running:", cmd | |
185 | err = os.system(cmd) | |
186 | ||
187 | if not err and config.runUninstall: | |
188 | cmd = "%s -f %s uninstall" % (config.MAKE, config.MAKEFILE) | |
189 | print "Running:", cmd | |
190 | err = os.system(cmd) | |
191 | ||
192 | return err | |
193 | ||
194 | ||
195 | #---------------------------------------------------------------------------- | |
196 | ||
197 | def usage(): | |
198 | print __doc__ | |
199 | ||
200 | #---------------------------------------------------------------------------- | |
201 | ||
202 | def swapslash(st): | |
203 | if sys.platform != 'win32': | |
204 | st = string.join(string.split(st, '\\'), '/') | |
205 | return st | |
206 | ||
207 | #---------------------------------------------------------------------------- | |
208 | ||
209 | def splitlines(st): | |
210 | return string.join(string.split(string.strip(st), ' '), ' \\\n\t') | |
211 | ||
212 | #---------------------------------------------------------------------------- | |
213 | ||
214 | class BuildConfig: | |
215 | def __init__(self, **kw): | |
216 | self.__dict__.update(kw) | |
217 | self.setDefaults() | |
218 | ||
219 | #------------------------------------------------------------ | |
220 | def setDefaults(self): | |
221 | self.VERSION = __version__ | |
222 | self.MODULE = '' | |
223 | self.SWIGFILES = [] | |
224 | self.SWIGFLAGS = '-c++ -shadow -python -keyword -dnone -I$(WXPSRCDIR)' | |
225 | self.SOURCES = [] | |
226 | self.PYFILES = [] | |
227 | self.LFLAGS = '' | |
228 | self.OTHERCFLAGS = '' | |
229 | self.OTHERLFLAGS = '' | |
230 | self.OTHERSWIGFLAGS = '' | |
231 | self.OTHERLIBS = '' | |
232 | self.OTHERTARGETS = '' | |
233 | self.OTHERINSTALLTARGETS = '' | |
234 | self.OTHERUNINSTALLTARGETS = '' | |
235 | self.OTHERRULES = '' | |
236 | self.DEFAULTRULE = 'default: $(GENCODEDIR) $(TARGET)' | |
237 | self.PYVERSION = sys.version[:3] | |
238 | self.PYPREFIX = sys.prefix | |
239 | self.EXECPREFIX = sys.exec_prefix | |
240 | self.WXDIR = '$(WXWIN)' | |
241 | self.FINAL = '0' | |
242 | self.WXP_USE_THREAD = '1' | |
243 | self.WXUSINGDLL = '1' | |
244 | self.OTHERDEP = '' | |
245 | self.WXPSRCDIR = '$(WXDIR)/utils/wxPython/src' | |
246 | self.SWIGDEPS = '' | |
247 | self.OTHERDEPS = '' | |
248 | ||
249 | ||
250 | if sys.platform == 'win32': | |
251 | self.MAKE = 'nmake' | |
252 | self.PYTHONLIB = '$(PYPREFIX)\\libs\\python15.lib' | |
253 | self.TARGETDIR = '$(PYPREFIX)\\wxPython' | |
254 | self.LIBS = '$(PYTHONLIB) $(WXPSRCDIR)\wxc.lib' | |
255 | self.GENCODEDIR = 'msw' | |
256 | self.SWIGTOOLKITFLAG = '-D__WXMSW__' | |
257 | self.OBJEXT = '.obj' | |
258 | self.TARGET = '$(MODULE).pyd' | |
259 | self.CFLAGS = '-I$(PYPREFIX)\include -I$(WXPSRCDIR) -I. /Fp$(MODULE).pch /YXhelpers.h -DSWIG_GLOBAL -DHAVE_CONFIG_H $(THREAD) ' | |
260 | self.LFLAGS = '$(DEBUGLFLAGS) /DLL /subsystem:windows,3.50 /machine:I386 /nologo' | |
261 | self.RESFILE = '' | |
262 | self.RESRULE = '' | |
263 | self.OVERRIDEFLAGS = '/GX-' | |
264 | self.RMCMD = '-erase ' | |
265 | self.WXPSRCDIR = os.path.normpath(self.WXPSRCDIR) | |
266 | self.CRTFLAG = '' | |
267 | ||
268 | ||
269 | else: | |
270 | self.MAKE = 'make' | |
271 | self.PYLIB = '$(EXECPREFIX)/lib/python$(PYVERSION)' | |
272 | self.LIBPL = '$(PYLIB)/config' | |
273 | self.PYTHONLIB = '$(LIBPL)/libpython$(PYVERSION).a' | |
274 | self.TARGETDIR = '$(EXECPREFIX)/lib/python$(PYVERSION)/site-packages/wxPython' | |
275 | self.TARGET = '$(MODULE)module$(SO)' | |
276 | self.OBJEXT = '.o' | |
277 | self.HELPERLIB = 'wxPyHelpers' | |
278 | self.HELPERLIBDIR = '/usr/local/lib' | |
279 | self.CFLAGS = '-DSWIG_GLOBAL -DHAVE_CONFIG_H $(THREAD) -I. '\ | |
280 | '`wx-config --cflags` -I$(PYINCLUDE) -I$(EXECINCLUDE) '\ | |
281 | '-I$(WXPSRCDIR)' | |
282 | self.LFLAGS = '-L$(WXPSRCDIR) `wx-config --libs`' | |
283 | self.LIBS = '-l$(HELPERLIB)' | |
284 | self.RMCMD = '-rm -f ' | |
285 | ||
286 | # **** What to do when I start supporting Motif, etc.??? | |
287 | self.GENCODEDIR = 'gtk' | |
288 | self.SWIGTOOLKITFLAG = '-D__WXGTK__' | |
289 | ||
290 | # Extract a few things from Python's Makefile... | |
291 | try: | |
292 | filename = os.path.join(self.EXECPREFIX, | |
293 | 'lib/python'+self.PYVERSION, | |
294 | 'config/Makefile') | |
295 | mfText = string.split(open(filename, 'r').read(), '\n') | |
296 | except IOError: | |
297 | raise SystemExit, "Python development files not found" | |
298 | ||
299 | self.CCC = self.findMFValue(mfText, 'CCC') | |
300 | self.CC = self.findMFValue(mfText, 'CC') | |
301 | self.OPT = self.findMFValue(mfText, 'OPT') | |
302 | self.SO = self.findMFValue(mfText, 'SO') | |
303 | self.LDSHARED = self.findMFValue(mfText, 'LDSHARED') | |
304 | self.CCSHARED = self.findMFValue(mfText, 'CCSHARED') | |
305 | #self.LINKFORSHARED = self.findMFValue(mfText, 'LINKFORSHARED') | |
306 | #self. = self.findMFValue(mfText, '') | |
307 | #self. = self.findMFValue(mfText, '') | |
308 | ||
309 | ||
310 | # The majority of cases will require LDSHARED to be | |
311 | # modified to use the C++ driver instead of the C driver | |
312 | # for linking. We'll try to do it here and if we goof up | |
313 | # then the user can correct it in their build.local file. | |
314 | self.LDSHARED = string.join(['$(CCC)'] + | |
315 | string.split(self.LDSHARED, ' ')[1:], | |
316 | ' ') | |
317 | ||
318 | ||
319 | #------------------------------------------------------------ | |
320 | def doFixups(self): | |
321 | # This is called after the config files have been evaluated | |
322 | # so we can do some sanity checking... | |
323 | if sys.platform != 'win32': | |
324 | if not self.CCC: | |
325 | print "Warning: C++ compiler not specified (CCC). Assuming c++" | |
326 | self.CCC = 'c++' | |
327 | if not self.CC: | |
328 | print "Warning: C compiler not specified (CC). Assuming cc" | |
329 | self.CC = 'cc' | |
330 | ||
331 | #------------------------------------------------------------ | |
332 | def findMFValue(self, mfText, st): | |
333 | # Find line begining with st= and return the value | |
334 | # Regex would probably be to cooler way to do this, but | |
335 | # I think this is the most understandable. | |
336 | for line in mfText: | |
337 | if string.find(line, st+'=') == 0: | |
338 | st = string.strip(line[len(st)+1:]) | |
339 | return st | |
340 | return None | |
341 | ||
342 | #------------------------------------------------------------ | |
343 | def makeMakefile(self): | |
344 | ||
345 | # make a list of object file names | |
346 | objects = "" | |
347 | for name in self.SWIGFILES: | |
348 | objects = objects + os.path.splitext(name)[0] + self.OBJEXT + ' ' | |
349 | for name in self.SOURCES: | |
350 | obj = os.path.basename(name) | |
351 | objects = objects + os.path.splitext(obj)[0] + self.OBJEXT + ' ' | |
352 | self.OBJECTS = splitlines(objects) | |
353 | ||
354 | ||
355 | # now build the text for the dependencies | |
356 | depends = "" | |
357 | for name in self.SWIGFILES: | |
358 | rootname = os.path.splitext(name)[0] | |
359 | text = '$(GENCODEDIR)/%s.cpp $(GENCODEDIR)/%s.py : %s.i %s\n' \ | |
360 | '$(TARGETDIR)\\%s.py : $(GENCODEDIR)\\%s.py\n' % \ | |
361 | (rootname, rootname, rootname, self.SWIGDEPS, rootname, rootname) | |
362 | depends = depends + text | |
363 | if self.OTHERDEPS: | |
364 | text = '%s%s : %s\n' % \ | |
365 | (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS) | |
366 | depends = depends + text | |
367 | for name in self.PYFILES: | |
368 | text = '$(TARGETDIR)\\%s.py : %s.py\n' % \ | |
369 | tuple([os.path.splitext(name)[0]] * 2) | |
370 | depends = depends + text | |
371 | if self.OTHERDEPS: | |
372 | for name in self.SOURCES: | |
373 | name = os.path.basename(name) | |
374 | text = '%s%s : %s\n' % \ | |
375 | (os.path.splitext(name)[0], self.OBJEXT, self.OTHERDEPS) | |
376 | depends = depends + text | |
377 | ||
378 | self.DEPENDS = swapslash(depends) | |
379 | ||
380 | ||
381 | # and the list of .py files | |
382 | pymodules = "" | |
383 | for name in self.SWIGFILES: | |
384 | pymodules = pymodules + '$(TARGETDIR)\\%s.py ' % os.path.splitext(name)[0] | |
385 | for name in self.PYFILES: | |
386 | pymodules = pymodules + '$(TARGETDIR)\\%s.py ' % os.path.splitext(name)[0] | |
387 | self.PYMODULES = splitlines(swapslash(pymodules)) | |
388 | ||
389 | ||
390 | # now make a list of the python files that would need uninstalled | |
391 | pycleanup = "" | |
392 | for name in self.SWIGFILES: | |
393 | pycleanup = pycleanup + self.makeCleanupList(name) | |
394 | for name in self.PYFILES: | |
395 | pycleanup = pycleanup + self.makeCleanupList(name) | |
396 | self.PYCLEANUP = swapslash(pycleanup) | |
397 | ||
398 | ||
399 | # finally, build the makefile | |
400 | if sys.platform == 'win32': | |
401 | if self.RESFILE: | |
402 | self.RESFILE = '$(MODULE).res' | |
403 | self.RESRULE = '$(MODULE).res : $(MODULE).rc $(WXDIR)\\include\\wx\\msw\\wx.rc\n\t'\ | |
404 | '$(rc) -r /i$(WXDIR)\\include -fo$@ $(MODULE).rc' | |
405 | text = win32Template % self.__dict__ | |
406 | else: | |
407 | text = unixTemplate % self.__dict__ | |
408 | f = open(self.MAKEFILE, 'w') | |
409 | f.write(text) | |
410 | f.close() | |
411 | ||
412 | print "Makefile created: ", self.MAKEFILE | |
413 | ||
414 | ||
415 | ||
416 | #------------------------------------------------------------ | |
417 | def makeCleanupList(self, name): | |
418 | st = "" | |
419 | st = st + '\t%s$(TARGETDIR)\\%s.py\n' % (self.RMCMD, os.path.splitext(name)[0]) | |
420 | st = st + '\t%s$(TARGETDIR)\\%s.pyc\n' % (self.RMCMD, os.path.splitext(name)[0]) | |
421 | st = st + '\t%s$(TARGETDIR)\\%s.pyo\n' % (self.RMCMD, os.path.splitext(name)[0]) | |
422 | return st | |
423 | ||
424 | ||
425 | #------------------------------------------------------------ | |
426 | def readConfigFiles(self, args): | |
427 | return self.processFile(self.bldCfg, 1) and \ | |
428 | self.processFile(os.path.join('../..', self.bldCfgLocal)) and \ | |
429 | self.processFile(os.path.join('..', self.bldCfgLocal)) and \ | |
430 | self.processFile(os.path.join('.', self.bldCfgLocal)) and \ | |
431 | self.processArgs(args) | |
432 | ||
433 | #------------------------------------------------------------ | |
434 | def processFile(self, filename, required=0): | |
435 | try: | |
436 | text = open(filename, 'r').read() | |
437 | except IOError: | |
438 | if required: | |
439 | print "Unable to open %s" % filename | |
440 | return 0 | |
441 | else: | |
442 | return 1 | |
443 | ||
444 | try: | |
445 | exec(text, self.__dict__) | |
446 | except: | |
447 | print "Error evaluating %s" % filename | |
448 | import traceback | |
449 | traceback.print_exc() | |
450 | return 0 | |
451 | return 1 | |
452 | ||
453 | ||
454 | #------------------------------------------------------------ | |
455 | def processArgs(self, args): | |
456 | try: | |
457 | for st in args: | |
458 | pair = string.split(st, '=') | |
459 | name = pair[0] | |
460 | value = pair[1] | |
461 | self.__dict__[name] = value | |
462 | except: | |
463 | print "Error parsing command-line: %s" % st | |
464 | return 0 | |
465 | ||
466 | return 1 | |
467 | ||
468 | ||
469 | #------------------------------------------------------------ | |
470 | ||
471 | ||
472 | ||
473 | ||
474 | ||
475 | #---------------------------------------------------------------------------- | |
476 | #---------------------------------------------------------------------------- | |
477 | #---------------------------------------------------------------------------- | |
478 | ||
479 | win32Template = ''' | |
480 | #---------------------------------------------------------------------- | |
481 | # This makefile was autogenerated from build.py. Your changes will be | |
482 | # lost if the generator is run again. You have been warned. | |
483 | #---------------------------------------------------------------------- | |
484 | ||
485 | WXDIR = %(WXDIR)s | |
486 | VERSION = %(VERSION)s | |
487 | MODULE = %(MODULE)s | |
488 | SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s | |
489 | CFLAGS = %(CFLAGS)s | |
490 | LFLAGS = %(LFLAGS)s | |
491 | PYVERSION = %(PYVERSION)s | |
492 | PYPREFIX = %(PYPREFIX)s | |
493 | EXECPREFIX = %(EXECPREFIX)s | |
494 | PYTHONLIB = %(PYTHONLIB)s | |
495 | FINAL = %(FINAL)s | |
496 | WXP_USE_THREAD = %(WXP_USE_THREAD)s | |
497 | WXUSINGDLL = %(WXUSINGDLL)s | |
498 | GENCODEDIR = %(GENCODEDIR)s | |
499 | RESFILE = %(RESFILE)s | |
500 | WXPSRCDIR = %(WXPSRCDIR)s | |
501 | ||
502 | ||
503 | TARGETDIR = %(TARGETDIR)s | |
504 | ||
505 | OBJECTS = %(OBJECTS)s | |
506 | PYMODULES = %(PYMODULES)s | |
507 | TARGET = %(TARGET)s | |
508 | ||
509 | ||
510 | ||
511 | ||
512 | !if "$(FINAL)" == "0" | |
513 | DEBUGLFLAGS = /DEBUG /INCREMENTAL:YES | |
514 | !else | |
515 | DEBUGLFLAGS = /INCREMENTAL:NO | |
516 | !endif | |
517 | !if "$(WXP_USE_THREAD)" == "1" | |
518 | THREAD=-DWXP_USE_THREAD=1 | |
519 | !endif | |
520 | ||
521 | ||
522 | ||
523 | ||
524 | NOPCH=1 | |
525 | OVERRIDEFLAGS=%(OVERRIDEFLAGS)s | |
526 | EXTRAFLAGS = $(CFLAGS) %(OTHERCFLAGS)s | |
527 | ||
528 | LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s | |
529 | EXTRALIBS = %(LIBS)s %(OTHERLIBS)s | |
530 | ||
531 | CRTFLAG=%(CRTFLAG)s | |
532 | ||
533 | #---------------------------------------------------------------------- | |
534 | ||
535 | !include $(WXDIR)\\src\\makevc.env | |
536 | ||
537 | #---------------------------------------------------------------------- | |
538 | ||
539 | %(DEFAULTRULE)s %(OTHERTARGETS)s | |
540 | ||
541 | ||
542 | ||
543 | install: $(TARGETDIR) $(TARGETDIR)\\$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s | |
544 | ||
545 | clean: | |
546 | -erase *.obj | |
547 | -erase *.exe | |
548 | -erase *.res | |
549 | -erase *.map | |
550 | -erase *.sbr | |
551 | -erase *.pdb | |
552 | -erase *.pch | |
553 | -erase $(MODULE).exp | |
554 | -erase $(MODULE).lib | |
555 | -erase $(MODULE).ilk | |
556 | -erase $(TARGET) | |
557 | ||
558 | ||
559 | uninstall: %(OTHERUNINSTALLTARGETS)s | |
560 | -erase $(TARGETDIR)\\$(TARGET) | |
561 | %(PYCLEANUP)s | |
562 | ||
563 | ||
564 | #---------------------------------------------------------------------- | |
565 | # implicit rule for compiling .cpp and .c files | |
566 | {}.cpp{}.obj: | |
567 | $(cc) @<< | |
568 | $(CPPFLAGS) /c /Tp $< | |
569 | << | |
570 | ||
571 | {$(GENCODEDIR)}.cpp{}.obj: | |
572 | $(cc) @<< | |
573 | $(CPPFLAGS) /c /Tp $< | |
574 | << | |
575 | ||
576 | {}.c{}.obj: | |
577 | $(cc) @<< | |
578 | $(CPPFLAGS) /c $< | |
579 | << | |
580 | ||
581 | .SUFFIXES : .i .py | |
582 | ||
583 | # Implicit rules to run SWIG | |
584 | {}.i{$(GENCODEDIR)}.cpp: | |
585 | swig $(SWIGFLAGS) -c -o $@ $< | |
586 | ||
587 | {}.i{$(GENCODEDIR)}.py: | |
588 | swig $(SWIGFLAGS) -c -o $(GENCODEDIR)\\tmp_wrap.cpp $< | |
589 | -erase $(GENCODEDIR)\\tmp_wrap.cpp | |
590 | ||
591 | ||
592 | {$(GENCODEDIR)}.py{$(TARGETDIR)}.py: | |
593 | copy $< $@ | |
594 | ||
595 | {}.py{$(TARGETDIR)}.py: | |
596 | copy $< $@ | |
597 | ||
598 | #---------------------------------------------------------------------- | |
599 | ||
600 | $(TARGET) : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(RESFILE) | |
601 | $(link) @<< | |
602 | /out:$@ | |
603 | $(LFLAGS) /def:$(MODULE).def /implib:./$(MODULE).lib | |
604 | $(DUMMYOBJ) $(OBJECTS) $(RESFILE) | |
605 | $(LIBS) | |
606 | << | |
607 | ||
608 | ||
609 | %(RESRULE)s | |
610 | ||
611 | ||
612 | $(TARGETDIR)\\$(TARGET) : $(TARGET) | |
613 | copy $(TARGET) $@ | |
614 | ||
615 | ||
616 | pycfiles : $(PYMODULES) | |
617 | $(EXECPREFIX)\\python $(PYPREFIX)\\Lib\\compileall.py -l $(TARGETDIR) | |
618 | $(EXECPREFIX)\\python -O $(PYPREFIX)\Lib\\compileall.py -l $(TARGETDIR) | |
619 | ||
620 | ||
621 | $(TARGETDIR) : | |
622 | mkdir $(TARGETDIR) | |
623 | ||
624 | $(GENCODEDIR): | |
625 | mkdir $(GENCODEDIR) | |
626 | ||
627 | #---------------------------------------------------------------------- | |
628 | ||
629 | %(DEPENDS)s | |
630 | ||
631 | #---------------------------------------------------------------------- | |
632 | ||
633 | showflags: | |
634 | @echo CPPFLAGS: | |
635 | @echo $(CPPFLAGS) | |
636 | @echo LFLAGS: | |
637 | @echo $(LFLAGS) | |
638 | ||
639 | ||
640 | ||
641 | %(OTHERRULES)s | |
642 | ''' | |
643 | ||
644 | #---------------------------------------------------------------------------- | |
645 | #---------------------------------------------------------------------------- | |
646 | #---------------------------------------------------------------------------- | |
647 | ||
648 | unixTemplate = ''' | |
649 | #---------------------------------------------------------------------- | |
650 | # This makefile was autogenerated from build.py. Your changes will be | |
651 | # lost if the generator is run again. You have been warned. | |
652 | #---------------------------------------------------------------------- | |
653 | ||
654 | ||
655 | ||
656 | WXDIR = %(WXDIR)s | |
657 | VERSION = %(VERSION)s | |
658 | MODULE = %(MODULE)s | |
659 | SWIGFLAGS = %(SWIGFLAGS)s %(SWIGTOOLKITFLAG)s %(OTHERSWIGFLAGS)s | |
660 | CFLAGS = %(CFLAGS)s $(OPT) %(OTHERCFLAGS)s | |
661 | LFLAGS = %(LFLAGS)s %(OTHERLFLAGS)s | |
662 | LIBS = %(LIBS)s %(OTHERLIBS)s | |
663 | PYVERSION = %(PYVERSION)s | |
664 | PYPREFIX = %(PYPREFIX)s | |
665 | EXECPREFIX = %(EXECPREFIX)s | |
666 | PYINCLUDE = $(PYPREFIX)/include/python$(PYVERSION) | |
667 | EXECINCLUDE = $(EXECPREFIX)/include/python$(PYVERSION) | |
668 | PYLIB = %(PYLIB)s | |
669 | LIBPL = %(LIBPL)s | |
670 | PYTHONLIB = %(PYTHONLIB)s | |
671 | FINAL = %(FINAL)s | |
672 | WXP_USE_THREAD = %(WXP_USE_THREAD)s | |
673 | GENCODEDIR = %(GENCODEDIR)s | |
674 | WXPSRCDIR = %(WXPSRCDIR)s | |
675 | HELPERLIB = %(HELPERLIB)s | |
676 | HELPERLIBDIR = %(HELPERLIBDIR)s | |
677 | ||
678 | TARGETDIR = %(TARGETDIR)s | |
679 | ||
680 | ||
681 | CCC = %(CCC)s | |
682 | CC = %(CC)s | |
683 | OPT = %(OPT)s | |
684 | SO = %(SO)s | |
685 | LDSHARED = %(LDSHARED)s | |
686 | CCSHARED = %(CCSHARED)s | |
687 | ||
688 | ||
689 | OBJECTS = %(OBJECTS)s | |
690 | PYMODULES = %(PYMODULES)s | |
691 | TARGET = %(TARGET)s | |
692 | ||
693 | ||
694 | ifeq ($(WXP_USE_THREAD), 1) | |
695 | THREAD=-DWXP_USE_THREAD | |
696 | endif | |
697 | ||
698 | #---------------------------------------------------------------------- | |
699 | ||
700 | %(DEFAULTRULE)s %(OTHERTARGETS)s | |
701 | ||
702 | install: $(TARGETDIR) $(TARGETDIR)/$(TARGET) pycfiles %(OTHERINSTALLTARGETS)s | |
703 | ||
704 | clean: | |
705 | -rm -f *.o *$(SO) *~ | |
706 | -rm -f $(TARGET) | |
707 | ||
708 | uninstall: %(OTHERUNINSTALLTARGETS)s | |
709 | -rm -f $(TARGETDIR)/$(TARGET) | |
710 | %(PYCLEANUP)s | |
711 | ||
712 | ||
713 | #---------------------------------------------------------------------- | |
714 | ||
715 | %%.o : %%.cpp | |
716 | $(CCC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $< | |
717 | ||
718 | %%.o : $(GENCODEDIR)/%%.cpp | |
719 | $(CCC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $< | |
720 | ||
721 | %%.o : %%.c | |
722 | $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $< | |
723 | ||
724 | %%.o : $(GENCODEDIR)/%%.c | |
725 | $(CC) $(CCSHARED) $(CFLAGS) $(OTHERCFLAGS) -c $< | |
726 | ||
727 | ifndef NOSWIG | |
728 | $(GENCODEDIR)/%%.cpp : %%.i | |
729 | swig $(SWIGFLAGS) -c -o $@ $< | |
730 | ||
731 | $(GENCODEDIR)/%%.py : %%.i | |
732 | swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $< | |
733 | rm $(GENCODEDIR)/tmp_wrap.cpp | |
734 | endif | |
735 | ||
736 | ||
737 | $(TARGETDIR)/%% : %% | |
738 | cp -f $< $@ | |
739 | ||
740 | $(TARGETDIR)/%% : $(GENCODEDIR)/%% | |
741 | cp -f $< $@ | |
742 | ||
743 | #---------------------------------------------------------------------- | |
744 | ||
745 | %(DEPENDS)s | |
746 | ||
747 | #---------------------------------------------------------------------- | |
748 | ||
749 | $(TARGET) : $(OBJECTS) | |
750 | $(LDSHARED) $(OBJECTS) $(LFLAGS) $(LIBS) $(OTHERLIBS) -o $(TARGET) | |
751 | ||
752 | ||
753 | ||
754 | pycfiles : $(PYMODULES) | |
755 | $(EXECPREFIX)/bin/python $(PYLIB)/compileall.py -l $(TARGETDIR) | |
756 | $(EXECPREFIX)/bin/python -O $(PYLIB)/compileall.py -l $(TARGETDIR) | |
757 | ||
758 | ||
759 | $(TARGETDIR) : | |
760 | mkdir -p $(TARGETDIR) | |
761 | ||
762 | $(GENCODEDIR): | |
763 | mkdir $(GENCODEDIR) | |
764 | ||
765 | #---------------------------------------------------------------------- | |
766 | ||
767 | ||
768 | %(OTHERRULES)s | |
769 | ||
770 | ||
771 | ||
772 | ''' | |
773 | ||
774 | ||
775 | #---------------------------------------------------------------------------- | |
776 | ||
777 | if __name__ == '__main__': | |
778 | err = main(sys.argv) | |
779 | sys.exit(err) | |
780 | ||
781 | #---------------------------------------------------------------------------- | |
782 | ||
783 | ||
784 | ||
785 | ||
786 | ||
787 | ||
788 | ||
789 |