-
Notifications
You must be signed in to change notification settings - Fork 16
/
configure.ac
516 lines (435 loc) · 14.1 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# configure.ac
#
# Copyright (C) 2023 wolfSSL Inc.
# All right reserved.
#
# This file is part of wolfPKCS11.
#
AC_COPYRIGHT([Copyright (C) 2014-2023 wolfSSL Inc.])
AC_PREREQ([2.63])
AC_INIT([wolfpkcs11],[1.3.0],[https://github.com/wolfssl/wolfpkcs11/issues],[wolfpkcs11],[http://www.wolfssl.com])
AC_CONFIG_AUX_DIR([build-aux])
# The following sets CFLAGS to empty if unset on command line.
: ${CFLAGS=""}
# Capture user C_EXTRA_FLAGS from configure line.
# Use of C_EXTRA_FLAGS is deprecated because CFLAGS was fixed but someone
# might still be using it.
CFLAGS="$CFLAGS $C_EXTRA_FLAGS $C_FLAGS"
# Test ar for the "U" option. Should be checked before the libtool macros.
xxx_ar_flags=$((ar --help) 2>&1)
AS_CASE([$xxx_ar_flags],[*'use actual timestamps and uids/gids'*],[: ${AR_FLAGS="Ucru"}])
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests])
AC_PROG_INSTALL
AC_ARG_PROGRAM
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([wolfpkcs11/config.h])
# shared library versioning
# The three numbers in the libpkcs11.so.*.*.* file name. Unfortunately
# increment if interfaces have been removed or changed
WOLFPKCS11_LIBRARY_VERSION_FIRST=3
# increment if interfaces have been added
# set to zero if WOLFPKCS11_LIBRARY_VERSION_FIRST is incremented
WOLFPKCS11_LIBRARY_VERSION_SECOND=1
# increment if source code has changed
# set to zero if WOLFPKCS11_LIBRARY_VERSION_FIRST is incremented or
# WOLFPKCS11_LIBRARY_VERSION_SECOND is incremented
WOLFPKCS11_LIBRARY_VERSION_THIRD=0
WOLFPKCS11_LIBRARY_VERSION=${WOLFPKCS11_LIBRARY_VERSION_FIRST}:${WOLFPKCS11_LIBRARY_VERSION_SECOND}:${WOLFPKCS11_LIBRARY_VERSION_THIRD}
AC_SUBST([WOLFPKCS11_LIBRARY_VERSION_FIRST])
AC_SUBST([WOLFPKCS11_LIBRARY_VERSION_SECOND])
AC_SUBST([WOLFPKCS11_LIBRARY_VERSION_THIRD])
AC_SUBST([WOLFPKCS11_LIBRARY_VERSION])
LT_PREREQ([2.2])
LT_INIT([disable-static], [win32-dll])
LT_LANG([C])
gl_VISIBILITY
AS_IF([test -n "$CFLAG_VISIBILITY"],
[AM_CPPFLAGS="$AM_CPPFLAGS $CFLAG_VISIBILITY"
CPPFLAGS="$CPPFLAGS $CFLAG_VISIBILITY"])
# silent
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
# Checks for header files.
AC_CHECK_SIZEOF([long long], 8)
AC_CHECK_SIZEOF([long], 4)
# Check headers/libs
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday inet_ntoa memset socket])
AC_CHECK_LIB([network],[socket])
# DEBUG
DEBUG_CFLAGS="-g -O0 -DDEBUG_WOLFPKCS11"
# Optimizations
OPTIMIZE_CFLAGS="-O2"
# Coverage
COVERAGE_CFLAGS="--coverage"
AX_DEBUG
AS_IF([test "x$ax_enable_debug" != "xno"],
[AM_CFLAGS="$DEBUG_CFLAGS $AM_CFLAGS -DDEBUG"],
[AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_CFLAGS -DNDEBUG"])
#COVERAGE
AX_COVERAGE
AS_IF([test "$ax_enable_coverage" = "yes"],
[AM_CFLAGS="$COVERAGE_CFLAGS $AM_CFLAGS"])
# Checks for typedefs, structures, and compiler characteristics.
if test "$ac_cv_sizeof_long" = "8"; then
AM_CFLAGS="$AM_CFLAGS -DSIZEOF_LONG=8"
else
if test "$ac_cv_sizeof_long_long" = "8"; then
AM_CFLAGS="$AM_CFLAGS -DSIZEOF_LONG_LONG=8"
fi
fi
# SINGLE THREADED
AC_ARG_ENABLE([singlethreaded],
[AS_HELP_STRING([--enable-singlethreaded],[Enable wolfPKCS11 single threaded (default: disabled)])],
[ ENABLED_SINGLETHREADED=$enableval ],
[ ENABLED_SINGLETHREADED=no ])
AS_IF([ test "x$ENABLED_SINGLETHREADED" = "xno" ],[
AX_PTHREAD([
AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.])
# If AX_PTHREAD is adding -Qunused-arguments, need to prepend with -Xcompiler libtool will use it. Newer
# versions of clang don't need the -Q flag when using pthreads.
AS_CASE([$PTHREAD_CFLAGS],[-Qunused-arguments*],[PTHREAD_CFLAGS="-Xcompiler $PTHREAD_CFLAGS"])
AM_CFLAGS="-D_POSIX_THREADS $AM_CFLAGS $PTHREAD_CFLAGS"
LIBS="$LIBS $PTHREAD_LIBS"
],[
ENABLED_SINGLETHREADED=yes
])
])
AS_IF([ test "x$ENABLED_SINGLETHREADED" = "xyes" ],[ AM_CFLAGS="-DSINGLE_THREADED $AM_CFLAGS" ])
AC_ARG_ENABLE([rsa],
[AS_HELP_STRING([--enable-rsa],[Enable RSA (default: enabled)])],
[ ENABLED_RSA=$enableval ],
[ ENABLED_RSA=yes ]
)
if test "$ENABLED_RSA" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DNO_RSA"
else
DISABLE_DEFS="$DISABLE_DEFS -DNO_RSA"
fi
AC_ARG_ENABLE([rsaoaep],
[AS_HELP_STRING([--enable-rsaoaep],[Enable RSA-OAEP (default: enabled)])],
[ ENABLED_RSAOAEP=$enableval ],
[ ENABLED_RSAOAEP=yes ]
)
if test "$ENABLED_RSA" = "no" || test "$ENABLED_RSAOAEP" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DWC_NO_RSA_OAEP"
else
DISABLE_DEFS="$DISABLE_DEFS -DWC_NO_RSA_OAEP"
fi
AC_ARG_ENABLE([rsapss],
[AS_HELP_STRING([--enable-rsapss],[Enable RSA-PSS (default: enabled)])],
[ ENABLED_RSAPSS=$enableval ],
[ ENABLED_RSAPSS=yes ]
)
if test "$ENABLED_RSA" = "yes" && test "$ENABLED_RSAPSS" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWC_RSA_PSS"
else
DISABLE_DEFS="$DISABLE_DEFS -DWC_RSA_PSS"
fi
AC_ARG_ENABLE([keygen],
[AS_HELP_STRING([--enable-keygen],[Enable Key Generation (default: enabled)])],
[ ENABLED_KEYGEN=$enableval ],
[ ENABLED_KEYGEN=yes ]
)
if test "$ENABLED_RSA" = "yes" && test "$ENABLED_KEYGEN" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN"
else
DISABLE_DEFS="$DISABLE_DEFS -DWOLFSSL_KEY_GEN"
fi
AC_ARG_ENABLE([ecc],
[AS_HELP_STRING([--enable-ecc],[Enable ECC (default: enabled)])],
[ ENABLED_ECC=$enableval ],
[ ENABLED_ECC=yes ]
)
if test "$ENABLED_ECC" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC"
else
DISABLE_DEFS="$DISABLE_DEFS -DHAVE_ECC"
fi
AC_ARG_ENABLE([dh],
[AS_HELP_STRING([--enable-dh],[Enable RSA (default: enabled)])],
[ ENABLED_DH=$enableval ],
[ ENABLED_DH=yes ]
)
if test "$ENABLED_DH" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DNO_DH"
else
DISABLE_DEFS="$DISABLE_DEFS -DNO_DH"
fi
AC_ARG_ENABLE([aes],
[AS_HELP_STRING([--enable-aes],[Enable AES (default: enabled)])],
[ ENABLED_AES=$enableval ],
[ ENABLED_AES=yes ]
)
if test "$ENABLED_AES" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DNO_AES"
else
DISABLE_DEFS="$DISABLE_DEFS -DNO_AES"
fi
AC_ARG_ENABLE([aescbc],
[AS_HELP_STRING([--enable-aescbc],[Enable AES-CBC (default: enabled)])],
[ ENABLED_AESCBC=$enableval ],
[ ENABLED_AESCBC=yes ]
)
if test "$ENABLED_AES" = "no" || test "$ENABLED_AESCBC" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DNO_AES_CBC"
else
DISABLE_DEFS="$DISABLE_DEFS -DNO_AES_CBC"
fi
AC_ARG_ENABLE([aesgcm],
[AS_HELP_STRING([--enable-aesgcm],[Enable AES-GCM (default: enabled)])],
[ ENABLED_AESGCM=$enableval ],
[ ENABLED_AESGCM=yes ]
)
if test "$ENABLED_AES" = "yes" && test "$ENABLED_AESGCM" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DHAVE_AESGCM"
else
DISABLE_DEFS="$DISABLE_DEFS -DHAVE_AESGCM"
fi
AC_ARG_ENABLE([hmac],
[AS_HELP_STRING([--enable-hmac],[Enable HMAC (default: enabled)])],
[ ENABLED_HMAC=$enableval ],
[ ENABLED_HMAC=yes ]
)
if test "$ENABLED_HMAC" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DNO_HMAC"
else
DISABLE_DEFS="$DISABLE_DEFS -DNO_HMAC"
fi
AC_ARG_ENABLE([md5],
[AS_HELP_STRING([--enable-md5],[Enable MD5 (default: enabled)])],
[ ENABLED_MD5=$enableval ],
[ ENABLED_MD5=yes ]
)
if test "$ENABLED_MD5" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DNO_MD5"
else
DISABLE_DEFS="$DISABLE_DEFS -DNO_MD5"
fi
AC_ARG_ENABLE([sha],
[AS_HELP_STRING([--enable-sha],[Enable SHA1 (default: enabled)])],
[ ENABLED_SHA1=$enableval ],
[ ENABLED_SHA1=yes ]
)
AC_ARG_ENABLE([sha1],
[AS_HELP_STRING([--enable-sha1],[Enable SHA1 (default: enabled)])],
[ ENABLED_SHA1=$enableval ],
[ ENABLED_SHA1=yes ]
)
if test "$ENABLED_SHA1" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DNO_SHA"
else
DISABLE_DEFS="$DISABLE_DEFS -DNO_SHA"
fi
AC_ARG_ENABLE([sha224],
[AS_HELP_STRING([--enable-sha224],[Enable SHA-224 (default: enabled)])],
[ ENABLED_SHA224=$enableval ],
[ ENABLED_SHA224=yes ]
)
if test "$ENABLED_SHA224" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA224"
else
DISABLE_DEFS="$DISABLE_DEFS -DWOLFSSL_SHA224"
fi
AC_ARG_ENABLE([sha256],
[AS_HELP_STRING([--enable-sha256],[Enable SHA-256 (default: enabled)])],
[ ENABLED_SHA256=$enableval ],
[ ENABLED_SHA256=yes ]
)
if test "$ENABLED_SHA256" = "no"
then
AM_CFLAGS="$AM_CFLAGS -DNO_SHA256"
else
DISABLE_DEFS="$DISABLE_DEFS -DNO_SHA256"
fi
AC_ARG_ENABLE([sha384],
[AS_HELP_STRING([--enable-sha384],[Enable SHA-384 (default: enabled)])],
[ ENABLED_SHA384=$enableval ],
[ ENABLED_SHA384=yes ]
)
if test "$ENABLED_SHA384" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA384"
else
DISABLE_DEFS="$DISABLE_DEFS -DWOLFSSL_SHA384"
fi
AC_ARG_ENABLE([sha512],
[AS_HELP_STRING([--enable-sha512],[Enable SHA-512 (default: enabled)])],
[ ENABLED_SHA512=$enableval ],
[ ENABLED_SHA512=yes ]
)
if test "$ENABLED_SHA512" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHA512"
else
DISABLE_DEFS="$DISABLE_DEFS -DWOLFSSL_SHA512"
fi
if test "$enable_shared" = "no"; then
AM_CFLAGS="$AM_CFLAGS -DHAVE_PKCS11_STATIC"
else
LIBS="$LIBS -ldl"
fi
AC_ARG_ENABLE([wolftpm],
[AS_HELP_STRING([--enable-wolftpm],[Enable wolfTPM keystore support (default: disabled)])],
[ ENABLED_TPM=$enableval ],
[ ENABLED_TPM=no ]
)
if test "$ENABLED_TPM" = "yes"
then
LIBS="$LIBS -lwolftpm"
AM_CFLAGS="$AM_CFLAGS -DWOLFPKCS11_TPM"
fi
AM_CONDITIONAL([BUILD_STATIC],[test "x$enable_shared" = "xno"])
# HARDEN FLAGS
AX_HARDEN_CC_COMPILER_FLAGS
OPTION_FLAGS="$CFLAGS $CPPFLAGS $AM_CFLAGS"
LIBS="$LIBS -lwolfssl -lm"
CREATE_HEX_VERSION
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_LDFLAGS])
# FINAL
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([wolfpkcs11/version.h])
AC_CONFIG_FILES([wolfpkcs11/options.h])
AX_CREATE_GENERIC_CONFIG
AX_AM_JOBSERVER([yes])
AC_OUTPUT
# force make clean
echo "---"
echo "Running make clean..."
make clean >/dev/null 2>&1
echo
# generate user options header
echo "---"
echo "Generating user options header..."
OPTION_FILE="wolfpkcs11/options.h"
rm -f $OPTION_FILE
echo "/* wolfpkcs11 options.h" > $OPTION_FILE
echo " * generated from configure options" >> $OPTION_FILE
echo " *" >> $OPTION_FILE
echo " * Copyright (C) 2006-2023 wolfSSL Inc." >> $OPTION_FILE
echo " *" >> $OPTION_FILE
echo " * * This file is part of wolfPKCS11." >> $OPTION_FILE
echo " *" >> $OPTION_FILE
echo " */" >> $OPTION_FILE
echo "" >> $OPTION_FILE
echo "#ifndef WOLFPKCS11_OPTIONS_H" >> $OPTION_FILE
echo "#define WOLFPKCS11_OPTIONS_H" >> $OPTION_FILE
echo "" >> $OPTION_FILE
echo "" >> $OPTION_FILE
echo "#ifdef __cplusplus" >> $OPTION_FILE
echo "extern \"C\" {" >> $OPTION_FILE
echo "#endif" >> $OPTION_FILE
echo "" >> $OPTION_FILE
for option in $OPTION_FLAGS; do
defonly=`echo $option | sed 's/-D//'`
if test "$defonly" != "$option"
then
noequalsign=`echo $defonly | sed 's/=/ /'`
if test "$noequalsign" = "NDEBUG" || test "$noequalsign" = "DEBUG"
then
echo "not outputting (N)DEBUG to $OPTION_FILE"
continue
fi
# allow user to igonore system options
ignoresys=no
if [[[ $noequalsign == _* ]]] ;
then
ignoresys=yes
echo "#ifndef WOLFSSL_OPTIONS_IGNORE_SYS" >> $OPTION_FILE
fi
noarg=`echo $defonly | sed 's/=.*//'`
echo "#undef $noarg" >> $OPTION_FILE
echo "#define $noequalsign" >> $OPTION_FILE
if test "$ignoresys" = "yes"
then
echo "#endif" >> $OPTION_FILE
fi
echo "" >> $OPTION_FILE
# else
# echo "option w/o begin -D is $option, not saving to $OPTION_FILE"
fi
done
for option in $DISABLE_DEFS; do
defonly=`echo $option | sed 's/-D//'`
if test "$defonly" != "$option"
then
noequalsign=`echo $defonly | sed 's/=/ /'`
if test "$noequalsign" = "NDEBUG" || test "$noequalsign" = "DEBUG"
then
echo "not outputting (N)DEBUG to $OPTION_FILE"
continue
fi
# allow user to igonore system options
ignoresys=no
if [[[ $noequalsign == _* ]]] ;
then
ignoresys=yes
echo "#ifndef WOLFSSL_OPTIONS_IGNORE_SYS" >> $OPTION_FILE
fi
noarg=`echo $defonly | sed 's/=.*//'`
echo "#undef $noarg" >> $OPTION_FILE
if test "$ignoresys" = "yes"
then
echo "#endif" >> $OPTION_FILE
fi
echo "" >> $OPTION_FILE
else
echo "option w/o begin -D is $option, not saving to $OPTION_FILE"
fi
done
echo "" >> $OPTION_FILE
echo "#ifdef __cplusplus" >> $OPTION_FILE
echo "}" >> $OPTION_FILE
echo "#endif" >> $OPTION_FILE
echo "" >> $OPTION_FILE
echo "" >> $OPTION_FILE
echo "#endif /* WOLFPKCS11_OPTIONS_H */" >> $OPTION_FILE
echo "" >> $OPTION_FILE
echo
# output config summary
echo "---"
echo "Configuration summary for $PACKAGE_NAME version $VERSION"
echo ""
echo " * Installation prefix: $prefix"
echo " * System type: $host_vendor-$host_os"
echo " * Host CPU: $host_cpu"
echo " * C Compiler: $CC"
echo " * C Flags: $CFLAGS"
echo " * CPP Flags: $CPPFLAGS"
echo " * Linker Flags: $LDFLAGS"
echo " * LIB Flags: $LIB"
echo " Features "
echo " * Single threaded: $ENABLED_SINGLETHREADED"
echo " * AES: $ENABLED_AES"
echo " * AES-CBC: $ENABLED_AESCBC"
echo " * AES-GCM: $ENABLED_AESGCM"
echo " * MD5: $ENABLED_MD5"
echo " * SHA: $ENABLED_SHA1"
echo " * SHA-224: $ENABLED_SHA224"
echo " * SHA-256: $ENABLED_SHA256"
echo " * SHA-384: $ENABLED_SHA384"
echo " * SHA-512: $ENABLED_SHA512"
echo " * HMAC: $ENABLED_HMAC"
echo " * RSA: $ENABLED_RSA"
echo " * RSA-OAEP: $ENABLED_RSAOAEP"
echo " * RSA-PSS: $ENABLED_RSAPSS"
echo " * DH: $ENABLED_DH"
echo " * ECC: $ENABLED_ECC"