1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
#-*- mode: Python;-*-
import sys
import os
sys.dont_write_bytecode = True
from regfi_version import REGFI_VERSION
ABI_VERSION=REGFI_VERSION.rsplit('.',1)[0]
# Package Maintainers: should any of these options in the first line be omitted during
# package build, instead relying on CFLAGS/LDFLAGS to specify them when appropriate?
cflags = '-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden'
cflags += ' -DREGFI_VERSION=\'"%s"\' ' % REGFI_VERSION
cflags += ' -ggdb'
cflags += ' -D_FORTIFY_SOURCE=2'
cflags += ' -fPIE'
linkflags = "-fPIE -pie " + os.environ.get('LDFLAGS','-z relro -z now')
lib_src = ['lib/regfi.c',
'lib/winsec.c',
'lib/range_list.c',
'lib/lru_cache.c',
'lib/void_stack.c']
cc=os.environ.get('CC', 'gcc')
env = Environment(ENV=os.environ,
CC=cc,
CFLAGS=cflags,
LINKFLAGS=linkflags,
CPPPATH=['include', '/usr/include'],
LIBPATH=['lib', '/usr/lib'],
LIBS=['m', 'pthread', 'regfi', 'talloc'])
# Libraries
libregfi_static = env.Library(lib_src)
libregfi = env.SharedLibrary(lib_src, LIBS=['m','pthread', 'talloc'],
SHLIBVERSION=ABI_VERSION)
# Executables
reglookup = env.Program(['src/reglookup.c'])
reglookup_recover = env.Program(['src/reglookup-recover.c'])
# Documentation
# This only needs to be run during the release/packaging process
man_fixup = "|sed 's/.SH DESCRIPTION/\\n.SH DESCRIPTION/'"
man_builder = Builder(action='docbook2x-man --to-stdout $SOURCE'
+ man_fixup + '| gzip -9 > $TARGET',
suffix = '.gz',
src_suffix = '.docbook')
env['BUILDERS']['ManPage'] = man_builder
man_reglookup = env.ManPage('doc/reglookup.1.docbook')
man_reglookup_recover = env.ManPage('doc/reglookup-recover.1.docbook')
man_reglookup_timeline = env.ManPage('doc/reglookup-timeline.1.docbook')
# Installation
prefix = os.environ.get('PREFIX','/usr/local')+'/'
destdir = os.environ.get('DESTDIR','')
bindir = os.environ.get('BINDIR', prefix + 'bin')
libdir = os.environ.get('LIBDIR', prefix + 'lib')
includedir = os.environ.get('INCLUDEDIR', prefix + 'include')
mandir = os.environ.get('MANDIR', prefix + 'man')
install_bin = [destdir + bindir, destdir + mandir]
env.Install(destdir+bindir, [reglookup, reglookup_recover, 'bin/reglookup-timeline'])
libinstall = env.InstallVersionedLib(destdir+libdir, [libregfi, libregfi_static], SHLIBVERSION=ABI_VERSION)
env.Install(destdir+includedir+'/regfi', Glob('include/*.h'))
env.Install(destdir+mandir+'/man1', [man_reglookup, man_reglookup_recover,
man_reglookup_timeline])
if os.getuid() == 0 and destdir == '':
env.AddPostAction(libinstall, 'ldconfig')
install_pyregfi = []
if sys.version_info[0] == 2:
install_pyregfi.append('pyregfi2-install.log')
env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py',
'python/pyregfi/structures.py',
'python/pyregfi/winsec.py'],
"python setup.py install --root=/%s | tee pyregfi2-install.log" % destdir)
python_path = os.popen('which python3').read()
if python_path != '':
install_pyregfi.append('pyregfi3-install.log')
env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py',
'python/pyregfi/structures.py',
'python/pyregfi/winsec.py'],
"python3 setup.py install --root=/%s | tee pyregfi3-install.log" % destdir)
# API documentation
regfi_doc = env.Command('doc/devel/regfi/index.html',
Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.regfi'],
'doxygen doc/devel/Doxyfile.regfi')
pyregfi_doc = env.Command('doc/devel/pyregfi/index.html',
Glob('python/pyregfi/*.py')+['doc/devel/Doxyfile.pyregfi', regfi_doc],
'doxygen doc/devel/Doxyfile.pyregfi')
install_items = install_bin + install_pyregfi
# User Friendly Targets
env.Alias('libregfi', libregfi)
env.Alias('reglookup', reglookup)
env.Alias('reglookup-recover', reglookup_recover)
env.Alias('bin', [reglookup_recover, reglookup])
env.Alias('doc', [man_reglookup,man_reglookup_recover,man_reglookup_timeline])
env.Alias('doc-devel', [regfi_doc, pyregfi_doc])
env.Alias('install_bin', install_bin)
env.Alias('install_pyregfi', install_pyregfi)
env.Alias('install', install_items)
Default('bin', libregfi)
|