source: trunk/SConstruct @ 282

Last change on this file since 282 was 282, checked in by tim, 9 years ago

.

File size: 4.6 KB
Line 
1import sys
2import os
3sys.dont_write_bytecode = True
4from regfi_version import REGFI_VERSION
5
6# Package Maintainers: should any of these options be omitted during package
7# build, instead relying on CFLAGS/LDFLAGS to specify them when appropriate?
8cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden'
9cflags += ' -DREGFI_VERSION=\'"%s"\' ' % REGFI_VERSION
10cflags += os.environ.get('CFLAGS','-fPIE -pie -fstack-protector -D_FORTIFY_SOURCE=2')
11
12linkflags = "-shared -fPIC -Wl,-soname,libregfi.so.%s " % REGFI_VERSION
13linkflags += os.environ.get('LDFLAGS','-z relro -z now')
14
15
16lib_src = ['lib/regfi.c',
17           'lib/winsec.c',
18           'lib/range_list.c',
19           'lib/lru_cache.c',
20           'lib/void_stack.c']
21
22cc=os.environ.get('CC', 'gcc')
23env = Environment(ENV=os.environ,
24                  CC=cc,
25                  CFLAGS=cflags,
26                  CPPPATH=['include', '/usr/local/include'],
27                  LIBPATH=['lib', '/usr/local/lib'],
28                  LIBS=['m', 'pthread', 'regfi', 'talloc'])
29
30
31# Libraries
32libregfi_static = env.Library(lib_src)
33libregfi = env.SharedLibrary(lib_src, LIBS=['m','pthread', 'talloc'],
34                             LINKFLAGS=linkflags)
35
36
37# Executables
38reglookup = env.Program(['src/reglookup.c'])
39reglookup_recover = env.Program(['src/reglookup-recover.c'])
40
41
42# Documentation
43#  This only needs to be run during the release/packaging process
44man_fixup = "|sed 's/.SH DESCRIPTION/\\n.SH DESCRIPTION/'"
45man_builder = Builder(action='docbook2x-man --to-stdout $SOURCE'
46                      + man_fixup + '| gzip -9 > $TARGET',
47                      suffix = '.gz',
48                      src_suffix = '.docbook')
49env['BUILDERS']['ManPage'] = man_builder
50
51man_reglookup = env.ManPage('doc/reglookup.1.docbook')
52man_reglookup_recover = env.ManPage('doc/reglookup-recover.1.docbook')
53man_reglookup_timeline = env.ManPage('doc/reglookup-timeline.1.docbook')
54
55# Installation
56prefix     = os.environ.get('PREFIX','/usr/local')+'/'
57destdir    = os.environ.get('DESTDIR','')
58bindir     = os.environ.get('BINDIR', prefix + 'bin')
59libdir     = os.environ.get('LIBDIR', prefix + 'lib')
60includedir = os.environ.get('INCLUDEDIR', prefix + 'include')
61mandir     = os.environ.get('MANDIR', prefix + 'man')
62
63install_bin = [destdir + bindir, destdir + mandir]
64install_lib = [destdir + libdir, destdir + includedir + '/regfi']
65
66env.Install(destdir+bindir, [reglookup, reglookup_recover, 'bin/reglookup-timeline'])
67libinstall = env.Install(destdir+libdir, [libregfi, libregfi_static])
68env.Install(destdir+includedir+'/regfi', Glob('include/*.h'))
69env.Install(destdir+mandir+'/man1', [man_reglookup, man_reglookup_recover,
70                                     man_reglookup_timeline])
71
72if os.getuid() == 0 and destdir == '':
73   env.AddPostAction(libinstall, 'ldconfig')
74
75install_pyregfi = []
76if sys.version_info[0] == 2:
77   install_pyregfi.append('pyregfi2-install.log')
78   env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py',
79                                        'python/pyregfi/structures.py',
80                                        'python/pyregfi/winsec.py'],
81               "python setup.py install --root=/%s | tee pyregfi2-install.log" % destdir)
82
83python_path = os.popen('which python3').read()
84if python_path != '':
85   install_pyregfi.append('pyregfi3-install.log')
86   env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py',
87                                        'python/pyregfi/structures.py',
88                                        'python/pyregfi/winsec.py'],
89               "python3 setup.py install --root=/%s | tee pyregfi3-install.log" % destdir)
90
91
92# API documentation
93regfi_doc = env.Command('doc/devel/regfi/index.html',
94                        Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.regfi'],
95                        'doxygen doc/devel/Doxyfile.regfi')
96pyregfi_doc = env.Command('doc/devel/pyregfi/index.html',
97                          Glob('python/pyregfi/*.py')+['doc/devel/Doxyfile.pyregfi', regfi_doc],
98                          'doxygen doc/devel/Doxyfile.pyregfi')
99
100install_items = install_bin + install_lib + install_pyregfi
101
102# User Friendly Targets
103env.Alias('libregfi', libregfi)
104env.Alias('reglookup', reglookup)
105env.Alias('reglookup-recover', reglookup_recover)
106env.Alias('bin', [reglookup_recover, reglookup])
107env.Alias('doc', [man_reglookup,man_reglookup_recover,man_reglookup_timeline])
108env.Alias('doc-devel', [regfi_doc, pyregfi_doc])
109env.Alias('install_bin', install_bin)
110env.Alias('install_lib', install_lib)
111env.Alias('install_pyregfi', install_pyregfi)
112env.Alias('install', install_items)
113
114Default('bin', libregfi)
Note: See TracBrowser for help on using the repository browser.