]> git.saurik.com Git - wxWidgets.git/blob - build/bakefiles/regenMakefile.py
quick fix for mac resource problems
[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, copy
11
12 # list of files that should _not_ be generated even thought we could do it:
13 DONT_GENERATE = [
14 '../../samples/Makefile.in',
15 '../../samples/samples.dsw',
16 '../../demos/demos.dsw',
17 '../../samples/html/html_samples.dsw',
18 '../../samples/opengl/opengl_samples.dsw',
19 '../../samples/mobile/mobile_samples.dsw',
20 ]
21
22 file = open('Makefile', 'wt')
23 file.write("""
24 # Generated by regenMakefile.py
25
26 BAKEFILE = bakefile -v
27
28
29 CDEPS = config.bkl common.bkl common_contrib.bkl
30 SDEPS = config.bkl common.bkl common_samples.bkl
31 MDEPS = common.bkl config.bkl files.bkl monolithic.bkl multilib.bkl opengl.bkl wxwin.py
32
33 DSWFLAGS = -DRUNTIME_LIBS=dynamic -DOFFICIAL_BUILD=0 -DUSE_HTML=1 \\
34 -DUSE_OPENGL=1 -DUSE_ODBC=1 -DMONOLITHIC=0 -DUSE_GUI=1 \\
35 -DDEBUG_INFO=default -DDEBUG_FLAG=default -DMSLU=0
36
37 COMPAT_TARGETS = ../../src/wxWindows.dsp
38
39 """)
40
41 lines = {}
42 all = {}
43 all['autoconf'] = []
44
45 linesCur = None
46
47 def addMakefile(bake, makedirs, deps=[], args={}):
48 """Adds rules to regenerate native makefile in directory 'makedir' from
49 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
50 other than 'bake'."""
51 print 'adding %s...' % bake
52 global linesCur
53 linesCur = ['\n']
54
55 def add(bake, makedirs, make, dep, format, args={}):
56 global linesCur
57 a = ''
58 if 'all' in args: a += ' %s' % args['all']
59 if format in args: a += ' %s' % args[format]
60 if format != 'autoconf' and 'not_autoconf' in args:
61 a += ' %s' % args['not_autoconf']
62 if format in makedirs:
63 makedir = makedirs[format]
64 else:
65 makedir = makedirs['all']
66 tfile = '%s/%s' % (makedir, make)
67
68 if tfile in DONT_GENERATE: return
69
70 linesCur.append('%s: %s' % (tfile, dep))
71 linesCur.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format, a, bake))
72 linesCur.append('\ttouch $@')
73 if format not in all: all[format] = []
74 all[format].append(tfile)
75
76 dep = string.join(deps + [bake], ' ')
77
78 add(bake, makedirs, 'Makefile.in', dep, 'autoconf', args)
79 add(bake, makedirs, 'makefile.bcc', dep, 'borland', args)
80 add(bake, makedirs, 'makefile.vc', dep, 'msvc', args)
81 add(bake, makedirs, 'makefile.gcc', dep, 'mingw', args)
82 add(bake, makedirs, 'makefile.wat', dep, 'watcom', args)
83 add(bake, makedirs,
84 (bake[1+bake.rfind('/'):]).replace('.bkl','.dsw'),
85 dep, 'msvc6prj', args)
86
87 lines[bake] = linesCur
88
89
90
91 # -----------------------------------------------
92 # Add the makefiles:
93 # -----------------------------------------------
94
95 # main makefile:
96 addMakefile('wx.bkl', {'all':'../msw','autoconf':'../..'}, [ '$(MDEPS)' ],
97 args={
98 'borland':'-DOPTIONS_FILE=config.bcc',
99 'msvc':'-DOPTIONS_FILE=config.vc',
100 'mingw':'-DOPTIONS_FILE=config.gcc',
101 'watcom':'-DOPTIONS_FILE=config.wat',
102 'msvc6prj':'$(DSWFLAGS)',
103 })
104
105 # samples main makefile:
106 addMakefile('../../samples/samples.bkl', {'all':'../../samples'},
107 args={
108 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
109 'borland':'-DOPTIONS_FILE=../build/msw/config.bcc -DWRITE_OPTIONS_FILE=0',
110 'msvc':'-DOPTIONS_FILE=../build/msw/config.vc -DWRITE_OPTIONS_FILE=0',
111 'mingw':'-DOPTIONS_FILE=../build/msw/config.gcc -DWRITE_OPTIONS_FILE=0',
112 'watcom':'-DOPTIONS_FILE=../build/msw/config.wat -DWRITE_OPTIONS_FILE=0',
113 })
114 addMakefile('../../demos/demos.bkl', {'all':'../../demos'},
115 args={
116 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
117 'borland':'-DOPTIONS_FILE=../build/msw/config.bcc -DWRITE_OPTIONS_FILE=0',
118 'msvc':'-DOPTIONS_FILE=../build/msw/config.vc -DWRITE_OPTIONS_FILE=0',
119 'mingw':'-DOPTIONS_FILE=../build/msw/config.gcc -DWRITE_OPTIONS_FILE=0',
120 'watcom':'-DOPTIONS_FILE=../build/msw/config.wat -DWRITE_OPTIONS_FILE=0',
121 })
122
123
124 CONTRIB_DIR = 1
125 SAMPLES_DIR = 2
126
127 def onSubmakefile(type, dirname, names):
128 bakes = [x for x in names if x.endswith('.bkl')]
129 if len(bakes) == 0: return
130 bakes.sort()
131 dirname = dirname.replace(os.sep, '/')
132 depth = dirname.count('/') - 2
133 if depth <= 0: return
134
135 if type==SAMPLES_DIR:
136 prefix = ''.join(['../' for i in range(0,depth)])
137 topdirflags = '-DWXTOPDIR=%s../' % prefix
138 srcdirflags = ''
139 cfgbase = '%s../build/msw/config.' % prefix
140 elif type==CONTRIB_DIR:
141 srcdirflags = '-DSRCDIR=../../src/%s' % dirname.split('/')[-1]
142 topdirflags = ' -DWXTOPDIR=../../../'
143 cfgbase = '../../../build/msw/config.'
144
145 args = {
146 'all':topdirflags,
147 'not_autoconf':srcdirflags,
148 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
149 'msvc':'-DOPTIONS_FILE='+cfgbase+'vc -DWRITE_OPTIONS_FILE=0',
150 'mingw':'-DOPTIONS_FILE='+cfgbase+'gcc -DWRITE_OPTIONS_FILE=0',
151 'borland':'-DOPTIONS_FILE='+cfgbase+'bcc -DWRITE_OPTIONS_FILE=0',
152 'watcom':'-DOPTIONS_FILE='+cfgbase+'wat -DWRITE_OPTIONS_FILE=0',
153 'msvc6prj':'$(DSWFLAGS)',
154 }
155
156 for bake in bakes:
157 if type==CONTRIB_DIR:
158 acdir = '../../contrib/src/%s' % dirname.split('/')[-1]
159 ruledep = '$(CDEPS)'
160 else:
161 acdir = dirname
162 ruledep = '$(SDEPS)'
163 addMakefile('%s/%s' % (dirname, bake),
164 {'all':dirname,'autoconf':acdir}, deps=[ruledep],
165 args=args)
166
167 os.path.walk(os.path.join('..','..','samples'),
168 onSubmakefile, SAMPLES_DIR)
169 os.path.walk(os.path.join('..','..','demos'),
170 onSubmakefile, SAMPLES_DIR)
171 os.path.walk(os.path.join('..','..','utils'),
172 onSubmakefile, SAMPLES_DIR)
173 os.path.walk(os.path.join('..','..','contrib','build'),
174 onSubmakefile, CONTRIB_DIR)
175 os.path.walk(os.path.join('..','..','contrib','samples'),
176 onSubmakefile, SAMPLES_DIR)
177 os.path.walk(os.path.join('..','..','contrib','utils'),
178 onSubmakefile, SAMPLES_DIR)
179
180
181 cleanCmds = ''
182 allK = all.keys()
183 allK.sort()
184 cleanList = []
185
186 for f in allK:
187 all[f].sort()
188
189 for f in allK:
190 for i in all[f]:
191 cleanList.append('\trm -f %s\n' % i)
192 cleanCmds = ''.join(cleanList)
193
194 for f in allK:
195 var = '%s_ALL' % f.upper()
196 file.write('%s = \\\n\t%s\n' % (var,' \\\n\t'.join(all[f])))
197
198 file.write('\nall: $(COMPAT_TARGETS)')
199 for f in allK:
200 file.write(' %s' % f)
201 file.write('\n\n')
202 for f in allK:
203 file.write('%s: $(%s_ALL)\n' % (f, f.upper()))
204
205 file.write("""
206 clean:
207 \trm -f ../../autoconf_inc.m4
208 \trm -f $(COMPAT_TARGETS)
209 %s
210
211 library: ../../Makefile.in\\
212 ../msw/makefile.bcc\\
213 ../msw/makefile.vc\\
214 ../msw/makefile.wat\\
215 ../msw/makefile.gcc\\
216 ../msw/wx.dsw\\
217 ../../src/wxWindows.dsp
218
219 ../../autoconf_inc.m4: ../../Makefile.in
220
221 ../../src/wxWindows.dsp: monolithic.bkl files.bkl
222 \t$(BAKEFILE) -Icompat -fwx24dsp -DUSE_GUI=1 -DWXUNIV=0 -o$@ wx.bkl
223 \ttouch $@
224
225 Makefile: regenMakefile.py
226 \t./regenMakefile.py
227 \t@echo
228 \t@echo -------------------------------------------
229 \t@echo Please rerun make, Makefile was regenerated
230 \t@echo -------------------------------------------
231 \t@echo
232 \t@exit 1
233 """ % cleanCmds)
234 linesK = lines.keys()
235 linesK.sort()
236 for lk in linesK:
237 for l in lines[lk]:
238 file.write('%s\n' % l)
239 file.close()