source: trunk/SConstruct @ 280

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

breaking up install targets

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