-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
171 lines (136 loc) · 3.72 KB
/
configure.in
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
dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Netrek installation
dnl to configure the system for the local environment.
AC_INIT(rsa.h)
AC_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_CPP
AC_PROG_RANLIB
AC_C_INLINE
#
# Check to see if GMP exists.
#
GMP_VER=-1
GMP_INC=""
GMP_LIB=""
GMP_DIR=""
# First, parse any --with-gmp args.
AC_ARG_WITH(gmp,
[ --with-gmp[=DIR] enable gmp support [DIR=yes, no, or gmp dir]]
[ (e.g. ../gmp-1.3.2, ../gmp-2.0.2)],
[
case "$withval" in
no)
GMP_VER=-2
;;
yes)
;;
*)
GMP_DIR="$withval"
;;
esac
]
)
# Paths to search for GMP header and library files. List only the parent
# directory of the include/ and lib/ dirs, e.g. "/usr/gnu" instead of
# both "/usr/gnu/include" and "/usr/gnu/lib"
GMP_PATH="$srcdir/gmp $srcdir/gmp-1.3.2 $srcdir/gmp-2.0.2 $srcdir/../gmp \
$srcdir/../gmp-1.3.2 $srcdir/../gmp-2.0.2"
# If GMP is not disabled...
if test $GMP_VER != -2; then
# If GMP directory was specified, do some smart checking
if test "$GMP_DIR" != ""; then
# prefix the search path with the provided path
GMP_PATH="$GMP_DIR $GMP_PATH"
# search for the header file
AC_MSG_CHECKING(for local gmp.h)
for path in $GMP_PATH; do
if test -r $path/gmp.h; then
GMP_VER=0
GMP_INC="-I$path"
break
elif test -r $path/include/gmp.h; then
GMP_VER=0
GMP_INC="-I$path/include"
break
fi
done
if test $GMP_VER = 0; then
AC_MSG_RESULT(found in $GMP_INC)
else
AC_MSG_RESULT(not found)
fi
# search for the library file only if header was found
if test $GMP_VER = 0; then
AC_MSG_CHECKING(for local libgmp.a)
for path in $GMP_PATH; do
if test -r $path/libgmp.a; then
GMP_VER=1
GMP_LIB="-L$path"
break
fi
if test -r $path/lib/libgmp.a; then
GMP_VER=1
GMP_LIB="-L$path/lib"
break
fi
done
if test $GMP_VER = 1; then
AC_MSG_RESULT(found in $GMP_LIB)
else
AC_MSG_RESULT(not found)
fi
# Check for GMP2
if test $GMP_VER = 1; then
LDOLD="$LDFLAGS"
LDFLAGS="$GMP_LIB -lgmp"
AC_CHECK_LIB(gmp, mpz_fdiv_q_ui, AC_DEFINE(HAVE_LIB_GMP2) GMP_VER=2)
LDFLAGS="$LDOLD"
fi
fi
fi
# If no GMP found yet, search the default system locations for it
# We want any local copy of GMP to override the system GMP
if test $GMP_VER = -1; then
AC_CHECK_HEADER(gmp.h, AC_DEFINE(HAVE_GMP_H) GMP_VER=0)
if test $GMP_VER = 0; then
AC_CHECK_LIB(gmp, mpz_init, AC_DEFINE(HAVE_LIB_GMP) GMP_VER=1)
fi
# Check for GMP2
if test $GMP_VER = 0; then
AC_CHECK_LIB(gmp, mpz_fdiv_q_ui, AC_DEFINE(HAVE_LIB_GMP2) GMP_VER=2)
fi
# Check for GMP3
if test $GMP_VER = 0; then
AC_CHECK_LIB(gmp, __gmpz_init, AC_DEFINE(HAVE_LIB_GMP3) GMP_VER=3)
fi
fi
fi
case $GMP_VER in
-1)
echo GMP support is disabled, non-GMP version of librsa will be built.
;;
0)
echo GMP not found, non-GMP version of librsa will be built.
GMP_TARGETS="nogmp"
;;
1)
echo GMP 1.x found, building librsa.a, librsa-gmp.a, mkkey.
GMP_TARGETS="librsa-gmp.a mkkey"
;;
2)
echo GMP 2.x found, building librsa.a, librsa-gmp.a, mkkey.
GMP_TARGETS="librsa-gmp.a mkkey"
;;
3)
echo GMP 3.x found, building librsa.a, librsa-gmp.a, mkkey.
GMP_TARGETS="librsa-gmp.a mkkey"
;;
*)
echo Unknown GMP configuration.
;;
esac
AC_SUBST(GMP_INC)
AC_SUBST(GMP_LIB)
AC_SUBST(GMP_TARGETS)
AC_OUTPUT(Makefile)