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