2003-06-23 15:50:43 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generates Makefile that is used to regenerate native makefiles from
|
|
|
|
# bakefiles.
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
|
|
|
|
import string, os.path
|
|
|
|
|
|
|
|
file = open('Makefile', 'wt')
|
|
|
|
file.write("""
|
|
|
|
# Generated by regenMakefile.py
|
|
|
|
|
|
|
|
BAKEFILE = bakefile
|
|
|
|
BAKEARGS = -v
|
|
|
|
|
|
|
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
lines = []
|
|
|
|
all = {}
|
2003-06-24 18:05:29 -04:00
|
|
|
all['autoconf'] = ['../../configure']
|
2003-06-23 15:50:43 -04:00
|
|
|
|
|
|
|
def addMakefile(bake, makedirs, deps=[], args={}):
|
|
|
|
"""Adds rules to regenerate native makefile in directory 'makedir' from
|
|
|
|
bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
|
|
|
|
other than 'bake'."""
|
|
|
|
print 'adding %s...' % bake
|
|
|
|
lines.append('')
|
|
|
|
lines.append('# from %s' % bake)
|
|
|
|
|
|
|
|
def add(bake, makedirs, make, dep, format, args={}):
|
|
|
|
a = ''
|
|
|
|
if 'all' in args: a += ' %s' % args['all']
|
|
|
|
if format in args: a += ' %s' % args[format]
|
|
|
|
if format in makedirs:
|
|
|
|
makedir = makedirs[format]
|
|
|
|
else:
|
|
|
|
makedir = makedirs['all']
|
|
|
|
tfile = '%s/%s' % (makedir, make)
|
2003-06-23 18:00:37 -04:00
|
|
|
lines.append('%s: %s' % (tfile, dep))
|
2003-06-23 15:50:43 -04:00
|
|
|
lines.append('\t$(BAKEFILE) $(BAKEARGS) -f%s -o%s%s %s' % \
|
|
|
|
(format, tfile, a, bake))
|
|
|
|
lines.append('\ttouch %s' % tfile)
|
|
|
|
if format not in all: all[format] = []
|
|
|
|
all[format].append(tfile)
|
|
|
|
|
|
|
|
dep = string.join(deps + [bake], ' ')
|
|
|
|
|
|
|
|
add(bake, makedirs, 'Makefile.in', dep, 'autoconf', args)
|
2003-06-27 17:53:57 -04:00
|
|
|
add(bake, makedirs, 'makefile.bcc', dep, 'borland', args)
|
2003-06-23 15:50:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------
|
|
|
|
# Add the makefiles:
|
|
|
|
# -----------------------------------------------
|
|
|
|
|
|
|
|
# main makefile:
|
|
|
|
addMakefile('wx.bkl', {'all':'..','autoconf':'../..'},
|
|
|
|
['common.bkl', 'config.bkl', 'files.bkl', 'monolithic.bkl',
|
2003-06-25 12:29:51 -04:00
|
|
|
'multilib.bkl', 'wxwin.py'])
|
2003-06-23 15:50:43 -04:00
|
|
|
|
|
|
|
# samples main makefile:
|
2003-06-28 11:00:23 -04:00
|
|
|
addMakefile('../../samples/samples.bkl', {'all':'../../samples'},
|
|
|
|
args={'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4'})
|
2003-06-23 15:50:43 -04:00
|
|
|
|
|
|
|
|
2003-06-24 20:26:27 -04:00
|
|
|
CONTRIB_DIR = 1
|
|
|
|
|
|
|
|
def onSubmakefile(type, dirname, names):
|
2003-06-23 15:50:43 -04:00
|
|
|
bakes = [x for x in names if x.endswith('.bkl')]
|
|
|
|
if len(bakes) == 0: return
|
|
|
|
depth = dirname.count('/') - 2
|
|
|
|
if depth <= 0: return
|
|
|
|
prefix = ''.join(['../' for i in range(0,depth)])
|
|
|
|
|
|
|
|
args = {
|
2003-06-27 05:32:58 -04:00
|
|
|
'all':'-DWXTOPDIR=%s../' % prefix,
|
2003-06-24 18:05:29 -04:00
|
|
|
'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
|
2003-06-23 15:50:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for bake in bakes:
|
2003-06-24 20:26:27 -04:00
|
|
|
if type==CONTRIB_DIR:
|
|
|
|
acdir = '../../contrib/src/%s' % dirname.split('/')[-1]
|
2003-06-25 12:29:51 -04:00
|
|
|
ruledep = 'common_contrib.bkl'
|
2003-06-24 20:26:27 -04:00
|
|
|
else:
|
|
|
|
acdir = dirname
|
2003-06-25 12:29:51 -04:00
|
|
|
ruledep = 'common_samples.bkl'
|
2003-06-24 19:52:06 -04:00
|
|
|
addMakefile('%s/%s' % (dirname, bake),
|
2003-06-24 20:26:27 -04:00
|
|
|
{'all':dirname,'autoconf':acdir},
|
2003-06-25 12:29:51 -04:00
|
|
|
deps=['common.bkl',ruledep,'config.bkl'],
|
2003-06-23 15:50:43 -04:00
|
|
|
args=args)
|
|
|
|
|
2003-06-24 20:26:27 -04:00
|
|
|
os.path.walk('../../samples', onSubmakefile, None)
|
|
|
|
os.path.walk('../../contrib/build', onSubmakefile, CONTRIB_DIR)
|
2003-06-23 15:50:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
cleanCmds = ''
|
|
|
|
for f in all:
|
|
|
|
for i in all[f]:
|
|
|
|
cleanCmds += '\trm -f %s\n' % i
|
|
|
|
|
|
|
|
for f in all:
|
|
|
|
var = '%s_ALL' % f.upper()
|
|
|
|
file.write('%s = %s\n' % (var,' '.join(all[f])))
|
|
|
|
|
|
|
|
file.write('all:')
|
|
|
|
for f in all:
|
|
|
|
file.write(' %s' % f)
|
|
|
|
file.write('\n\n')
|
|
|
|
for f in all:
|
|
|
|
file.write('%s: $(%s_ALL)\n' % (f, f.upper()))
|
|
|
|
|
|
|
|
file.write("""
|
|
|
|
clean:
|
|
|
|
\trm -f ../../autoconf_inc.m4
|
|
|
|
%s
|
|
|
|
|
2003-06-23 17:12:56 -04:00
|
|
|
../../autoconf_inc.m4: ../../Makefile.in
|
2003-06-23 15:50:43 -04:00
|
|
|
../../configure: ../../autoconf_inc.m4
|
|
|
|
\t(cd ../.. ; aclocal && autoconf)
|
|
|
|
|
|
|
|
Makefile: regenMakefile.py
|
|
|
|
\t./regenMakefile.py
|
|
|
|
\t@echo
|
|
|
|
\t@echo -------------------------------------------
|
|
|
|
\t@echo Please rerun make, Makefile was regenerated
|
|
|
|
\t@echo -------------------------------------------
|
|
|
|
\t@echo
|
|
|
|
\t@exit 1
|
|
|
|
""" % cleanCmds)
|
|
|
|
for l in lines:
|
|
|
|
file.write('%s\n' % l)
|
|
|
|
file.close()
|