]> git.saurik.com Git - wxWidgets.git/blame - build/bakefiles/regenMakefile.py
bakefile build system
[wxWidgets.git] / build / bakefiles / regenMakefile.py
CommitLineData
ddf98968
VS
1#!/usr/bin/env python
2
3#
4# Generates Makefile that is used to regenerate native makefiles from
5# bakefiles.
6#
7# $Id$
8#
9
10import string, os.path
11
12file = open('Makefile', 'wt')
13file.write("""
14# Generated by regenMakefile.py
15
16BAKEFILE = bakefile
17BAKEARGS = -v
18
19
20""")
21
22lines = []
23all = {}
24all['autoconf'] = ['../../configure', '../../samples/configure']
25
26def addMakefile(bake, makedirs, deps=[], args={}):
27 """Adds rules to regenerate native makefile in directory 'makedir' from
28 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
29 other than 'bake'."""
30 print 'adding %s...' % bake
31 lines.append('')
32 lines.append('# from %s' % bake)
33
34 def add(bake, makedirs, make, dep, format, args={}):
35 a = ''
36 if 'all' in args: a += ' %s' % args['all']
37 if format in args: a += ' %s' % args[format]
38 if format in makedirs:
39 makedir = makedirs[format]
40 else:
41 makedir = makedirs['all']
42 tfile = '%s/%s' % (makedir, make)
43 lines.append('%s: %s Makefile' % (tfile, dep))
44 lines.append('\t$(BAKEFILE) $(BAKEARGS) -f%s -o%s%s %s' % \
45 (format, tfile, a, bake))
46 lines.append('\ttouch %s' % tfile)
47 if format not in all: all[format] = []
48 all[format].append(tfile)
49
50 dep = string.join(deps + [bake], ' ')
51
52 add(bake, makedirs, 'Makefile.in', dep, 'autoconf', args)
53
54
55
56# -----------------------------------------------
57# Add the makefiles:
58# -----------------------------------------------
59
60# main makefile:
61addMakefile('wx.bkl', {'all':'..','autoconf':'../..'},
62 ['common.bkl', 'config.bkl', 'files.bkl', 'monolithic.bkl',
63 'wxwin.py'])
64
65# samples main makefile:
66addMakefile('../../samples/samples.bkl', {'all':'../../samples'})
67
68
69def onSample(arg, dirname, names):
70 bakes = [x for x in names if x.endswith('.bkl')]
71 if len(bakes) == 0: return
72 depth = dirname.count('/') - 2
73 if depth <= 0: return
74 prefix = ''.join(['../' for i in range(0,depth)])
75
76 args = {
77 'all':'-DWXTOPDIR=/%s..' % prefix,
78 'autoconf':'-DAUTOCONF_MACROS_FILE=../../samples/autoconf_inc.m4',
79 }
80
81 for bake in bakes:
82 addMakefile('%s/%s' % (dirname, bake), {'all':dirname},
83 deps=['common.bkl','common_samples.bkl','config.bkl'],
84 args=args)
85
86os.path.walk('../../samples', onSample, None)
87
88
89cleanCmds = ''
90for f in all:
91 for i in all[f]:
92 cleanCmds += '\trm -f %s\n' % i
93
94for f in all:
95 var = '%s_ALL' % f.upper()
96 file.write('%s = %s\n' % (var,' '.join(all[f])))
97
98file.write('all:')
99for f in all:
100 file.write(' %s' % f)
101file.write('\n\n')
102for f in all:
103 file.write('%s: $(%s_ALL)\n' % (f, f.upper()))
104
105file.write("""
106clean:
107\trm -f ../../autoconf_inc.m4
108\trm -f ../../samples/autoconf_inc.m4
109%s
110
111../../configure: ../../autoconf_inc.m4
112\t(cd ../.. ; aclocal && autoconf)
113
114../../samples/configure: ../../samples/autoconf_inc.m4
115\t(cd ../../samples ; aclocal && autoconf)
116
117Makefile: regenMakefile.py
118\t./regenMakefile.py
119\t@echo
120\t@echo -------------------------------------------
121\t@echo Please rerun make, Makefile was regenerated
122\t@echo -------------------------------------------
123\t@echo
124\t@exit 1
125""" % cleanCmds)
126for l in lines:
127 file.write('%s\n' % l)
128file.close()