X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6bd5dab59251364f1b94af4b6d7ba03be44e730a..672abd7a83fbff9058ce16ee78a3ef9c684a9319:/build/bakefiles/regenMakefile.py diff --git a/build/bakefiles/regenMakefile.py b/build/bakefiles/regenMakefile.py index 083895793f..db6fa6a3d0 100755 --- a/build/bakefiles/regenMakefile.py +++ b/build/bakefiles/regenMakefile.py @@ -7,49 +7,61 @@ # $Id$ # -import string, os.path +import string, os.path, copy file = open('Makefile', 'wt') file.write(""" # Generated by regenMakefile.py -BAKEFILE = bakefile -BAKEARGS = -v +BAKEFILE = bakefile -v +CDEPS = config.bkl common.bkl common_contrib.bkl +SDEPS = config.bkl common.bkl common_samples.bkl +MDEPS = common.bkl config.bkl files.bkl monolithic.bkl multilib.bkl opengl.bkl wxwin.py """) -lines = [] +lines = {} all = {} -all['autoconf'] = ['../../configure', '../../samples/configure'] +all['autoconf'] = ['../../configure'] + +linesCur = None def addMakefile(bake, makedirs, deps=[], args={}): """Adds rules to regenerate native makefile in directory 'makedir' from bakefiles 'bake'. 'deps' contains additional dependencies (bakefiles other than 'bake'.""" print 'adding %s...' % bake - lines.append('') - lines.append('# from %s' % bake) + global linesCur + linesCur = ['\n'] def add(bake, makedirs, make, dep, format, args={}): + global linesCur a = '' if 'all' in args: a += ' %s' % args['all'] if format in args: a += ' %s' % args[format] + if format != 'autoconf' and 'not_autoconf' in args: + a += ' %s' % args['not_autoconf'] if format in makedirs: makedir = makedirs[format] else: makedir = makedirs['all'] tfile = '%s/%s' % (makedir, make) - lines.append('%s: %s Makefile' % (tfile, dep)) - lines.append('\t$(BAKEFILE) $(BAKEARGS) -f%s -o%s%s %s' % \ - (format, tfile, a, bake)) - lines.append('\ttouch %s' % tfile) + linesCur.append('%s: %s' % (tfile, dep)) + linesCur.append('\t$(BAKEFILE) -f%s -o$@ %s %s' % (format, a, bake)) + linesCur.append('\ttouch $@') if format not in all: all[format] = [] all[format].append(tfile) dep = string.join(deps + [bake], ' ') add(bake, makedirs, 'Makefile.in', dep, 'autoconf', args) + add(bake, makedirs, 'makefile.bcc', dep, 'borland', args) + add(bake, makedirs, 'makefile.vc', dep, 'msvc', args) + add(bake, makedirs, 'makefile.gcc', dep, 'mingw', args) + add(bake, makedirs, 'makefile.wat', dep, 'watcom', args) + + lines[bake] = linesCur @@ -58,64 +70,108 @@ def addMakefile(bake, makedirs, deps=[], args={}): # ----------------------------------------------- # main makefile: -addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}, - ['common.bkl', 'config.bkl', 'files.bkl', 'monolithic.bkl', - 'wxwin.py']) +addMakefile('wx.bkl', {'all':'..','autoconf':'../..'}, [ '$(MDEPS)' ], + args={ + 'borland':'-DOPTIONS_FILE=config.bcc', + 'msvc':'-DOPTIONS_FILE=config.vc', + 'mingw':'-DOPTIONS_FILE=config.gcc', + 'watcom':'-DOPTIONS_FILE=config.wat', + }) # samples main makefile: -addMakefile('../../samples/samples.bkl', {'all':'../../samples'}) +addMakefile('../../samples/samples.bkl', {'all':'../../samples'}, + args={ + 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4', + 'borland':'-DOPTIONS_FILE=../build/config.bcc -DWRITE_OPTIONS_FILE=0', + 'msvc':'-DOPTIONS_FILE=../build/config.vc -DWRITE_OPTIONS_FILE=0', + 'mingw':'-DOPTIONS_FILE=../build/config.gcc -DWRITE_OPTIONS_FILE=0', + 'watcom':'-DOPTIONS_FILE=../build/config.wat -DWRITE_OPTIONS_FILE=0', + }) + +CONTRIB_DIR = 1 +SAMPLES_DIR = 2 -def onSample(arg, dirname, names): +def onSubmakefile(type, dirname, names): bakes = [x for x in names if x.endswith('.bkl')] if len(bakes) == 0: return + bakes.sort() + dirname = dirname.replace(os.sep, '/') depth = dirname.count('/') - 2 if depth <= 0: return - prefix = ''.join(['../' for i in range(0,depth)]) + + if type==SAMPLES_DIR: + prefix = ''.join(['../' for i in range(0,depth)]) + dirflags = '-DWXTOPDIR=%s../' % prefix + cfgbase = '%s../build/config.' % prefix + elif type==CONTRIB_DIR: + dirflags = '-DSRCDIR=../../src/%s' % dirname.split('/')[-1] + dirflags += ' -DWXTOPDIR=../../../' + cfgbase = '../../../build/config.' args = { - 'all':'-DWXTOPDIR=/%s..' % prefix, - 'autoconf':'-DAUTOCONF_MACROS_FILE=../../samples/autoconf_inc.m4', + 'not_autoconf':dirflags, + 'autoconf':'-DAUTOCONF_MACROS_FILE=../../autoconf_inc.m4', + 'msvc':'-DOPTIONS_FILE='+cfgbase+'vc -DWRITE_OPTIONS_FILE=0', + 'mingw':'-DOPTIONS_FILE='+cfgbase+'gcc -DWRITE_OPTIONS_FILE=0', + 'borland':'-DOPTIONS_FILE='+cfgbase+'bcc -DWRITE_OPTIONS_FILE=0', + 'watcom':'-DOPTIONS_FILE='+cfgbase+'wat -DWRITE_OPTIONS_FILE=0', } for bake in bakes: - addMakefile('%s/%s' % (dirname, bake), {'all':dirname}, - deps=['common.bkl','common_samples.bkl','config.bkl'], + if type==CONTRIB_DIR: + acdir = '../../contrib/src/%s' % dirname.split('/')[-1] + ruledep = '$(CDEPS)' + else: + acdir = dirname + ruledep = '$(SDEPS)' + addMakefile('%s/%s' % (dirname, bake), + {'all':dirname,'autoconf':acdir}, deps=[ruledep], args=args) -os.path.walk('../../samples', onSample, None) +os.path.walk(os.path.join('..','..','samples'), + onSubmakefile, SAMPLES_DIR) +os.path.walk(os.path.join('..','..','contrib','build'), + onSubmakefile, CONTRIB_DIR) +os.path.walk(os.path.join('..','..','contrib','samples'), + onSubmakefile, SAMPLES_DIR) cleanCmds = '' -for f in all: +allK = all.keys() +allK.sort() +cleanList = [] + +for f in allK: + all[f].sort() + +for f in allK: for i in all[f]: - cleanCmds += '\trm -f %s\n' % i + cleanList.append('\trm -f %s\n' % i) + cleanCmds = ''.join(cleanList) -for f in all: +for f in allK: var = '%s_ALL' % f.upper() - file.write('%s = %s\n' % (var,' '.join(all[f]))) + file.write('%s = \\\n\t%s\n' % (var,' \\\n\t'.join(all[f]))) file.write('all:') -for f in all: +for f in allK: file.write(' %s' % f) file.write('\n\n') -for f in all: +for f in allK: file.write('%s: $(%s_ALL)\n' % (f, f.upper())) file.write(""" clean: \trm -f ../../autoconf_inc.m4 -\trm -f ../../samples/autoconf_inc.m4 %s +library: ../../Makefile.in ../makefile.bcc ../makefile.vc ../makefile.wat ../makefile.gcc + ../../autoconf_inc.m4: ../../Makefile.in ../../configure: ../../autoconf_inc.m4 \t(cd ../.. ; aclocal && autoconf) -../../samples/autoconf_inc.m4: ../../samples/Makefile.in -../../samples/configure: ../../samples/autoconf_inc.m4 -\t(cd ../../samples ; aclocal && autoconf) - Makefile: regenMakefile.py \t./regenMakefile.py \t@echo @@ -125,6 +181,9 @@ Makefile: regenMakefile.py \t@echo \t@exit 1 """ % cleanCmds) -for l in lines: - file.write('%s\n' % l) +linesK = lines.keys() +linesK.sort() +for lk in linesK: + for l in lines[lk]: + file.write('%s\n' % l) file.close()