forked from OpenSC/engine_pkcs11
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
340 lines (299 loc) · 7.61 KB
/
configure.ac
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
AC_PREREQ(2.60)
define([PACKAGE_VERSION_MAJOR], [0])
define([PACKAGE_VERSION_MINOR], [1])
define([PACKAGE_VERSION_FIX], [9])
define([PACKAGE_SUFFIX], [-svn])
AC_INIT([engine_pkcs11],[PACKAGE_VERSION_MAJOR.PACKAGE_VERSION_MINOR.PACKAGE_VERSION_FIX[]PACKAGE_SUFFIX])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([${PACKAGE_NAME}], [${PACKAGE_VERSION}])
ENGINE_PKCS11_VERSION_MAJOR="PACKAGE_VERSION_MAJOR"
ENGINE_PKCS11_VERSION_MINOR="PACKAGE_VERSION_MINOR"
ENGINE_PKCS11_VERSION_FIX="PACKAGE_VERSION_FIX"
AC_CONFIG_SRCDIR([src/engine_pkcs11.c])
AC_CANONICAL_HOST
AC_PROG_CC
PKG_PROG_PKG_CONFIG
AC_C_BIGENDIAN
AC_MSG_CHECKING([svn checkout])
if test -e "${srcdir}/packaged"; then
svn_checkout="no"
else
svn_checkout="yes"
fi
AC_MSG_RESULT([${svn_checkout}])
AC_ARG_WITH(
[cygwin-native],
[AS_HELP_STRING([--with-cygwin-native],[compile native win32])],
,
[with_cygwin_native="no"]
)
dnl Check for some target-specific stuff
test -z "${WIN32}" && WIN32="no"
test -z "${CYGWIN}" && CYGWIN="no"
case "${host}" in
*-mingw*|*-winnt*)
WIN32="yes"
CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
WIN_LIBPREFIX="lib"
;;
*-cygwin*)
AC_MSG_CHECKING([cygwin mode to use])
CYGWIN="yes"
if test "${with_cygwin_native}" = "yes"; then
AC_MSG_RESULT([Using native win32])
CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
CFLAGS="${CFLAGS} -mno-cygwin"
WIN32="yes"
else
AC_MSG_RESULT([Using cygwin])
CPPFLAGS="${CPPFLAGS} -DCRYPTOKI_FORCE_WIN32"
WIN_LIBPREFIX="cyg"
AC_DEFINE([USE_CYGWIN], [1], [Define if you are on Cygwin])
fi
;;
esac
AC_ARG_ENABLE(
[strict],
[AS_HELP_STRING([--enable-strict],[enable strict compile mode @<:@disabled@:>@])],
,
[enable_strict="no"]
)
AC_ARG_ENABLE(
[pedantic],
[AS_HELP_STRING([--enable-pedantic],[enable pedantic compile mode @<:@disabled@:>@])],
,
[enable_pedantic="no"]
)
AC_ARG_ENABLE(
[doc],
[AS_HELP_STRING([--enable-doc],[enable installation of documents @<:@disabled@:>@])],
,
[enable_doc="no"]
)
AC_ARG_WITH(
[enginesdir],
[AS_HELP_STRING([--with-enginesdir],[OpenSSL engines directory @<:@LIBDIR/engines@:>@])],
[enginesdir="${withval}"],
[enginesdir="\$(libdir)/engines"]
)
dnl Checks for programs.
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_PROG_SED
AC_PROG_MAKE_SET
dnl Add libtool support.
ifdef(
[LT_INIT],
[
LT_INIT([win32-dll])
LT_LANG([Windows Resource])
],
[
AC_LIBTOOL_WIN32_DLL
AC_LIBTOOL_RC
AC_PROG_LIBTOOL
]
)
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([ \
errno.h fcntl.h malloc.h stdlib.h inttypes.h \
string.h strings.h sys/time.h unistd.h \
locale.h getopt.h dlfcn.h utmp.h \
])
PKG_CHECK_MODULES([LIBP11], [libp11 >= 0.2.5],, [AC_MSG_ERROR([libp11 >= 0.2.5 is required])])
dnl These required for svn checkout
AC_ARG_VAR([XSLTPROC], [xsltproc utility])
AC_ARG_VAR([SVN], [subversion utility])
AC_ARG_VAR([WGET], [wget utility])
AC_ARG_VAR([WGET_OPTS], [wget options])
AC_ARG_VAR([TR], [tr utility])
AC_CHECK_PROGS([XSLTPROC],[xsltproc])
AC_CHECK_PROGS([SVN],[svn])
AC_CHECK_PROGS([WGET],[wget])
AC_CHECK_PROGS([TR],[tr])
test -z "${WGET_OPTS}" && WGET_OPTS="-nv"
dnl svn checkout dependencies
if test "${svn_checkout}" = "yes"; then
AC_MSG_CHECKING([XSLTPROC requirement])
if test -n "${XSLTPROC}"; then
AC_MSG_RESULT([ok])
else
if test "${enable_doc}" = "yes"; then
AC_MSG_ERROR([Missing XSLTPROC svn build with doc])
else
AC_MSG_WARN(["make dist" will not work])
fi
fi
AC_MSG_CHECKING([svn doc build dependencies])
if test -n "${SVN}" -a -n "${TR}" -a -n "${WGET}"; then
AC_MSG_RESULT([ok])
else
if test "${enable_doc}" = "yes"; then
AC_MSG_ERROR([Missing SVN, TR or WGET for svn doc build])
else
AC_MSG_WARN(["make dist" will not work])
fi
fi
fi
PKG_CHECK_MODULES(
[OPENSSL],
[libcrypto >= 0.9.7],
,
[PKG_CHECK_MODULES(
[OPENSSL],
[openssl >= 0.9.7],
,
[AC_CHECK_LIB(
[crypto],
[RSA_version],
[OPENSSL_LIBS="-lcrypto"],
[AC_MSG_ERROR([Cannot find OpenSSL])]
)]
)]
)
# ok, now we might (or not) have ssl and an engine.
# still room for "improvements", i.e. hacks to work
# with old engines.
AC_MSG_CHECKING([for openssl version])
saved_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${OPENSSL_CFLAGS}"
AC_EGREP_CPP(
[new],
[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090704fL
new
#else
old
#endif
],
[
AC_MSG_RESULT([good, 0.9.7d or later])
old_openssl="no"
],
[
AC_MSG_RESULT([not so good, 0.9.7d or later would be better])
old_openssl="yes"
]
)
CPPFLAGS="${saved_CPPFLAGS}"
if test "x$old_openssl" = "xyes"; then
# openssl found, but version less than 0.9.7d
# linking libcrypto.a statically possible?
saved_CFLAGS="${CFLAGS}"
saved_LIBS="${LIBS}"
CFLAGS="${CFLAGS} ${OPENSSL_CFLAGS}"
if echo "${OPENSSL_LIBS}" | grep -- "-L" > /dev/null; then
OPENSSL_DIR="$(echo "${OPENSSL_LIBS}" | ${SED} 's/.*-L\([^ ]*\).*/\1/')"
else
OPENSSL_DIR="${usrlibdir}"
fi
LIBS="${LIBS} ${OPENSSL_DIR}/libcrypto.a"
AC_CHECK_LIB(
[dl],
[dlopen]
)
AC_MSG_CHECKING([should link static openssl])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <string.h>
#include <openssl/opensslv.h>
#include <openssl/engine.h>
#include <openssl/rand.h>
int test(void)
{
char a[2048];
ENGINE *e;
e = ENGINE_new();
ENGINE_load_dynamic();
if (!e) return 1;
memset(a, 0, sizeof(a));
RAND_add(a, sizeof(a), sizeof(a));
return(RAND_status() <= 0);
}
]])],
[
AC_MSG_RESULT([yes])
ENGINE_LINK="${OPENSSL_DIR}/libcrypto.a"
],
[AC_MSG_ERROR([OpenSSL is old and cannot link with its static library])]
)
CFLAGS="${saved_CFLAGS}"
LIBS="${saved_LIBS}"
fi
#@alonbl: This was never actually used.
#
# now - last part to do: check if we gain anything from
# funny parameters to link openssl with.
#saved_LDFLAGS="${LDFLAGS}"
#for test_flags in "-Wl,-Bsymbolic" "-G -Wl,-Bsymbolic" "-Wl,-all_load"; do
# AC_MSG_CHECKING([whether we can use ${test_flags}])
# LDFLAGS="${saved_LDFLAGS} ${test_flags}"
# AC_LINK_IFELSE(
# [AC_LANG_PROGRAM([[
#int test()
#{
# return 1;
#}
# ]])],
# [result="yes"],
# [result="no"]
# )
# AC_MSG_RESULT([${result}])
# if test "${result}" = "yes"; then
# OPENSSL_EXTRA_LDFLAGS="${test_flags}"
# break;
# fi
#done
#LDFLAGS="${saved_LDFLAGS}"
AC_SUBST([enginesdir])
AC_SUBST([ENGINE_LINK])
AC_SUBST([ENGINE_PKCS11_VERSION_MAJOR])
AC_SUBST([ENGINE_PKCS11_VERSION_MINOR])
AC_SUBST([ENGINE_PKCS11_VERSION_FIX])
AC_SUBST([WIN_LIBPREFIX])
AC_SUBST([OPENSSL_EXTRA_LDFLAGS])
AM_CONDITIONAL([SVN_CHECKOUT], [test "${svn_checkout}" = "yes"])
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AM_CONDITIONAL([CYGWIN], [test "${CYGWIN}" = "yes"])
AM_CONDITIONAL([ENABLE_DOC], [test "${enable_doc}" = "yes"])
if test "${enable_pedantic}" = "yes"; then
enable_strict="yes";
CFLAGS="${CFLAGS} -pedantic"
fi
if test "${enable_strict}" = "yes"; then
CFLAGS="${CFLAGS} -Wall -Wextra"
fi
AC_CONFIG_FILES([
Makefile
doc/Makefile
doc/nonpersistent/Makefile
src/Makefile
src/versioninfo.rc
])
AC_OUTPUT
cat <<EOF
engine_pkcs11 has been configured with the following options:
Version: ${PACKAGE_VERSION}
Libraries: $(eval eval eval echo "${libdir}")
doc support: ${enable_doc}
Host: ${host}
Compiler: ${CC}
Preprocessor flags: ${CPPFLAGS}
Compiler flags: ${CFLAGS}
Linker flags: ${LDFLAGS}
Libraries: ${LIBS}
enginesdir ${enginesdir}
LIBP11_CFLAGS: ${LIBP11_CFLAGS}
LIBP11_LIBS: ${LIBP11_LIBS}
OPENSSL_CFLAGS: ${OPENSSL_CFLAGS}
OPENSSL_LIBS: ${OPENSSL_LIBS}
OPENSSL_EXTRA_LDFLAGS: ${OPENSSL_EXTRA_LDFLAGS}
ENGINE_LINK: ${ENGINE_LINK}
EOF