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