4 # Generates Makefile that is used to regenerate native makefiles from
10 import string
, os
.path
12 file = open('Makefile', 'wt')
14 # Generated by regenMakefile.py
24 all
['autoconf'] = ['../../configure']
26 def addMakefile(bake
, makedirs
, deps
=[], args
={}):
27 """Adds rules to regenerate native makefile in directory 'makedir' from
28 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
30 print 'adding %s...' % bake
32 lines
.append('# from %s' % bake
)
34 def add(bake
, makedirs
, make
, dep
, format
, args
={}):
36 if 'all' in args
: a
+= ' %s' % args
['all']
37 if format
in args
: a
+= ' %s' % args
[format
]
38 if format
in makedirs
:
39 makedir
= makedirs
[format
]
41 makedir
= makedirs
['all']
42 tfile
= '%s/%s' % (makedir
, make
)
43 lines
.append('%s: %s' % (tfile
, dep
))
44 lines
.append('\t$(BAKEFILE) $(BAKEARGS) -f%s -o%s%s %s' % \
45 (format
, tfile
, a
, bake
))
46 lines
.append('\ttouch %s' % tfile
)
47 if format
not in all
: all
[format
] = []
48 all
[format
].append(tfile
)
50 dep
= string
.join(deps
+ [bake
], ' ')
52 add(bake
, makedirs
, 'Makefile.in', dep
, 'autoconf', args
)
56 # -----------------------------------------------
58 # -----------------------------------------------
61 addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}
,
62 ['common.bkl', 'config.bkl', 'files.bkl', 'monolithic.bkl',
63 'multilib.bkl', 'wxwin.py'])
65 # samples main makefile:
66 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
)
71 def onSubmakefile(type, dirname
, names
):
72 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
73 if len(bakes
) == 0: return
74 depth
= dirname
.count('/') - 2
76 prefix
= ''.join(['../' for i
in range(0,depth
)])
79 'all':'-DWXTOPDIR=%s../' % prefix
,
80 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
85 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
86 ruledep
= 'common_contrib.bkl'
89 ruledep
= 'common_samples.bkl'
90 addMakefile('%s/%s' % (dirname
, bake
),
91 {'all':dirname,'autoconf':acdir}
,
92 deps
=['common.bkl',ruledep
,'config.bkl'],
95 os
.path
.walk('../../samples', onSubmakefile
, None)
96 os
.path
.walk('../../contrib/build', onSubmakefile
, CONTRIB_DIR
)
102 cleanCmds
+= '\trm -f %s\n' % i
105 var
= '%s_ALL' % f
.upper()
106 file.write('%s = %s\n' % (var
,' '.join(all
[f
])))
110 file.write(' %s' % f
)
113 file.write('%s: $(%s_ALL)\n' % (f
, f
.upper()))
117 \trm -f ../../autoconf_inc.m4
120 ../../autoconf_inc.m4: ../../Makefile.in
121 ../../configure: ../../autoconf_inc.m4
122 \t(cd ../.. ; aclocal && autoconf)
124 Makefile: regenMakefile.py
127 \t@echo -------------------------------------------
128 \t@echo Please rerun make, Makefile was regenerated
129 \t@echo -------------------------------------------
134 file.write('%s\n' % l
)