source: trunk/SConstruct @ 282

Last change on this file since 282 was 282, checked in by tim, 9 years ago

.

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