-
Notifications
You must be signed in to change notification settings - Fork 85
/
configure
executable file
·183 lines (158 loc) · 4.44 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
#!/bin/bash
#
# This configure script is hand-generated, not auto-generated.
# It creates the file kaldi.mk, which is %included by the Makefiles
# in the subdirectories.
# The file kaldi.mk is editable by hand-- for example, you may want to
# remove the options -g -O0 -DKALDI_PARANOID, or edit the
# -DKALDI_DOUBLE_PRECISION option (to be 1 not 0),
# Example command lines:
# ./configure
# ./configure --shared ## shared libraries.
# ./configure --mkl-root=/opt/intel/mkl
# ./configure --mkl-root=/opt/intel/mkl --threaded-math=yes
# ./configure --mkl-root=/opt/intel/mkl --threaded-math=yes --mkl-threading=tbb
# This is for MKL 11.3 -- which does not seem to provide Intel OMP libs
# ./configure --openblas-root=../tools/OpenBLAS/install # before doing
# # this, cd to ../tools and type "make openblas". Note:
# # this is not working correctly on all platforms, do "make test"
# # and look out for segmentation faults.
# ./configure --atlas-root=../tools/ATLAS/build
#This should be incremented after every significant change of the configure script
#I.e. after each change that affects the kaldi.mk or the build system as whole
CONFIGURE_VERSION=1
OUTPUT_MK=apiai.mk
INCLUDE_PATHS="/usr/include /usr/local/include"
LIBRARY_PATHS="/usr/lib /usr/local/lib /usr/local/lib64"
APIAI_CXX_FLAGS=
function rel2abs {
if [ ! -z "$1" ]; then
case "${1}" in
[./]*)
echo "$(cd ${1%/*}; pwd)/${1##*/}"
;;
*)
echo "${PWD}/${1}"
;;
esac
fi
}
function read_dirname {
local dir_name=`expr "X$1" : '[^=]*=\(.*\)'`;
local retval=`rel2abs $dir_name`
[ -z $retval ] && echo "Bad option '$1': no such directory: $dir_name" >&2 && exit 1;
echo $retval
}
function is_set {
local myvar=${1:-notset}
if [ "$myvar" == "notset" ]; then
return 1
else
return 0
fi
}
## First do some checks. These verify that all the things are
## here that should be here.
if ! [ -x "$PWD/configure" ]; then
echo 'You must run "configure" from the src/ directory.'
exit 1
fi
## Default locations for Kaldi sources.
KALDIROOT=$(rel2abs ../kaldi)
function usage {
echo 'Usage: ./configure [--kaldi-root=KALDIROOT]';
}
cmd_line="$0 $@" # Save the command line to include in kaldi.mk
while [ $# -gt 0 ];
do
case "$1" in
--help)
usage; exit 0 ;;
--version)
echo $CONFIGURE_VERSION; exit 0 ;;
--kaldi-root=*)
KALDIROOT=$(read_dirname $1);
shift ;;
*) echo "Unknown argument: $1, exiting"; usage; exit 1 ;;
esac
done
function failure {
echo "***configure failed: $* ***" >&2
if [ -f kaldi.mk ]; then rm kaldi.mk; fi
exit 1;
}
function check_exists {
if [ ! -f $1 ]; then failure "$1 not found."; fi
}
function exit_success {
echo "SUCCESS"
exit 0;
}
function check_sys_library {
case $(uname -s) in
Darwin)
for file in $1; do
for path in $LIBRARY_PATHS; do
local result="${path}/lib${file}.a"
echo -n "Checking ${result}..." >&2
if [ -f "$result" ]; then
echo "OK" >&2
echo $result
break 2
else
echo "Not found" >&2
fi
done
done
;;
*)
echo -n "Looking for $1 library: "
local response=$(whereis lib$1)
local libpath=${response##*:}
if [ -z "$libpath" ]; then
echo "Not found"
failure "Library $1 not found"
else
echo $libpath
fi
;;
esac
}
function check_header_file {
for file in $1; do
for path in $INCLUDE_PATHS; do
local result="${path}/${file}"
echo -n "Checking ${result}..." >&2
if [ -f "$result" ]; then
echo "OK" >&2
echo $result
break 2
else
echo "Not found" >&2
fi
done
done
}
echo "Configuring ..."
echo "Looking for Kaldi sources in \"$KALDIROOT\"..."
check_exists "$KALDIROOT/src/kaldi.mk"
check_sys_library fcgi
check_sys_library fcgi++
FCGIO_H=$(check_header_file "fcgio.h")
if [ -z "$FCGIO_H" ]; then
FCGIO_H=$(check_header_file "fastcgi/fcgio.h")
if [ -z "$FCGIO_H" ]; then
failure "fcgio.h not found"
else
APIAI_CXX_FLAGS="$APIAI_CXX_FLAGS -I$(dirname $FCGIO_H)"
fi
fi
# back up the old one in case we modified it
if [ -f "$OUTPUT_MK" ]; then
echo "Backing up $OUTPUT_MK to $OUTPUT_MK.bak"
cp $OUTPUT_MK ${OUTPUT_MK}.bak
fi
printf "# This file was generated using the following command:\n# $cmd_line\n\n" > $OUTPUT_MK
printf "KALDI_PATH = $KALDIROOT/src\n" >> $OUTPUT_MK
printf "APIAI_CXX_FLAGS = $APIAI_CXX_FLAGS\n" >> $OUTPUT_MK
exit_success