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