]> git.donarmstrong.com Git - lilypond.git/blob - SConstruct
lekker hakken
[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 (PackageOption ('prefix', 'Install prefix', '/usr/'))
22 ## `Path' means a directory rather than a path?
23 opts.Add (PathOption ('prefix', 'Install prefix', '/usr/'))
24 opts.AddOptions (
25         BoolOption ('warnings', 'compile with -Wall and similiar',
26                    1),
27         BoolOption ('debugging', 'compile with debugging symbols',
28                     0),
29         BoolOption ('optimising', 'compile with optimising',
30                     1),
31         BoolOption ('shared', 'build shared libraries',
32                     1),
33         BoolOption ('static', 'build static libraries',
34                     0),
35         )
36
37 Help (opts.GenerateHelpText (env))
38
39 env = Environment (options = opts)
40
41 if env['debugging']:
42         env.Append (CFLAGS = '-g')
43         env.Append (CXXFLAGS = '-g')
44 if env['optimising']:
45         env.Append (CFLAGS = '-O2')
46         env.Append (CXXFLAGS = '-O2 -DSTRING_UTILS_INLINED')
47 if env['warnings']:
48         env.Append (CFLAGS = '-W -Wall')
49         env.Append (CXXFLAGS = '-W -Wall -Wconversion')
50
51 conf = Configure (env)
52
53 #ugh -- hardcode territory
54 defines = {
55    'DIRSEP' : "'/'",
56    'PATHSEP' : "':'",
57
58    'PACKAGE': '"lilypond"',
59    'TOPLEVEL_VERSION' : '"2.3.6"',
60    'DATADIR' : '"' + os.getcwd () + '/share"',
61    'PACKAGE_DATADIR': 'DATADIR "/" PACKAGE',
62    'LILYPOND_DATADIR' : 'PACKAGE_DATADIR',
63    'LOCAL_PACKAGE_DATADIR' : 'PACKAGE_DATADIR "/" TOPLEVEL_VERSION',
64    'LOCAL_LILYPOND_DATADIR' : 'LOCAL_PACKAGE_DATADIR',
65    'LOCALEDIR' : '"' + os.getcwd () + '/share/locale"',
66 }
67
68 headers = ('sys/stat.h', 'assert.h', 'kpathsea/kpathsea.h')
69 for i in headers:
70         if conf.CheckCHeader (i):
71                 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
72                 defines[key] = '1'
73
74 ccheaders = ('sstream',)
75 for i in ccheaders:
76         if conf.CheckCXXHeader (i):
77                 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
78                 defines[key] = '1'
79
80 functions = ('gettext', 'isinf', 'memmem', 'snprintf', 'vsnprintf')
81 for i in functions:
82         if 0 or conf.CheckFunc (i):
83                 key = re.sub ('[./]', '_', 'HAVE_' + string.upper (i))
84                 defines[key] = '1'
85
86 if conf.CheckLib ('dl'):
87         pass
88
89 if conf.CheckLib ('kpathsea'):
90         defines['KPATHSEA'] = '1'
91
92 # ugh?
93 config = open ('config.h', 'w')
94 for i in defines.keys ():
95         config.write ('#define %s %s\n' % (i, defines[i]))
96 config.close ()
97 env = conf.Finish ()
98
99 if os.path.exists ('parser'):
100         env.Append (LIBPATH = ['#/flower', '#/lily', '#/parser', '#/gui',],
101                     CPPPATH = ['#',])
102 else:   
103         env.Append (LIBPATH = ['#/flower', '#/lily',],
104                     CPPPATH = ['#',])
105
106 os.system (sys.executable \
107            + ' ./stepmake/bin/make-version.py VERSION > version.hh')
108
109 Export ('env')
110
111
112 if 1:
113         #simple: build in ./flower
114         SConscript ('flower/SConscript')
115 else:
116         # moellik: build in [/tmp/build/]flower[/out]
117         # werkt 'bijna', maar glob in flower/Sconscript snapt niet
118         # dat-i in flower SCRDRI moet globben
119         builddir = ''
120         outdir = 'out'
121
122         d = 'flower'
123         alias = os.path.join (builddir, d, outdir)
124         env.BuildDir (alias, d)
125         SConscript (os.path.join (alias, 'SConscript'))
126
127 env.ParseConfig ('guile-config compile')
128
129 SConscript ('lily/SConscript')
130 if os.path.exists ('parser'):
131         SConscript ('parser/SConscript')
132         SConscript ('gui/SConscript')
133         SConscript ('main/SConscript')