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