source: trunk/SConstruct @ 279

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

some changes requested by debian maintainers

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