source: trunk/SConstruct @ 280

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

breaking up install targets

File size: 4.4 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
[280]60install_bin = [destdir + bindir, destdir + mandir]
61install_lib = [destdir + libdir, destdir + includedir + '/regfi']
[212]62
[277]63env.Install(destdir+bindir, [reglookup, reglookup_recover, 'bin/reglookup-timeline'])
64libinstall = env.Install(destdir+libdir, [libregfi, libregfi_static])
65env.Install(destdir+includedir+'/regfi', Glob('include/*.h'))
66env.Install(destdir+mandir+'/man1', [man_reglookup, man_reglookup_recover,
67                                     man_reglookup_timeline])
[279]68
69if os.getuid() == 0 and destdir == '':
[277]70   env.AddPostAction(libinstall, 'ldconfig')
71
[280]72install_pyregfi = []
[212]73if sys.version_info[0] == 2:
[280]74   install_pyregfi.append('pyregfi2-install.log')
[253]75   env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py',
76                                        'python/pyregfi/structures.py',
77                                        'python/pyregfi/winsec.py'],
[279]78               "python setup.py install --root=/%s | tee pyregfi2-install.log" % destdir)
[189]79
[212]80python_path = os.popen('which python3').read()
81if python_path != '':
[280]82   install_pyregfi.append('pyregfi3-install.log')
[253]83   env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py',
84                                        'python/pyregfi/structures.py',
85                                        'python/pyregfi/winsec.py'],
[279]86               "python3 setup.py install --root=/%s | tee pyregfi3-install.log" % destdir)
[212]87
[238]88# API documentation
89regfi_doc = env.Command('doc/devel/regfi/index.html',
90                        Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.regfi'],
91                        'doxygen doc/devel/Doxyfile.regfi')
92pyregfi_doc = env.Command('doc/devel/pyregfi/index.html',
93                          Glob('python/pyregfi/*.py')+['doc/devel/Doxyfile.pyregfi', regfi_doc],
94                          'doxygen doc/devel/Doxyfile.pyregfi')
[212]95
[280]96install_items = install_bin + install_lib + install_pyregfi
[238]97
[187]98# User Friendly Targets
99env.Alias('libregfi', libregfi)
100env.Alias('reglookup', reglookup)
101env.Alias('reglookup-recover', reglookup_recover)
102env.Alias('bin', [reglookup_recover, reglookup])
103env.Alias('doc', [man_reglookup,man_reglookup_recover,man_reglookup_timeline])
[238]104env.Alias('doc-devel', [regfi_doc, pyregfi_doc])
[280]105env.Alias('install_bin', install_bin)
106env.Alias('install_lib', install_lib)
107env.Alias('install_pyregfi', install_pyregfi)
[212]108env.Alias('install', install_items)
[187]109
110Default('bin', libregfi)
Note: See TracBrowser for help on using the repository browser.