[211] | 1 | import sys |
---|
[212] | 2 | import os |
---|
[234] | 3 | sys.dont_write_bytecode = True |
---|
[232] | 4 | from regfi_version import REGFI_VERSION |
---|
[211] | 5 | |
---|
[225] | 6 | cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden' |
---|
[232] | 7 | cflags += ' -DREGFI_VERSION=\'"%s"\'' % REGFI_VERSION |
---|
[225] | 8 | cflags += ' -ggdb' |
---|
[187] | 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 | |
---|
[191] | 16 | env = Environment(CFLAGS=cflags, |
---|
| 17 | CPPPATH=['include', '/usr/local/include'], |
---|
| 18 | LIBPATH=['lib', '/usr/local/lib'], |
---|
[195] | 19 | LIBS=['m', 'pthread', 'regfi', 'talloc']) |
---|
[191] | 20 | |
---|
[194] | 21 | |
---|
[187] | 22 | # Libraries |
---|
| 23 | libregfi_static = env.Library(lib_src) |
---|
[203] | 24 | libregfi = env.SharedLibrary(lib_src, LIBS=['m','pthread', 'talloc']) |
---|
[187] | 25 | |
---|
[189] | 26 | |
---|
[187] | 27 | # Executables |
---|
[191] | 28 | reglookup = env.Program(['src/reglookup.c']) |
---|
| 29 | reglookup_recover = env.Program(['src/reglookup-recover.c']) |
---|
[187] | 30 | |
---|
[189] | 31 | |
---|
[187] | 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', |
---|
[189] | 38 | src_suffix = '.docbook') |
---|
[187] | 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 | |
---|
[189] | 45 | # Installation |
---|
| 46 | prefix='/usr/local/' |
---|
[212] | 47 | install_items = [prefix+'bin', |
---|
| 48 | prefix+'lib', |
---|
| 49 | prefix+'include/regfi', |
---|
| 50 | prefix+'man'] |
---|
| 51 | |
---|
[189] | 52 | env.Install(prefix+'bin', [reglookup, reglookup_recover, 'bin/reglookup-timeline']) |
---|
| 53 | env.Install(prefix+'lib', [libregfi, libregfi_static]) |
---|
[193] | 54 | env.Install(prefix+'include/regfi', Glob('include/*.h')) |
---|
[189] | 55 | env.Install(prefix+'man/man1', [man_reglookup, man_reglookup_recover, |
---|
| 56 | man_reglookup_timeline]) |
---|
| 57 | |
---|
[212] | 58 | if sys.version_info[0] == 2: |
---|
| 59 | install_items.append('pyregfi2-install.log') |
---|
| 60 | env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py', 'python/pyregfi/structures.py'], |
---|
| 61 | "python pyregfi-distutils.py install | tee pyregfi2-install.log") |
---|
[189] | 62 | |
---|
[212] | 63 | python_path = os.popen('which python3').read() |
---|
| 64 | if python_path != '': |
---|
| 65 | install_items.append('pyregfi3-install.log') |
---|
| 66 | env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py', 'python/pyregfi/structures.py'], |
---|
| 67 | "python3 pyregfi-distutils.py install | tee pyregfi3-install.log") |
---|
| 68 | |
---|
| 69 | |
---|
[187] | 70 | # User Friendly Targets |
---|
| 71 | env.Alias('libregfi', libregfi) |
---|
| 72 | env.Alias('reglookup', reglookup) |
---|
| 73 | env.Alias('reglookup-recover', reglookup_recover) |
---|
| 74 | env.Alias('bin', [reglookup_recover, reglookup]) |
---|
| 75 | env.Alias('doc', [man_reglookup,man_reglookup_recover,man_reglookup_timeline]) |
---|
[212] | 76 | env.Alias('install', install_items) |
---|
[187] | 77 | |
---|
| 78 | Default('bin', libregfi) |
---|