-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSConstruct
104 lines (83 loc) · 3.09 KB
/
SConstruct
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
######################################
# What do we want to build
subdirs_min = Split("core programs viewer vector man scripts")
subdirs_max = subdirs_min + Split("tests misc")
######################################
## import python libraries
import os
import platform
if platform.python_version()<"2.7":
import distutils.sysconfig as sysconfig
else:
import sysconfig
######################################
# Create environment, add some methods
env = Environment ()
Export('env')
# UseLibs -- use pkg-config libraries
def UseLibs(env, libs):
if isinstance(libs, list):
libs = " ".join(libs)
env.ParseConfig('pkg-config --cflags --libs %s' % libs)
env.AddMethod(UseLibs)
# SymLink -- create a symlink
# Arguments target and linkname follow standard order (look at ln(1))
# wd is optional base directory for both
def SymLink(env, target, linkname, wd=None):
if wd:
env.Command(wd+'/'+linkname, wd+'/'+target, "ln -s -- %s %s/%s" % (target, wd, linkname))
else:
env.Command(linkname, target, "ln -s -- %s %s" % (target, linkname))
env.AddMethod(SymLink)
######################################
## Add default flags
if 'GCCVER' in os.environ:
ver = os.environ['GCCVER']
env.Replace (CC = ("gcc-%s" % ver))
env.Replace (CXX = ("g++-%s" % ver))
if 'CCFLAGS' in os.environ:
env.Append (CCFLAGS=os.environ['CCFLAGS'])
env.Append (CCFLAGS=['-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1'])
env.Append (CCFLAGS=['-Werror=return-type', '-Wall'])
env.Append (CCFLAGS='-std=gnu++11')
env.Append (ENV = {'PKG_CONFIG_PATH': os.getcwd()+'/core/pc'})
if os.getenv('PKG_CONFIG_PATH'):
env.Append (ENV = {'PKG_CONFIG_PATH':
[ os.getcwd()+'/core/pc', os.getenv('PKG_CONFIG_PATH')]})
env.Append (CPPPATH = "#core")
env.Append (LIBPATH = "#core")
env.Append (LIBS = "mapsoft")
######################################
## Parse command-line arguments:
env.PREFIX = ARGUMENTS.get('prefix', '')
env.bindir=env.PREFIX+'/usr/bin'
env.datadir=env.PREFIX+'/usr/share/mapsoft'
env.man1dir=env.PREFIX+'/usr/share/man/man1'
env.figlibdir=env.PREFIX+'/usr/share/xfig/Libraries'
env.libdir=env.PREFIX+ sysconfig.get_config_var('LIBDIR')
env.desktopdir=env.PREFIX+'/usr/share/applications'
env.Alias('install', [env.bindir, env.man1dir,
env.datadir, env.figlibdir, env.libdir, env.desktopdir])
if ARGUMENTS.get('debug', 0):
env.Append (CCFLAGS='-ggdb')
env.Append (LINKFLAGS='-ggdb')
if ARGUMENTS.get('profile', 0):
env.Append (CCFLAGS='-pg')
env.Append (LINKFLAGS='-pg')
if ARGUMENTS.get('gprofile', 0):
env.Append (LINKFLAGS='-lprofiler')
if ARGUMENTS.get('gheapcheck', 0):
env.Append (LINKFLAGS='-ltcmalloc')
if ARGUMENTS.get('minimal', 0):
SConscript(list(map(lambda s: s + "/SConscript", subdirs_min)))
else:
SConscript(list(map(lambda s: s + "/SConscript", subdirs_max)))
Help("""
You can build mapsoft with the following options:
scons -Q debug=1 // build with -ggdb
scons -Q profile=1 // build with -pg
scons -Q gheapcheck=1 // build with -ltcmalloc
scons -Q minimal=1 // skip misc and tests dirs
scons -Q prefix=<prefix> // set installation prefix
""")
# vim: ft=python tw=0