forked from OpenSC/libp11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
305 lines (265 loc) · 7.87 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
dnl -*- mode: m4; -*-
AC_PREREQ(2.60)
# When bumping versions see also the LT version numbers below.
define([PACKAGE_VERSION_MAJOR], [0])
define([PACKAGE_VERSION_MINOR], [4])
define([PACKAGE_VERSION_FIX], [13])
define([PACKAGE_SUFFIX], [_git])
AC_INIT([libp11],[PACKAGE_VERSION_MAJOR.PACKAGE_VERSION_MINOR.PACKAGE_VERSION_FIX[]PACKAGE_SUFFIX])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([subdir-objects])
LIBP11_VERSION_MAJOR="PACKAGE_VERSION_MAJOR"
LIBP11_VERSION_MINOR="PACKAGE_VERSION_MINOR"
LIBP11_VERSION_FIX="PACKAGE_VERSION_FIX"
AC_CONFIG_SRCDIR([src/libp11.h])
# silent build by default
ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CANONICAL_HOST
AC_PROG_CC
PKG_PROG_PKG_CONFIG
AC_C_BIGENDIAN
# we need to set our soversion based on openssl's soversion to avoid
# issues with applications linking to new openssl, old libp11, and vice versa
case "`$PKG_CONFIG --modversion --silence-errors libcrypto || \
$PKG_CONFIG --modversion openssl`" in
3.0.*) # Predicted engines directory prefix for OpenSSL 3.x
LIBP11_LT_OLDEST="3"
debian_ssl_prefix="openssl-3.0.0";;
1.1.*) # Predicted engines directory prefix for OpenSSL 1.1.x
LIBP11_LT_OLDEST="3"
debian_ssl_prefix="openssl-1.1.0";;
1.0.*) # Engines directory prefix for OpenSSL 1.0.x
LIBP11_LT_OLDEST="2"
debian_ssl_prefix="openssl-1.0.0";;
*) # Engines directory prefix for OpenSSL 0.9.x
LIBP11_LT_OLDEST="2"
debian_ssl_prefix="ssl";;
esac
# LT Version numbers, remember to change them just *before* a release.
# (Code changed: REVISION++)
# (Oldest interface removed: OLDEST++)
# (Interfaces added: CURRENT++, REVISION=0)
#
# Note that at this moment we tie the oldest (soname) version to
# the openssl version we link to. If the ABI is broken on a later
# release, we should either stick to supporting a single openssl ABI
# or bump the LT_OLDEST version sufficiently to avoid clashes.
LIBP11_LT_REVISION="0"
LIBP11_LT_CURRENT="8"
LIBP11_LT_AGE="$((${LIBP11_LT_CURRENT}-${LIBP11_LT_OLDEST}))"
gl_LD_VERSION_SCRIPT
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} -D_WIN32_WINNT=0x0600 -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])
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(
[api-doc],
[AS_HELP_STRING([--enable-api-doc],[enable generation and installation of API documents @<:@disabled@:>@])],
,
[enable_api_doc="no"]
)
AC_ARG_WITH(
[apidocdir],
[AS_HELP_STRING([--with-apidocdir],[put API documents at this directory @<:@HTMLDIR/api@:>@])],
[apidocdir="${with_apidocdir}"],
[apidocdir="\$(htmldir)/api"]
)
AC_ARG_WITH(
[enginesdir],
[AS_HELP_STRING([--with-enginesdir], [OpenSSL engines directory])],
[enginesexecdir="${withval}"],
[
enginesexecdir="`$PKG_CONFIG --variable=enginesdir --silence-errors libcrypto`"
if test "${enginesexecdir}" = ""; then
libcryptodir="`$PKG_CONFIG --variable=libdir --silence-errors libcrypto || \
$PKG_CONFIG --variable=libdir openssl`"
if test -d "$libcryptodir/$debian_ssl_prefix/engines"; then
# Debian-based OpenSSL package (for example Ubuntu)
enginesexecdir="$libcryptodir/$debian_ssl_prefix/engines"
else # Default OpenSSL engines directory
enginesexecdir="$libcryptodir/engines"
fi
if test "${prefix}" != "NONE" -o "${exec_prefix}" != "NONE"; then
# Override the autodetected value with the default
enginesexecdir="\$(libdir)"
fi
fi
]
)
AC_ARG_WITH(
[pkcs11-module],
[AS_HELP_STRING([--with-pkcs11-module], [default PKCS11 module])],
[pkcs11_module="${withval}"],
[pkcs11_module="`$PKG_CONFIG --variable=proxy_module --silence-errors p11-kit-1`"])
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 \
])
AC_ARG_VAR([DOXYGEN], [doxygen utility])
AC_CHECK_PROGS([DOXYGEN],[doxygen])
test "${enable_api_doc}" = "yes" -a -z "${DOXYGEN}" && AC_MSG_ERROR([doxygen is required for API doc])
if test "${WIN32}" != "yes"; then
AC_SEARCH_LIBS(
[dlopen],
[dl],
,
[AC_MSG_ERROR([dlopen required])]
)
AX_PTHREAD
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
fi
PKG_CHECK_MODULES(
[OPENSSL],
[libcrypto >= 0.9.8],
,
[AC_MSG_ERROR([libcrypto >= 0.9.8 is required])]
)
if test -n "${pkcs11_module}"; then
AC_DEFINE_UNQUOTED(
[DEFAULT_PKCS11_MODULE],
"${pkcs11_module}",
[Default PKCS#11 module.])
fi
pkgconfigdir="\$(libdir)/pkgconfig"
AC_SUBST([pkgconfigdir])
AC_SUBST([apidocdir])
AC_SUBST([enginesexecdir])
AC_SUBST([LIBP11_VERSION_MAJOR])
AC_SUBST([LIBP11_VERSION_MINOR])
AC_SUBST([LIBP11_VERSION_FIX])
AC_SUBST([LIBP11_LT_CURRENT])
AC_SUBST([LIBP11_LT_REVISION])
AC_SUBST([LIBP11_LT_AGE])
AC_SUBST([LIBP11_LT_OLDEST])
AC_SUBST([WIN_LIBPREFIX])
AC_SUBST([SHARED_EXT], $(eval echo "${shrext_cmds}"))
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AM_CONDITIONAL([CYGWIN], [test "${CYGWIN}" = "yes"])
AM_CONDITIONAL([ENABLE_API_DOC], [test "${enable_api_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_MSG_CHECKING([if libtool needs -no-undefined flag to build shared libraries])
case "$host_os" in
cygwin*|msys*|mingw*)
## Add in the -no-undefined flag to LDFLAGS for libtool.
AC_MSG_RESULT([yes])
LDFLAGS="$LDFLAGS -no-undefined"
;;
*)
## Don't add in anything.
AC_MSG_RESULT([no])
;;
esac
AC_CONFIG_FILES([
Makefile
src/Makefile
src/libp11.pc
src/libp11.rc
src/pkcs11.rc
doc/Makefile
doc/doxygen.conf
examples/Makefile
tests/Makefile
])
AC_OUTPUT
AC_MSG_NOTICE([creating src/libp11.map])
# We do it *after* the src directory is created
rm -f src/libp11.map
echo "LIBP11_${LIBP11_LT_OLDEST}" >src/libp11.map
echo "{" >>src/libp11.map
echo "global:" >>src/libp11.map
tr '\n' ';' <$srcdir/src/libp11.exports >>src/libp11.map
echo "" >>src/libp11.map
echo "local:" >>src/libp11.map
echo '*;' >>src/libp11.map
echo "};" >>src/libp11.map
chmod ugo-w src/libp11.map
cat <<EOF
libp11 has been configured with the following options:
Version: ${PACKAGE_VERSION}
libp11 directory: $(eval eval eval echo "${libdir}")
Engine directory: ${enginesexecdir}
Default PKCS11 module: ${pkcs11_module}
API doc support: ${enable_api_doc}
Host: ${host}
Compiler: ${CC}
Preprocessor flags: ${CPPFLAGS}
Compiler flags: ${CFLAGS}
Linker flags: ${LDFLAGS}
Libraries: ${LIBS}
OPENSSL_CFLAGS: ${OPENSSL_CFLAGS}
OPENSSL_LIBS: ${OPENSSL_LIBS}
EOF
# vim: set noexpandtab: