~cypheon/elfelli

ref: 366eb2da9b0ba700e35ed60878bbf8e9416d2539 elfelli/SConstruct -rw-r--r-- 2.1 KiB
366eb2da — Johann Rudloff Better and cleaner installation. 15 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- Python -*-

import tools.Gettext

def DefQuote(str):
        return r'\"%s\"' % str

def CheckPkgConfig(context, min_version='0'):
        context.Message('Checking for pkgconfig... ')
        r = context.TryAction('pkg-config --atleast-pkgconfig-version %s' % min_version)
        context.Result(r[0])
        return r[0]

def PkgConfig(context, pkg, version, version_op='>='):
        context.Message('Checking for %s %s %s... ' % (pkg, version_op, version))

	context.env.ParseConfig('pkg-config --cflags --libs "%s %s %s"' % (pkg, version_op, version))
	context.Result(True)
	return True

env = Environment(BUILDERS={'MO': tools.Gettext.GettextMOBuilder})

opts = Options('elfelli.conf')
opts.Add(BoolOption('debug', 'Set to build debug version', 1))
opts.Add(BoolOption('profiling', 'Set to enable profiling', 0))
opts.Add(('prefix', 'Directory to install elfelli under', '/usr/local'))
opts.Update(env)
opts.Save('elfelli.conf', env)

if COMMAND_LINE_TARGETS:
        targets = COMMAND_LINE_TARGETS
else:
        targets = DEFAULT_TARGETS

conf = env.Configure(custom_tests =
                 {'CheckPkgConfig': CheckPkgConfig,
                  'PkgConfig': PkgConfig})

if not conf.CheckPkgConfig('0.15'):
        Exit(1)
if not conf.PkgConfig('gtkmm-2.4', '2.8'):
        Exit(1)

if env['profiling']:
	env.AppendUnique(CPPDEFINES='PROFILING')

if env['debug']:
	env.AppendUnique(CXXFLAGS=['-g', '-O0'], CPPDEFINES='DEBUG')
else:
	env.AppendUnique(CXXFLAGS=['-O3'], CPPDEFINES='NDEBUG')

paths = {"bindir": env['prefix'] + '/bin',
         "datadir": env['prefix'] + '/share/elfelli',
         "localedir": env['prefix'] + '/share/locale'}
env.Dictionary().update(paths)

env.AppendUnique(CPPDEFINES=[('DATADIR', DefQuote(env['datadir'])),
                             ('LOCALEDIR', DefQuote(env['localedir']))])

env.Alias("install", paths.values())

Help("""
scons        Build the program.
scons -c     Clean build directories.
scons -h     Show this help.

Options:""" + opts.GenerateHelpText(env))

Export('env')
SConscript(['src/SConscript', 'data/SConscript', 'po/SConscript'])