]> git.saurik.com Git - wxWidgets.git/blame - build/bakefiles/regenMakefile.py
added all samples
[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
2ae7eb26 10import string, os.path, copy
ddf98968 11
f2f7877d
VS
12# list of files that should _not_ be generated even thought we could do it:
13DONT_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',
19]
20
ddf98968
VS
21file = open('Makefile', 'wt')
22file.write("""
23# Generated by regenMakefile.py
24
31009f33 25BAKEFILE = bakefile -v
ddf98968
VS
26
27
31009f33
VS
28CDEPS = config.bkl common.bkl common_contrib.bkl
29SDEPS = config.bkl common.bkl common_samples.bkl
50da51ee 30MDEPS = common.bkl config.bkl files.bkl monolithic.bkl multilib.bkl opengl.bkl wxwin.py
6839868c 31
4f6e1dac 32DSWFLAGS = -DRUNTIME_LIBS=dynamic -DOFFICIAL_BUILD=0 -DUSE_HTML=1 \\
bb41dcbe 33 -DUSE_OPENGL=1 -DUSE_ODBC=1 -DMONOLITHIC=0 -DUSE_GUI=1 \\
4f6e1dac 34 -DDEBUG_INFO=default -DDEBUG_FLAG=default
1dbdb45d
VS
35
36COMPAT_TARGETS = ../../src/wxWindows.dsp
37
ddf98968
VS
38""")
39
2ae7eb26 40lines = {}
ddf98968 41all = {}
b19f771f 42all['autoconf'] = []
ddf98968 43
2ae7eb26
VS
44linesCur = None
45
ddf98968
VS
46def 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
2ae7eb26
VS
51 global linesCur
52 linesCur = ['\n']
ddf98968
VS
53
54 def add(bake, makedirs, make, dep, format, args={}):
2ae7eb26 55 global linesCur
ddf98968
VS
56 a = ''
57 if 'all' in args: a += ' %s' % args['all']
58 if format in args: a += ' %s' % args[format]
2e1a466f
VS
59 if format != 'autoconf' and 'not_autoconf' in args:
60 a += ' %s' % args['not_autoconf']
ddf98968
VS
61 if format in makedirs:
62 makedir = makedirs[format]
63 else:
64 makedir = makedirs['all']
65 tfile = '%s/%s' % (makedir, make)
f2f7877d
VS
66
67 if tfile in DONT_GENERATE: return
68
2ae7eb26
VS
69 linesCur.append('%s: %s' % (tfile, dep))
70 linesCur.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format, a, bake))
71 linesCur.append('\ttouch $@')
ddf98968
VS
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)
f5f530fd 78 add(bake, makedirs, 'makefile.bcc', dep, 'borland', args)
e234d4c9 79 add(bake, makedirs, 'makefile.vc', dep, 'msvc', args)
2e1a466f 80 add(bake, makedirs, 'makefile.gcc', dep, 'mingw', args)
31009f33 81 add(bake, makedirs, 'makefile.wat', dep, 'watcom', args)
f2f7877d
VS
82 add(bake, makedirs,
83 (bake[1+bake.rfind('/'):]).replace('.bkl','.dsw'),
84 dep, 'msvc6prj', args)
2ae7eb26
VS
85
86 lines[bake] = linesCur
ddf98968
VS
87
88
89
90# -----------------------------------------------
91# Add the makefiles:
92# -----------------------------------------------
93
94# main makefile:
698bfad5 95addMakefile('wx.bkl', {'all':'../msw','autoconf':'../..'}, [ '$(MDEPS)' ],
73d01310
VS
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',
6839868c 101 'msvc6prj':'$(DSWFLAGS)',
73d01310 102 })
ddf98968
VS
103
104# samples main makefile:
fd3880a7 105addMakefile('../../samples/samples.bkl', {'all':'../../samples'},
73d01310
VS
106 args={
107 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
698bfad5
VS
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',
3534e34a
VS
112 })
113addMakefile('../../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',
73d01310 120 })
ddf98968
VS
121
122
a90f1b0b 123CONTRIB_DIR = 1
2e1a466f 124SAMPLES_DIR = 2
a90f1b0b
VS
125
126def onSubmakefile(type, dirname, names):
ddf98968
VS
127 bakes = [x for x in names if x.endswith('.bkl')]
128 if len(bakes) == 0: return
2ae7eb26 129 bakes.sort()
2e1a466f 130 dirname = dirname.replace(os.sep, '/')
ddf98968
VS
131 depth = dirname.count('/') - 2
132 if depth <= 0: return
2e1a466f
VS
133
134 if type==SAMPLES_DIR:
135 prefix = ''.join(['../' for i in range(0,depth)])
136 dirflags = '-DWXTOPDIR=%s../' % prefix
698bfad5 137 cfgbase = '%s../build/msw/config.' % prefix
2e1a466f
VS
138 elif type==CONTRIB_DIR:
139 dirflags = '-DSRCDIR=../../src/%s' % dirname.split('/')[-1]
140 dirflags += ' -DWXTOPDIR=../../../'
698bfad5 141 cfgbase = '../../../build/msw/config.'
ddf98968
VS
142
143 args = {
e54bb212 144 'all':dirflags,
481290e2 145 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
73d01310
VS
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',
6839868c 150 'msvc6prj':'$(DSWFLAGS)',
ddf98968 151 }
6839868c 152
ddf98968 153 for bake in bakes:
a90f1b0b
VS
154 if type==CONTRIB_DIR:
155 acdir = '../../contrib/src/%s' % dirname.split('/')[-1]
31009f33 156 ruledep = '$(CDEPS)'
a90f1b0b
VS
157 else:
158 acdir = dirname
31009f33 159 ruledep = '$(SDEPS)'
c0608865 160 addMakefile('%s/%s' % (dirname, bake),
31009f33 161 {'all':dirname,'autoconf':acdir}, deps=[ruledep],
ddf98968
VS
162 args=args)
163
2e1a466f
VS
164os.path.walk(os.path.join('..','..','samples'),
165 onSubmakefile, SAMPLES_DIR)
2e903934
VS
166os.path.walk(os.path.join('..','..','demos'),
167 onSubmakefile, SAMPLES_DIR)
2e1a466f
VS
168os.path.walk(os.path.join('..','..','contrib','build'),
169 onSubmakefile, CONTRIB_DIR)
3560dc76
VS
170os.path.walk(os.path.join('..','..','contrib','samples'),
171 onSubmakefile, SAMPLES_DIR)
9fae71ed
VS
172os.path.walk(os.path.join('..','..','contrib','utils'),
173 onSubmakefile, SAMPLES_DIR)
ddf98968
VS
174
175
176cleanCmds = ''
2ae7eb26
VS
177allK = all.keys()
178allK.sort()
179cleanList = []
57700c50
VS
180
181for f in allK:
182 all[f].sort()
183
2ae7eb26 184for f in allK:
ddf98968 185 for i in all[f]:
2ae7eb26 186 cleanList.append('\trm -f %s\n' % i)
2ae7eb26 187 cleanCmds = ''.join(cleanList)
ddf98968 188
2ae7eb26 189for f in allK:
ddf98968 190 var = '%s_ALL' % f.upper()
2ae7eb26 191 file.write('%s = \\\n\t%s\n' % (var,' \\\n\t'.join(all[f])))
ddf98968 192
1dbdb45d 193file.write('\nall: $(COMPAT_TARGETS)')
2ae7eb26 194for f in allK:
ddf98968
VS
195 file.write(' %s' % f)
196file.write('\n\n')
2ae7eb26 197for f in allK:
ddf98968
VS
198 file.write('%s: $(%s_ALL)\n' % (f, f.upper()))
199
200file.write("""
201clean:
202\trm -f ../../autoconf_inc.m4
1dbdb45d 203\trm -f $(COMPAT_TARGETS)
ddf98968
VS
204%s
205
698bfad5
VS
206library: ../../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
daa66792 213
6bd5dab5 214../../autoconf_inc.m4: ../../Makefile.in
ddf98968 215
1dbdb45d
VS
216../../src/wxWindows.dsp: monolithic.bkl files.bkl
217\t$(BAKEFILE) -Icompat -fwx24dsp -DUSE_GUI=1 -DWXUNIV=0 -o$@ wx.bkl
29f76293 218\ttouch $@
1dbdb45d 219
ddf98968
VS
220Makefile: 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)
2ae7eb26
VS
229linesK = lines.keys()
230linesK.sort()
231for lk in linesK:
232 for l in lines[lk]:
233 file.write('%s\n' % l)
ddf98968 234file.close()