-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconfigure
executable file
·196 lines (159 loc) · 5.37 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
# Check that all prerequisites are available
error_status=0
error_messages=
error_cause=
function add_message() {
error_messages=$(echo -e "$@\n$error_messages")
error_status=1
}
# Prints message to screen
function show() {
echo -n "$@... "
}
# Sets the cause for error
function set_error() {
error_cause="$@."
}
# Evaluate and check
function check() {
eval "$@" &>/dev/null
if (( $? != 0)); then
echo "error"
add_message $error_cause
else
echo "ok"
fi
}
# Evaluate and check, fail on error
function check-fail() {
eval "$@" &>/dev/null
if (( $? != 0)); then
echo "fatal error"
add_message $error_cause
print-status
else
echo "ok"
fi
}
# Print status
function print-status() {
echo -e "\n================================"
if [[ $error_status == 1 ]]; then
echo "Configure has failed due to the following reasons:"
echo "$error_messages"
echo "FAIL"
exit 1
else
echo "Configure completed successfully. Run make -f to compile NuevoMatch."
fi
}
# Check python version
show "Checking python"
set_error "Cannot get version of python3"
check /usr/bin/env python3 --version | cut -d " " -f 2
python_version=$(/usr/bin/env python3 -c "import sys; print('%d.%d' % sys.version_info[0:2])" )
python35_okay=$( echo $python_version | awk '$1 >= 3.5 {print 1}' )
show "Checking python version"
set_error "Python version should be at least 3.5"
check [[ $python35_okay == 1 ]]
# Set the python-dev include path
export python_include_path=$(/usr/bin/env python3 -c "from sysconfig import get_paths; print(get_paths()['include'])" )
show "Checking for python include path"
set_error "Python include directory ($python_include_path) is missing. Make sure the python-dev package is installed."
check [[ -d $python_include_path ]]
# Check whether python-dev is installed
show "Checking whether python-dev is available on machine"
set_error "Cannot access file '$python_include_path/Python.h'. Make sure the python-dev package is installed."
check [[ -e $python_include_path/Python.h ]]
# Python prerequisites
libraries=( tensorflow numpy distutils matplotlib )
for lib in ${libraries[@]}; do
show "Checking Python prerequisite '$lib'"
set_error "Cannot import python library $lib. Make sure it is installed."
check python3 -c \"import $lib\"
done
# FMA support
show "Checking for AVX2/FMA support"
set_error "CPU does not support AVX2/FMA extensions."
check [[ $(grep fma /proc/cpuinfo | wc -l) -ne 0 ]]
# G++ Available
show "Checking whether g++ is available"
set_error "g++ was not found on the system."
check [[ $(which g++ | wc -l) -ne 0 ]]
# Make Bin directory and sub-makefiles
BIN_DIR=$(dirname $0)/bin
mkdir -p $BIN_DIR 2>/dev/null
# Get all object files
files="$(find src/ -name "*.cpp") "
files+="$(find tools/ -name "*.cpp") "
logfile=$BIN_DIR/makefile.log
# Generate makefile for source file $1
# All other params are additional arguments for G++
# @param $1 Source-code filename
# @param $2 Compile flags
function generate_makefile() {
name=$(basename $1)
filename="${name%.*}"
g++ -std=c++11 -mavx2 -mfma -I./include/ -MM $1 > $BIN_DIR/$filename.mk 2>$logfile
sed -i "s@^\(.*\.o\):@$BIN_DIR/\1:@" $BIN_DIR/$filename.mk 2>$logfile
echo -e "\t\$(CXX) ${@:2:99} \$(INCLUDES) \$(LIBRARIES)" \
"-c $1 -o $BIN_DIR/$filename.o\n" >> $BIN_DIR/$filename.mk 2>$logfile
}
for f in $files; do
n=$(basename $f)
show "Generating makefile for $n"
set_error "Error generating sub-makefile for $n. See '$logfile' for details."
check generate_makefile $f "\$\(CXXFLAGS\) \$\(SIMDFLAGS\) \$\(DBGFLAGS\)"
done
# Make sub-makefile for vendor adapter
files="$(find vendor/ -name "*.cpp") "
for f in $files; do
n=$(basename $f)
show "Generating makefile for $n"
set_error "Error generating sub-makefile for $n. See '$logfile' for details."
check generate_makefile $f "-O2 -std=c++14 -fpermissive \$\(DBGFLAGS\)"
done
# Merge all makefiles
function merge_makefiles() {
sub_files=$(ls $BIN_DIR/*.mk | grep -v "objects.mk")
cat $sub_files > $BIN_DIR/objects.mk
echo "$sub_files" | xargs rm -f
}
show "Merging all makefiles"
set_error "Could not merge generated makefiles into objects.mk"
check merge_makefiles
# Clone TupleMerge and compile it
my_dir=$PWD
TUPLEMERGE_DIR=tuplemerge
logfile=$TUPLEMERGE_DIR/errors.log
if [[ ! -d $TUPLEMERGE_DIR ]]; then
show "Cloning TupleMerge from GitHub"
git clone https://github.com/drjdaly/tuplemerge $TUPLEMERGE_DIR &> /dev/null
cd $TUPLEMERGE_DIR
git checkout tags/v1.0 &> /dev/null
echo "ok"
show "Patching TupleMerge"
set_error "Error pactching TupleMerge. Try to patch manually with tuplemerge.patch"
git checkout tags/v1.0 &>/dev/null
git reset --hard tags/v1.0 &>/dev/null
check-fail git apply --ignore-whitespace --ignore-space-change ../tuplemerge.patch
cd $my_dir
fi
function compile_tuplemerge() {
make -C $TUPLEMERGE_DIR -j &> $logfile
}
show "Compiling TupleMerge"
set_error "Error compiling TupleMerge. See '$logfile' for deatils."
check compile_tuplemerge
show "Creating libtuplemerge.a"
set_error "Could not generate libtuplemerge.a. See '$logfile' for deatils."
check ar crf $BIN_DIR/libtuplemerge.a \
$TUPLEMERGE_DIR/cmap.o \
$TUPLEMERGE_DIR/TupleSpaceSearch.o \
$TUPLEMERGE_DIR/TupleMergeOnline.o \
$TUPLEMERGE_DIR/TupleMergeOffline.o \
$TUPLEMERGE_DIR/SlottedTable.o \
$TUPLEMERGE_DIR/Simulation.o \
$TUPLEMERGE_DIR/MapExtensions.o &>> $logfile
print-status