| 1 | # ############################################################################# |
|---|
| 2 | # SConstruct: SCons build instructions |
|---|
| 3 | # |
|---|
| 4 | # Copyright 2006-2007 Chip Norkus |
|---|
| 5 | # See the COPYING file for more information on licensing and use. |
|---|
| 6 | # |
|---|
| 7 | # $Id$ |
|---|
| 8 | # |
|---|
| 9 | # ############################################################################# |
|---|
| 10 | |
|---|
| 11 | ############################################################################### |
|---|
| 12 | # Initial setup (Python path tweaks etc) |
|---|
| 13 | |
|---|
| 14 | package_name = "superstring" |
|---|
| 15 | package_version = "1.0" |
|---|
| 16 | |
|---|
| 17 | EnsurePythonVersion(2,2) |
|---|
| 18 | EnsureSConsVersion(0,96,92) |
|---|
| 19 | |
|---|
| 20 | import glob, os, sys |
|---|
| 21 | # let's just stick the realpath() for ./build in there at the front. THis |
|---|
| 22 | # allows us to use our custom test code in the 'tests' module there. |
|---|
| 23 | sys.path.insert(0, os.path.realpath('./build')) |
|---|
| 24 | import tests |
|---|
| 25 | |
|---|
| 26 | ############################################################################### |
|---|
| 27 | # Global environment setup. Import the user's $PATH for our own sanity. |
|---|
| 28 | env = Environment(ENV = { |
|---|
| 29 | 'PATH': os.environ['PATH'], |
|---|
| 30 | }, |
|---|
| 31 | CPPPATH = ['#/include'] |
|---|
| 32 | ) |
|---|
| 33 | |
|---|
| 34 | ############################################################################### |
|---|
| 35 | # Options |
|---|
| 36 | |
|---|
| 37 | opts = Options(None, ARGUMENTS) |
|---|
| 38 | opts.AddOptions( |
|---|
| 39 | # Other path options are handled below |
|---|
| 40 | PathOption('prefix', 'Installation prefix', '/usr/local', |
|---|
| 41 | tests.PathIsDirCreateAccess), |
|---|
| 42 | ) |
|---|
| 43 | opts.Update(env) |
|---|
| 44 | |
|---|
| 45 | # Okay, let's make some dumb guesses: If the name already contains |
|---|
| 46 | # 'package' in it let's go ahead and not add that again. If the name is |
|---|
| 47 | # standard (/usr, /usr/local, /opt) let's add it there. Other than that we |
|---|
| 48 | # aren't too smart. :) |
|---|
| 49 | if env['prefix'] == '/usr' or env['prefix'] == '/opt': |
|---|
| 50 | # /usr and /opt need special handling to stuff things in /etc |
|---|
| 51 | sysconfdir = '/etc' |
|---|
| 52 | else: |
|---|
| 53 | sysconfdir = env['prefix'] + '/etc' |
|---|
| 54 | |
|---|
| 55 | dir_suffix = '' |
|---|
| 56 | if not package_name in env['prefix']: |
|---|
| 57 | dir_suffix = '/' + package_name |
|---|
| 58 | |
|---|
| 59 | opts.AddOptions( |
|---|
| 60 | BoolOption('debug', 'Enable creation of debugging symbols', 0), |
|---|
| 61 | BoolOption('warnings', 'Compile with aggressive warning checks', 1), |
|---|
| 62 | PathOption('libdir', "Library installation directory", |
|---|
| 63 | env['prefix'] + '/lib' + dir_suffix, tests.PathIsDirCreateAccess), |
|---|
| 64 | PathOption('includedir', 'C header installation directory', |
|---|
| 65 | env['prefix'] + '/include', tests.PathIsDirCreateAccess), |
|---|
| 66 | ) |
|---|
| 67 | opts.Update(env) |
|---|
| 68 | |
|---|
| 69 | env.Help(opts.GenerateHelpText(env)) |
|---|
| 70 | |
|---|
| 71 | ############################################################################### |
|---|
| 72 | # Configuration tests |
|---|
| 73 | conf = env.Configure(config_h = 'include/config.h', |
|---|
| 74 | custom_tests = tests.tests) |
|---|
| 75 | |
|---|
| 76 | conf.CheckCCompiler() |
|---|
| 77 | conf.CheckCVersion() |
|---|
| 78 | |
|---|
| 79 | # Set compiler options |
|---|
| 80 | if env['CC'] == 'gcc': |
|---|
| 81 | if env['debug']: |
|---|
| 82 | env.AppendUnique(CCFLAGS = ['-O', '-g3']) |
|---|
| 83 | if env['warnings']: |
|---|
| 84 | env.AppendUnique(CCFLAGS = Split(''' |
|---|
| 85 | -Wall -Wshadow -Wmissing-declarations -Wpointer-arith -Wcast-align |
|---|
| 86 | -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations |
|---|
| 87 | -Wredundant-decls -Winline -Wbad-function-cast |
|---|
| 88 | ''')) |
|---|
| 89 | |
|---|
| 90 | conf.Finish() |
|---|
| 91 | |
|---|
| 92 | ############################################################################### |
|---|
| 93 | # Build options and subsidiary code |
|---|
| 94 | |
|---|
| 95 | env.Export(['env', 'tests']) |
|---|
| 96 | |
|---|
| 97 | env.Install(env['includedir'] + '/superstring', |
|---|
| 98 | glob.glob('include/superstring/*.h')) |
|---|
| 99 | |
|---|
| 100 | # dummy install target with our various prefixes. |
|---|
| 101 | env.Alias('install', env['libdir'], env['includedir']) |
|---|
| 102 | |
|---|
| 103 | # and call our sub-scripts. |
|---|
| 104 | env.SConscript('source/SConscript') |
|---|
| 105 | |
|---|
| 106 | # vi:set ts=8 sts=4 sw=4 tw=76 et syntax=python: |
|---|