1 | import sys |
---|
2 | import os |
---|
3 | sys.dont_write_bytecode = True |
---|
4 | from bletchley_version import BLETCHLEY_VERSION |
---|
5 | |
---|
6 | cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden' |
---|
7 | cflags += ' -DBLETCHLEY_VERSION=\'"%s"\'' % BLETCHLEY_VERSION |
---|
8 | cflags += ' -ggdb' |
---|
9 | |
---|
10 | #lib_src = ['lib/bletchley.c', |
---|
11 | # 'lib/winsec.c', |
---|
12 | # 'lib/range_list.c', |
---|
13 | # 'lib/lru_cache.c', |
---|
14 | # 'lib/void_stack.c'] |
---|
15 | |
---|
16 | cc=os.environ.get('CC', 'gcc') |
---|
17 | env = Environment(ENV=os.environ, |
---|
18 | CC=cc, |
---|
19 | CFLAGS=cflags, |
---|
20 | CPPPATH=['include', '/usr/local/include'], |
---|
21 | LIBPATH=['lib', '/usr/local/lib'], |
---|
22 | LIBS=[]) |
---|
23 | |
---|
24 | # Libraries |
---|
25 | #libbletchley_static = env.Library(lib_src) |
---|
26 | #libbletchley = env.SharedLibrary(lib_src, LIBS=['m','pthread', 'talloc'], |
---|
27 | # LINKFLAGS="-shared -fPIC -Wl,-soname,libbletchley.so.%s" % BLETCHLEY_VERSION) |
---|
28 | |
---|
29 | |
---|
30 | # Executable binaries |
---|
31 | bletchley_nextrand = env.Program('bin/bletchley-nextrand', ['src/nextrand.c']) |
---|
32 | |
---|
33 | |
---|
34 | # Documentation |
---|
35 | # This only needs to be run during the release/packaging process |
---|
36 | #man_fixup = "|sed 's/.SH DESCRIPTION/\\n.SH DESCRIPTION/'" |
---|
37 | #man_builder = Builder(action='docbook2x-man --to-stdout $SOURCE' |
---|
38 | # + man_fixup + '| gzip -9 > $TARGET', |
---|
39 | # suffix = '.gz', |
---|
40 | # src_suffix = '.docbook') |
---|
41 | #env['BUILDERS']['ManPage'] = man_builder |
---|
42 | |
---|
43 | #man_bletchley = env.ManPage('doc/bletchley.1.docbook') |
---|
44 | #man_bletchley_recover = env.ManPage('doc/bletchley-recover.1.docbook') |
---|
45 | #man_bletchley_timeline = env.ManPage('doc/bletchley-timeline.1.docbook') |
---|
46 | |
---|
47 | # Installation |
---|
48 | prefix = os.environ.get('PREFIX','/usr/local')+'/' |
---|
49 | destdir = os.environ.get('DESTDIR','') |
---|
50 | bindir = os.environ.get('BINDIR', prefix + 'bin') |
---|
51 | libdir = os.environ.get('LIBDIR', prefix + 'lib') |
---|
52 | includedir = os.environ.get('INCLUDEDIR', prefix + 'include') |
---|
53 | mandir = os.environ.get('MANDIR', prefix + 'man') |
---|
54 | |
---|
55 | install_items = [destdir + bindir] |
---|
56 | |
---|
57 | env.Install(destdir+bindir, [bletchley_nextrand, 'bin/bletchley-analyze']) |
---|
58 | #libinstall = env.Install(destdir+libdir, [libbletchley, libbletchley_static]) |
---|
59 | #env.Install(destdir+includedir+'/bletchley', Glob('include/*.h')) |
---|
60 | #env.Install(destdir+mandir+'/man1', [man_bletchley, man_bletchley_recover, |
---|
61 | # man_bletchley_timeline]) |
---|
62 | #if os.getuid() == 0: |
---|
63 | # env.AddPostAction(libinstall, 'ldconfig') |
---|
64 | |
---|
65 | if sys.version_info[0] == 2: |
---|
66 | install_items.append('bletchley-python2.log') |
---|
67 | env.Command('bletchley-python2.log', Glob('lib/bletchley/*.py')+Glob('lib/bletchley/PaddingOracle/*.py'), |
---|
68 | "python bletchley-distutils install --root=/%s | tee bletchley-python2.log" % destdir) |
---|
69 | |
---|
70 | python_path = os.popen('which python3').read() |
---|
71 | if python_path != '': |
---|
72 | install_items.append('bletchley-python3.log') |
---|
73 | env.Command('bletchley-python3.log', Glob('lib/bletchley/*.py')+Glob('lib/bletchley/PaddingOracle/*.py'), |
---|
74 | "python3 bletchley-distutils install --root=/%s | tee bletchley-python3.log" % destdir) |
---|
75 | |
---|
76 | # API documentation |
---|
77 | #bletchley_doc = env.Command('doc/devel/bletchley/index.html', |
---|
78 | # Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.bletchley'], |
---|
79 | # 'doxygen doc/devel/Doxyfile.bletchley') |
---|
80 | #pybletchley_doc = env.Command('doc/devel/pybletchley/index.html', |
---|
81 | # Glob('python/pybletchley/*.py')+['doc/devel/Doxyfile.pybletchley', bletchley_doc], |
---|
82 | # 'doxygen doc/devel/Doxyfile.pybletchley') |
---|
83 | |
---|
84 | |
---|
85 | # User Friendly Targets |
---|
86 | env.Alias('bin', [bletchley_nextrand]) |
---|
87 | #env.Alias('doc', [man_bletchley,man_bletchley_recover,man_bletchley_timeline]) |
---|
88 | #env.Alias('doc-devel', [bletchley_doc, pybletchley_doc]) |
---|
89 | env.Alias('install', install_items) |
---|
90 | |
---|
91 | Default('bin') |
---|