forked from bytedance/terark-zip
-
Notifications
You must be signed in to change notification settings - Fork 10
/
gen_env_conf.sh
executable file
·96 lines (88 loc) · 1.92 KB
/
gen_env_conf.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
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
#!/bin/bash
#set -x
CXX=$1
COMPILER=$2
EnvConf=$3
echo COMPILER=$COMPILER 1>&2
#EnvConf=Make.env.conf-${COMPILER}
rm -f $EnvConf
mkdir -p `dirname $EnvConf`
if false; then # comment out BDB
if test -z "$BDB_HOME"; then
hasbdb=0
for dir in "" /usr /usr/local /opt "$HOME" "$HOME/opt"
do
if [ -f ${dir}/include/db.h ]; then
BDB_VER=`sed -n 's/[# \t]*define.*DB_VERSION_STRING.*Berkeley DB \([0-9]*\.[0-9]*\).*:.*/\1/p' ${dir}/include/db.h`
if [ -z "$BDB_VER" ]; then
echo can not find version number in ${dir}/include/db.h, try next >&2
else
BDB_HOME=$dir
hasbdb=1
break
fi
fi
done
else
hasbdb=1
BDB_VER=`sed -n 's/[# \t]*define.*DB_VERSION_STRING.*Berkeley DB \([0-9]*\.[0-9]*\).*:.*/\1/p' ${BDB_HOME}/include/db.h`
fi
#------------------------------------------------
if [ $hasbdb -eq 0 ]; then
echo "couldn't found BerkeleyDB" 1>&2
else
echo "found BerkeleyDB-${BDB_VER}" 1>&2
cat >> $EnvConf << EOF
BDB_HOME := $BDB_HOME
BDB_VER := $BDB_VER
MAYBE_BDB_DBG = \${bdb_util_d}
MAYBE_BDB_RLS = \${bdb_util_r}
EOF
#------------------------------------------------
fi
fi # if false, comment out BDB
fname=is_cygwin_$$
cat > ${fname}.cpp << "EOF"
#include <stdio.h>
int main() {
#ifdef __CYGWIN__
printf("1");
#else
printf("0");
#endif
return 0;
}
EOF
if $CXX ${fname}.cpp -o ${fname}.exe; then
IS_CYGWIN=`./${fname}.exe`
echo IS_CYGWIN=$IS_CYGWIN >> $EnvConf
fi
rm -f ${fname}.*
if false; then
fname=has_inheriting_cons_$$
cat > ${fname}.cpp << "EOF"
struct A {
A(int) {}
A(int,int){}
};
struct B : public A {
using A::A;
};
int main() {
B b1(111);
B b2(2,2);
return 0;
}
EOF
rm -f src/terark/my_auto_config.hpp
touch src/terark/my_auto_config.hpp
if $CXX -std=c++11 ${fname}.cpp > /dev/null 2>&1; then
echo '#define TERARK_HAS_INHERITING_CONSTRUCTORS' >> src/terark/my_auto_config.hpp
fi
rm -f ${fname}.cpp
if [ "$IS_CYGWIN" -eq 1 ]; then
rm -f a.exe
else
rm -f a.out
fi
fi # if false