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