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
Line 
1#-*- mode: Python;-*-
2
3import sys
4import os
5sys.dont_write_bytecode = True
6from regfi_version import REGFI_VERSION
7ABI_VERSION=REGFI_VERSION.rsplit('.',1)[0]
8
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?
11cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden'
12cflags += ' -DREGFI_VERSION=\'"%s"\' ' % REGFI_VERSION
13cflags += os.environ.get('CFLAGS','-fPIE -pie -fstack-protector -D_FORTIFY_SOURCE=2')
14
15linkflags = "-fPIC " + os.environ.get('LDFLAGS',"-Wl,-z,relro,-z,now")
16
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
23cc=os.environ.get('CC', 'gcc')
24env = Environment(ENV=os.environ,
25                  CC=cc,
26                  CFLAGS=cflags,
27                  LINKFLAGS=linkflags,
28                  CPPPATH=['include', '/usr/local/include'],
29                  LIBPATH=['lib', '/usr/local/lib'],
30                  LIBS=['m', 'pthread', 'regfi', 'talloc'])
31
32
33# Libraries
34libregfi_static = env.Library(lib_src)
35libregfi = env.SharedLibrary(lib_src, LIBS=['m','pthread', 'talloc'],
36                             SHLIBVERSION=ABI_VERSION)
37
38
39# Executables
40reglookup = env.Program(['src/reglookup.c'])
41reglookup_recover = env.Program(['src/reglookup-recover.c'])
42
43
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',
50                      src_suffix = '.docbook')
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
57# Installation
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')
64
65install_bin = [destdir + bindir, destdir + mandir]
66install_lib = [destdir + libdir, destdir + includedir + '/regfi']
67
68env.Install(destdir+bindir, [reglookup, reglookup_recover, 'bin/reglookup-timeline'])
69libinstall = env.InstallVersionedLib(destdir+libdir, [libregfi, libregfi_static], SHLIBVERSION=ABI_VERSION)
70env.Install(destdir+includedir+'/regfi', Glob('include/*.h'))
71env.Install(destdir+mandir+'/man1', [man_reglookup, man_reglookup_recover,
72                                     man_reglookup_timeline])
73
74if os.getuid() == 0 and destdir == '':
75   env.AddPostAction(libinstall, 'ldconfig')
76
77install_pyregfi = []
78if sys.version_info[0] == 2:
79   install_pyregfi.append('pyregfi2-install.log')
80   env.Command('pyregfi2-install.log', ['python/pyregfi/__init__.py',
81                                        'python/pyregfi/structures.py',
82                                        'python/pyregfi/winsec.py'],
83               "python setup.py install --root=/%s | tee pyregfi2-install.log" % destdir)
84
85python_path = os.popen('which python3').read()
86if python_path != '':
87   install_pyregfi.append('pyregfi3-install.log')
88   env.Command('pyregfi3-install.log', ['python/pyregfi/__init__.py',
89                                        'python/pyregfi/structures.py',
90                                        'python/pyregfi/winsec.py'],
91               "python3 setup.py install --root=/%s | tee pyregfi3-install.log" % destdir)
92
93
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')
101
102install_items = install_bin + install_lib + install_pyregfi
103
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])
110env.Alias('doc-devel', [regfi_doc, pyregfi_doc])
111env.Alias('install_bin', install_bin)
112env.Alias('install_lib', install_lib)
113env.Alias('install_pyregfi', install_pyregfi)
114env.Alias('install', install_items)
115
116Default('bin', libregfi)
Note: See TracBrowser for help on using the repository browser.