source: trunk/SConstruct @ 289

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

attempting to address outstanding packaging issues

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