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