source: trunk/SConstruct @ 277

Last change on this file since 277 was 277, checked in by tim, 12 years ago

incorporated a version of Adam Golebiowski's build patches
reworked REGFI_VERSION and began using it in pyregfi installation

File size: 4.1 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                             LINKFLAGS="-shared -fPIC -Wl,-soname,libregfi.so.%s" % REGFI_VERSION)
28
29
30# Executables
31reglookup = env.Program(['src/reglookup.c'])
32reglookup_recover = env.Program(['src/reglookup-recover.c'])
33
34
35# Documentation
36#  This only needs to be run during the release/packaging process
37man_fixup = "|sed 's/.SH DESCRIPTION/\\n.SH DESCRIPTION/'"
38man_builder = Builder(action='docbook2x-man --to-stdout $SOURCE'
39                      + man_fixup + '| gzip -9 > $TARGET',
40                      suffix = '.gz',
41                      src_suffix = '.docbook')
42env['BUILDERS']['ManPage'] = man_builder
43
44man_reglookup = env.ManPage('doc/reglookup.1.docbook')
45man_reglookup_recover = env.ManPage('doc/reglookup-recover.1.docbook')
46man_reglookup_timeline = env.ManPage('doc/reglookup-timeline.1.docbook')
47
48# Installation
49prefix     = os.environ.get('PREFIX','/usr/local')+'/'
50destdir    = os.environ.get('DESTDIR','')
51bindir     = os.environ.get('BINDIR', prefix + 'bin')
52libdir     = os.environ.get('LIBDIR', prefix + 'lib')
53includedir = os.environ.get('INCLUDEDIR', prefix + 'include')
54mandir     = os.environ.get('MANDIR', prefix + 'man')
55
56install_items = [destdir + bindir,
57                 destdir + libdir,
58                 destdir + includedir + '/regfi',
59                 destdir + mandir]
60
61
62env.Install(destdir+bindir, [reglookup, reglookup_recover, 'bin/reglookup-timeline'])
63libinstall = env.Install(destdir+libdir, [libregfi, libregfi_static])
64env.Install(destdir+includedir+'/regfi', Glob('include/*.h'))
65env.Install(destdir+mandir+'/man1', [man_reglookup, man_reglookup_recover,
66                                     man_reglookup_timeline])
67if os.getuid() == 0:
68   env.AddPostAction(libinstall, 'ldconfig')
69
70if sys.version_info[0] == 2:
71   install_items.append('pyregfi2-install.log')
72   env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py',
73                                        'python/pyregfi/structures.py',
74                                        'python/pyregfi/winsec.py'],
75               "python pyregfi-distutils.py install --root=%s | tee pyregfi2-install.log" % destdir)
76
77python_path = os.popen('which python3').read()
78if python_path != '':
79   install_items.append('pyregfi3-install.log')
80   env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py',
81                                        'python/pyregfi/structures.py',
82                                        'python/pyregfi/winsec.py'],
83               "python3 pyregfi-distutils.py install --root=%s | tee pyregfi3-install.log" % destdir)
84
85# API documentation
86regfi_doc = env.Command('doc/devel/regfi/index.html',
87                        Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.regfi'],
88                        'doxygen doc/devel/Doxyfile.regfi')
89pyregfi_doc = env.Command('doc/devel/pyregfi/index.html',
90                          Glob('python/pyregfi/*.py')+['doc/devel/Doxyfile.pyregfi', regfi_doc],
91                          'doxygen doc/devel/Doxyfile.pyregfi')
92
93
94# User Friendly Targets
95env.Alias('libregfi', libregfi)
96env.Alias('reglookup', reglookup)
97env.Alias('reglookup-recover', reglookup_recover)
98env.Alias('bin', [reglookup_recover, reglookup])
99env.Alias('doc', [man_reglookup,man_reglookup_recover,man_reglookup_timeline])
100env.Alias('doc-devel', [regfi_doc, pyregfi_doc])
101env.Alias('install', install_items)
102
103Default('bin', libregfi)
Note: See TracBrowser for help on using the repository browser.