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 '../../samples/html/html_samples.dsw',
17 '../../samples/opengl/opengl_samples.dsw',
20 file = open('Makefile', 'wt')
22 # Generated by regenMakefile.py
24 BAKEFILE = bakefile -v
27 CDEPS = config.bkl common.bkl common_contrib.bkl
28 SDEPS = config.bkl common.bkl common_samples.bkl
29 MDEPS = common.bkl config.bkl files.bkl monolithic.bkl multilib.bkl opengl.bkl wxwin.py
31 DSWFLAGS = -DRUNTIME_LIBS=dynamic -DOFFICIAL_BUILD=0 -DUSE_HTML=1 \\
32 -DUSE_OPENGL=1 -DUSE_ODBC=1 -DMONOLITHIC=0 -DUSE_GUI=1 \\
33 -DDEBUG_INFO=default -DDEBUG_FLAG=default
35 COMPAT_TARGETS = ../../src/wxWindows.dsp
45 def addMakefile(bake
, makedirs
, deps
=[], args
={}):
46 """Adds rules to regenerate native makefile in directory 'makedir' from
47 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
49 print 'adding %s...' % bake
53 def add(bake
, makedirs
, make
, dep
, format
, args
={}):
56 if 'all' in args
: a
+= ' %s' % args
['all']
57 if format
in args
: a
+= ' %s' % args
[format
]
58 if format
!= 'autoconf' and 'not_autoconf' in args
:
59 a
+= ' %s' % args
['not_autoconf']
60 if format
in makedirs
:
61 makedir
= makedirs
[format
]
63 makedir
= makedirs
['all']
64 tfile
= '%s/%s' % (makedir
, make
)
66 if tfile
in DONT_GENERATE
: return
68 linesCur
.append('%s: %s' % (tfile
, dep
))
69 linesCur
.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format
, a
, bake
))
70 linesCur
.append('\ttouch $@')
71 if format
not in all
: all
[format
] = []
72 all
[format
].append(tfile
)
74 dep
= string
.join(deps
+ [bake
], ' ')
76 add(bake
, makedirs
, 'Makefile.in', dep
, 'autoconf', args
)
77 add(bake
, makedirs
, 'makefile.bcc', dep
, 'borland', args
)
78 add(bake
, makedirs
, 'makefile.vc', dep
, 'msvc', args
)
79 add(bake
, makedirs
, 'makefile.gcc', dep
, 'mingw', args
)
80 add(bake
, makedirs
, 'makefile.wat', dep
, 'watcom', args
)
82 (bake
[1+bake
.rfind('/'):]).replace('.bkl','.dsw'),
83 dep
, 'msvc6prj', args
)
85 lines
[bake
] = linesCur
89 # -----------------------------------------------
91 # -----------------------------------------------
94 addMakefile('wx.bkl', {'all':'../msw','autoconf':'../..'}
, [ '$(MDEPS)' ],
96 'borland':'-DOPTIONS_FILE=config.bcc',
97 'msvc':'-DOPTIONS_FILE=config.vc',
98 'mingw':'-DOPTIONS_FILE=config.gcc',
99 'watcom':'-DOPTIONS_FILE=config.wat',
100 'msvc6prj':'$(DSWFLAGS)',
103 # samples main makefile:
104 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
,
106 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
107 'borland':'-DOPTIONS_FILE=../build/msw/config.bcc -DWRITE_OPTIONS_FILE=0',
108 'msvc':'-DOPTIONS_FILE=../build/msw/config.vc -DWRITE_OPTIONS_FILE=0',
109 'mingw':'-DOPTIONS_FILE=../build/msw/config.gcc -DWRITE_OPTIONS_FILE=0',
110 'watcom':'-DOPTIONS_FILE=../build/msw/config.wat -DWRITE_OPTIONS_FILE=0',
118 def onSubmakefile(type, dirname
, names
):
119 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
120 if len(bakes
) == 0: return
122 dirname
= dirname
.replace(os
.sep
, '/')
123 depth
= dirname
.count('/') - 2
124 if depth
<= 0: return
126 if type==SAMPLES_DIR
:
127 prefix
= ''.join(['../' for i
in range(0,depth
)])
128 dirflags
= '-DWXTOPDIR=%s../' % prefix
129 cfgbase
= '%s../build/msw/config.' % prefix
130 elif type==CONTRIB_DIR
:
131 dirflags
= '-DSRCDIR=../../src/%s' % dirname
.split('/')[-1]
132 dirflags
+= ' -DWXTOPDIR=../../../'
133 cfgbase
= '../../../build/msw/config.'
137 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
138 'msvc':'-DOPTIONS_FILE='+cfgbase
+'vc -DWRITE_OPTIONS_FILE=0',
139 'mingw':'-DOPTIONS_FILE='+cfgbase
+'gcc -DWRITE_OPTIONS_FILE=0',
140 'borland':'-DOPTIONS_FILE='+cfgbase
+'bcc -DWRITE_OPTIONS_FILE=0',
141 'watcom':'-DOPTIONS_FILE='+cfgbase
+'wat -DWRITE_OPTIONS_FILE=0',
142 'msvc6prj':'$(DSWFLAGS)',
146 if type==CONTRIB_DIR
:
147 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
152 addMakefile('%s/%s' % (dirname
, bake
),
153 {'all':dirname,'autoconf':acdir}
, deps
=[ruledep
],
156 os
.path
.walk(os
.path
.join('..','..','samples'),
157 onSubmakefile
, SAMPLES_DIR
)
158 os
.path
.walk(os
.path
.join('..','..','demos'),
159 onSubmakefile
, SAMPLES_DIR
)
160 os
.path
.walk(os
.path
.join('..','..','contrib','build'),
161 onSubmakefile
, CONTRIB_DIR
)
162 os
.path
.walk(os
.path
.join('..','..','contrib','samples'),
163 onSubmakefile
, SAMPLES_DIR
)
164 os
.path
.walk(os
.path
.join('..','..','contrib','utils'),
165 onSubmakefile
, SAMPLES_DIR
)
178 cleanList
.append('\trm -f %s\n' % i
)
179 cleanCmds
= ''.join(cleanList
)
182 var
= '%s_ALL' % f
.upper()
183 file.write('%s = \\\n\t%s\n' % (var
,' \\\n\t'.join(all
[f
])))
185 file.write('\nall: $(COMPAT_TARGETS)')
187 file.write(' %s' % f
)
190 file.write('%s: $(%s_ALL)\n' % (f
, f
.upper()))
194 \trm -f ../../autoconf_inc.m4
195 \trm -f $(COMPAT_TARGETS)
198 library: ../../Makefile.in\\
199 ../msw/makefile.bcc\\
201 ../msw/makefile.wat\\
202 ../msw/makefile.gcc\\
204 ../../src/wxWindows.dsp
206 ../../autoconf_inc.m4: ../../Makefile.in
208 ../../src/wxWindows.dsp: monolithic.bkl files.bkl
209 \t$(BAKEFILE) -Icompat -fwx24dsp -DUSE_GUI=1 -DWXUNIV=0 -o$@ wx.bkl
212 Makefile: regenMakefile.py
215 \t@echo -------------------------------------------
216 \t@echo Please rerun make, Makefile was regenerated
217 \t@echo -------------------------------------------
221 linesK
= lines
.keys()
225 file.write('%s\n' % l
)