4 # Generates Makefile that is used to regenerate native makefiles from
10 import string
, os
.path
, copy
12 file = open('Makefile', 'wt')
14 # Generated by regenMakefile.py
16 BAKEFILE = bakefile -v
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
23 DSWFLAGS = -DRUNTIME_LIBS=dynamic -DOFFICIAL_BUILD=0 -DUSE_HTML=1 \\
24 -DUSE_OPENGL=1 -DUSE_ODBC=1 -DMONOLITHIC=0 -DUSE_GUI=1 \\
25 -DDEBUG_INFO=default -DDEBUG_FLAG=default
27 COMPAT_TARGETS = ../../src/wxWindows.dsp
37 def addMakefile(bake
, makedirs
, deps
=[], args
={}):
38 """Adds rules to regenerate native makefile in directory 'makedir' from
39 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
41 print 'adding %s...' % bake
45 def add(bake
, makedirs
, make
, dep
, format
, args
={}):
48 if 'all' in args
: a
+= ' %s' % args
['all']
49 if format
in args
: a
+= ' %s' % args
[format
]
50 if format
!= 'autoconf' and 'not_autoconf' in args
:
51 a
+= ' %s' % args
['not_autoconf']
52 if format
in makedirs
:
53 makedir
= makedirs
[format
]
55 makedir
= makedirs
['all']
56 tfile
= '%s/%s' % (makedir
, make
)
57 linesCur
.append('%s: %s' % (tfile
, dep
))
58 linesCur
.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format
, a
, bake
))
59 linesCur
.append('\ttouch $@')
60 if format
not in all
: all
[format
] = []
61 all
[format
].append(tfile
)
63 dep
= string
.join(deps
+ [bake
], ' ')
65 add(bake
, makedirs
, 'Makefile.in', dep
, 'autoconf', args
)
66 add(bake
, makedirs
, 'makefile.bcc', dep
, 'borland', args
)
67 add(bake
, makedirs
, 'makefile.vc', dep
, 'msvc', args
)
68 add(bake
, makedirs
, 'makefile.gcc', dep
, 'mingw', args
)
69 add(bake
, makedirs
, 'makefile.wat', dep
, 'watcom', args
)
71 if 'msvc6prj' in args
and args
['msvc6prj'] != None:
73 (bake
[1+bake
.rfind('/'):]).replace('.bkl','.dsw'),
74 dep
, 'msvc6prj', args
)
76 lines
[bake
] = linesCur
80 # -----------------------------------------------
82 # -----------------------------------------------
85 addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}
, [ '$(MDEPS)' ],
87 'borland':'-DOPTIONS_FILE=config.bcc',
88 'msvc':'-DOPTIONS_FILE=config.vc',
89 'mingw':'-DOPTIONS_FILE=config.gcc',
90 'watcom':'-DOPTIONS_FILE=config.wat',
91 'msvc6prj':'$(DSWFLAGS)',
94 # samples main makefile:
95 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
,
97 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
98 'borland':'-DOPTIONS_FILE=../build/config.bcc -DWRITE_OPTIONS_FILE=0',
99 'msvc':'-DOPTIONS_FILE=../build/config.vc -DWRITE_OPTIONS_FILE=0',
100 'mingw':'-DOPTIONS_FILE=../build/config.gcc -DWRITE_OPTIONS_FILE=0',
101 'watcom':'-DOPTIONS_FILE=../build/config.wat -DWRITE_OPTIONS_FILE=0',
109 def onSubmakefile(type, dirname
, names
):
110 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
111 if len(bakes
) == 0: return
113 dirname
= dirname
.replace(os
.sep
, '/')
114 depth
= dirname
.count('/') - 2
115 if depth
<= 0: return
117 if type==SAMPLES_DIR
:
118 prefix
= ''.join(['../' for i
in range(0,depth
)])
119 dirflags
= '-DWXTOPDIR=%s../' % prefix
120 cfgbase
= '%s../build/config.' % prefix
121 elif type==CONTRIB_DIR
:
122 dirflags
= '-DSRCDIR=../../src/%s' % dirname
.split('/')[-1]
123 dirflags
+= ' -DWXTOPDIR=../../../'
124 cfgbase
= '../../../build/config.'
127 'not_autoconf':dirflags
,
128 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
129 'msvc':'-DOPTIONS_FILE='+cfgbase
+'vc -DWRITE_OPTIONS_FILE=0',
130 'mingw':'-DOPTIONS_FILE='+cfgbase
+'gcc -DWRITE_OPTIONS_FILE=0',
131 'borland':'-DOPTIONS_FILE='+cfgbase
+'bcc -DWRITE_OPTIONS_FILE=0',
132 'watcom':'-DOPTIONS_FILE='+cfgbase
+'wat -DWRITE_OPTIONS_FILE=0',
133 'msvc6prj':'$(DSWFLAGS)',
137 if bake
.endswith('_samples.bkl'):
138 args
['msvc6prj'] = None
139 if type==CONTRIB_DIR
:
140 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
145 addMakefile('%s/%s' % (dirname
, bake
),
146 {'all':dirname,'autoconf':acdir}
, deps
=[ruledep
],
149 os
.path
.walk(os
.path
.join('..','..','samples'),
150 onSubmakefile
, SAMPLES_DIR
)
151 os
.path
.walk(os
.path
.join('..','..','demos'),
152 onSubmakefile
, SAMPLES_DIR
)
153 os
.path
.walk(os
.path
.join('..','..','contrib','build'),
154 onSubmakefile
, CONTRIB_DIR
)
155 os
.path
.walk(os
.path
.join('..','..','contrib','samples'),
156 onSubmakefile
, SAMPLES_DIR
)
157 os
.path
.walk(os
.path
.join('..','..','contrib','utils'),
158 onSubmakefile
, SAMPLES_DIR
)
171 cleanList
.append('\trm -f %s\n' % i
)
172 cleanCmds
= ''.join(cleanList
)
175 var
= '%s_ALL' % f
.upper()
176 file.write('%s = \\\n\t%s\n' % (var
,' \\\n\t'.join(all
[f
])))
178 file.write('\nall: $(COMPAT_TARGETS)')
180 file.write(' %s' % f
)
183 file.write('%s: $(%s_ALL)\n' % (f
, f
.upper()))
187 \trm -f ../../autoconf_inc.m4
188 \trm -f $(COMPAT_TARGETS)
191 library: ../../Makefile.in ../makefile.bcc ../makefile.vc ../makefile.wat ../makefile.gcc
193 ../../autoconf_inc.m4: ../../Makefile.in
195 ../../src/wxWindows.dsp: monolithic.bkl files.bkl
196 \t$(BAKEFILE) -Icompat -fwx24dsp -DUSE_GUI=1 -DWXUNIV=0 -o$@ wx.bkl
198 Makefile: regenMakefile.py
201 \t@echo -------------------------------------------
202 \t@echo Please rerun make, Makefile was regenerated
203 \t@echo -------------------------------------------
207 linesK
= lines
.keys()
211 file.write('%s\n' % l
)