source: trunk/SConstruct @ 281

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

comments to maintainers

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
[281]75# Package Maintainers: Do you need more control over these next two sections?
[280]76install_pyregfi = []
[212]77if sys.version_info[0] == 2:
[280]78   install_pyregfi.append('pyregfi2-install.log')
[253]79   env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py',
80                                        'python/pyregfi/structures.py',
81                                        'python/pyregfi/winsec.py'],
[279]82               "python setup.py install --root=/%s | tee pyregfi2-install.log" % destdir)
[189]83
[212]84python_path = os.popen('which python3').read()
85if python_path != '':
[280]86   install_pyregfi.append('pyregfi3-install.log')
[253]87   env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py',
88                                        'python/pyregfi/structures.py',
89                                        'python/pyregfi/winsec.py'],
[279]90               "python3 setup.py install --root=/%s | tee pyregfi3-install.log" % destdir)
[212]91
[281]92
[238]93# API documentation
94regfi_doc = env.Command('doc/devel/regfi/index.html',
95                        Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.regfi'],
96                        'doxygen doc/devel/Doxyfile.regfi')
97pyregfi_doc = env.Command('doc/devel/pyregfi/index.html',
98                          Glob('python/pyregfi/*.py')+['doc/devel/Doxyfile.pyregfi', regfi_doc],
99                          'doxygen doc/devel/Doxyfile.pyregfi')
[212]100
[280]101install_items = install_bin + install_lib + install_pyregfi
[238]102
[187]103# User Friendly Targets
104env.Alias('libregfi', libregfi)
105env.Alias('reglookup', reglookup)
106env.Alias('reglookup-recover', reglookup_recover)
107env.Alias('bin', [reglookup_recover, reglookup])
108env.Alias('doc', [man_reglookup,man_reglookup_recover,man_reglookup_timeline])
[238]109env.Alias('doc-devel', [regfi_doc, pyregfi_doc])
[280]110env.Alias('install_bin', install_bin)
111env.Alias('install_lib', install_lib)
112env.Alias('install_pyregfi', install_pyregfi)
[212]113env.Alias('install', install_items)
[187]114
115Default('bin', libregfi)
Note: See TracBrowser for help on using the repository browser.