4 # Generates Makefile that is used to regenerate native makefiles from
10 import string
, os
.path
, copy
12 # list of files that should _not_ be generated even thought we could do it:
14 '../../samples/Makefile.in',
15 '../../samples/samples.dsw',
16 '../../demos/demos.dsw',
17 '../../samples/html/html_samples.dsw',
18 '../../samples/opengl/opengl_samples.dsw',
21 file = open('Makefile', 'wt')
23 # Generated by regenMakefile.py
25 BAKEFILE = bakefile -v
28 CDEPS = config.bkl common.bkl common_contrib.bkl
29 SDEPS = config.bkl common.bkl common_samples.bkl
30 MDEPS = common.bkl config.bkl files.bkl monolithic.bkl multilib.bkl opengl.bkl wxwin.py
32 DSWFLAGS = -DRUNTIME_LIBS=dynamic -DOFFICIAL_BUILD=0 -DUSE_HTML=1 \\
33 -DUSE_OPENGL=1 -DUSE_ODBC=1 -DMONOLITHIC=0 -DUSE_GUI=1 \\
34 -DDEBUG_INFO=default -DDEBUG_FLAG=default
36 COMPAT_TARGETS = ../../src/wxWindows.dsp
46 def addMakefile(bake
, makedirs
, deps
=[], args
={}):
47 """Adds rules to regenerate native makefile in directory 'makedir' from
48 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
50 print 'adding %s...' % bake
54 def add(bake
, makedirs
, make
, dep
, format
, args
={}):
57 if 'all' in args
: a
+= ' %s' % args
['all']
58 if format
in args
: a
+= ' %s' % args
[format
]
59 if format
!= 'autoconf' and 'not_autoconf' in args
:
60 a
+= ' %s' % args
['not_autoconf']
61 if format
in makedirs
:
62 makedir
= makedirs
[format
]
64 makedir
= makedirs
['all']
65 tfile
= '%s/%s' % (makedir
, make
)
67 if tfile
in DONT_GENERATE
: return
69 linesCur
.append('%s: %s' % (tfile
, dep
))
70 linesCur
.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format
, a
, bake
))
71 linesCur
.append('\ttouch $@')
72 if format
not in all
: all
[format
] = []
73 all
[format
].append(tfile
)
75 dep
= string
.join(deps
+ [bake
], ' ')
77 add(bake
, makedirs
, 'Makefile.in', dep
, 'autoconf', args
)
78 add(bake
, makedirs
, 'makefile.bcc', dep
, 'borland', args
)
79 add(bake
, makedirs
, 'makefile.vc', dep
, 'msvc', args
)
80 add(bake
, makedirs
, 'makefile.gcc', dep
, 'mingw', args
)
81 add(bake
, makedirs
, 'makefile.wat', dep
, 'watcom', args
)
83 (bake
[1+bake
.rfind('/'):]).replace('.bkl','.dsw'),
84 dep
, 'msvc6prj', args
)
86 lines
[bake
] = linesCur
90 # -----------------------------------------------
92 # -----------------------------------------------
95 addMakefile('wx.bkl', {'all':'../msw','autoconf':'../..'}
, [ '$(MDEPS)' ],
97 'borland':'-DOPTIONS_FILE=config.bcc',
98 'msvc':'-DOPTIONS_FILE=config.vc',
99 'mingw':'-DOPTIONS_FILE=config.gcc',
100 'watcom':'-DOPTIONS_FILE=config.wat',
101 'msvc6prj':'$(DSWFLAGS)',
104 # samples main makefile:
105 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
,
107 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
108 'borland':'-DOPTIONS_FILE=../build/msw/config.bcc -DWRITE_OPTIONS_FILE=0',
109 'msvc':'-DOPTIONS_FILE=../build/msw/config.vc -DWRITE_OPTIONS_FILE=0',
110 'mingw':'-DOPTIONS_FILE=../build/msw/config.gcc -DWRITE_OPTIONS_FILE=0',
111 'watcom':'-DOPTIONS_FILE=../build/msw/config.wat -DWRITE_OPTIONS_FILE=0',
113 addMakefile('../../demos/demos.bkl', {'all':'../../demos'}
,
115 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
116 'borland':'-DOPTIONS_FILE=../build/msw/config.bcc -DWRITE_OPTIONS_FILE=0',
117 'msvc':'-DOPTIONS_FILE=../build/msw/config.vc -DWRITE_OPTIONS_FILE=0',
118 'mingw':'-DOPTIONS_FILE=../build/msw/config.gcc -DWRITE_OPTIONS_FILE=0',
119 'watcom':'-DOPTIONS_FILE=../build/msw/config.wat -DWRITE_OPTIONS_FILE=0',
126 def onSubmakefile(type, dirname
, names
):
127 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
128 if len(bakes
) == 0: return
130 dirname
= dirname
.replace(os
.sep
, '/')
131 depth
= dirname
.count('/') - 2
132 if depth
<= 0: return
134 if type==SAMPLES_DIR
:
135 prefix
= ''.join(['../' for i
in range(0,depth
)])
136 dirflags
= '-DWXTOPDIR=%s../' % prefix
137 cfgbase
= '%s../build/msw/config.' % prefix
138 elif type==CONTRIB_DIR
:
139 dirflags
= '-DSRCDIR=../../src/%s' % dirname
.split('/')[-1]
140 dirflags
+= ' -DWXTOPDIR=../../../'
141 cfgbase
= '../../../build/msw/config.'
145 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
146 'msvc':'-DOPTIONS_FILE='+cfgbase
+'vc -DWRITE_OPTIONS_FILE=0',
147 'mingw':'-DOPTIONS_FILE='+cfgbase
+'gcc -DWRITE_OPTIONS_FILE=0',
148 'borland':'-DOPTIONS_FILE='+cfgbase
+'bcc -DWRITE_OPTIONS_FILE=0',
149 'watcom':'-DOPTIONS_FILE='+cfgbase
+'wat -DWRITE_OPTIONS_FILE=0',
150 'msvc6prj':'$(DSWFLAGS)',
154 if type==CONTRIB_DIR
:
155 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
160 addMakefile('%s/%s' % (dirname
, bake
),
161 {'all':dirname,'autoconf':acdir}
, deps
=[ruledep
],
164 os
.path
.walk(os
.path
.join('..','..','samples'),
165 onSubmakefile
, SAMPLES_DIR
)
166 os
.path
.walk(os
.path
.join('..','..','demos'),
167 onSubmakefile
, SAMPLES_DIR
)
168 os
.path
.walk(os
.path
.join('..','..','contrib','build'),
169 onSubmakefile
, CONTRIB_DIR
)
170 os
.path
.walk(os
.path
.join('..','..','contrib','samples'),
171 onSubmakefile
, SAMPLES_DIR
)
172 os
.path
.walk(os
.path
.join('..','..','contrib','utils'),
173 onSubmakefile
, SAMPLES_DIR
)
186 cleanList
.append('\trm -f %s\n' % i
)
187 cleanCmds
= ''.join(cleanList
)
190 var
= '%s_ALL' % f
.upper()
191 file.write('%s = \\\n\t%s\n' % (var
,' \\\n\t'.join(all
[f
])))
193 file.write('\nall: $(COMPAT_TARGETS)')
195 file.write(' %s' % f
)
198 file.write('%s: $(%s_ALL)\n' % (f
, f
.upper()))
202 \trm -f ../../autoconf_inc.m4
203 \trm -f $(COMPAT_TARGETS)
206 library: ../../Makefile.in\\
207 ../msw/makefile.bcc\\
209 ../msw/makefile.wat\\
210 ../msw/makefile.gcc\\
212 ../../src/wxWindows.dsp
214 ../../autoconf_inc.m4: ../../Makefile.in
216 ../../src/wxWindows.dsp: monolithic.bkl files.bkl
217 \t$(BAKEFILE) -Icompat -fwx24dsp -DUSE_GUI=1 -DWXUNIV=0 -o$@ wx.bkl
220 Makefile: regenMakefile.py
223 \t@echo -------------------------------------------
224 \t@echo Please rerun make, Makefile was regenerated
225 \t@echo -------------------------------------------
229 linesK
= lines
.keys()
233 file.write('%s\n' % l
)