-
Notifications
You must be signed in to change notification settings - Fork 3
/
Config-all
executable file
·162 lines (129 loc) · 3.79 KB
/
Config-all
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
#!/bin/bash
#
# New and hopefully very much easier configuration script
#
# ============================================================
AddAM() {
while read path; do
if [ "$path" ]; then
echo "configure: $path.am"
fi
done
}
# ============================================================
contains()
{
key=$1
shift
for a; do
if [ $a == $key ]; then return 0;
fi
done
return 1
}
# ============================================================
try_gmp() {
if [ -f $1/gmp.h ]; then
for gmplib in libgmp.a libgmp.so libgmp.dll.a; do
if [ -f $2/$gmplib ]; then
printf "GMP Library found\n"
printf " gmp.h found at $1\n"
printf " %s found at $2\n" "$gmplib"
CPPFLAGS="-I$1 $CPPFLAGS"
LDFLAGS="-L$2 $LDFLAGS"
return 0
fi
done
fi
return 1
}
find_gmp() {
try_gmp $GMP_INCLUDE $GMP_LIBRARY && return 0
try_gmp /opt/local/include /opt/local/lib && return 0
try_gmp /opt/homebrew/include /opt/homebrew/lib && return 0
try_gmp /usr/local/include /usr/local/lib && return 0
try_gmp /usr/local/include /usr/local/lib64 && return 0
try_gmp /usr/include /usr/lib && return 0
try_gmp /usr/include /usr/lib64 && return 0
try_gmp /usr/include/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu && return 0
try_gmp /mingw/include /mingw/lib && return 0
printf "Could not find gmp Library, switching to --without-gmp.\n"
printf "You can specify the location using environment variables\n"
printf "GMP_INCLUDE (the path to gmp.h) and GMP_LIBRARY.\n\n"
return 1
}
# ============================================================
printf "\n------------------------------------------------------------\n"
printf "Building configure script"
printf "\n------------------------------------------------------------\n"
printf "\n"
tmpmf=`mktemp`
printf "configure: configure.ac\n\tautoreconf --force --install\n\n" > $tmpmf
awk '/AC_CONFIG_FILES/{p=1} {if (p) print} /\]\)/{p=0}' configure.ac | sed 's/AC_CONFIG_FILES(\[//' | tr -d ')]' | AddAM >> $tmpmf
make -f $tmpmf
if [ "$?" -ne "0" ]; then
printf "\nCouldn't build configure script, bailing out.\n\n"
rm $tmpmf
exit 1
fi
rm $tmpmf
printf "\n------------------------------------------------------------\n"
printf "Checking for libraries"
printf "\n------------------------------------------------------------\n"
printf "\n"
export CC=gcc
export CXX=g++
export CXXFLAGS="$CXXFLAGS -Wall -std=c++11"
export LDFLAGS=""
export CPPFLAGS=""
GMP_STATUS=""
if contains "--without-gmp" $@; then
echo "Building without GMP library"
GMP_STATUS="--without-gmp"
else
find_gmp || GMP_STATUS="--without-gmp"
fi
printf "\n"
printf "\n------------------------------------------------------------\n"
printf "Configuring development version"
printf "\n------------------------------------------------------------\n"
printf "\n"
if [ ! -d bin-devel ]; then
mkdir bin-devel
fi
cd bin-devel
COMMON_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-ggdb -DDEVELOPMENT_CODE $COMMON_CXXFLAGS"
../configure --prefix=$PWD $@ $GMP_STATUS
ok="$?"
cd ..
if [ "$ok" != "0" ]; then
exit 1
fi
printf "\n"
printf "\n------------------------------------------------------------\n"
printf "Configuring release version"
printf "\n------------------------------------------------------------\n"
printf "\n"
if [ ! -d bin-release ]; then
mkdir bin-release
fi
cd bin-release
CXXFLAGS="-O3 $COMMON_CXXFLAGS"
../configure --prefix=$PWD $@ $GMP_STATUS
ok="$?"
cd ..
if [ "$ok" != "0" ]; then
exit 1
fi
printf "\n"
printf "\n------------------------------------------------------------\n"
printf "Summary"
printf "\n------------------------------------------------------------\n"
printf "\n"
if [ "$GMP_STATUS" ]; then
echo "GMP library: NOT FOUND. Some features will be missing!"
else
echo "GMP library: found"
fi
printf "\n"