source: trunk/SConstruct @ 273

Last change on this file since 273 was 273, checked in by tim, 13 years ago

allowed compiler to be specified via CC environment variable
fixed 3 uninitialized variable problems discovered by clang source analyzer

File size: 3.7 KB
Line 
1import sys
2import os
3sys.dont_write_bytecode = True
4from regfi_version import REGFI_VERSION
5
6cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden'
7cflags += ' -DREGFI_VERSION=\'"%s"\'' % REGFI_VERSION
8cflags += ' -ggdb'
9
10lib_src = ['lib/regfi.c',
11           'lib/winsec.c',
12           'lib/range_list.c',
13           'lib/lru_cache.c',
14           'lib/void_stack.c']
15
16cc=os.environ.get('CC', 'gcc')
17env = Environment(ENV=os.environ,
18                  CC=cc,
19                  CFLAGS=cflags,
20                  CPPPATH=['include', '/usr/local/include'],
21                  LIBPATH=['lib', '/usr/local/lib'],
22                  LIBS=['m', 'pthread', 'regfi', 'talloc'])
23
24# Libraries
25libregfi_static = env.Library(lib_src)
26libregfi = env.SharedLibrary(lib_src, LIBS=['m','pthread', 'talloc'])
27
28
29# Executables
30reglookup = env.Program(['src/reglookup.c'])
31reglookup_recover = env.Program(['src/reglookup-recover.c'])
32
33
34# Documentation
35#  This only needs to be run during the release/packaging process
36man_fixup = "|sed 's/.SH DESCRIPTION/\\n.SH DESCRIPTION/'"
37man_builder = Builder(action='docbook2x-man --to-stdout $SOURCE'
38                      + man_fixup + '| gzip -9 > $TARGET',
39                      suffix = '.gz',
40                      src_suffix = '.docbook')
41env['BUILDERS']['ManPage'] = man_builder
42
43man_reglookup = env.ManPage('doc/reglookup.1.docbook')
44man_reglookup_recover = env.ManPage('doc/reglookup-recover.1.docbook')
45man_reglookup_timeline = env.ManPage('doc/reglookup-timeline.1.docbook')
46
47# Installation
48prefix='/usr/local/'
49if 'PREFIX' in os.environ:
50   prefix = os.environ['PREFIX']+'/'
51
52install_items = [prefix+'bin',
53                 prefix+'lib',
54                 prefix+'include/regfi',
55                 prefix+'man']
56
57env.Install(prefix+'bin', [reglookup, reglookup_recover, 'bin/reglookup-timeline'])
58libinstall = env.Install(prefix+'lib', [libregfi, libregfi_static])
59env.Install(prefix+'include/regfi', Glob('include/*.h'))
60env.Install(prefix+'man/man1', [man_reglookup, man_reglookup_recover,
61                                man_reglookup_timeline])
62env.AddPostAction(libinstall, 'ldconfig')
63
64if sys.version_info[0] == 2:
65   install_items.append('pyregfi2-install.log')
66   env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py',
67                                        'python/pyregfi/structures.py',
68                                        'python/pyregfi/winsec.py'],
69               "python pyregfi-distutils.py install | tee pyregfi2-install.log")
70
71python_path = os.popen('which python3').read()
72if python_path != '':
73   install_items.append('pyregfi3-install.log')
74   env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py',
75                                        'python/pyregfi/structures.py',
76                                        'python/pyregfi/winsec.py'],
77               "python3 pyregfi-distutils.py install | tee pyregfi3-install.log")
78
79# API documentation
80regfi_doc = env.Command('doc/devel/regfi/index.html',
81                        Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.regfi'],
82                        'doxygen doc/devel/Doxyfile.regfi')
83pyregfi_doc = env.Command('doc/devel/pyregfi/index.html',
84                          Glob('python/pyregfi/*.py')+['doc/devel/Doxyfile.pyregfi', regfi_doc],
85                          'doxygen doc/devel/Doxyfile.pyregfi')
86
87
88# User Friendly Targets
89env.Alias('libregfi', libregfi)
90env.Alias('reglookup', reglookup)
91env.Alias('reglookup-recover', reglookup_recover)
92env.Alias('bin', [reglookup_recover, reglookup])
93env.Alias('doc', [man_reglookup,man_reglookup_recover,man_reglookup_timeline])
94env.Alias('doc-devel', [regfi_doc, pyregfi_doc])
95env.Alias('install', install_items)
96
97Default('bin', libregfi)
Note: See TracBrowser for help on using the repository browser.