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
!= 'autoconf' and 'not_autoconf' in args
:
39 a
+= ' %s' % args
['not_autoconf']
40 if format
in makedirs
:
41 makedir
= makedirs
[format
]
43 makedir
= makedirs
['all']
44 tfile
= '%s/%s' % (makedir
, make
)
45 lines
.append('%s: %s' % (tfile
, dep
))
46 lines
.append('\t$(BAKEFILE) $(BAKEARGS) -f%s -o%s%s %s' % \
47 (format
, tfile
, a
, bake
))
48 lines
.append('\ttouch %s' % tfile
)
49 if format
not in all
: all
[format
] = []
50 all
[format
].append(tfile
)
52 dep
= string
.join(deps
+ [bake
], ' ')
54 add(bake
, makedirs
, 'Makefile.in', dep
, 'autoconf', args
)
55 add(bake
, makedirs
, 'makefile.bcc', dep
, 'borland', args
)
56 add(bake
, makedirs
, 'makefile.vc', dep
, 'msvc', args
)
57 add(bake
, makedirs
, 'makefile.gcc', dep
, 'mingw', args
)
61 # -----------------------------------------------
63 # -----------------------------------------------
66 addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}
,
67 ['common.bkl', 'config.bkl', 'files.bkl', 'monolithic.bkl',
68 'multilib.bkl', 'wxwin.py'])
70 # samples main makefile:
71 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
,
72 args
={'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4'}
)
78 def onSubmakefile(type, dirname
, names
):
79 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
80 if len(bakes
) == 0: return
81 dirname
= dirname
.replace(os
.sep
, '/')
82 depth
= dirname
.count('/') - 2
86 prefix
= ''.join(['../' for i
in range(0,depth
)])
87 dirflags
= '-DWXTOPDIR=%s../' % prefix
88 elif type==CONTRIB_DIR
:
89 dirflags
= '-DSRCDIR=../../src/%s' % dirname
.split('/')[-1]
90 dirflags
+= ' -DWXTOPDIR=../../../'
93 'not_autoconf':dirflags
,
94 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
99 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
100 ruledep
= 'common_contrib.bkl'
103 ruledep
= 'common_samples.bkl'
104 addMakefile('%s/%s' % (dirname
, bake
),
105 {'all':dirname,'autoconf':acdir}
,
106 deps
=['common.bkl',ruledep
,'config.bkl'],
109 os
.path
.walk(os
.path
.join('..','..','samples'),
110 onSubmakefile
, SAMPLES_DIR
)
111 os
.path
.walk(os
.path
.join('..','..','contrib','build'),
112 onSubmakefile
, CONTRIB_DIR
)
118 cleanCmds
+= '\trm -f %s\n' % i
121 var
= '%s_ALL' % f
.upper()
122 file.write('%s = %s\n' % (var
,' '.join(all
[f
])))
126 file.write(' %s' % f
)
129 file.write('%s: $(%s_ALL)\n' % (f
, f
.upper()))
133 \trm -f ../../autoconf_inc.m4
136 ../../autoconf_inc.m4: ../../Makefile.in
137 ../../configure: ../../autoconf_inc.m4
138 \t(cd ../.. ; aclocal && autoconf)
140 Makefile: regenMakefile.py
143 \t@echo -------------------------------------------
144 \t@echo Please rerun make, Makefile was regenerated
145 \t@echo -------------------------------------------
150 file.write('%s\n' % l
)