-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.sh
executable file
·70 lines (61 loc) · 1.35 KB
/
config.sh
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
#!/bin/sh
usage()
{
echo 'usage: config.sh [options]'
echo '-h --help print usage'
echo '--prefix=<prefix> install prefix'
echo '--build-test build test programs'
exit 1
}
brickred_install_prefix='/usr/local'
brickred_compile_flag=
brickred_link_flag=
brickred_build_test='no'
options=`getopt -o h -l \
help,\
prefix:,\
build-test\
-- "$@"`
eval set -- "$options"
while [ $# -gt 0 ]
do
case "$1" in
-h|--help) usage;;
--prefix) brickred_install_prefix=$2; shift;;
--build-test) brickred_build_test=yes;;
--) shift; break;;
*) usage;;
esac
shift
done
# check compiler
which g++ >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo 'can not find g++'
exit 1
fi
# check make
which make >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo 'can not find make'
exit 1
fi
# check epoll_create1
echo '
#include <sys/epoll.h>
int main()
{
int fd = epoll_create1(EPOLL_CLOEXEC);
}
' | g++ -x c++ -o /dev/null - >/dev/null 2>&1
if [ $? -ne 0 ]
then
brickred_compile_flag=$brickred_compile_flag' -DBRICKRED_BUILD_DONT_HAVE_EPOLL_CREATE1'
fi
# output
echo "BRICKRED_INSTALL_PREFIX = $brickred_install_prefix" >config.mak
echo "BRICKRED_COMPILE_FLAG = $brickred_compile_flag" >>config.mak
echo "BRICKRED_LINK_FLAG = $brickred_link_flag" >>config.mak
echo "BRICKRED_BUILD_TEST = $brickred_build_test" >>config.mak