-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·67 lines (51 loc) · 2.22 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
"""
Creates Makefile(s) for building Veins.
"""
import os
import sys
from subprocess import check_call
from logging import warning, error
from optparse import OptionParser
import fnmatch
# Option handling
parser = OptionParser()
parser.add_option("--with-inet", dest="inet", help="link Veins with a version of the INET Framework installed in PATH [default: do not link with INET]", metavar="PATH")
(options, args) = parser.parse_args()
if args:
warning("Superfluous command line arguments: \"%s\"" % " ".join(args))
# Start with default flags
makemake_flags = ['-f', '--deep', '--no-deep-includes', '--make-so', '-I', '.', '-o', 'veins', '-O', 'out']
run_libs = [os.path.join('src', 'veins')]
run_neds = [os.path.join('src', 'veins')]
# Add flags for INET
if options.inet:
fname = os.path.join(options.inet, 'Version')
try:
with open(fname, 'r') as file:
version = file.read().rstrip()
if not version == 'inet-2.3.0':
warning('Unsupported INET Version. Expecting inet-2.3.0, found "%s"' % version)
except IOError as e:
error('Could not determine INET Version: %s' % (fname, e))
sys.exit(1)
inet_header_dirs = set()
inet_src_path = os.path.join(options.inet, 'src')
for root, dirnames, filenames in os.walk(inet_src_path):
for filename in fnmatch.filter(filenames, '*.h'):
inet_header_dirs.add(os.path.relpath(os.path.dirname(os.path.join(root, filename)), 'src'))
inet_includes = ['-I' + s for s in inet_header_dirs]
inet_link = ["-L" + os.path.join(os.path.relpath(options.inet, 'src'), 'src'), "-linet"]
inet_defs = ["-DINET_IMPORT", "-DWITH_INET"]
makemake_flags += inet_includes + inet_link + inet_defs
run_libs = [os.path.relpath(os.path.join(options.inet, 'src', 'inet'))] + run_libs
run_neds = [os.path.relpath(os.path.join(options.inet, 'src'))] + run_neds
# Start creating files
if not os.path.isdir('out'):
os.mkdir('out')
f = open(os.path.join('out', 'config.py'), 'w')
f.write('run_libs = %s\n' % repr(run_libs))
f.write('run_neds = %s\n' % repr(run_neds))
f.close()
check_call(['env', 'opp_makemake'] + makemake_flags, cwd='src')
print 'Configure done. You can now run "make".'