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 | 'bin/bletchley-http2py', 'bin/bletchley-encode', |
---|
59 | 'bin/bletchley-decode']) |
---|
60 | #libinstall = env.Install(destdir+libdir, [libbletchley, libbletchley_static]) |
---|
61 | #env.Install(destdir+includedir+'/bletchley', Glob('include/*.h')) |
---|
62 | #env.Install(destdir+mandir+'/man1', [man_bletchley, man_bletchley_recover, |
---|
63 | # man_bletchley_timeline]) |
---|
64 | #if os.getuid() == 0: |
---|
65 | # env.AddPostAction(libinstall, 'ldconfig') |
---|
66 | |
---|
67 | #if sys.version_info[0] == 2: |
---|
68 | # install_items.append('bletchley-python2.log') |
---|
69 | # env.Command('bletchley-python2.log', Glob('lib/bletchley/*.py')+Glob('lib/bletchley/CBC/*.py'), |
---|
70 | # "python bletchley-distutils install --root=/%s | tee bletchley-python2.log" % destdir) |
---|
71 | |
---|
72 | python_path = os.popen('which python3').read() |
---|
73 | if python_path != '': |
---|
74 | install_items.append('bletchley-python3.log') |
---|
75 | env.Command('bletchley-python3.log', Glob('lib/bletchley/*.py')+Glob('lib/bletchley/CBC/*.py'), |
---|
76 | "python3 bletchley-distutils install --root=/%s | tee bletchley-python3.log" % destdir) |
---|
77 | |
---|
78 | # API documentation |
---|
79 | #bletchley_doc = env.Command('doc/devel/bletchley/index.html', |
---|
80 | # Glob('lib/*.c')+Glob('include/*.h')+['doc/devel/Doxyfile.bletchley'], |
---|
81 | # 'doxygen doc/devel/Doxyfile.bletchley') |
---|
82 | #pybletchley_doc = env.Command('doc/devel/pybletchley/index.html', |
---|
83 | # Glob('python/pybletchley/*.py')+['doc/devel/Doxyfile.pybletchley', bletchley_doc], |
---|
84 | # 'doxygen doc/devel/Doxyfile.pybletchley') |
---|
85 | |
---|
86 | |
---|
87 | # User Friendly Targets |
---|
88 | env.Alias('bin', [bletchley_nextrand]) |
---|
89 | #env.Alias('doc', [man_bletchley,man_bletchley_recover,man_bletchley_timeline]) |
---|
90 | #env.Alias('doc-devel', [bletchley_doc, pybletchley_doc]) |
---|
91 | env.Alias('install', install_items) |
---|
92 | |
---|
93 | Default('bin') |
---|