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 -DMONOLITHIC=0 -DUSE_GUI=1 \\
25 -DDEBUG_INFO=default -DDEBUG_FLAG=default
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
38 print 'adding %s...' % bake
42 def add(bake
, makedirs
, make
, dep
, format
, args
={}):
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
]
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
)
60 dep
= string
.join(deps
+ [bake
], ' ')
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
)
68 if 'msvc6prj' in args
and args
['msvc6prj'] != None:
70 (bake
[1+bake
.rfind('/'):]).replace('.bkl','.dsw'),
71 dep
, 'msvc6prj', args
)
73 lines
[bake
] = linesCur
77 # -----------------------------------------------
79 # -----------------------------------------------
82 addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}
, [ '$(MDEPS)' ],
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)',
91 # samples main makefile:
92 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
,
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',
106 def onSubmakefile(type, dirname
, names
):
107 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
108 if len(bakes
) == 0: return
110 dirname
= dirname
.replace(os
.sep
, '/')
111 depth
= dirname
.count('/') - 2
112 if depth
<= 0: return
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.'
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)',
134 if bake
.endswith('_samples.bkl'):
135 args
['msvc6prj'] = None
136 if type==CONTRIB_DIR
:
137 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
142 addMakefile('%s/%s' % (dirname
, bake
),
143 {'all':dirname,'autoconf':acdir}
, deps
=[ruledep
],
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
)
166 cleanList
.append('\trm -f %s\n' % i
)
167 cleanCmds
= ''.join(cleanList
)
170 var
= '%s_ALL' % f
.upper()
171 file.write('%s = \\\n\t%s\n' % (var
,' \\\n\t'.join(all
[f
])))
175 file.write(' %s' % f
)
178 file.write('%s: $(%s_ALL)\n' % (f
, f
.upper()))
182 \trm -f ../../autoconf_inc.m4
185 library: ../../Makefile.in ../makefile.bcc ../makefile.vc ../makefile.wat ../makefile.gcc
187 ../../autoconf_inc.m4: ../../Makefile.in
189 Makefile: regenMakefile.py
192 \t@echo -------------------------------------------
193 \t@echo Please rerun make, Makefile was regenerated
194 \t@echo -------------------------------------------
198 linesK
= lines
.keys()
202 file.write('%s\n' % l
)