]> git.saurik.com Git - wxWidgets.git/blame - build/bakefiles/regenMakefile.py
no need to define STRICT here either
[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
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
21MDEPS = common.bkl config.bkl files.bkl monolithic.bkl multilib.bkl wxwin.py
ddf98968
VS
22""")
23
24lines = []
25all = {}
481290e2 26all['autoconf'] = ['../../configure']
ddf98968
VS
27
28def addMakefile(bake, makedirs, deps=[], args={}):
29 """Adds rules to regenerate native makefile in directory 'makedir' from
30 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
31 other than 'bake'."""
32 print 'adding %s...' % bake
33 lines.append('')
ddf98968
VS
34
35 def add(bake, makedirs, make, dep, format, args={}):
36 a = ''
37 if 'all' in args: a += ' %s' % args['all']
38 if format in args: a += ' %s' % args[format]
2e1a466f
VS
39 if format != 'autoconf' and 'not_autoconf' in args:
40 a += ' %s' % args['not_autoconf']
ddf98968
VS
41 if format in makedirs:
42 makedir = makedirs[format]
43 else:
44 makedir = makedirs['all']
45 tfile = '%s/%s' % (makedir, make)
a0034878 46 lines.append('%s: %s' % (tfile, dep))
5646c3f8 47 lines.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format, a, bake))
31009f33 48 lines.append('\ttouch $@')
ddf98968
VS
49 if format not in all: all[format] = []
50 all[format].append(tfile)
51
52 dep = string.join(deps + [bake], ' ')
53
54 add(bake, makedirs, 'Makefile.in', dep, 'autoconf', args)
f5f530fd 55 add(bake, makedirs, 'makefile.bcc', dep, 'borland', args)
e234d4c9 56 add(bake, makedirs, 'makefile.vc', dep, 'msvc', args)
2e1a466f 57 add(bake, makedirs, 'makefile.gcc', dep, 'mingw', args)
31009f33 58 add(bake, makedirs, 'makefile.wat', dep, 'watcom', args)
ddf98968
VS
59
60
61
62# -----------------------------------------------
63# Add the makefiles:
64# -----------------------------------------------
65
66# main makefile:
31009f33 67addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}, [ '$(MDEPS)' ])
ddf98968
VS
68
69# samples main makefile:
fd3880a7
VS
70addMakefile('../../samples/samples.bkl', {'all':'../../samples'},
71 args={'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4'})
ddf98968
VS
72
73
a90f1b0b 74CONTRIB_DIR = 1
2e1a466f 75SAMPLES_DIR = 2
a90f1b0b
VS
76
77def onSubmakefile(type, dirname, names):
ddf98968
VS
78 bakes = [x for x in names if x.endswith('.bkl')]
79 if len(bakes) == 0: return
2e1a466f 80 dirname = dirname.replace(os.sep, '/')
ddf98968
VS
81 depth = dirname.count('/') - 2
82 if depth <= 0: return
2e1a466f
VS
83
84 if type==SAMPLES_DIR:
85 prefix = ''.join(['../' for i in range(0,depth)])
86 dirflags = '-DWXTOPDIR=%s../' % prefix
87 elif type==CONTRIB_DIR:
88 dirflags = '-DSRCDIR=../../src/%s' % dirname.split('/')[-1]
89 dirflags += ' -DWXTOPDIR=../../../'
ddf98968
VS
90
91 args = {
2e1a466f 92 'not_autoconf':dirflags,
481290e2 93 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
ddf98968
VS
94 }
95
96 for bake in bakes:
a90f1b0b
VS
97 if type==CONTRIB_DIR:
98 acdir = '../../contrib/src/%s' % dirname.split('/')[-1]
31009f33 99 ruledep = '$(CDEPS)'
a90f1b0b
VS
100 else:
101 acdir = dirname
31009f33 102 ruledep = '$(SDEPS)'
c0608865 103 addMakefile('%s/%s' % (dirname, bake),
31009f33 104 {'all':dirname,'autoconf':acdir}, deps=[ruledep],
ddf98968
VS
105 args=args)
106
2e1a466f
VS
107os.path.walk(os.path.join('..','..','samples'),
108 onSubmakefile, SAMPLES_DIR)
109os.path.walk(os.path.join('..','..','contrib','build'),
110 onSubmakefile, CONTRIB_DIR)
3560dc76
VS
111os.path.walk(os.path.join('..','..','contrib','samples'),
112 onSubmakefile, SAMPLES_DIR)
ddf98968
VS
113
114
115cleanCmds = ''
116for f in all:
117 for i in all[f]:
118 cleanCmds += '\trm -f %s\n' % i
119
120for f in all:
121 var = '%s_ALL' % f.upper()
122 file.write('%s = %s\n' % (var,' '.join(all[f])))
123
124file.write('all:')
125for f in all:
126 file.write(' %s' % f)
127file.write('\n\n')
128for f in all:
129 file.write('%s: $(%s_ALL)\n' % (f, f.upper()))
130
131file.write("""
132clean:
133\trm -f ../../autoconf_inc.m4
ddf98968
VS
134%s
135
6bd5dab5 136../../autoconf_inc.m4: ../../Makefile.in
ddf98968
VS
137../../configure: ../../autoconf_inc.m4
138\t(cd ../.. ; aclocal && autoconf)
139
ddf98968
VS
140Makefile: regenMakefile.py
141\t./regenMakefile.py
142\t@echo
143\t@echo -------------------------------------------
144\t@echo Please rerun make, Makefile was regenerated
145\t@echo -------------------------------------------
146\t@echo
147\t@exit 1
148""" % cleanCmds)
149for l in lines:
150 file.write('%s\n' % l)
151file.close()