From: Jan Nieuwenhuizen Date: Thu, 8 Jul 2004 14:45:58 +0000 (+0000) Subject: * lily/main.cc (dir_info): Print variables in sh format. X-Git-Tag: release/2.3.7~100 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b4812a4b3ae5288022bcf34c588c902ecbee5609;p=lilypond.git * lily/main.cc (dir_info): Print variables in sh format. * mf/SConscript: Update multiple target rules. * SConstruct (assert_version): Add. --- diff --git a/.cvsignore b/.cvsignore index a156e7d3ff..039f8c348d 100644 --- a/.cvsignore +++ b/.cvsignore @@ -40,3 +40,4 @@ share tfm tfm.[0-9] out +custom.py diff --git a/ChangeLog b/ChangeLog index 99cbda7641..7e20de471d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2004-07-08 Jan Nieuwenhuizen + * lily/main.cc (dir_info): Print variables in sh format. + * lily/includable-lexer.cc: Use #if iso #ifdef for HAVE_ tests. * mf/SConscript: Update multiple target rules. diff --git a/SConstruct b/SConstruct index ec3cc86da4..7cf431902d 100644 --- a/SConstruct +++ b/SConstruct @@ -18,16 +18,26 @@ import os out='out-scons' optimising=0 debugging=1 -prefix=os.getcwd () - +gui=1 +os.path.join (os.getcwd (), '=install') ''' # TODO: -# * mf: pfa -# *, Documentation, ly etc. - +# * running from build-dir, without installing? +# - scons will not install, if PREFIX lives outside of CWD +# - build symlink tree +# + mimicking regular installation setup? +# + use tweaked scons 'install' target? +# * commandline targets: +# - clean => -c +# - dist, tar => env.Tar +# * Documentation, scripts +# * env.Tar +# * more fine-grained config.h -- move lilypondprefix to version.hh? +# - config.h: changes after system upgrades, affects all files +# - version.hh: prefix, version etc? affects few import re import glob @@ -53,6 +63,10 @@ opts.AddOptions ( 0), BoolOption ('static', 'build static libraries', 1), + BoolOption ('gui', 'build with GNOME backend (EXPERIMENTAL)', + 1), + BoolOption ('verbose', 'run commands with verbose flag', + 0), ) Help (opts.GenerateHelpText (env)) @@ -70,8 +84,13 @@ env['version'] = packagepython.version_tuple_to_str (package.version) env['bindir'] = os.path.join (env['prefix'], 'bin') env['sharedir'] = os.path.join (env['prefix'], 'share') env['libdir'] = os.path.join (env['prefix'], 'lib') -env['lilypondprefix'] = os.path.join (env['sharedir'], 'lilypond', - env['version']) +env['localedir'] = os.path.join (env['sharedir'], 'locale') + +env['sharedir_package'] = os.path.join (env['sharedir'], package.name) +env['sharedir_package_version'] = os.path.join (env['sharedir_package'], + env['version']) +env['lilypondprefix'] = os.path.join (env['sharedir_package_version']) + if env['debugging']: env.Append (CFLAGS = '-g') @@ -92,41 +111,44 @@ env['MFMODE'] = 'ljfour' conf = Configure (env) -#ugh -- hardcode territory defines = { - '0DIRSEP' : "'/'", - '1PATHSEP' : "':'", - - '2PACKAGE': '"lilypond"', - '3TOPLEVEL_VERSION' : '"2.3.6"', - '4DATADIR' : '"' + os.getcwd () + '/share"', - '5PACKAGE_DATADIR': 'DATADIR "/" PACKAGE', - '6LILYPOND_DATADIR' : 'PACKAGE_DATADIR', - '7LOCAL_PACKAGE_DATADIR' : 'PACKAGE_DATADIR "/" TOPLEVEL_VERSION', - '8LOCAL_LILYPOND_DATADIR' : 'LOCAL_PACKAGE_DATADIR', - '9LOCALEDIR' : '"' + os.getcwd () + '/share/locale"', + 'DIRSEP' : "'/'", + 'PATHSEP' : "':'", + 'TOPLEVEL_VERSION' : '"' + env['version'] + '"', + 'PACKAGE': '"' + package.name + '"', + 'DATADIR' : '"' + env['sharedir'] + '"', + 'LILYPOND_DATADIR' : '"' + env['sharedir_package'] + '"', + 'LOCAL_LILYPOND_DATADIR' : '"' + env['sharedir_package_version'] + '"', + 'LOCALEDIR' : '"' + env['localedir'] + '"', } -headers = ('sys/stat.h', 'assert.h', 'kpathsea/kpathsea.h') + +command = r"""python -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'""" #" +print command +PYTHON_INCLUDE = os.popen (command).read () +env.Append (CPPPATH = PYTHON_INCLUDE) + + +headers = ('sys/stat.h', 'assert.h', 'kpathsea/kpathsea.h', 'Python.h') for i in headers: if conf.CheckCHeader (i): - key = re.sub ('[./]', '_', 'zHAVE_' + string.upper (i)) + key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i)) defines[key] = '1' ccheaders = ('sstream',) for i in ccheaders: if conf.CheckCXXHeader (i): - key = re.sub ('[./]', '_', 'zHAVE_' + string.upper (i)) + key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i)) defines[key] = '1' functions = ('gettext', 'isinf', 'memmem', 'snprintf', 'vsnprintf') for i in functions: if 0 or conf.CheckFunc (i): - key = re.sub ('[./]', '_', 'zHAVE_' + string.upper (i)) + key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i)) defines[key] = '1' -key = 'zHAVE_FLEXLEXER_YY_CURRENT_BUFFER' +key = 'HAVE_FLEXLEXER_YY_CURRENT_BUFFER' defines[key] = conf.TryCompile ("""using namespace std; #include class yy_flex_lexer: public yyFlexLexer @@ -142,19 +164,31 @@ if conf.CheckLib ('dl'): pass if conf.CheckLib ('kpathsea'): - defines['zKPATHSEA'] = '1' + defines['KPATHSEA'] = '1' # huh? if conf.CheckLib ('kpathsea', 'kpse_find_file'): - defines['zHAVE_KPSE_FIND_FILE'] = '1' - -env = conf.Finish () - -Export ('env') + defines['HAVE_KPSE_FIND_FILE'] = '1' +if conf.CheckLib ('kpathsea', 'kpse_find_tfm'): + defines['HAVE_KPSE_FIND_TFM'] = '1' #this could happen after flower... env.ParseConfig ('guile-config compile') +#this could happen only for compiling pango-* +if env['gui']: + env.ParseConfig ('pkg-config --cflags --libs gtk+-2.0') + env.ParseConfig ('pkg-config --cflags --libs pango') + if conf.CheckCHeader ('pango/pangofc-fontmap.h'): + defines['HAVE_PANGO_PANGOFC_FONTMAP_H'] = '1' + + if conf.CheckLib ('pango-1.0', + 'pango_fc_font_map_add_decoder_find_func'): + defines['HAVE_PANGO_CVS'] = '1' + defines['HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC'] = '1' + +env = conf.Finish () + build = env['build'] out = env['out'] ##reldir = str (Dir ('.').srcnode ()) @@ -163,11 +197,14 @@ outdir = os.path.join (env['build'], reldir, env['out']) if not os.path.exists (outdir): os.mkdir (outdir) +def list_sort (lst): + sorted = lst + sorted.sort () + return sorted + config = open (os.path.join (outdir, 'config.h'), 'w') -sort_helper = defines.keys () -sort_helper.sort () -for i in sort_helper: - config.write ('#define %s %s\n' % (i[1:], defines[i])) +for i in list_sort (defines.keys ()): + config.write ('#define %s %s\n' % (i, defines[i])) config.close () os.system (sys.executable \ @@ -181,38 +218,69 @@ else: env.Append (LIBPATH = ['#/flower/' + out,], CPPPATH = [outdir, '#',]) +vre = re.compile ('^.*[^-.0-9]([0-9][0-9]*\.[0-9][.0-9]*).*$', re.DOTALL) def get_version (program): command = '(%(program)s --version || %(program)s -V) 2>&1' % vars () - output = os.popen (command).readline ()[:-1] - v = re.sub ('^.*[^-.0-9]([0-9][0-9]*\.[0-9][.0-9]*).*$', '\\1', output) + output = os.popen (command).read () + v = re.sub (vre, '\\1', output) return string.split (v, '.') -def assert_version (program, minimal, description, package): +def assert_version (lst, program, minimal, description, package): global required sys.stdout.write ('Checking %s version... ' % program) actual = get_version (program) sys.stdout.write (string.join (actual, '.')) sys.stdout.write ('\n') if actual < string.split (minimal, '.'): - required.append ((description, package, - string.join (minimal, '.'), - program, - string.join (actual, '.'))) + lst.append ((description, package, minimal, program, + string.join (actual, '.'))) required = [] -assert_version ('gcc', '3.0.5', 'GNU C compiler', 'gcc') -assert_version ('makeinfo', '4.7', 'Makeinfo tool', 'texinfo') +assert_version (required, 'gcc', '2.8', 'GNU C compiler', 'gcc') +assert_version (required, 'g++', '3.0.5', 'GNU C++ compiler', 'g++') +assert_version (required, 'python', '2.1', 'Python (www.python.org)', 'python') +assert_version (required, 'guile-config', '1.6', 'GUILE development', + 'libguile-dev or guile-devel') +# Do not use bison 1.50 and 1.75. +assert_version (required, 'bison', '1.25', 'Bison -- parser generator', + 'bison') +assert_version (required, 'flex', '0.0', 'Flex -- lexer generator', 'flex') + + +optional = [] +assert_version (optional, 'makeinfo', '4.7', 'Makeinfo tool', 'texinfo') +assert_version (optional, 'guile', '1.6', 'GUILE scheme', + 'libguile-dev or guile-devel') +assert_version (optional, 'mftrace', '1.0.27', 'Metafont tracing Type1', + 'mftrace') +assert_version (optional, 'perl', '4.0', + 'Perl practical efficient readonly language', 'perl') if required: print print '********************************' print 'Please install required packages' -for i in required: - print '%s: %s-%s or newer (found: %s-%s)' % i + for i in required: + print '%s: %s-%s or newer (found: %s-%s)' % i + +if optional: + print + print '*************************************' + print 'Consider installing optional packages' + for i in optional: + print '%s: %s-%s or newer (found: %s-%s)' % i + +#env['tarball'] = os.path.join (outdir, +# package.name + '-' + env['version'] + '.tar.gz') + +env['tarball'] = os.path.join ('~/tmp', + package.name + '-' + env['version'] + '.tar.gz') -#subdirs = ('mf',) -#subdirs = ('flower', 'lily', 'parser', 'gui', 'main',) -subdirs = ('flower', 'lily', 'mf') +Export ('env') + +#subdirs = ['mf',] +#subdirs = ['flower', 'lily', 'parser', 'gui', 'main',] +subdirs = ['flower', 'lily', 'mf', 'scm', 'ly'] for d in subdirs: b = os.path.join (build, d, out) # Support clean sourctree build (srcdir build) @@ -223,3 +291,13 @@ for d in subdirs: env.BuildDir (b, d, duplicate=0) SConscript (os.path.join (b, 'SConscript')) + +readmes = ['AUTHORS.txt', 'ChangeLog', 'NEWS.txt'] + +#testing +env.Append (TARFLAGS = '-z --owner=0 --group=0') +env.Append (GZIPFLAGS = '-9') +all_sources = ['SConstruct',] + readmes + subdirs +x = env.Tar (env['tarball'], all_sources) + + diff --git a/flower/SConscript b/flower/SConscript index 1477b80cc3..121ad45917 100644 --- a/flower/SConscript +++ b/flower/SConscript @@ -7,6 +7,7 @@ here = os.getcwd () reldir = str (Dir ('.').srcnode ()) os.chdir (reldir) sources = glob.glob ('*.cc') +includes = glob.glob ('include/*.hh') os.chdir (here) name = 'flower' @@ -18,3 +19,7 @@ if env['static']: e.Library (name, sources) if not env['static'] or env['shared']: e.SharedLibrary (name, sources) + +#testing +all_sources = ['SConscript',] + sources + includes +x = env.Tar (env['tarball'], all_sources) diff --git a/lily/SConscript b/lily/SConscript index e67d938c55..910a260688 100644 --- a/lily/SConscript +++ b/lily/SConscript @@ -7,6 +7,7 @@ here = os.getcwd () reldir = str (Dir ('.').srcnode ()) os.chdir (reldir) sources = glob.glob ('*.cc') + ['parser.yy', 'lexer.ll'] +includes = glob.glob ('include/*.hh') os.chdir (here) name = 'lyparser' @@ -14,6 +15,16 @@ name = 'lyparser' Import ('env') e = env.Copy () +#let's do this after the split +#sources = filter (lambda x: x != 'pangofc-afm-decoder.cc', sources) +#pango = env.Copy () +#if pango['gui']: +# pango.ParseConfig ('pkg-config --cflags --libs gtk+-2.0') +# pango.ParseConfig ('pkg-config --cflags --libs pango') +#pango.Object ('foo-' + 'pangofc-afm-decoder.o', 'pangofc-afm-decoder.cc') +# +#e.Object ('pangofc-afm-decoder.o', 'foo-pangofc-afm-deocder.o') + e.Append (YACCFLAGS = '-d') outdir = os.path.join (env['build'], reldir, env['out']) e.Append (CPPPATH = [outdir, '#/lily/include', '#/flower/include']) @@ -22,16 +33,14 @@ e.Depends ('my-lily-lexer.o', 'parser.cc') e.Depends ('my-lily-parser.o', 'parser.cc') # some stuff here from lily-as-lib -if not os.path.exists ('main.cc'): - if env['static']: - e.Library (name, sources) - if not env['static'] or env['shared']: - e.SharedLibrary (name, sources) -else: - #e.Append (LIBS = ['lygui', 'lyparser', 'lily', 'flower']) - e.Append (LIBS = ['flower']) - e.ParseConfig ('guile-config link') - name = 'lilypond-bin' - lily = e.Program (name, sources) - env.Install (env['bindir'], lily) - env.Alias ('install', env['bindir']) +e.Append (LIBS = ['flower']) +e.ParseConfig ('guile-config link') +name = 'lilypond-bin' +lily = e.Program (name, sources) +env.Install (env['bindir'], lily) +env.Alias ('install', env['bindir']) + + +#testing +all_sources = ['SConscript',] + sources + includes +x = env.Tar (env['tarball'], all_sources) diff --git a/lily/main.cc b/lily/main.cc index a7fd529735..74ac10ecd4 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -140,12 +140,12 @@ static void dir_info (FILE *out) { fputs ("\n", out); - fprintf (out, "lilypond_datadir: `%s'\n", LILYPOND_DATADIR); - fprintf (out, "local_lilypond_datadir: `%s'\n", LOCAL_LILYPOND_DATADIR); - fprintf (out, "localedir: `%s'\n", LOCALEDIR); + fprintf (out, "LILYPOND_DATADIR=\"%s\"\n", LILYPOND_DATADIR); + fprintf (out, "LOCAL_LILYPOND_DATADIR=\%s\"\n", LOCAL_LILYPOND_DATADIR); + fprintf (out, "LOCALEDIR=\"%s\"\n", LOCALEDIR); char *lilypond_prefix = getenv ("LILYPONDPREFIX"); - fprintf (out, "LILYPONDPREFIX: `%s'\n", + fprintf (out, "LILYPONDPREFIX=\"%s\"\n", (lilypond_prefix ? lilypond_prefix : "")); } diff --git a/ly/SConscript b/ly/SConscript new file mode 100644 index 0000000000..9ad8fa1793 --- /dev/null +++ b/ly/SConscript @@ -0,0 +1,21 @@ +# -*-python-*- + +import glob +import os + +here = os.getcwd () +reldir = str (Dir ('.').srcnode ()) +os.chdir (reldir) +sources = glob.glob ('*.ly') +os.chdir (here) + +Import ('env') +e = env.Copy () +outdir = os.path.join (env['build'], reldir, env['out']) +lydir = os.path.join (env['sharedir_package_version'], 'ly') +env.Install (lydir, sources) +env.Alias ('install', lydir) + +#testing +all_sources = ['SConscript',] + sources +x = env.Tar (env['tarball'], all_sources) diff --git a/mf/SConscript b/mf/SConscript index 2e010a4efc..a12f880efc 100644 --- a/mf/SConscript +++ b/mf/SConscript @@ -8,6 +8,7 @@ import sys here = os.getcwd () reldir = str (Dir ('.').srcnode ()) os.chdir (reldir) +sources = glob.glob ('*.mf') #mf_sources = reduce (+, mf_sources = reduce (lambda x, y: x + y, map (glob.glob, @@ -23,8 +24,6 @@ MFMODE = env['MFMODE'] def add_log_enc_ly_tex_target (target, source, env): base = os.path.splitext (str (target[0]))[0] et = (map (lambda x: base + x, ['.log', '.enc', '.ly', '.tex'])) - #es = (map (lambda x: base + '.mf', et)) - #return (target + et, source + es) return (target + et, source) outdir = os.path.join (env['build'], reldir, env['out']) @@ -37,36 +36,6 @@ tfm = Builder (action = ('(cd ' + outdir + ' && ' \ src_suffix = '.mf', emitter = add_log_enc_ly_tex_target) -## How do do multiple targets? Does emitter not take care of this? -#log = Builder (action = ('(cd ' + outdir + ' && ' \ -# + 'MFINPUTS=.:' + str (Dir ('#/mf')) \ -# + ' mf "\\mode:=%(MFMODE)s; nonstopmode; ' \ -# + ' input $$(basename $SOURCE);" ' \ -# + ' | grep -v "@\|>>")') % vars (), -# suffix = '.log', -# src_suffix = '.mf') -#enc = Builder (action = ('(cd ' + outdir + ' && ' \ -# + 'MFINPUTS=.:' + str (Dir ('#/mf')) \ -# + ' mf "\\mode:=%(MFMODE)s; nonstopmode; ' \ -# + ' input $$(basename $SOURCE);" ' \ -# + ' | grep -v "@\|>>")') % vars (), -# suffix = '.enc', -# src_suffix = '.mf') -#ly = Builder (action = ('(cd ' + outdir + ' && ' \ -# + 'MFINPUTS=.:' + str (Dir ('#/mf')) \ -# + ' mf "\\mode:=%(MFMODE)s; nonstopmode; ' \ -# + ' input $$(basename $SOURCE);" ' \ -# + ' | grep -v "@\|>>")') % vars (), -# suffix = '.ly', -# src_suffix = '.mf') -#tex = Builder (action = ('(cd ' + outdir + ' && ' \ -# + 'MFINPUTS=.:' + str (Dir ('#/mf')) \ -# + ' mf "\\mode:=%(MFMODE)s; nonstopmode; ' \ -# + ' input $$(basename $SOURCE);" ' \ -# + ' | grep -v "@\|>>")') % vars (), -# suffix = '.tex', -# src_suffix = '.mf') - afm = Builder (action = (sys.executable + ' buildscripts/mf-to-table.py ' \ + ' --package=. --outdir=%(outdir)s '\ @@ -84,11 +53,17 @@ def add_enc_src (target, source, env): def encoding_opt (target): base = os.path.splitext (os.path.basename (str (target[0])))[0] - enc = os.path.join (outdir, base + '.enc') - if os.path.exists (enc): + ##enc = os.path.join (outdir, base + '.enc') + enc = base + '.enc' + if os.path.exists (os.path.join (outdir, enc)): return ' --encoding=' + enc return '' +def verbose_opt (env, opt): + if env['verbose']: + return opt + return '' + # UGH, should fix --output option for mftrace xpfa = Builder (action = ('MFINPUTS=.:' + str (Dir ('#/mf')) \ + ' mftrace -I %(outdir)s --pfa' \ @@ -102,14 +77,18 @@ xpfa = Builder (action = ('MFINPUTS=.:' + str (Dir ('#/mf')) \ def run_mftrace (target, source, env): TARGET = target[0] SOURCE = source[0] + mf = os.path.basename (str (source[0])) + base = os.path.splitext (os.path.basename (str (target[0])))[0] + enc = base + '.enc' + mfdir = os.path.join (here, reldir) outdir = os.path.join (env['build'], reldir, env['out']) - command = ('MFINPUTS=.:' + str (Dir ('#/mf')) \ - + ' mftrace -I %(outdir)s --pfa' \ - + ' --simplify --keep-trying' \ - + ' $(basename %(SOURCE)s .mf) ' \ + command = ('(cd %(outdir)s && ' + + ' MFINPUTS=.:%(outdir)s:' + mfdir\ + + ' mftrace --pfa --simplify --keep-trying' \ + + ' --include=%(outdir)s'\ + + verbose_opt (env, ' --verbose') \ + encoding_opt (target) \ - + ' && mv $(basename %(TARGET)s) %(TARGET)s') \ - % vars () + + ' %(mf)s)') % vars () return os.system (command) pfa = Builder (action = run_mftrace, @@ -119,20 +98,19 @@ pfa = Builder (action = run_mftrace, e = env.Copy (BUILDERS = {'Tfm' : tfm, -# 'Log' : log, 'Enc' : enc, 'Ly' : ly, 'Tex' : tex, 'Afm' : afm, 'Pfa' : pfa}, MFINPUTS = '#/mf') #mf_sources = ('feta16.mf',) #mf_sources = ('feta-braces-a.mf',) -sources = map (lambda x: os.path.splitext (x)[0], mf_sources) +font_stems = map (lambda x: os.path.splitext (x)[0], mf_sources) -t = map (e.Tfm, sources) -a = map (e.Afm, sources) -p = map (e.Pfa, sources) +t = map (e.Tfm, font_stems) +a = map (e.Afm, font_stems) +p = map (e.Pfa, font_stems) -map (lambda x: e.Depends (x + '.pfa', x + '.enc'), sources) -#map (lambda x: e.Depends (x + '.pfa', x + '.log'), sources) +map (lambda x: e.Depends (x + '.pfa', x + '.enc'), font_stems) +#map (lambda x: e.Depends (x + '.pfa', x + '.log'), font_stems) tfmdir = os.path.join (env['lilypondprefix'], 'fonts/tfm') afmdir = os.path.join (env['lilypondprefix'], 'afm') @@ -145,4 +123,6 @@ env.Alias ('install', tfmdir) env.Alias ('install', afmdir) env.Alias ('install', pfadir) - +#testing +all_sources = ['SConscript',] + sources +x = env.Tar (env['tarball'], all_sources) diff --git a/scm/SConscript b/scm/SConscript new file mode 100644 index 0000000000..db12e43bfa --- /dev/null +++ b/scm/SConscript @@ -0,0 +1,21 @@ +# -*-python-*- + +import glob +import os + +here = os.getcwd () +reldir = str (Dir ('.').srcnode ()) +os.chdir (reldir) +sources = glob.glob ('*.scm') +os.chdir (here) + +Import ('env') +e = env.Copy () +outdir = os.path.join (env['build'], reldir, env['out']) +scmdir = os.path.join (env['sharedir_package_version'], 'scm') +env.Install (scmdir, sources) +env.Alias ('install', scmdir) + +#testing +all_sources = ['SConscript',] + sources +x = env.Tar (env['tarball'], all_sources)