]> git.donarmstrong.com Git - lilypond.git/blob - SConstruct
ugh
[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    '0DIRSEP' : "'/'",
55    '1PATHSEP' : "':'",
56
57    '2PACKAGE': '"lilypond"',
58    '3TOPLEVEL_VERSION' : '"2.3.6"',
59    '4DATADIR' : '"' + os.getcwd () + '/share"',
60    '5PACKAGE_DATADIR': 'DATADIR "/" PACKAGE',
61    '6LILYPOND_DATADIR' : 'PACKAGE_DATADIR',
62    '7LOCAL_PACKAGE_DATADIR' : 'PACKAGE_DATADIR "/" TOPLEVEL_VERSION',
63    '8LOCAL_LILYPOND_DATADIR' : 'LOCAL_PACKAGE_DATADIR',
64    '9LOCALEDIR' : '"' + 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 ('[./]', '_', 'zHAVE_' + 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 ('[./]', '_', 'zHAVE_' + 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 ('[./]', '_', 'zHAVE_' + 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 sort_helper = defines.keys ()
94 sort_helper.sort ()
95 #for i in defines.keys ():
96 for i in sort_helper:
97         config.write ('#define %s %s\n' % (i[1:], defines[i]))
98 config.close ()
99 env = conf.Finish ()
100
101 os.system (sys.executable \
102            + ' ./stepmake/bin/make-version.py VERSION > version.hh')
103
104 Export ('env')
105
106 #this could happen after flower...
107 env.ParseConfig ('guile-config compile')
108
109 builddir = ''
110 outdir = env['outdir']
111
112 if os.path.exists ('parser'):
113         env.Append (LIBPATH = ['#/flower', '#/lily', '#/parser', '#/gui',],
114                     CPPPATH = ['#',])
115 else:   
116         env.Append (LIBPATH = ['#/flower/' + outdir,],
117                     CPPPATH = ['#',])
118
119
120 #ugh: remove make config output
121 if os.path.exists ('lily/out/config.h'):
122         os.unlink ('lily/out/config.h')
123
124 subdirs = ('flower', 'lily',)
125 #subdirs = ('flower', 'lily', 'parser', 'gui', 'main',)
126 for d in subdirs:
127         alias = os.path.join (builddir, d, outdir)
128         env.BuildDir (alias, d)
129         SConscript (os.path.join (alias, 'SConscript'))
130