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
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
|
dnl Process this file with autoconf to produce a configure script. -*-m4-*-
dnl
dnl %CopyrightBegin%
dnl
dnl Copyright Ericsson AB 2018-2020. All Rights Reserved.
dnl
dnl Licensed under the Apache License, Version 2.0 (the "License");
dnl you may not use this file except in compliance with the License.
dnl You may obtain a copy of the License at
dnl
dnl http://www.apache.org/licenses/LICENSE-2.0
dnl
dnl Unless required by applicable law or agreed to in writing, software
dnl distributed under the License is distributed on an "AS IS" BASIS,
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dnl See the License for the specific language governing permissions and
dnl limitations under the License.
dnl
dnl %CopyrightEnd%
dnl
dnl define([AC_CACHE_LOAD], )dnl
dnl define([AC_CACHE_SAVE], )dnl
AC_INIT(vsn.mk)
AC_CONFIG_AUX_DIRS(${ERL_TOP}/erts/autoconf)
if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then
AC_CANONICAL_HOST
else
host_os=win32
fi
AC_LANG(C)
LM_PRECIOUS_VARS
if test "$cross_compiling" = "yes"; then
CROSS_COMPILING=yes
else
CROSS_COMPILING=no
fi
AC_SUBST(CROSS_COMPILING)
ERL_XCOMP_SYSROOT_INIT
AC_PROG_CC
LM_WINDOWS_ENVIRONMENT
ERL_DED
AC_MSG_CHECKING([for multiarch directory])
multiarch_dir=
if test "$GCC" = "yes"; then
multiarch_dir=`$CC $CFLAGS -print-multiarch 2>/dev/null`
if test $? -ne 0; then
multiarch_dir=
fi
fi
if test "$multiarch_dir" = ""; then
AC_MSG_RESULT([not found])
else
AC_MSG_RESULT([$multiarch_dir])
fi
dnl
dnl SSL, SSH and CRYPTO need the OpenSSL libraries
dnl
dnl Check flags --with-ssl, --without-ssl --with-ssl=PATH.
dnl If no option is given or --with-ssl is set without a path then we
dnl search for OpenSSL libraries and header files in the standard locations.
dnl If set to --without-ssl we disable the use of SSL, SSH and CRYPTO.
dnl If set to --with-ssl=PATH we use that path as the prefix, i.e. we
dnl use "PATH/include" and "PATH/lib".
AC_CHECK_SIZEOF(void *)
std_ssl_locations="/usr/local /usr/sfw /usr /opt/local /usr/pkg /usr/local/openssl /usr/local/opt/openssl /usr/lib/openssl /usr/openssl /usr/local/ssl /usr/lib/ssl /usr/ssl /"
AC_ARG_WITH(ssl,
AS_HELP_STRING([--with-ssl=PATH], [base location of OpenSSL include and lib directories])
AS_HELP_STRING([--with-ssl], [use SSL (default)])
AS_HELP_STRING([--without-ssl], [don't use SSL]))
AC_ARG_WITH(ssl-lib-subdir,
AS_HELP_STRING([--with-ssl-lib-subdir=RELATIVE_PATH],
[specify extra OpenSSL lib sub-directory to search in (relative to base directory)]),
[
case "$with_ssl_lib_subdir" in
yes|no)
with_ssl_lib_subdir=
;;
*)
;;
esac
],
[with_ssl_lib_subdir=]) #default
AC_ARG_WITH(ssl-incl,
AS_HELP_STRING([--with-ssl-incl=PATH],
[base location of OpenSSL include dir (if different than base location specified by --with-ssl=PATH)]),
[
case X$with_ssl in
X | Xyes | Xno) AC_MSG_ERROR([--with-ssl-incl=PATH set without --with-ssl=PATH]);;
esac
],
[with_ssl_incl=$with_ssl]) #default
AC_ARG_WITH(ssl-zlib,
AS_HELP_STRING([--with-ssl-zlib=PATH], [Path to static zlib library to link the
crypto NIF with. This zlib library is most
often not necessary but might be needed in
order to link the NIF in some cases.]),
[], [with_ssl_zlib=default]) #default
AC_ARG_WITH(ssl-rpath,
AS_HELP_STRING([--with-ssl-rpath=yes|no|PATHS],
[runtime library path for OpenSSL. Default is "yes", which equates to a
number of standard locations. If "no", then no runtime
library paths will be used. Anything else should be a
comma or colon separated list of paths.]),
[
case X$with_ssl in
Xno) AC_MSG_ERROR([--with-ssl-rpath set without --with-ssl]);;
esac
],
[with_ssl_rpath=default]) #default
AC_ARG_ENABLE(dynamic-ssl-lib,
AS_HELP_STRING([--enable-dynamic-ssl-lib],
[enable using dynamic openssl libraries when linking the crypto NIF])
AS_HELP_STRING([--disable-dynamic-ssl-lib],
[disable using dynamic openssl libraries when linking the crypto NIF]),
[ case "$enableval" in
no) enable_dynamic_ssl=no ;;
*) enable_dynamic_ssl=yes ;;
esac ], enable_dynamic_ssl=undefined)
AC_ARG_ENABLE(evp-dh,
AS_HELP_STRING([--disable-evp-dh],
[intentionally undocumented workaround]),
[ case "$enableval" in
no) DISABLE_EVP_DH=1;;
*) DISABLE_EVP_DH=0;;
esac ], DISABLE_EVP_DH=0)
AC_ARG_ENABLE(evp-hmac,
AS_HELP_STRING([--disable-evp-hmac],
[intentionally undocumented workaround]),
[ case "$enableval" in
no) DISABLE_EVP_HMAC=1;;
*) DISABLE_EVP_HMAC=0;;
esac ], DISABLE_EVP_HMAC=0)
AC_ARG_ENABLE(deprecated_warnings,
AS_HELP_STRING([--disable-deprecated-warnings],
[disable warnings for deprecated functions in cryptolib (default is to warn, except for OpenSSL 3.x where the default is not to warn)]),
[ case "$enableval" in
no) deprecated_warnings=no;;
*) deprecated_warnings=yes;;
esac ], deprecated_warnings=default_yes)
AC_DEFUN([ERL_LINK_CRYPTO_IFELSE], [
test_cflags=$1
test_ldflags=$2
test_libs=$3
saveCFLAGS="$CFLAGS"
saveLDFLAGS="$LDFLAGS"
saveLIBS="$LIBS"
CFLAGS="$DED_BASIC_CFLAGS $test_cflags"
LDFLAGS="$DED_LDFLAGS_CONFTEST $test_ldflags"
LIBS="$LIBS $test_libs"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <openssl/hmac.h>
]],
[[
HMAC(0, 0, 0, 0, 0, 0, 0);
]])],
[
$4
],
[
$5
])
CFLAGS="$saveCFLAGS"
LDFLAGS="$saveLDFLAGS"
LIBS="$saveLIBS"
])
AC_DEFUN([ERL_CRYPTO_CHECK_LIB], [
# Check for static and dynamic crypto library in the directory
# given as argument...
#
# Written as a macro in order to avoid writing the tests twice...
idir=$1
prfx=$2
rdir=$3
dir="$prfx$rdir"
static_crypto_lib_name=crypto
static_ssl_lib_name=ssl
static_extra_libs="$forced_static_zlib"
static_lib_dir=
dynamic_crypto_lib_name=crypto
dynamic_ssl_lib_name=ssl
dynamic_extra_libs="$forced_static_zlib"
dynamic_lib_dir=
dynamic_runtime_lib_dir=
found_static_lib=no
found_dynamic_lib=no
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-I$idir/include"
AC_EGREP_CPP(^yes.?$,[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090803fL
yes
#endif
],
[valid_include=yes],
[valid_include=no])
AC_EGREP_CPP(^yes.?$,[
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_MAJOR == 3
yes
#endif
],
[v3_include=yes],
[v3_include=no])
CPPFLAGS="$save_CPPFLAGS"
if test $valid_include != yes; then
static_crypto_lib_name=
static_ssl_lib_name=
static_extra_libs=
static_lib_dir=
dynamic_crypto_lib_name=
dynamic_ssl_lib_name=
dynamic_extra_libs=
dynamic_lib_dir=
dynamic_runtime_lib_dir=
elif test "$host_os" = "win32" ; then
if test -f "$dir/lib/VC/static/libcrypto${lib_bits}MD.lib"; then
static_crypto_lib_name=libcrypto${lib_bits}MD
static_ssl_lib_name="libssl${lib_bits}MD"
static_extra_libs="$static_extra_libs -lCRYPT32 -lWS2_32"
static_lib_dir="$dir/lib/VC/static"
found_static_lib=yes
fi
if test -f "$dir/lib/VC/libcrypto${lib_bits}MD.lib"; then
dynamic_crypto_lib_name=libcrypto${lib_bits}MD
dynamic_ssl_lib_name="libssl${lib_bits}MD"
dynamic_runtime_lib_dir="$rdir/lib/VC"
dynamic_lib_dir="$dir/lib/VC"
found_dynamic_lib=yes
fi
else # Non windows...
case "$host_os" in
darwin*)
static_ext=.a
dynamic_ext=.dylib;;
*)
static_ext=.a
dynamic_ext=.so;;
esac
for sdir in $search_subdirs; do
if test -f "$dir/$sdir/lib$dynamic_crypto_lib_name$dynamic_ext"; then
found_dynlib=yes
else
found_dynlib=no
case $host_os in
openbsd*)
# libcrypto.so got a suffix on (at least some) openbsd.
# If we find libcrypto.so with suffix, we try to link
# to it using -lcrypto ...
for f in "$dir/$sdir/lib$dynamic_crypto_lib_name$dynamic_ext"*; do
test -f "$f" && found_dynlib=yes
break
done;;
*)
;;
esac
fi
if test $found_dynlib = yes; then
# Found dynamic library; check if it links...
dynamic_lib_dir="$dir/$sdir"
dynamic_runtime_lib_dir="$rdir/$sdir"
ERL_LINK_CRYPTO_IFELSE(
["-I$idir/include"],
["-L$dynamic_lib_dir"],
["-l$dynamic_crypto_lib_name $dynamic_extra_libs"],
[found_dynamic_lib=yes],
[found_dynamic_lib=no])
if test $found_dynamic_lib = no -a $static_zlib != no; then
# No, but linking with zlib as well might help...
dynamic_extra_libs="$dynamic_extra_libs $static_zlib"
ERL_LINK_CRYPTO_IFELSE(
["-I$idir/include"],
["-L$dynamic_lib_dir"],
["-l$dynamic_crypto_lib_name $dynamic_extra_libs"],
[found_dynamic_lib=yes],
[found_dynamic_lib=no])
fi
fi
if test -f "$dir/$sdir/lib$static_crypto_lib_name$static_ext"; then
# Found static library; check if it links...
static_lib_dir="$dir/$sdir"
ERL_LINK_CRYPTO_IFELSE(
["-I$idir/include"],
[],
["$dir/$sdir/lib$static_crypto_lib_name$static_ext $static_extra_libs"],
[found_static_lib=yes],
[found_static_lib=no])
if test $found_static_lib = no -a $static_zlib != no; then
# No, but inking with zlib as well might help...
static_extra_libs="$static_extra_libs $static_zlib"
ERL_LINK_CRYPTO_IFELSE(
["-I$idir/include"],
[],
["$dir/$sdir/lib$static_crypto_lib_name$static_ext $static_extra_libs"],
[found_static_lib=yes],
[found_static_lib=no])
fi
fi
if test $found_static_lib = yes -o $found_dynamic_lib = yes; then
break
fi
done
fi
])
# Remove all SKIP files from previous runs
for a in ssl crypto ssh; do
rm -f "$ERL_TOP/lib/$a/SKIP"
done
# Setup subdirectories to search in...
search_subdirs="lib"
if test "$ac_cv_sizeof_void_p" = "8"; then
search_subdirs="$search_subdirs lib64 lib/64"
else
search_subdirs="$search_subdirs lib32 lib/32"
fi
test "$multiarch_dir" = "" || search_subdirs="lib/$multiarch_dir $search_subdirs"
test "$with_ssl_lib_subdir" = "" || search_subdirs="$with_ssl_lib_subdir $search_subdirs"
# We might need to link with zlib, so first check if we can find
# a static zlib to use if needed...
static_zlib=no
forced_static_zlib=
case "$with_ssl_zlib" in
no)
;;
default | yes)
AC_MSG_CHECKING([for static zlib])
for dir in $std_ssl_locations; do
for sdir in $search_subdirs; do
if test -f "$erl_xcomp_sysroot$dir/$sdir/libz.a"; then
static_zlib="$erl_xcomp_sysroot$dir/$sdir/libz.a"
break
fi
done
test "$static_zlib" = "no" || break
done
AC_MSG_RESULT([$static_zlib])
if test $with_ssl_zlib = yes; then
if test $static_zlib = no; then
AC_MSG_ERROR([linking with zlib requested by user, but no such library was found])
fi
forced_static_zlib="$static_zlib"
static_zlib=no
fi;;
*) # PATH
AC_MSG_CHECKING([for static zlib])
if test -f "$with_ssl_zlib/libz.a"; then
forced_static_zlib="$with_ssl_zlib/libz.a"
else
for sdir in $search_subdirs; do
if test -f "$with_ssl_zlib/$sdir/libz.a"; then
forced_static_zlib="$with_ssl_zlib/$sdir/libz.a"
break
fi
done
fi
if test "$forced_static_zlib" = ""; then
AC_MSG_ERROR([linking with zlib requested by user, but no such library was found in $with_ssl_zlib])
fi
AC_MSG_RESULT([$forced_static_zlib])
;;
esac
if test $enable_dynamic_ssl = undefined; then
if test "$host_os" = "win32" ; then
enable_dynamic_ssl=default_no
else
enable_dynamic_ssl=default_yes
fi
fi
case $enable_dynamic_ssl in
yes|default_yes)
SSL_DYNAMIC_ONLY=yes;;
*)
SSL_DYNAMIC_ONLY=no;;
esac
case "$erl_xcomp_without_sysroot-$with_ssl" in
yes-* | no-no)
SSL_APP=
CRYPTO_APP=
SSH_APP=
if test "$with_ssl" != "no"; then
skip="Cannot search for ssl; missing cross system root (erl_xcomp_sysroot)."
fi
for a in ssl crypto ssh; do
echo "$skip" > $ERL_TOP/lib/$a/SKIP
done
;;
no-yes | no- )
# We search for OpenSSL in the common OS standard locations.
SSL_APP=ssl
CRYPTO_APP=crypto
SSH_APP=ssh
if test "$host_os" = "win32" ; then
if test "x$ac_cv_sizeof_void_p" = "x8"; then
std_win_ssl_locations="/mnt/c/OpenSSL-Win64 /c/OpenSSL-Win64 /mnt/c/opt/local64/pgm/OpenSSL /opt/local64/pgm/OpenSSL /cygdrive/c/OpenSSL-Win64"
lib_bits=64
else
std_win_ssl_locations="/mnt/c/OpenSSL-Win32 /c/OpenSSL-Win32 /mnt/c/OpenSSL /c/OpenSSL /cygdrive/c/OpenSSL /opt/local/pgm/OpenSSL /opt/local32/pgm/OpenSSL /mnt/c/opt/local/pgm/OpenSSL /mnt/c/opt/local32/pgm/OpenSSL /cygdrive/c/OpenSSL-Win32"
lib_bits=32
fi
else
std_win_ssl_locations=""
fi
usable_crypto=no
AC_MSG_CHECKING([for OpenSSL crypto library with version >= 0.9.8c in standard locations])
for rdir in $std_win_ssl_locations $std_ssl_locations; do
if test -f "$erl_xcomp_isysroot$rdir/include/openssl/opensslv.h"; then
SSL_INCDIR="$erl_xcomp_isysroot$rdir"
SSL_INCLUDE="-I$SSL_INCDIR/include"
ERL_CRYPTO_CHECK_LIB(["$SSL_INCDIR"], ["$erl_xcomp_sysroot"], ["$rdir"])
case $enable_dynamic_ssl-$found_dynamic_lib-$found_static_lib in
no-*-no)
;; # Dynamic linking against ssl library disabled by user, and no static library found
yes-no-*)
;; # Static linking against ssl library disabled by user, and no dynamic library found
*-no-no)
;; # Neither static nor dynamic ssl library found
no-*-yes | default_no-*-yes | default_yes-no-yes)
# Link statically...
SSL_CRYPTO_LIBNAME=$static_crypto_lib_name
SSL_SSL_LIBNAME=$static_ssl_lib_name
SSL_LIBDIR="$static_lib_dir"
SSL_EXTRA_LIBS="$static_extra_libs"
SSL_RUNTIME_LIBDIR=
SSL_DYNAMIC_ONLY=no
usable_crypto=yes
break;;
*-yes-*)
# Link dynamically...
SSL_CRYPTO_LIBNAME=$dynamic_crypto_lib_name
SSL_SSL_LIBNAME=$dynamic_ssl_lib_name
SSL_EXTRA_LIBS="$dynamic_extra_libs"
SSL_LIBDIR="$dynamic_lib_dir"
SSL_RUNTIME_LIBDIR="$dynamic_runtime_lib_dir"
SSL_DYNAMIC_ONLY=yes
usable_crypto=yes
break;;
esac
fi
done
if test $usable_crypto = yes ; then
if test $SSL_DYNAMIC_ONLY = yes; then
AC_MSG_RESULT([dynamic $SSL_CRYPTO_LIBNAME library in $SSL_LIBDIR])
else
AC_MSG_RESULT([static $SSL_CRYPTO_LIBNAME library in $SSL_LIBDIR])
fi
else
AC_MSG_RESULT([no])
SSL_APP=
CRYPTO_APP=
SSH_APP=
SSL_INCDIR=
SSL_INCLUDE=
SSL_CRYPTO_LIBNAME=
SSL_SSL_LIBNAME=
SSL_INCDIR=
SSL_RUNTIME_LIBDIR=
SSL_LIBDIR=
case "$with_ssl-$enable_dynamic_ssl" in
yes-yes)
AC_MSG_ERROR([crypto library with dynamic linking requested by user, but no such library was found])
;;
yes-no)
AC_MSG_ERROR([crypto library with static linking requested by user, but no such library was found])
;;
yes-*)
AC_MSG_ERROR([crypto library requested by user, but no such library was found])
;;
*)
AC_MSG_WARN([No (usable) OpenSSL found, skipping ssl, ssh and crypto applications])
;;
esac
for a in ssl crypto ssh; do
echo "No usable OpenSSL found" > $ERL_TOP/lib/$a/SKIP
done
fi
;;
*)
# Option given with PATH to package
if test ! -d "$with_ssl" ; then
AC_MSG_ERROR(Invalid path to option --with-ssl=PATH)
fi
if test ! -d "$with_ssl_incl" ; then
AC_MSG_ERROR(Invalid path to option --with-ssl-incl=PATH)
fi
AC_MSG_CHECKING([for OpenSSL header in $with_ssl_incl])
if test -f "$with_ssl_incl/include/openssl/opensslv.h"; then
AC_MSG_RESULT([yes])
else
AC_MSG_ERROR([no OpenSSL header found in $with_ssl_incl])
fi
SSL_INCDIR="$with_ssl_incl"
AC_MSG_CHECKING([for OpenSSL in $with_ssl])
ERL_CRYPTO_CHECK_LIB(["$with_ssl_incl"], [""], ["$with_ssl"])
case $enable_dynamic_ssl-$found_dynamic_lib-$found_static_lib in
no-*-no)
AC_MSG_ERROR([dynamic linking against crypto library disabled by user, but no static library found in $with_ssl]);;
yes-no-*)
AC_MSG_ERROR([static linking against crypto library disabled by user, but no dynamic library found in $with_ssl]);;
*-no-no)
AC_MSG_ERROR([neither static nor dynamic crypto library found in $with_ssl]);;
no-*-yes | default_no-*-yes | default_yes-no-yes)
# Link statically...
SSL_CRYPTO_LIBNAME=$static_crypto_lib_name
SSL_SSL_LIBNAME=$static_ssl_lib_name
SSL_LIBDIR="$static_lib_dir"
SSL_EXTRA_LIBS="$static_extra_libs"
SSL_RUNTIME_LIBDIR=
SSL_DYNAMIC_ONLY=no;;
*-yes-*)
# Link dynamically...
SSL_CRYPTO_LIBNAME=$dynamic_crypto_lib_name
SSL_SSL_LIBNAME=$dynamic_ssl_lib_name
SSL_EXTRA_LIBS="$dynamic_extra_libs"
SSL_LIBDIR="$dynamic_lib_dir"
SSL_RUNTIME_LIBDIR="$dynamic_runtime_lib_dir"
SSL_DYNAMIC_ONLY=yes;;
esac
if test $SSL_DYNAMIC_ONLY = yes; then
AC_MSG_RESULT([dynamic $SSL_CRYPTO_LIBNAME library in $SSL_LIBDIR])
else
AC_MSG_RESULT([static $SSL_CRYPTO_LIBNAME library in $SSL_LIBDIR])
fi
SSL_INCLUDE="-I$with_ssl_incl/include"
SSL_APP=ssl
CRYPTO_APP=crypto
SSH_APP=ssh
if test "$cross_compiling" = "yes"; then
SSL_RUNTIME_LIBDIR=`echo "$SSL_LIBDIR" | sed -n "s|^$erl_xcomp_sysroot\(/*\)\(.*\)\$|/\2|p"`
else
SSL_RUNTIME_LIBDIR="$SSL_LIBDIR"
fi
esac
SSL_DED_LD_RUNTIME_LIBRARY_PATH=
ded_ld_rflg="$DED_LD_FLAG_RUNTIME_LIBRARY_PATH"
case "$with_ssl_rpath" in
yes | default) # Use standard lib locations for ssl runtime library path
AC_MSG_CHECKING([for runtime library path to use])
if test $enable_dynamic_ssl = no -a "$with_ssl_rpath" = yes; then
AC_MSG_ERROR([requested by user, but user also requested static linking])
fi
if test "$CRYPTO_APP" = ""; then
if test "$with_ssl_rpath" = yes; then
AC_MSG_ERROR([requested by user, but could not be used since no crypto library was found])
fi
AC_MSG_RESULT([])
elif test "$ded_ld_rflg" = ""; then
if test "$with_ssl_rpath" = yes; then
AC_MSG_ERROR([requested by user, but cannot be set on this platform])
fi
AC_MSG_RESULT([])
elif test "$SSL_DYNAMIC_ONLY" != "yes"; then
if test "$with_ssl_rpath" = yes; then
AC_MSG_WARN([requested by user, but dynamic linking will not be used])
else
AC_MSG_RESULT([])
fi
else
libdirs="/lib"
dir_lib64=no
dir_lib_64=no
dir_lib32=no
dir_lib_32=no
dir_multiarch=no
dir_with_ssl_lib_subdir=no
test "$multiarch_dir" = "" || dir_multiarch=yes
test "$with_ssl_lib_subdir" = "" || dir_with_ssl_lib_subdir=yes
case "$SSL_RUNTIME_LIBDIR" in
*/lib/64 | */lib/64/ ) dir_lib_64=yes;;
*/lib64 | */lib64/ ) dir_lib64=yes;;
*/lib/32 | */lib/32/ ) dir_lib_32=yes;;
*/lib32 | */lib32/ ) dir_lib32=yes;;
*) ;;
esac
for dir in $std_ssl_locations; do
if test "$ac_cv_sizeof_void_p" = "8"; then
test $dir_lib_64 = no &&
test -d "$erl_xcomp_sysroot$dir/lib/64" &&
dir_lib_64=yes
test $dir_lib64 = no &&
test -d "$erl_xcomp_sysroot$dir/lib64" &&
dir_lib64=yes
else
test $dir_lib_32 = no &&
test -d "$erl_xcomp_sysroot$dir/lib/32" &&
dir_lib_32=yes
test $dir_lib32 = no &&
test -d "$erl_xcomp_sysroot$dir/lib32" &&
dir_lib32=yes
fi
test $dir_multiarch = no &&
test -d "$erl_xcomp_sysroot$dir/lib/$multiarch_dir" &&
dir_multiarch=yes
done
test $dir_with_ssl_lib_subdir = yes && libdirs="/$with_ssl_lib_subdir $libdirs"
test $dir_multiarch = yes && libdirs="/lib/$multiarch_dir $libdirs"
test $dir_lib_64 = yes && libdirs="/lib/64 $libdirs"
test $dir_lib64 = yes && libdirs="/lib64 $libdirs"
test $dir_lib_32 = yes && libdirs="/lib/32 $libdirs"
test $dir_lib32 = yes && libdirs="/lib32 $libdirs"
#
# We try the follwing runtime paths in the
# following order:
# 1. Standard ssl locations with all variations
# of lib subdirectories that we know of
# 2. Standard ssl locations with all variations
# of lib subdirectories that we know of and
# exist on this machine
# 3. Determined $SSL_RUNTIME_LIBDIR
# If none of the above links, we skip runtime
# library path...
#
for type in std x_std curr; do
ded_ld_rpath="$ded_ld_rflg$SSL_RUNTIME_LIBDIR"
rpath="$SSL_RUNTIME_LIBDIR"
if test $type != curr; then
for ldir in $libdirs; do
for dir in $std_ssl_locations; do
test "$SSL_RUNTIME_LIBDIR" != "$dir$ldir" || continue
test $type != x_std || test -d "$erl_xcomp_sysroot$dir$ldir" || continue
if test "$dir" = "/"; then
libdir="$ldir"
else
libdir="$dir$ldir"
fi
ded_ld_rpath="$ded_ld_rpath $ded_ld_rflg$libdir"
rpath="$rpath:$libdir"
done
done
fi
# Check that it still links when we add the runtime path...
ERL_LINK_CRYPTO_IFELSE(
["$SSL_INCLUDE"],
["$ded_ld_rpath -L$SSL_LIBDIR"],
["-l$SSL_CRYPTO_LIBNAME $SSL_EXTRA_LIBS"],
[rpath_success=yes],
[rpath_success=no])
test "$rpath_success" = "yes" && break
done
test "$rpath_success" = "yes" || { ded_ld_rpath=; rpath=; }
SSL_DED_LD_RUNTIME_LIBRARY_PATH="$ded_ld_rpath"
if test "$rpath" != ""; then
AC_MSG_RESULT([$rpath])
elif test "$with_ssl_rpath" = yes; then
AC_MSG_ERROR([requested by user, but could not be used])
else
AC_MSG_WARN([unable to set run path during linking])
fi
fi
;;
no) # Use no ssl runtime library path
SSL_DED_LD_RUNTIME_LIBRARY_PATH=
;;
*) # Use ssl runtime library paths set by --with-ssl-rpath (without any check)
AC_MSG_CHECKING([whether runtime library path can be set])
if test $enable_dynamic_ssl = no; then
AC_MSG_ERROR([runtime library path requested by user, but user also requested static linking])
elif test "$CRYPTO_APP" = ""; then
if test "$with_ssl_rpath" = yes; then
AC_MSG_ERROR([runtime library path requested by user, but could not be set since no crypto library was found])
fi
AC_MSG_RESULT([])
elif test "$ded_ld_rflg" = ""; then
if test "$with_ssl_rpath" = yes; then
AC_MSG_ERROR([runtime library path requested by user, but cannot be set on this platform])
fi
AC_MSG_RESULT([])
elif test "$SSL_DYNAMIC_ONLY" != "yes"; then
if test "$with_ssl_rpath" = yes; then
AC_MSG_WARN([runtime library path requested by user, but dynamic linking will not be used])
else
AC_MSG_RESULT([])
fi
else
ded_ld_rpath=
delimit=
rpath=
rpath_delimit=
save_ifs="$IFS"; IFS=",:"
for dir in $with_ssl_rpath; do
ded_ld_rpath="$ded_ld_rpath$delimit$ded_ld_rflg$dir"
delimit=" "
rpath="$rpath$rpath_delimit$dir"
rpath_delimit=":"
done
IFS="$save_ifs"
SSL_DED_LD_RUNTIME_LIBRARY_PATH="$ded_ld_rpath"
ERL_LINK_CRYPTO_IFELSE(
["$SSL_INCLUDE"],
["$ded_ld_rpath -L$SSL_LIBDIR"],
["-l$SSL_CRYPTO_LIBNAME $SSL_EXTRA_LIBS"],
[rpath_success=yes],
[rpath_success=no])
if test "$rpath_success" = yes; then
AC_MSG_RESULT([yes; using $rpath])
else
AC_MSG_ERROR([runtime library path requested by user, but link failed])
fi
fi
;;
esac
AC_ARG_ENABLE(fips,
AS_HELP_STRING([--enable-fips], [enable OpenSSL FIPS mode support])
AS_HELP_STRING([--disable-fips], [disable OpenSSL FIPS mode support (default)]),
[ case "$enableval" in
yes) enable_fips_support=yes ;;
*) enable_fips_support=no ;;
esac ], enable_fips_support=no)
if test "x$enable_fips_support" = "xyes" && test "$CRYPTO_APP" != ""; then
saveCFLAGS="$CFLAGS"
saveLDFLAGS="$LDFLAGS"
saveLIBS="$LIBS"
CFLAGS="$DED_BASIC_CFLAGS $SSL_INCLUDE"
if test $SSL_DYNAMIC_ONLY = yes; then
LDFLAGS="$DED_LDFLAGS_CONFTEST $ded_ld_rpath -L$SSL_LIBDIR"
LIBS="$LIBS -l$SSL_CRYPTO_LIBNAME $SSL_EXTRA_LIBS"
else
LDFLAGS="$DED_LDFLAGS_CONFTEST"
if test "$host_os" = "win32" ; then
LIBS="$LIBS $SSL_LIBDIR/$SSL_CRYPTO_LIBNAME.lib $SSL_EXTRA_LIBS"
else
LIBS="$LIBS $SSL_LIBDIR/lib$SSL_CRYPTO_LIBNAME.a $SSL_EXTRA_LIBS"
fi
fi
AC_CHECK_FUNC([FIPS_mode_set],
[SSL_FLAGS="-DFIPS_SUPPORT"],
[SSL_FLAGS=])
CFLAGS="$saveCFLAGS"
LDFLAGS="$saveLDFLAGS"
LIBS="$saveLIBS"
else
SSL_FLAGS=
fi
if test "x$v3_include" = "xyes" && test "x$deprecated_warnings" = "xdefault_yes" && test "$CRYPTO_APP" != ""; then
deprecated_warnings=no
fi
if test "x$deprecated_warnings" = "xno" && test "$CRYPTO_APP" != "" ; then
SSL_FLAGS="$SSL_FLAGS -Wno-deprecated-declarations"
fi
AC_SUBST(SSL_INCLUDE)
AC_SUBST(SSL_INCDIR)
AC_SUBST(SSL_LIBDIR)
AC_SUBST(SSL_FLAGS)
AC_SUBST(SSL_CRYPTO_LIBNAME)
AC_SUBST(SSL_SSL_LIBNAME)
AC_SUBST(SSL_EXTRA_LIBS)
AC_SUBST(SSL_DED_LD_RUNTIME_LIBRARY_PATH)
AC_SUBST(SSL_DYNAMIC_ONLY)
AC_SUBST(DISABLE_EVP_DH)
AC_SUBST(DISABLE_EVP_HMAC)
AC_OUTPUT(c_src/$host/Makefile:c_src/Makefile.in)
|