-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·156 lines (126 loc) · 3.66 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/sh
# default program values unless already defined in environment
: ${CC:=gcc}
: ${SWIG:=swig}
: ${F2PY:=f2py}
: ${PYTHON:=python}
: ${CFLAGS:=-fPIC}
# Available tests-suites
TESTS_SUITES=`echo tests/*/ | sed -e "s@tests@@g" -e "s@/@@g"`
# File generated by this script
OUTPUT_FILE=env.mk
help_message()
{
cat <<EOF
Usage: ./configure [options]
Generate file $OUTPUT_FILE
Defaults for the options are specified in brackets.
Configuration
-h, --help display this help and exit
--with-gcc=path Set location of C compiler[$CC]
--with-python=path Set location of Python interpretor [$PYTHON]
--with-swig=path Set location of interface generator[$SWIG]
--with-f2py=path Set location of Fortran to Python
inteface generator [$F2PY]
--boost-include=path Path to Boost.Python headers
--boost-library=path Path to Boost.Python headers
--without-tests=test Comma separated list of tests-suite to avoid.
[$TESTS_SUITES]
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags[$CFLAGS]
PYTHON Python interpreter
SWIG Interface generator
F2PY Fortran to Python interface generator
BOOST_INCLUDE_PATH Path to Boost.Python headers
BOOST_LIBRARY_PATH Path to Boost libraries
EOF
}
create_env_file ()
{
cat > "$OUTPUT_FILE" <<EOF
export CC = $CC
export PYTHON = $PYTHON
export SWIG = $SWIG
export F2PY = $F2PY
export CFLAGS = $CFLAGS
export BOOST_INCLUDE_PATH = $BOOST_INCLUDE_PATH
export BOOST_LIBRARY_PATH = $BOOST_LIBRARY_PATH
export DISABLED_TESTS = $DISABLED_TESTS
EOF
}
if ! hash getopt >/dev/null 2>&1; then
create_env_file
cat <<EOF
Can not find executable \`getopt', required to parse arguments given to this script.
$OUTPUT_FILE has be created with default values. You might need to edit it manually.
EOF
exit 1
fi
# Invoke options parser
TEMP=`getopt -o h --long help,with-python:,with-swig:,with-f2py:,with-gcc:,boost-include:,boost-library:,disable-test: -n bootstrap.sh -- "$@"`
if [ $? != 0 ]; then echo "Abort." >&2; exit 1; fi
eval set -- "$TEMP"
while true; do
case "$1" in
--boost-include)
BOOST_INCLUDE_PATH="$2"
shift 2
;;
--boost-library)
BOOST_LIBRARY_PATH="$2"
shift 2
;;
--disable-test)
for wt in `echo "$2" | tr , ' '`; do
found=false
for t in $TESTS_SUITES; do
if [ "$t" = "$wt" ] ;then
found=true
break
fi
done
if [ $found = false ]; then
echo "Error: unknown tests-suite $wt" >/dev/stderr
exit 1
fi
DISABLED_TESTS="$DISABLED_TESTS,$wt"
done
shift 2
;;
-h|--help)
help_message
exit 0
;;
--with-swig)
SWIG="$2"
shift 2
;;
--with-python)
PYTHON="$2"
shift 2
;;
--with-f2py)
F2PY="$2"
shift 2
;;
--with-gcc)
CC="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Error occured while parsing arguments." > /dev/stderr
exit 1
esac
done
# cleanup
DISABLED_TESTS=`echo "$DISABLED_TESTS" | sed -e "s/^,\?//"`
create_env_file
cat <<EOF
File $OUTPUT_FILE has been generated. Now you can build and test the project:
\$ make test
EOF