]> git.donarmstrong.com Git - lilypond.git/blob - SConstruct
Update.
[lilypond.git] / SConstruct
1 # -*-python-*-
2 #
3 # Experimental scons building
4 # TODO:
5 #   * install
6 #   * build in out/ ?
7 #   * mf, Documentation, ly etc.
8 #   * --srcdir ?  (mkdir =build; cd =build; scons -Y .. ;
9 #     ===> os.chdir (Dir ('.').srcdir ()); glob.glob (*.cc); os.chdir (cwd) ?
10
11
12 import re
13 import glob
14 import os
15 import sys
16 import string
17
18 env = Environment ()
19
20 opts = Options (None, ARGUMENTS)
21 opts.Add ('prefix', 'Install prefix', '/usr/')
22 opts.Add ('outdir', 'Output directory', 'out')
23 opts.AddOptions (
24         BoolOption ('warnings', 'compile with -Wall and similiar',
25                    1),
26         BoolOption ('debugging', 'compile with debugging symbols',
27                     0),
28         BoolOption ('optimising', 'compile with optimising',
29                     1),
30         BoolOption ('shared', 'build shared libraries',
31                     0),
32         BoolOption ('static', 'build static libraries',
33                     1),
34         )
35
36 Help (opts.GenerateHelpText (env))
37
38 env = Environment (options = opts)
39
40 if env['debugging']:
41         env.Append (CFLAGS = '-g')
42         env.Append (CXXFLAGS = '-g')
43 if env['optimising']:
44         env.Append (CFLAGS = '-O2')
45         env.Append (CXXFLAGS = '-O2 -DSTRING_UTILS_INLINED')
46 if env['warnings']:
47         env.Append (CFLAGS = '-W -Wall')
48         env.Append (CXXFLAGS = '-W -Wall -Wconversion')
49
50 conf = Configure (env)
51
52 #ugh -- hardcode territory
53 defines = {
54    'DIRSEP' : "'/'",
55    'PATHSEP' : "':'",
56
57    'PACKAGE': '"lilypond"',
58    'TOPLEVEL_VERSION' : '"2.3.6"',
59    'DATADIR' : '"' + os.getcwd () + '/share"',
60    'PACKAGE_DATADIR': 'DATADIR "/" PACKAGE',
61    'LILYPOND_DATADIR' : 'PACKAGE_DATADIR',
62    'LOCAL_PACKAGE_DATADIR' : 'PACKAGE_DATADIR "/" TOPLEVEL_VERSION',
63    'LOCAL_LILYPOND_DATADIR' : 'LOCAL_PACKAGE_DATADIR',
64    'LOCALEDIR' : '"' + os.getcwd () + '/share/locale"',
65 }
66
67 headers = ('sys/stat.h', 'assert.h', 'kpathsea/kpathsea.h')
68 for i in headers:
69         if conf.CheckCHeader (i):
70                 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
71                 defines[key] = '1'
72
73 ccheaders = ('sstream',)
74 for i in ccheaders:
75         if conf.CheckCXXHeader (i):
76                 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
77                 defines[key] = '1'
78
79 functions = ('gettext', 'isinf', 'memmem', 'snprintf', 'vsnprintf')
80 for i in functions:
81         if 0 or conf.CheckFunc (i):
82                 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
83                 defines[key] = '1'
84
85 if conf.CheckLib ('dl'):
86         pass
87
88 if conf.CheckLib ('kpathsea'):
89         defines['KPATHSEA'] = '1'
90
91 # ugh?
92 config = open ('config.h', 'w')
93 for i in defines.keys ():
94         config.write ('#define %s %s\n' % (i, defines[i]))
95 config.close ()
96 env = conf.Finish ()
97
98 os.system (sys.executable \
99            + ' ./stepmake/bin/make-version.py VERSION > version.hh')
100
101 Export ('env')
102
103 #this could happen after flower...
104 env.ParseConfig ('guile-config compile')
105
106 builddir = ''
107 outdir = env['outdir']
108
109 if os.path.exists ('parser'):
110         env.Append (LIBPATH = ['#/flower', '#/lily', '#/parser', '#/gui',],
111                     CPPPATH = ['#',])
112 else:   
113         env.Append (LIBPATH = ['#/flower/' + outdir,],
114                     CPPPATH = ['#',])
115
116
117 #ugh: remove make config output
118 if os.path.exists ('lily/out/config.h'):
119         os.unlink ('lily/out/config.h')
120
121 subdirs = ('flower', 'lily',)
122 #subdirs = ('flower', 'lily', 'parser', 'gui', 'main',)
123 for d in subdirs:
124         alias = os.path.join (builddir, d, outdir)
125         env.BuildDir (alias, d)
126         SConscript (os.path.join (alias, 'SConscript'))
127