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