source: trunk/SConstruct @ 277

Last change on this file since 277 was 277, checked in by tim, 13 years ago

incorporated a version of Adam Golebiowski's build patches
reworked REGFI_VERSION and began using it in pyregfi installation

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