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
33 def addMakefile(bake
, makedirs
, deps
=[], args
={}):
34 """Adds rules to regenerate native makefile in directory 'makedir' from
35 bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles
37 print 'adding %s...' % bake
41 def add(bake
, makedirs
, make
, dep
, format
, args
={}):
44 if 'all' in args
: a
+= ' %s' % args
['all']
45 if format
in args
: a
+= ' %s' % args
[format
]
46 if format
!= 'autoconf' and 'not_autoconf' in args
:
47 a
+= ' %s' % args
['not_autoconf']
48 if format
in makedirs
:
49 makedir
= makedirs
[format
]
51 makedir
= makedirs
['all']
52 tfile
= '%s/%s' % (makedir
, make
)
53 linesCur
.append('%s: %s' % (tfile
, dep
))
54 linesCur
.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format
, a
, bake
))
55 linesCur
.append('\ttouch $@')
56 if format
not in all
: all
[format
] = []
57 all
[format
].append(tfile
)
59 dep
= string
.join(deps
+ [bake
], ' ')
61 add(bake
, makedirs
, 'Makefile.in', dep
, 'autoconf', args
)
62 add(bake
, makedirs
, 'makefile.bcc', dep
, 'borland', args
)
63 add(bake
, makedirs
, 'makefile.vc', dep
, 'msvc', args
)
64 add(bake
, makedirs
, 'makefile.gcc', dep
, 'mingw', args
)
65 add(bake
, makedirs
, 'makefile.wat', dep
, 'watcom', args
)
67 if 'msvc6prj' in args
and args
['msvc6prj'] != None:
69 (bake
[1+bake
.rfind('/'):]).replace('.bkl','.dsw'),
70 dep
, 'msvc6prj', args
)
72 lines
[bake
] = linesCur
76 # -----------------------------------------------
78 # -----------------------------------------------
81 addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}
, [ '$(MDEPS)' ],
83 'borland':'-DOPTIONS_FILE=config.bcc',
84 'msvc':'-DOPTIONS_FILE=config.vc',
85 'mingw':'-DOPTIONS_FILE=config.gcc',
86 'watcom':'-DOPTIONS_FILE=config.wat',
87 'msvc6prj':'$(DSWFLAGS)',
90 # samples main makefile:
91 addMakefile('../../samples/samples.bkl', {'all':'../../samples'}
,
93 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
94 'borland':'-DOPTIONS_FILE=../build/config.bcc -DWRITE_OPTIONS_FILE=0',
95 'msvc':'-DOPTIONS_FILE=../build/config.vc -DWRITE_OPTIONS_FILE=0',
96 'mingw':'-DOPTIONS_FILE=../build/config.gcc -DWRITE_OPTIONS_FILE=0',
97 'watcom':'-DOPTIONS_FILE=../build/config.wat -DWRITE_OPTIONS_FILE=0',
105 def onSubmakefile(type, dirname
, names
):
106 bakes
= [x
for x
in names
if x
.endswith('.bkl')]
107 if len(bakes
) == 0: return
109 dirname
= dirname
.replace(os
.sep
, '/')
110 depth
= dirname
.count('/') - 2
111 if depth
<= 0: return
113 if type==SAMPLES_DIR
:
114 prefix
= ''.join(['../' for i
in range(0,depth
)])
115 dirflags
= '-DWXTOPDIR=%s../' % prefix
116 cfgbase
= '%s../build/config.' % prefix
117 elif type==CONTRIB_DIR
:
118 dirflags
= '-DSRCDIR=../../src/%s' % dirname
.split('/')[-1]
119 dirflags
+= ' -DWXTOPDIR=../../../'
120 cfgbase
= '../../../build/config.'
123 'not_autoconf':dirflags
,
124 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4',
125 'msvc':'-DOPTIONS_FILE='+cfgbase
+'vc -DWRITE_OPTIONS_FILE=0',
126 'mingw':'-DOPTIONS_FILE='+cfgbase
+'gcc -DWRITE_OPTIONS_FILE=0',
127 'borland':'-DOPTIONS_FILE='+cfgbase
+'bcc -DWRITE_OPTIONS_FILE=0',
128 'watcom':'-DOPTIONS_FILE='+cfgbase
+'wat -DWRITE_OPTIONS_FILE=0',
129 'msvc6prj':'$(DSWFLAGS)',
133 if bake
.endswith('_samples.bkl'):
134 args
['msvc6prj'] = None
135 if type==CONTRIB_DIR
:
136 acdir
= '../../contrib/src/%s' % dirname
.split('/')[-1]
141 addMakefile('%s/%s' % (dirname
, bake
),
142 {'all':dirname,'autoconf':acdir}
, deps
=[ruledep
],
145 os
.path
.walk(os
.path
.join('..','..','samples'),
146 onSubmakefile
, SAMPLES_DIR
)
147 os
.path
.walk(os
.path
.join('..','..','contrib','build'),
148 onSubmakefile
, CONTRIB_DIR
)
149 os
.path
.walk(os
.path
.join('..','..','contrib','samples'),
150 onSubmakefile
, SAMPLES_DIR
)
151 os
.path
.walk(os
.path
.join('..','..','contrib','utils'),
152 onSubmakefile
, SAMPLES_DIR
)
165 cleanList
.append('\trm -f %s\n' % i
)
166 cleanCmds
= ''.join(cleanList
)
169 var
= '%s_ALL' % f
.upper()
170 file.write('%s = \\\n\t%s\n' % (var
,' \\\n\t'.join(all
[f
])))
174 file.write(' %s' % f
)
177 file.write('%s: $(%s_ALL)\n' % (f
, f
.upper()))
181 \trm -f ../../autoconf_inc.m4
184 library: ../../Makefile.in ../makefile.bcc ../makefile.vc ../makefile.wat ../makefile.gcc
186 ../../autoconf_inc.m4: ../../Makefile.in
188 Makefile: regenMakefile.py
191 \t@echo -------------------------------------------
192 \t@echo Please rerun make, Makefile was regenerated
193 \t@echo -------------------------------------------
197 linesK
= lines
.keys()
201 file.write('%s\n' % l
)