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
26 all
['autoconf'] = ['../../configure']
30 def addMakefile(bake
, makedirs
, deps
=[], args
={}):
31 """Adds rules to regenerate native makefile in directory 'makedir' from
32 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
34 print 'adding %s...' % bake
38 def add(bake
, makedirs
, make
, dep
, format
, args
={}):
41 if 'all' in args
: a
+= ' %s' % args
['all']
42 if format
in args
: a
+= ' %s' % args
[format
]
43 if format
!= 'autoconf' and 'not_autoconf' in args
:
44 a
+= ' %s' % args
['not_autoconf']
45 if format
in makedirs
:
46 makedir
= makedirs
[format
]
48 makedir
= makedirs
['all']
49 tfile
= '%s/%s' % (makedir
, make
)
50 linesCur
.append('%s: %s' % (tfile
, dep
))
51 linesCur
.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format
, a
, bake
))
52 linesCur
.append('\ttouch $@')
53 if format
not in all
: all
[format
] = []
54 all
[format
].append(tfile
)
56 dep
= string
.join(deps
+ [bake
], ' ')
58 add(bake
, makedirs
, 'Makefile.in', dep
, 'autoconf', args
)
59 add(bake
, makedirs
, 'makefile.bcc', dep
, 'borland', args
)
60 add(bake
, makedirs
, 'makefile.vc', dep
, 'msvc', args
)
61 add(bake
, makedirs
, 'makefile.gcc', dep
, 'mingw', args
)
62 add(bake
, makedirs
, 'makefile.wat', dep
, 'watcom', args
)
64 lines
[bake
] = linesCur
68 # -----------------------------------------------
70 # -----------------------------------------------
73 addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}
, [ '$(MDEPS)' ],
75 'borland':'-DOPTIONS_FILE=config.bcc',
76 'msvc':'-DOPTIONS_FILE=config.vc',
77 'mingw':'-DOPTIONS_FILE=config.gcc',
78 'watcom':'-DOPTIONS_FILE=config.wat',
81 # samples main makefile:
82 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
,
84 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
85 'borland':'-DOPTIONS_FILE=../build/config.bcc -DWRITE_OPTIONS_FILE=0',
86 'msvc':'-DOPTIONS_FILE=../build/config.vc -DWRITE_OPTIONS_FILE=0',
87 'mingw':'-DOPTIONS_FILE=../build/config.gcc -DWRITE_OPTIONS_FILE=0',
88 'watcom':'-DOPTIONS_FILE=../build/config.wat -DWRITE_OPTIONS_FILE=0',
95 def onSubmakefile(type, dirname
, names
):
96 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
97 if len(bakes
) == 0: return
99 dirname
= dirname
.replace(os
.sep
, '/')
100 depth
= dirname
.count('/') - 2
101 if depth
<= 0: return
103 if type==SAMPLES_DIR
:
104 prefix
= ''.join(['../' for i
in range(0,depth
)])
105 dirflags
= '-DWXTOPDIR=%s../' % prefix
106 cfgbase
= '%s../build/config.' % prefix
107 elif type==CONTRIB_DIR
:
108 dirflags
= '-DSRCDIR=../../src/%s' % dirname
.split('/')[-1]
109 dirflags
+= ' -DWXTOPDIR=../../../'
110 cfgbase
= '../../../build/config.'
113 'not_autoconf':dirflags
,
114 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
115 'msvc':'-DOPTIONS_FILE='+cfgbase
+'vc -DWRITE_OPTIONS_FILE=0',
116 'mingw':'-DOPTIONS_FILE='+cfgbase
+'gcc -DWRITE_OPTIONS_FILE=0',
117 'borland':'-DOPTIONS_FILE='+cfgbase
+'bcc -DWRITE_OPTIONS_FILE=0',
118 'watcom':'-DOPTIONS_FILE='+cfgbase
+'wat -DWRITE_OPTIONS_FILE=0',
122 if type==CONTRIB_DIR
:
123 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
128 addMakefile('%s/%s' % (dirname
, bake
),
129 {'all':dirname,'autoconf':acdir}
, deps
=[ruledep
],
132 os
.path
.walk(os
.path
.join('..','..','samples'),
133 onSubmakefile
, SAMPLES_DIR
)
134 os
.path
.walk(os
.path
.join('..','..','contrib','build'),
135 onSubmakefile
, CONTRIB_DIR
)
136 os
.path
.walk(os
.path
.join('..','..','contrib','samples'),
137 onSubmakefile
, SAMPLES_DIR
)
146 cleanList
.append('\trm -f %s\n' % i
)
148 cleanCmds
= ''.join(cleanList
)
151 var
= '%s_ALL' % f
.upper()
152 file.write('%s = \\\n\t%s\n' % (var
,' \\\n\t'.join(all
[f
])))
156 file.write(' %s' % f
)
159 file.write('%s: $(%s_ALL)\n' % (f
, f
.upper()))
163 \trm -f ../../autoconf_inc.m4
166 ../../autoconf_inc.m4: ../../Makefile.in
167 ../../configure: ../../autoconf_inc.m4
168 \t(cd ../.. ; aclocal && autoconf)
170 Makefile: regenMakefile.py
173 \t@echo -------------------------------------------
174 \t@echo Please rerun make, Makefile was regenerated
175 \t@echo -------------------------------------------
179 linesK
= lines
.keys()
183 file.write('%s\n' % l
)