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
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 wxwin.py
26 all
['autoconf'] = ['../../configure']
28 def addMakefile(bake
, makedirs
, deps
=[], args
={}):
29 """Adds rules to regenerate native makefile in directory 'makedir' from
30 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
32 print 'adding %s...' % bake
35 def add(bake
, makedirs
, make
, dep
, format
, args
={}):
37 if 'all' in args
: a
+= ' %s' % args
['all']
38 if format
in args
: a
+= ' %s' % args
[format
]
39 if format
!= 'autoconf' and 'not_autoconf' in args
:
40 a
+= ' %s' % args
['not_autoconf']
41 if format
in makedirs
:
42 makedir
= makedirs
[format
]
44 makedir
= makedirs
['all']
45 tfile
= '%s/%s' % (makedir
, make
)
46 lines
.append('%s: %s' % (tfile
, dep
))
47 lines
.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format
, a
, bake
))
48 lines
.append('\ttouch $@')
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
)
58 add(bake
, makedirs
, 'makefile.wat', dep
, 'watcom', args
)
62 # -----------------------------------------------
64 # -----------------------------------------------
67 addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}
, [ '$(MDEPS)' ])
69 # samples main makefile:
70 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
,
71 args
={'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4'}
)
77 def onSubmakefile(type, dirname
, names
):
78 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
79 if len(bakes
) == 0: return
80 dirname
= dirname
.replace(os
.sep
, '/')
81 depth
= dirname
.count('/') - 2
85 prefix
= ''.join(['../' for i
in range(0,depth
)])
86 dirflags
= '-DWXTOPDIR=%s../' % prefix
87 elif type==CONTRIB_DIR
:
88 dirflags
= '-DSRCDIR=../../src/%s' % dirname
.split('/')[-1]
89 dirflags
+= ' -DWXTOPDIR=../../../'
92 'not_autoconf':dirflags
,
93 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
98 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
103 addMakefile('%s/%s' % (dirname
, bake
),
104 {'all':dirname,'autoconf':acdir}
, deps
=[ruledep
],
107 os
.path
.walk(os
.path
.join('..','..','samples'),
108 onSubmakefile
, SAMPLES_DIR
)
109 os
.path
.walk(os
.path
.join('..','..','contrib','build'),
110 onSubmakefile
, CONTRIB_DIR
)
111 os
.path
.walk(os
.path
.join('..','..','contrib','samples'),
112 onSubmakefile
, SAMPLES_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
)