-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure.ac
159 lines (134 loc) · 4.57 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
define([PKCS11_VERSION_MAJOR], [0])
define([PKCS11_VERSION_MINOR], [1])
define([PKCS11_VERSION_PATCH], [0])
define([VERSION_SUFFIX], [])
define([LIB_VERSION_CURRENT], [1])
define([LIB_VERSION_AGE], [1])
define([LIB_VERSION_REVISION], [0])
AC_PREREQ(2.64)
AC_INIT([pkcs11-util],[PKCS11_VERSION_MAJOR.PKCS11_VERSION_MINOR.PKCS11_VERSION_PATCH[]VERSION_SUFFIX])
AC_CONFIG_HEADER([src/config.h])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE(foreign 1.11 -Wall -Wno-portability silent-rules tar-pax no-dist-gzip dist-xz subdir-objects)
AC_USE_SYSTEM_EXTENSIONS
VERSION_INFO="LIB_VERSION_CURRENT:LIB_VERSION_REVISION:LIB_VERSION_AGE"
AC_SUBST([VERSION_INFO])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
LT_INIT
AC_LIBTOOL_WIN32_DLL
AC_CANONICAL_HOST
have_windows="no"
case "$host_os" in
mingw*)
have_windows="yes"
;;
esac
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_LN_S
AC_PROG_EGREP
gl_VISIBILITY
AC_MSG_CHECKING([if libraries can be versioned])
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
if test "$GLD"; then
have_ld_version_script=yes
AC_MSG_RESULT(yes)
else
have_ld_version_script=no
AC_MSG_RESULT(no)
AC_MSG_WARN(*** You have not enabled versioned symbols.)
fi
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
AX_APPEND_LINK_FLAGS([ -Wl,--as-needed -Wl,--gc-sections ],[LDFLAGS])
AX_APPEND_COMPILE_FLAGS([ -Wall -pedantic --std=c11 ])
AC_C_BIGENDIAN
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_FUNCS([getopt_long])
AC_CHECK_LIB(dl, dlsym)
# AC_CHECK_FUNCS([strndup],, AC_DEFINE([_GNU_SOURCE], [], [Linux requires _GNU_SOURCE for strndup]))
AC_ARG_WITH(
[pkcs11-module],
[AS_HELP_STRING([--with-pkcs11-module], [Default PKCS#11 module])],
[pkcs11_module="${withval}"]
)
if test x"$pkcs11_module" == x""; then
AC_PATH_PROG([PKG_CONFIG], [pkg-config])
if test x"$PKG_CONFIG" != x""; then
NSS_LIBDIR=`$PKG_CONFIG nss --variable=libdir 2>/dev/null`
if test x"NSS_LIBDIR" != x""; then
if test `uname` == "Darwin" ; then
NSS_LIBNAME="libsoftokn3.dylib" ;
else
NSS_LIBNAME="libsoftokn3.so" ;
if test ! -f "$NSS_LIBDIR/$NSS_LIBNAME" -a -f "$NSS_LIBDIR/nss/$NSS_LIBNAME" ; then
NSS_LIBNAME="nss/$NSS_LIBNAME" ;
fi
fi
pkcs11_module="$NSS_LIBDIR/$NSS_LIBNAME"
fi
if test ! -f "$pkcs11_module" ; then
if test `uname` == "Darwin" ; then
pkcs11_module=`ls -1 /usr/local/Cellar/nss/*/lib/libsoftokn3.dylib | sort | tail -1` ;
else
# pkcs11_module=`ls -1 /usr/lib*/*/nss/libsoftokn3.so | sort | tail -1` ;
pkcs11_module=`find /usr/ -ipath "*/nss/*" -a -iname libsoftokn3.so 2>/dev/null | sort | tail -1` ;
fi
fi
fi
fi
if test x"$pkcs11_module" != x"" -a -f "$pkcs11_module"; then
pkcs11_path=`echo $pkcs11_module | sed 's|\\\\|\\\\\\\\|g'`
AC_DEFINE_UNQUOTED([DEFAULT_PKCS11_MODULE], "${pkcs11_path}", [Default PKCS#11 module])
DEFAULT_PKCS11_MODULE="${pkcs11_module}"
fi
AC_SUBST([DEFAULT_PKCS11_MODULE])
AX_CHECK_OPENSSL
if test x"$OPENSSL_LIBS" != x""; then
AC_DEFINE_UNQUOTED([HAVE_OPENSSL], [1], [Compiled with OpenSSL])
AC_MSG_CHECKING([whether OpenSSL version support ECDSA custom methods])
CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
AC_RUN_IFELSE(AC_LANG_SOURCE([[AC_LANG_DEFINES_PROVIDED
#include <openssl/rsa.h>
#include <openssl/ecdsa.h>
#if ((defined(LIBRESSL_VERSION_NUMBER) && \
(LIBRESSL_VERSION_NUMBER >= 0x20010002L))) || \
(defined(ECDSA_F_ECDSA_METHOD_NEW))
int main() { return 0; }
#else
int main() { return -1; }
#endif
]]),[
HAVE_OPENSSL_ECC=1
AC_MSG_RESULT([yes])
], [
HAVE_OPENSSL_ECC=0
AC_MSG_RESULT([no])
])
fi
AC_SUBST([HAVE_OPENSSL])
AC_SUBST([HAVE_OPENSSL_ECC])
AM_CONDITIONAL(HAVE_OPENSSL, test "$OPENSSL_LIBS" != "")
AX_PTHREAD
AC_SUBST([HAVE_PTHREAD])
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$LIBS $PTHREAD_LIBS"
AC_CONFIG_FILES([Makefile])
AC_CACHE_SAVE
AC_OUTPUT
AC_MSG_RESULT([
$PACKAGE $VERSION
=====
host_os: ${host_os}
prefix: ${prefix}
sysconfdir: ${sysconfdir}
libdir: ${libdir}
includedir: ${includedir}
compiler: ${CC}
cflags: ${CFLAGS}
ldflags: ${LDFLAGS} ${OPENSSL_LDFLAGS} ${OPENSSL_LIBS}
pkcs11_module: ${pkcs11_module}
openssl binary: ${OPENSSL_BIN}
])