9dd998cdc0
Add a configure script in the root of the repository that looks and feels like one that would be generated by autotools. This script simply generates a CONFIG file for you, which used to be done by hand. Now to build SPDK you can do the following: ./configure --with-dpdk=path make Change-Id: I44ebb91f0cb1468b86da4c0033ac1406595d4967 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
52 lines
1.6 KiB
Python
Executable File
52 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
comment = re.compile('^\s*#')
|
|
assign = re.compile('^\s*([a-zA-Z_]+)\s*(\?)?=\s*([^#]*)')
|
|
|
|
args = os.environ.copy()
|
|
for arg in sys.argv:
|
|
m = assign.match(arg)
|
|
if m:
|
|
var = m.group(1).strip()
|
|
val = m.group(3).strip()
|
|
args[var] = val
|
|
|
|
# special case for DPDK_DIR, which is short for CONFIG_DPDK_DIR
|
|
if 'DPDK_DIR' in args and 'CONFIG_DPDK_DIR' not in args:
|
|
args['CONFIG_DPDK_DIR'] = args['DPDK_DIR']
|
|
|
|
defs = {}
|
|
for config in ('CONFIG', 'CONFIG.local'):
|
|
try:
|
|
with open(config) as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if not comment.match(line):
|
|
m = assign.match(line)
|
|
if m:
|
|
var = m.group(1).strip()
|
|
default = m.group(3).strip()
|
|
val = default
|
|
if var in args:
|
|
val = args[var]
|
|
if default.lower() == 'y' or default.lower() == 'n':
|
|
if val.lower() == 'y':
|
|
defs["SPDK_{}".format(var)] = 1
|
|
else:
|
|
defs["SPDK_{}".format(var)] = 0
|
|
else:
|
|
strval = val.replace('"', '\"')
|
|
defs["SPDK_{}".format(var)] = strval
|
|
except IOError:
|
|
continue
|
|
|
|
for key, value in defs.items():
|
|
if value == 0:
|
|
print "#undef {}".format(key)
|
|
else:
|
|
print "#define {} {}".format(key, value)
|