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