]> git.saurik.com Git - wxWidgets.git/blob - build/bakefiles/regenMakefile.py
added recent new files (still can't run bakefile to regen the makefiles though...)
[wxWidgets.git] / build / bakefiles / regenMakefile.py
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
10 import string, os.path
11
12 file = open('Makefile', 'wt')
13 file.write("""
14 # Generated by regenMakefile.py
15
16 BAKEFILE = bakefile
17 BAKEARGS = -v
18
19
20 """)
21
22 lines = []
23 all = {}
24 all['autoconf'] = ['../../configure']
25
26 def 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' % (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 add(bake, makedirs, 'makefile.bcc', dep, 'borland', args)
54 add(bake, makedirs, 'makefile.vc', dep, 'msvc', args)
55
56
57
58 # -----------------------------------------------
59 # Add the makefiles:
60 # -----------------------------------------------
61
62 # main makefile:
63 addMakefile('wx.bkl', {'all':'..','autoconf':'../..'},
64 ['common.bkl', 'config.bkl', 'files.bkl', 'monolithic.bkl',
65 'multilib.bkl', 'wxwin.py'])
66
67 # samples main makefile:
68 addMakefile('../../samples/samples.bkl', {'all':'../../samples'},
69 args={'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4'})
70
71
72 CONTRIB_DIR = 1
73
74 def onSubmakefile(type, dirname, names):
75 bakes = [x for x in names if x.endswith('.bkl')]
76 if len(bakes) == 0: return
77 depth = dirname.count('/') - 2
78 if depth <= 0: return
79 prefix = ''.join(['../' for i in range(0,depth)])
80
81 args = {
82 'all':'-DWXTOPDIR=%s../' % prefix,
83 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
84 }
85
86 for bake in bakes:
87 if type==CONTRIB_DIR:
88 acdir = '../../contrib/src/%s' % dirname.split('/')[-1]
89 ruledep = 'common_contrib.bkl'
90 else:
91 acdir = dirname
92 ruledep = 'common_samples.bkl'
93 addMakefile('%s/%s' % (dirname, bake),
94 {'all':dirname,'autoconf':acdir},
95 deps=['common.bkl',ruledep,'config.bkl'],
96 args=args)
97
98 os.path.walk('../../samples', onSubmakefile, None)
99 os.path.walk('../../contrib/build', onSubmakefile, CONTRIB_DIR)
100
101
102 cleanCmds = ''
103 for f in all:
104 for i in all[f]:
105 cleanCmds += '\trm -f %s\n' % i
106
107 for f in all:
108 var = '%s_ALL' % f.upper()
109 file.write('%s = %s\n' % (var,' '.join(all[f])))
110
111 file.write('all:')
112 for f in all:
113 file.write(' %s' % f)
114 file.write('\n\n')
115 for f in all:
116 file.write('%s: $(%s_ALL)\n' % (f, f.upper()))
117
118 file.write("""
119 clean:
120 \trm -f ../../autoconf_inc.m4
121 %s
122
123 ../../autoconf_inc.m4: ../../Makefile.in
124 ../../configure: ../../autoconf_inc.m4
125 \t(cd ../.. ; aclocal && autoconf)
126
127 Makefile: regenMakefile.py
128 \t./regenMakefile.py
129 \t@echo
130 \t@echo -------------------------------------------
131 \t@echo Please rerun make, Makefile was regenerated
132 \t@echo -------------------------------------------
133 \t@echo
134 \t@exit 1
135 """ % cleanCmds)
136 for l in lines:
137 file.write('%s\n' % l)
138 file.close()