source: trunk/SConstruct@ 279

Last change on this file since 279 was 279, checked in by tim, 10 years ago

some changes requested by debian maintainers

File size: 4.2 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_items = [destdir + bindir,
61 destdir + libdir,
62 destdir + includedir + '/regfi',
63 destdir + mandir]
64
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
75if sys.version_info[0] == 2:
76 install_items.append('pyregfi2-install.log')
77 env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py',
78 'python/pyregfi/structures.py',
79 'python/pyregfi/winsec.py'],
80 "python setup.py install --root=/%s | tee pyregfi2-install.log" % destdir)
81
82python_path = os.popen('which python3').read()
83if python_path != '':
84 install_items.append('pyregfi3-install.log')
85 env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py',
86 'python/pyregfi/structures.py',
87 'python/pyregfi/winsec.py'],
88 "python3 setup.py install --root=/%s | tee pyregfi3-install.log" % destdir)
89
90# API documentation
91regfi_doc = env.Command('doc/devel/regfi/index.html',
92 Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.regfi'],
93 'doxygen doc/devel/Doxyfile.regfi')
94pyregfi_doc = env.Command('doc/devel/pyregfi/index.html',
95 Glob('python/pyregfi/*.py')+['doc/devel/Doxyfile.pyregfi', regfi_doc],
96 'doxygen doc/devel/Doxyfile.pyregfi')
97
98
99# User Friendly Targets
100env.Alias('libregfi', libregfi)
101env.Alias('reglookup', reglookup)
102env.Alias('reglookup-recover', reglookup_recover)
103env.Alias('bin', [reglookup_recover, reglookup])
104env.Alias('doc', [man_reglookup,man_reglookup_recover,man_reglookup_timeline])
105env.Alias('doc-devel', [regfi_doc, pyregfi_doc])
106env.Alias('install', install_items)
107
108Default('bin', libregfi)
Note: See TracBrowser for help on using the repository browser.