Removed wxGetOsVersion stub. It's now handled by utilscmn.cpp.
[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
10import string, os.path
11
12file = open('Makefile', 'wt')
13file.write("""
14# Generated by regenMakefile.py
15
16BAKEFILE = bakefile
17BAKEARGS = -v
18
19
20""")
21
22lines = []
23all = {}
481290e2 24all['autoconf'] = ['../../configure']
ddf98968
VS
25
26def addMakefile(bake, makedirs, deps=[], args={}):
27 """Adds rules to regenerate native makefile in directory 'makedir' from
28 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
29 other than 'bake'."""
30 print 'adding %s...' % bake
31 lines.append('')
32 lines.append('# from %s' % bake)
33
34 def add(bake, makedirs, make, dep, format, args={}):
35 a = ''
36 if 'all' in args: a += ' %s' % args['all']
37 if format in args: a += ' %s' % args[format]
38 if format in makedirs:
39 makedir = makedirs[format]
40 else:
41 makedir = makedirs['all']
42 tfile = '%s/%s' % (makedir, make)
a0034878 43 lines.append('%s: %s' % (tfile, dep))
ddf98968
VS
44 lines.append('\t$(BAKEFILE) $(BAKEARGS) -f%s -o%s%s %s' % \
45 (format, tfile, a, bake))
46 lines.append('\ttouch %s' % tfile)
47 if format not in all: all[format] = []
48 all[format].append(tfile)
49
50 dep = string.join(deps + [bake], ' ')
51
52 add(bake, makedirs, 'Makefile.in', dep, 'autoconf', args)
f5f530fd 53 add(bake, makedirs, 'makefile.bcc', dep, 'borland', args)
ddf98968
VS
54
55
56
57# -----------------------------------------------
58# Add the makefiles:
59# -----------------------------------------------
60
61# main makefile:
62addMakefile('wx.bkl', {'all':'..','autoconf':'../..'},
63 ['common.bkl', 'config.bkl', 'files.bkl', 'monolithic.bkl',
e86e1522 64 'multilib.bkl', 'wxwin.py'])
ddf98968
VS
65
66# samples main makefile:
67addMakefile('../../samples/samples.bkl', {'all':'../../samples'})
68
69
a90f1b0b
VS
70CONTRIB_DIR = 1
71
72def onSubmakefile(type, dirname, names):
ddf98968
VS
73 bakes = [x for x in names if x.endswith('.bkl')]
74 if len(bakes) == 0: return
75 depth = dirname.count('/') - 2
76 if depth <= 0: return
77 prefix = ''.join(['../' for i in range(0,depth)])
78
79 args = {
66fc7908 80 'all':'-DWXTOPDIR=%s../' % prefix,
481290e2 81 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
ddf98968
VS
82 }
83
84 for bake in bakes:
a90f1b0b
VS
85 if type==CONTRIB_DIR:
86 acdir = '../../contrib/src/%s' % dirname.split('/')[-1]
e86e1522 87 ruledep = 'common_contrib.bkl'
a90f1b0b
VS
88 else:
89 acdir = dirname
e86e1522 90 ruledep = 'common_samples.bkl'
c0608865 91 addMakefile('%s/%s' % (dirname, bake),
a90f1b0b 92 {'all':dirname,'autoconf':acdir},
e86e1522 93 deps=['common.bkl',ruledep,'config.bkl'],
ddf98968
VS
94 args=args)
95
a90f1b0b
VS
96os.path.walk('../../samples', onSubmakefile, None)
97os.path.walk('../../contrib/build', onSubmakefile, CONTRIB_DIR)
ddf98968
VS
98
99
100cleanCmds = ''
101for f in all:
102 for i in all[f]:
103 cleanCmds += '\trm -f %s\n' % i
104
105for f in all:
106 var = '%s_ALL' % f.upper()
107 file.write('%s = %s\n' % (var,' '.join(all[f])))
108
109file.write('all:')
110for f in all:
111 file.write(' %s' % f)
112file.write('\n\n')
113for f in all:
114 file.write('%s: $(%s_ALL)\n' % (f, f.upper()))
115
116file.write("""
117clean:
118\trm -f ../../autoconf_inc.m4
ddf98968
VS
119%s
120
6bd5dab5 121../../autoconf_inc.m4: ../../Makefile.in
ddf98968
VS
122../../configure: ../../autoconf_inc.m4
123\t(cd ../.. ; aclocal && autoconf)
124
ddf98968
VS
125Makefile: regenMakefile.py
126\t./regenMakefile.py
127\t@echo
128\t@echo -------------------------------------------
129\t@echo Please rerun make, Makefile was regenerated
130\t@echo -------------------------------------------
131\t@echo
132\t@exit 1
133""" % cleanCmds)
134for l in lines:
135 file.write('%s\n' % l)
136file.close()