-
Notifications
You must be signed in to change notification settings - Fork 24
/
gen_env_conf.sh
executable file
·149 lines (139 loc) · 3.44 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
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
#!/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`
hasboost=0
if [ -z "$BOOST_INC" ]; then
boost_prefix=""
else
boost_prefix=`dirname $BOOST_INC`
fi
for dir in "$boost_prefix" /usr /usr/local /opt $HOME $HOME/opt
do
vf=${dir}/include/boost/version.hpp
# echo dir=$dir >&2
if test -s $vf; then
if test -d ${dir}/lib32; then
DIR_LIB32=${dir}/lib32
else
DIR_LIB32=${dir}/lib
fi
if test -d ${dir}/lib64; then
DIR_LIB64=${dir}/lib64
else
DIR_LIB64=${dir}/lib
fi
WORD_BITS=`uname -m | sed 's/.*_\(64\|32\)/\1/'`
DIR_LIB="DIR_LIB${WORD_BITS}"
BOOST_VERSION=`sed -n '/define\s\+BOOST_VERSION/s/^.*BOOST_VERSION\s\+\([0-9]*\).*/\1/p' $vf`
BOOST_LIB_VERSION=`sed -n '/define\s\+BOOST_LIB_VERSION/s/.*BOOST_LIB_VERSION[^"]*"\([0-9_.]*\)".*/\1/p' $vf`
if test -z "$BOOST_SUFFIX"; then
for lib in $DIR_LIB32 $DIR_LIB64; do
for suf in \
-${COMPILER}-mt-d-${BOOST_LIB_VERSION}.a \
-${COMPILER}-mt-d-${BOOST_LIB_VERSION}.so \
-${COMPILER}-mt-d-${BOOST_LIB_VERSION}.so \
-mt.so \
-mt.so.5 \
-mt.so.6 \
".a"
do
if test -e $lib/libboost_thread$suf -a -z "$BOOST_SUFFIX"; then
BOOST_SUFFIX=$suf
fi
done
done
if expr match "$BOOST_SUFFIX" '.*\.a$' > /dev/null; then
BOOST_SUFFIX=${BOOST_SUFFIX%.a*}
fi
if expr match "$BOOST_SUFFIX" '.*\.so' > /dev/null; then
BOOST_SUFFIX=${BOOST_SUFFIX%.so*}
fi
fi
cat >> $EnvConf <<- EOF
WORD_BITS := ${WORD_BITS}
DIR_LIB32 := ${DIR_LIB32}
DIR_LIB64 := ${DIR_LIB64}
DIR_LIB := `eval 'echo ${'$DIR_LIB'}'`
BOOST_LIB_VERSION := ${BOOST_LIB_VERSION}
BOOST_INC := ${dir}/include
BOOST_LIB := ${dir}/lib64
BOOST_SUFFIX := ${BOOST_SUFFIX}
EOF
if test "${COMPILER%-*}" = gcc && expr "${COMPILER#*-} < 4.7"; then
if test ${BOOST_VERSION} -lt 104900; then
echo BOOST_VERSION=${BOOST_VERSION} will wrongly define BOOST_DISABLE_THREADS for ${COMPILER} >&2
fi
fi
hasboost=1
break
fi
done
if [ $hasboost -eq 0 ]; then
echo $'\33[31m\33[1mFATAL: can not find boost\33[0m' 1>&2
exit 1
fi
cat > is_cygwin.cpp << "EOF"
#include <stdio.h>
int main() {
#ifdef __CYGWIN__
printf("1");
#else
printf("0");
#endif
return 0;
}
EOF
if $CXX is_cygwin.cpp -o is_cygwin.exe; then
IS_CYGWIN=`./is_cygwin.exe`
echo IS_CYGWIN=$IS_CYGWIN >> $EnvConf
fi
rm -f is_cygwin.*
if [ "$IS_CYGWIN" = 0 ]; then
cat > get_glibc_version.cpp << "EOF"
#include <stdio.h>
int main() {
printf("%d.%d\n", __GLIBC__, __GLIBC_MINOR__);
return 0;
}
EOF
if $CXX get_glibc_version.cpp -o get_glibc_version.exe; then
GLIBC_VERSION=`./get_glibc_version.exe`
echo GLIBC_VERSION_FULL=${GLIBC_VERSION} >> $EnvConf
echo GLIBC_VERSION_MAJOR=`echo ${GLIBC_VERSION} | cut -d. -f1` >> $EnvConf
echo GLIBC_VERSION_MINOR=`echo ${GLIBC_VERSION} | cut -d. -f2` >> $EnvConf
else
echo "can not detect glibc version" 1>&2
fi
rm -f get_glibc_version.*
fi
cat > has_inheriting_cons.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/nark/my_auto_config.hpp
touch src/nark/my_auto_config.hpp
if $CXX -std=c++11 has_inheriting_cons.cpp > /dev/null 2>&1; then
echo '#define NARK_HAS_INHERITING_CONSTRUCTORS' >> src/nark/my_auto_config.hpp
fi
rm -f has_inheriting_cons.cpp
if [ "$IS_CYGWIN" -eq 1 ]; then
rm -f a.exe
else
rm -f a.out
fi