-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
1550 lines (1397 loc) · 52.7 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
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
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
AC_INIT([openconnect], [9.12])
AC_LANG([C])
AC_CONFIG_HEADERS([config.h])
m4_ifdef([AC_CONFIG_MACRO_DIRS], [AC_CONFIG_MACRO_DIRS([m4])])
PKG_PROG_PKG_CONFIG
AC_CANONICAL_HOST
AM_MAINTAINER_MODE([enable])
AM_INIT_AUTOMAKE([foreign tar-ustar subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_PREREQ([2.62])
# Upstream's pkg.m4 (since 0.27) offers this now, but define our own
# compatible version in case the local version of pkgconfig isn't new enough.
# https://bugs.freedesktop.org/show_bug.cgi?id=48743
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
[AC_ARG_WITH([pkgconfigdir],
[AS_HELP_STRING([--with-pkgconfigdir],
[install directory for openconnect.pc pkg-config file])],
[],[with_pkgconfigdir='$(libdir)/pkgconfig'])
AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
use_openbsd_libtool=
symver_time=
symver_getline=
symver_asprintf=
symver_vasprintf=
symver_win32_strerror=
symver_win32_setenv=
# Autoconf is stupid and if the first time it needs to find the C compiler
# is conditional (as it is here for some of the MinGW checks), it forgets
# to ever look for one in the other code paths. Do it explicitly here.
AC_PROG_CC
# Before autoconf 2.70, AC_PROG_CC_C99 appears to be necessary for some
# compilers if you want C99 support. Starting with 2.70, it is obsolete.
m4_version_prereq([2.70], [:], [AC_PROG_CC_C99])
default_browser=xdg-open
have_vhost=no
case $host_os in
*linux* | *gnu* | *nacl*)
have_vhost=yes
AC_MSG_NOTICE([Applying feature macros for GNU build])
AC_DEFINE(_GNU_SOURCE, 1, [_GNU_SOURCE])
;;
*netbsd*)
AC_MSG_NOTICE([Applying feature macros for NetBSD build])
AC_DEFINE(_POSIX_C_SOURCE, 200112L, [_POSIX_C_SOURCE])
AC_DEFINE(_NETBSD_SOURCE, 1, [_NETBSD_SOURCE])
;;
*openbsd*)
AC_MSG_NOTICE([Applying feature macros for OpenBSD build])
use_openbsd_libtool=true
;;
*solaris*|*sunos*)
AC_MSG_NOTICE([Applying workaround for broken SunOS time() function])
AC_DEFINE(HAVE_SUNOS_BROKEN_TIME, 1, [On SunOS time() can go backwards])
symver_time="openconnect__time;"
;;
*mingw32*|*mingw64*|*msys*)
AC_MSG_NOTICE([Applying feature macros for MinGW/Windows build])
# For GetVolumeInformationByHandleW() which is Vista+
AC_DEFINE(_WIN32_WINNT, 0x600, [Windows API version])
have_win=yes
# For asprintf()
AC_DEFINE(_GNU_SOURCE, 1, [_GNU_SOURCE])
symver_win32_strerror="openconnect__win32_strerror;"
symver_win32_setenv="openconnect__win32_setenv;"
# Win32 does have the SCard API
system_pcsc_libs="-lwinscard"
system_pcsc_cflags=
AC_CHECK_TOOL([WINDRES], [windres], [])
AC_ARG_ENABLE([nsis-installer],
AS_HELP_STRING([--disable-nsis-installer], [Do not build an NSIS installer]),
[USE_NSIS=$enableval], [USE_NSIS=yes])
if test "$USE_NSIS" = "yes"; then
AC_CHECK_TOOL([MAKENSIS], [makensis], [])
fi
default_browser=open
case $host_cpu in
x86_64|amd64)
wintun_arch=amd64
;;
*86)
wintun_arch=x86
;;
aarch64|arm64)
wintun_arch=arm64
;;
arm*)
wintun_arch=arm
;;
esac
AC_SUBST(WINTUN_ARCH, "$wintun_arch")
# Per https://github.com/MisterDA/ocaml/commit/5855ce5ffd931a2802d5b9a5b2987ab0b276fd0a,
# "The header file <afunix.h> declares the `struct sockaddr_un` type, but hasn't been picked by mingw-w64."
AC_CHECK_HEADER([afunix.h], AC_DEFINE([HAVE_AF_UNIX_H], 1, [MinGW has afunix.h]))
# MINGW_HAS_SECURE_API may only work on newer MinGW:
# https://stackoverflow.com/a/51977723
AC_DEFINE(MINGW_HAS_SECURE_API, 1, [Try to make getenv_s and _putenv_s available])
AC_CHECK_DECL(_putenv_s, [AC_DEFINE(HAVE_PUTENV_S_DECL, 1, [MinGW declares _putenv_s])], [], [#include <sec_api/stdlib_s.h>])
AC_CHECK_DECL(getenv_s, [AC_DEFINE(HAVE_GETENV_S_DECL, 1, [MinGW declares getenv_s])], [], [#include <sec_api/stdlib_s.h>])
;;
*darwin*)
system_pcsc_libs="-Wl,-framework -Wl,PCSC"
system_pcsc_cflags=
default_browser=open
;;
*)
# On FreeBSD the only way to get vsyslog() visible is to define
# *nothing*, which makes absolutely everything visible.
# On Darwin enabling _POSIX_C_SOURCE breaks <sys/mount.h> because
# u_long and other types don't get defined. OpenBSD is similar.
;;
esac
AM_CONDITIONAL(OPENCONNECT_WIN32, [ test "$have_win" = "yes" ])
if test "$have_win" = "yes"; then
#required for vpnc-script-win.js and wintun
AC_CHECK_PROG(have_curl, curl, yes)
AC_CHECK_PROG(have_unzip, unzip, yes)
AC_CHECK_PROG(have_jq, jq, yes)
if test "${wintun_arch}" != ""; then
if test "${have_curl}" != "yes"; then
wintun_arch=
else
if test "${have_unzip}" != "yes"; then
wintun_arch=
fi
fi
fi
fi
build_nsis=no
if test "$MAKENSIS" != ""; then
#disable NSIS build if we cannot extract wintun
if test "${wintun_arch}" != ""; then
build_nsis=yes
else
AC_MSG_WARN([Disabling NSIS installer since wintun cannot be included])
fi
fi
AM_CONDITIONAL(BUILD_NSIS, [ test "$build_nsis" = "yes" ])
AM_CONDITIONAL(OPENCONNECT_WINTUN, [ test "${wintun_arch}" != "" ])
AC_ARG_WITH([external-browser],
[AS_HELP_STRING([--with-external-browser],
[command to use for spawning external web browser])])
if test "$with_external_browser" = "yes" || test "$with_external_browser" = ""; then
if test "$have_win" != ""; then
with_external_browser=${default_browser}
elif test "$default_browser" != ""; then
AC_MSG_CHECKING([for ${default_browser}])
AC_PATH_PROG(with_external_browser, ${default_browser}, no)
else
with_external_browser=no
fi
fi
if test "$with_external_browser" != "no"; then
if test -x "${with_external_browser}" -o -n "$have_win"; then
AC_DEFINE_UNQUOTED(DEFAULT_EXTERNAL_BROWSER, "${with_external_browser}", [External browser executable])
else
AC_MSG_ERROR([${with_external_browser} does not seem to be executable.])
fi
fi
AC_ARG_WITH([vpnc-script],
[AS_HELP_STRING([--with-vpnc-script],
[default location of vpnc-script helper])])
if test "$with_vpnc_script" = "yes" || test "$with_vpnc_script" = ""; then
AC_MSG_CHECKING([for vpnc-script in standard locations])
if test "$have_win" = "yes"; then
with_vpnc_script=vpnc-script-win.js
#downloading and amending vpnc-script-win.js depends on curl and jq. Disable it if they are missing, which *should* cause configure to stop
if test "${have_curl}" != "yes"; then
with_vpnc_script=no
else
if test "${have_jq}" != "yes"; then
with_vpnc_script=no
fi
fi
AC_MSG_RESULT([${with_vpnc_script}])
else
for with_vpnc_script in /usr/local/share/vpnc-scripts/vpnc-script /usr/local/sbin/vpnc-script /usr/share/vpnc-scripts/vpnc-script /usr/sbin/vpnc-script /etc/vpnc/vpnc-script; do
if test -x "$with_vpnc_script"; then
break
fi
done
if ! test -x "$with_vpnc_script"; then
AC_MSG_ERROR([${with_vpnc_script} does not seem to be executable.]
[OpenConnect will not function correctly without a vpnc-script.]
[See https://www.infradead.org/openconnect/vpnc-script.html for more details.]
[]
[If you are building a distribution package, please ensure that your]
[packaging is correct, and that a vpnc-script will be installed when the]
[user installs your package. You should provide a --with-vpnc-script=]
[argument to this configure script, giving the full path where the script]
[will be installed.]
[]
[The standard location is ${with_vpnc_script}. To bypass this error and]
[build OpenConnect to use the script from this location, even though it is]
[not present at the time you are building OpenConnect, pass the argument]
["--with-vpnc-script=${with_vpnc_script}"])
else
AC_MSG_RESULT([${with_vpnc_script}])
fi
fi
fi
if test "$with_vpnc_script" = "no"; then
AC_MSG_ERROR(You cannot disable vpnc-script.
OpenConnect will not function correctly without it.
See https://www.infradead.org/openconnect/vpnc-script.html)
elif test "$have_win" = "yes"; then
# Oh Windows how we hate thee. If user specifies a vpnc-script and it contains
# backslashes, double them all up to survive escaping.
with_vpnc_script="$(echo "${with_vpnc_script}" | sed s/\\\\/\\\\\\\\/g)"
fi
AC_DEFINE_UNQUOTED(DEFAULT_VPNCSCRIPT, "${with_vpnc_script}", [Default vpnc-script locatin])
AC_SUBST(DEFAULT_VPNCSCRIPT, "${with_vpnc_script}")
AC_CHECK_FUNC(fdevname_r, [AC_DEFINE(HAVE_FDEVNAME_R, 1, [Have fdevname_r() function])], [])
AC_CHECK_FUNC(statfs, [AC_DEFINE(HAVE_STATFS, 1, [Have statfs() function])], [])
AC_CHECK_FUNC(getline, [AC_DEFINE(HAVE_GETLINE, 1, [Have getline() function])],
[symver_getline="openconnect__getline;"])
AC_CHECK_FUNC(strcasestr, [AC_DEFINE(HAVE_STRCASESTR, 1, [Have strcasestr() function])], [])
AC_CHECK_FUNC(strndup, [AC_DEFINE(HAVE_STRNDUP, 1, [Have strndup() function])], [])
AC_CHECK_FUNC(strchrnul, [AC_DEFINE(HAVE_STRCHRNUL, 1, [Have strchrnul() function])], [])
AC_CHECK_FUNC(asprintf, [AC_DEFINE(HAVE_ASPRINTF, 1, [Have asprintf() function])],
[symver_asprintf="openconnect__asprintf;"])
AC_CHECK_FUNC(vasprintf, [AC_DEFINE(HAVE_VASPRINTF, 1, [Have vasprintf() function])],
[symver_vasprintf="openconnect__vasprintf;"])
AC_MSG_CHECKING([for __builtin_clz])
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[return __builtin_clz(0xffffffff);])],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BUILTIN_CLZ, 1, [Have __builtin_clz()])],
[AC_MSG_RESULT(no)])
if test -n "$symver_vasprintf"; then
AC_MSG_CHECKING([for va_copy])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <stdarg.h>
va_list a;],[
va_list b;
va_copy(b,a);
va_end(b);])],
[AC_DEFINE(HAVE_VA_COPY, 1, [Have va_copy()])
AC_MSG_RESULT(va_copy)],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <stdarg.h>
va_list a;],[
va_list b;
__va_copy(b,a);
va_end(b);])],
[AC_DEFINE(HAVE___VA_COPY, 1, [Have __va_copy()])
AC_MSG_RESULT(__va_copy)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([Your system lacks vasprintf() and va_copy()])])
])
fi
AC_SUBST(SYMVER_TIME, $symver_time)
AC_SUBST(SYMVER_GETLINE, $symver_getline)
AC_SUBST(SYMVER_ASPRINTF, $symver_asprintf)
AC_SUBST(SYMVER_VASPRINTF, $symver_vasprintf)
AC_SUBST(SYMVER_WIN32_STRERROR, $symver_win32_strerror)
AC_SUBST(SYMVER_WIN32_SETENV, $symver_win32_setenv)
AS_COMPILER_FLAGS(WFLAGS,
"-Wall
-Wextra
-Wno-missing-field-initializers
-Wno-sign-compare
-Wno-unused-parameter
-Werror=pointer-to-int-cast
-Werror-implicit-function-declaration
-Wformat-nonliteral
-Wformat-security
-Winit-self
-Wmissing-declarations
-Wmissing-include-dirs
-Wnested-externs
-Wpointer-arith
-Wwrite-strings")
AC_SUBST(WFLAGS, [$WFLAGS])
oldCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $WFLAGS"
AC_MSG_CHECKING([For memset_s])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>],[[
unsigned char *foo[16];
memset_s(foo, 16, 0, 16);]])],
[AC_MSG_RESULT([yes])
AC_DEFINE(__STDC_WANT_LIB_EXT1__, 1, [To request memset_s])
AC_DEFINE(HAVE_MEMSET_S, 1, [Have memset_s() function])],
[AC_MSG_RESULT([no])
AC_CHECK_FUNC(explicit_memset,
[AC_DEFINE(HAVE_EXPLICIT_MEMSET, 1, [Have explicit_memset() function])],
[AC_CHECK_FUNC(explicit_bzero,
[AC_DEFINE(HAVE_EXPLICIT_BZERO, 1, [Have explicit_bzero() function])],
[])
])
])
CFLAGS="$oldCFLAGS"
AC_MSG_CHECKING([For localtime_r])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>],[[
struct tm tm;
time_t t = 0;
localtime_r(&t, &tm);]])],
[AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_LOCALTIME_R, 1, [Have localtime_r() function])],
[AC_MSG_RESULT([no])])
if test "$have_win" = yes; then
# Checking "properly" for __attribute__((dllimport,stdcall)) functions is non-trivial
LIBS="$LIBS -lws2_32 -lshlwapi -lsecur32 -liphlpapi"
AC_MSG_CHECKING([For localtime_s])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>],[[
struct tm tm;
time_t t = 0;
localtime_s(&tm, (time_t)0);]])],
[AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_LOCALTIME_S, 1, [Have localtime_s() function])],
[AC_MSG_RESULT([no])])
else
AC_CHECK_FUNC(socket, [], AC_CHECK_LIB(socket, socket, [], AC_MSG_ERROR(Cannot find socket() function)))
fi
have_inet_aton=yes
AC_CHECK_FUNC(inet_aton, [], AC_CHECK_LIB(nsl, inet_aton, [], have_inet_aton=no))
if test "$have_inet_aton" = "yes"; then
AC_DEFINE(HAVE_INET_ATON, 1, [Have inet_aton()])
fi
AC_MSG_CHECKING([for IPV6_PATHMTU socket option])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>],[
int foo = IPV6_PATHMTU; (void)foo;])],
[AC_DEFINE(HAVE_IPV6_PATHMTU, 1, [Have IPV6_PATHMTU socket option])
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
AC_CHECK_FUNC(__android_log_vprint, [], AC_CHECK_LIB(log, __android_log_vprint, [], []))
AC_ENABLE_SHARED
AC_DISABLE_STATIC
AC_CHECK_FUNC(nl_langinfo, [AC_DEFINE(HAVE_NL_LANGINFO, 1, [Have nl_langinfo() function])], [])
AC_CHECK_FUNC(posix_spawn, [AC_DEFINE(HAVE_POSIX_SPAWN, 1, [Have posix_spawn() function])], [])
if test "$ac_cv_func_nl_langinfo" = "yes"; then
AM_ICONV
if test "$am_cv_func_iconv" = "yes"; then
AC_SUBST(ICONV_LIBS, [$LTLIBICONV])
AC_SUBST(ICONV_CFLAGS, [$INCICONV])
AC_DEFINE(HAVE_ICONV, 1, [Have iconv() function])
fi
fi
AM_CONDITIONAL(OPENCONNECT_ICONV, [test "$am_cv_func_iconv" = "yes"])
AC_ARG_ENABLE([nls],
AS_HELP_STRING([--disable-nls], [Do not use Native Language Support]),
[USE_NLS=$enableval], [USE_NLS=yes])
LIBINTL=
if test "$USE_NLS" = "yes"; then
AC_PATH_PROG(MSGFMT, msgfmt)
if test "$MSGFMT" = ""; then
AC_MSG_ERROR(msgfmt could not be found. Try configuring with --disable-nls)
fi
fi
LIBINTL=
if test "$USE_NLS" = "yes"; then
AC_MSG_CHECKING([for functional NLS support])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <locale.h>
#include <libintl.h>],[
setlocale(LC_ALL, "");
bindtextdomain("openconnect", "/tmp");
(void)dgettext("openconnect", "foo");])],
[AC_MSG_RESULT(yes)],
[AC_LIB_LINKFLAGS_BODY([intl])
oldLIBS="$LIBS"
LIBS="$LIBINTL $LIBS"
oldCFLAGS="$LIBS"
CFLAGS="$CFLAGS $INCINTL"
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <locale.h>
#include <libintl.h>],[
setlocale(LC_ALL, "");
bindtextdomain("openconnect", "/tmp");
(void)dgettext("openconnect", "foo");])],
[AC_MSG_RESULT(yes (with $INCINTL $LIBINTL))],
[AC_MSG_RESULT(no)
USE_NLS=no])
LIBS="$oldLIBS"])
fi
if test "$USE_NLS" = "yes"; then
AC_SUBST(INTL_LIBS, [$LTLIBINTL])
AC_SUBST(INTL_CFLAGS, [$INCINTL])
AC_DEFINE(ENABLE_NLS, 1, [Enable NLS support])
fi
AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"])
AC_ARG_WITH([system-cafile],
AS_HELP_STRING([--with-system-cafile],
[Location of the default system CA certificate file for old (<3.0.20) GnuTLS versions]))
# We will use GnuTLS by default if it's present. We used to support
# using GnuTLS for the TLS connections and OpenSSL for DTLS, but none
# of the reasons for that make sense any more.
AC_ARG_WITH([gnutls],
AS_HELP_STRING([--without-gnutls], [Do not attempt to use GnuTLS; use OpenSSL instead]))
AC_ARG_WITH([openssl],
AS_HELP_STRING([--with-openssl], [Location of OpenSSL build dir]))
ssl_library=
esp=
dtls=
hpke=
if test "$with_openssl" != "" -a "$with_openssl" != "no"; then
if test "$with_gnutls" = ""; then
with_gnutls=no
elif test "$with_gnutls" = "yes"; then
AC_MSG_ERROR([You cannot choose both GnuTLS and OpenSSL.])
fi
fi
# First, check if GnuTLS exists and is usable
if test "$with_gnutls" = "yes" || test "$with_gnutls" = ""; then
PKG_CHECK_MODULES(GNUTLS, gnutls,
[if ! $PKG_CONFIG --atleast-version=3.2.10 gnutls; then
AC_MSG_WARN([Your GnuTLS is too old. At least v3.2.10 is required])
else
ssl_library=GnuTLS
fi], [:])
elif test "$with_gnutls" != "no"; then
AC_MSG_ERROR(Values other than 'yes' or 'no' for --with-gnutls are not supported)
fi
# Do we need to look for OpenSSL?
if test "$ssl_library" = ""; then
if test "$with_gnutls" = "yes" -o "$with_openssl" = "no"; then
AC_MSG_ERROR([Suitable GnuTLS required but not found])
elif test "$with_openssl" = "yes" -o "$with_openssl" = ""; then
PKG_CHECK_MODULES(OPENSSL, openssl, [AC_SUBST(SSL_PC, [openssl])],
[oldLIBS="$LIBS"
LIBS="-lssl -lcrypto $LIBS"
AC_MSG_CHECKING([for OpenSSL without pkg-config])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <openssl/ssl.h>
#include <openssl/err.h>],[
SSL_library_init();
ERR_clear_error();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();])],
[AC_MSG_RESULT(yes)
AC_SUBST([OPENSSL_LIBS], ["-lssl -lcrypto"])
AC_SUBST([OPENSSL_CFLAGS], [])]
AC_SUBST([openssl_pc_libs], [$OPENSSL_LIBS]),
[AC_MSG_RESULT(no)
AC_MSG_ERROR(Could not build against OpenSSL)])
LIBS="$oldLIBS"])
ssl_library=OpenSSL
PKG_CHECK_MODULES(P11KIT, p11-kit-1,
# libp11 0.4.7 fails to export ERR_LIB_PKCS11 so we don't know what it
# is and can't match its errors, which we need to for login checks.
[PKG_CHECK_MODULES(LIBP11, libp11 != 0.4.7,
[AC_DEFINE(HAVE_LIBP11, 1, [Have libp11 and p11-kit for OpenSSL])
AC_SUBST(P11KIT_PC, ["libp11 p11-kit-1"])
proxy_module="`$PKG_CONFIG --variable=proxy_module p11-kit-1`"
pkcs11_support="libp11"
AC_DEFINE_UNQUOTED([DEFAULT_PKCS11_MODULE], "${proxy_module}", [p11-kit proxy])],
[:])], [:])
else
OPENSSL_CFLAGS="-I${with_openssl}/include ${OPENSSL_CFLAGS}"
if test -r "${with_openssl}/libssl.a" -a -r "${with_openssl}/libcrypto.a"; then
OPENSSL_LIBS="${with_openssl}/libssl.a ${with_openssl}/libcrypto.a -ldl -lz -pthread"
elif test -r "${with_openssl}/crypto/.libs/libcrypto.a" -a \
-r "${with_openssl}/ssl/.libs/libssl.a"; then
OPENSSL_LIBS="${with_openssl}/ssl/.libs/libssl.a ${with_openssl}/crypto/.libs/libcrypto.a -ldl -lz -pthread"
else
AC_MSG_ERROR(Could not find OpenSSL libraries in ${with_openssl});
fi
AC_SUBST(OPENSSL_CFLAGS)
AC_SUBST(OPENSSL_LIBS)
enable_static=yes
enable_shared=no
ssl_library=OpenSSL
fi
fi
AC_ARG_WITH([openssl-version-check],
AS_HELP_STRING([--without-openssl-version-check], [Do not check for known-broken OpenSSL versions]))
AC_ARG_WITH([gnutls-version-check],
AS_HELP_STRING([--without-gnutls-version-check], [Do not check for known-broken GnuTLS versions]))
AC_ARG_WITH([default-gnutls-priority],
AS_HELP_STRING([--with-default-gnutls-priority=STRING],
[Provide a default string as GnuTLS priority string]),
default_gnutls_priority=$withval)
if test -n "$default_gnutls_priority"; then
AC_DEFINE_UNQUOTED([DEFAULT_PRIO], ["$default_gnutls_priority"], [The GnuTLS priority string])
fi
AC_ARG_WITH([gnutls-tss2],
AS_HELP_STRING([--with-gnutls-tss2], [Specify TSS2 library (tss2-esys, ibmtss)]))
tss2lib=none
case "$ssl_library" in
OpenSSL)
oldLIBS="${LIBS}"
oldCFLAGS="${CFLAGS}"
LIBS="${OPENSSL_LIBS} ${LIBS}"
CFLAGS="${CFLAGS} ${OPENSSL_CFLAGS}"
# Check for the various known-broken versions of OpenSSL, which includes LibreSSL.
if test "$with_openssl_version_check" != "no"; then
AC_MSG_CHECKING([for known-broken versions of OpenSSL])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <openssl/opensslv.h>],
[#if defined(LIBRESSL_VERSION_NUMBER)
#error Bad OpenSSL
#endif
])],
[],
[AC_MSG_RESULT(yes)
AC_MSG_ERROR([LibreSSL does not support Cisco DTLS.]
[Build with OpenSSL or GnuTLS instead.])])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <openssl/opensslv.h>],[#if \
(OPENSSL_VERSION_NUMBER == 0x10002000L || \
(OPENSSL_VERSION_NUMBER >= 0x100000b0L && OPENSSL_VERSION_NUMBER <= 0x100000c0L) || \
(OPENSSL_VERSION_NUMBER >= 0x10001040L && OPENSSL_VERSION_NUMBER <= 0x10001060L))
#error Bad OpenSSL
#endif
])],
[],
[AC_MSG_RESULT(yes)
AC_MSG_ERROR(This version of OpenSSL is known to be broken with Cisco DTLS.
See http://rt.openssl.org/Ticket/Display.html?id=2984&user=guest&pass=guest
Add --without-openssl-version-check to configure args to avoid this check, or
perhaps consider building with GnuTLS instead.)])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <openssl/opensslv.h>],[#if \
(OPENSSL_VERSION_NUMBER == 0x1000200fL)
#error Bad OpenSSL
#endif
])],
[],
[AC_MSG_RESULT(yes)
AC_MSG_ERROR(This version of OpenSSL is known to be broken with Cisco DTLS.
See http://rt.openssl.org/Ticket/Display.html?id=3703&user=guest&pass=guest
and http://rt.openssl.org/Ticket/Display.html?id=3711&user=guest&pass=guest
Add --without-openssl-version-check to configure args to avoid this check, or
perhaps consider building with GnuTLS instead.)])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <openssl/opensslv.h>],[#if \
((OPENSSL_VERSION_NUMBER >= 0x10001110L && OPENSSL_VERSION_NUMBER <= 0x10001150L) || \
(OPENSSL_VERSION_NUMBER >= 0x10002050L && OPENSSL_VERSION_NUMBER <= 0x10002090L))
#error Bad OpenSSL
#endif
])],
[],
[AC_MSG_RESULT(yes)
AC_MSG_ERROR(This version of OpenSSL is known to be broken with Cisco DTLS.
See http://rt.openssl.org/Ticket/Display.html?id=4631&user=guest&pass=guest
Add --without-openssl-version-check to configure args to avoid this check, or
perhaps consider building with GnuTLS instead.)])
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([for ENGINE_by_id() in OpenSSL])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/engine.h>],
[ENGINE_by_id("foo");])],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ENGINE, [1], [OpenSSL has ENGINE support])],
[AC_MSG_RESULT(no)
AC_MSG_NOTICE([Building without OpenSSL TPM ENGINE support])])
AC_MSG_CHECKING([for dtls1_stop_timer() in OpenSSL])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>
#include <stdlib.h>
extern void dtls1_stop_timer(SSL *);],
[dtls1_stop_timer(NULL);])],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DTLS1_STOP_TIMER, [1], [OpenSSL has dtls1_stop_timer() function])],
[AC_MSG_RESULT(no)])
# DTLS_client_method() and DTLSv1_2_client_method() were both added between
# OpenSSL v1.0.1 and v1.0.2. DTLSV1.2_client_method() was later deprecated
# in v1.1.0 so we use DTLS_client_method() as our check for DTLSv1.2 support
# and that's what we actually use in openssl-dtls.c too.
AC_MSG_CHECKING([for DTLS_client_method() in OpenSSL])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>],
[DTLS_client_method();])],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DTLS12, [1], [OpenSSL has DTLS_client_method() function])],
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING([for SSL_CTX_set_min_proto_version() in OpenSSL])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>],
[SSL_CTX_set_min_proto_version((void *)0, 0);])],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SSL_CTX_PROTOVER, [1], [OpenSSL has SSL_CTX_set_min_proto_version() function])],
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING([for BIO_meth_free() in OpenSSL])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/bio.h>],
[BIO_meth_free((void *)0);])],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BIO_METH_FREE, [1], [OpenSSL has BIO_meth_free() function])],
[AC_MSG_RESULT(no)])
AC_CHECK_FUNC(HMAC_CTX_copy,
[esp=yes],
[AC_MSG_WARN([ESP support will be disabled])])
AC_MSG_CHECKING([for SSL_CIPHER_find() in OpenSSL])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>],
[SSL_CIPHER_find((void *)0, "");])],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SSL_CIPHER_FIND, [1], [OpenSSL has SSL_CIPHER_find() function])],
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING([for HKDF support in OpenSSL])
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>
#include <openssl/kdf.h>],
[EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL);
EVP_PKEY_CTX_hkdf_mode(ctx, EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND);])],
[AC_MSG_RESULT(yes)
hpke=yes],
[AC_MSG_RESULT(no)])
LIBS="${oldLIBS}"
CFLAGS="${oldCFLAGS}"
dtls=yes
AC_DEFINE(OPENCONNECT_OPENSSL, 1, [Using OpenSSL])
AC_DEFINE(OPENSSL_SUPPRESS_DEPRECATED, 1, [We need to update to OpenSSL 3.0.0 API])
AC_SUBST(SSL_LIBS, ['$(OPENSSL_LIBS)'])
AC_SUBST(SSL_CFLAGS, ['$(OPENSSL_CFLAGS)'])
;;
GnuTLS)
oldlibs="$LIBS"
oldcflags="$CFLAGS"
LIBS="$GNUTLS_LIBS $LIBS"
CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
esp=yes
dtls=yes
# Check for the known-broken versions of GnuTLS,
if test "$with_gnutls_version_check" != "no"; then
AC_MSG_CHECKING([for known-broken versions of GnuTLS])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <gnutls/gnutls.h>],
[#if GNUTLS_VERSION_NUMBER >= 0x030603 && GNUTLS_VERSION_NUMBER <= 0x03060c
#error Bad GnuTLS
#endif
])],
[],
[AC_MSG_RESULT(yes)
AC_MSG_ERROR([DTLS is insecure in GnuTLS v3.6.3 through v3.6.12.]
[See https://gitlab.com/gnutls/gnutls/issues/960]
[Add --without-gnutls-version-check to configure args to avoid this check (DTLS]
[will still be disabled at runtime), or build with another version.])])
AC_MSG_RESULT(no)
fi
AC_CHECK_FUNC(gnutls_system_key_add_x509,
[AC_DEFINE(HAVE_GNUTLS_SYSTEM_KEYS, 1, [From GnuTLS 3.4.0])], [])
AC_CHECK_FUNC(gnutls_pkcs11_add_provider,
[PKG_CHECK_MODULES(P11KIT, p11-kit-1,
[AC_DEFINE(HAVE_P11KIT, 1, [Have. P11. Kit.])
pkcs11_support=GnuTLS
AC_SUBST(P11KIT_PC, p11-kit-1)],
[:])], [])
# From GnuTLS 3.6.13
AC_CHECK_FUNC(gnutls_hkdf_expand, [have_hkdf=yes], [have_hkdf=no])
LIBS="-ltspi $oldlibs"
AC_MSG_CHECKING([for Trousers tss library])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <trousers/tss.h>
#include <trousers/trousers.h>],[
int err = Tspi_Context_Create((void *)0);
Trspi_Error_String(err);])],
[AC_MSG_RESULT(yes)
AC_SUBST([TSS_LIBS], [-ltspi])
AC_SUBST([TSS_CFLAGS], [])
AC_DEFINE(HAVE_TROUSERS, 1, [Have Trousers TSS library])],
[AC_MSG_RESULT(no)])
LIBS="$oldlibs"
CFLAGS="$oldcflags"
if test "$have_hkdf" = "yes"; then
PKG_CHECK_MODULES(HOGWEED, [hogweed],
[AC_MSG_CHECKING([For hogweed built-in mini-gmp])
LIBS="$oldlibs $HOGWEED_LIBS"
CFLAGS="$oldcflags $HOGWEED_CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <nettle/ecc.h>],
[mpz_clear((void *)0);])],
[AC_MSG_RESULT(yes)
AC_SUBST(HPKE_CFLAGS, ['$(HOGWEED_FLAGS)'])
AC_SUBST(HPKE_LIBS, ['$(HOGWEED_LIBS)'])
hpke=yes],
[AC_MSG_RESULT(no)
PKG_CHECK_MODULES(GMP, [gmp],
[hpke=yes
AC_SUBST(HPKE_CFLAGS, ['$(HOGWEED_FLAGS) $(GMP_CFLAGS)'])
AC_SUBST(HPKE_LIBS, ['$(HOGWEED_LIBS) $(GMP_LIBS)'])],
[AC_MSG_CHECKING([for gmp without pkgconfig])
LIBS="$LIBS -lgmp"
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <gmp.h>],
[mpz_clear((void *)0);])],
[AC_MSG_RESULT(yes)
AC_SUBST(HPKE_CFLAGS, ['$(HOGWEED_FLAGS)'])
AC_SUBST(HPKE_LIBS, ['$(HOGWEED_LIBS) -lgmp'])
hpke=yes],
[AC_MSG_RESULT(no)])
])
])
LIBS="$oldlibs"
CFLAGS="$oldcflags"],
[:])
fi
PKG_CHECK_MODULES(TASN1, [libtasn1], [have_tasn1=yes], [have_tasn1=no])
if test "$have_tasn1" = "yes"; then
if test "$with_gnutls_tss2" = "yes" -o "$with_gnutls_tss2" = "tss2-esys" -o "$with_gnutls_tss2" = ""; then
PKG_CHECK_MODULES(TSS2_ESYS, [tss2-esys tss2-mu tss2-tctildr],
[AC_DEFINE(HAVE_TSS2, 1, [Have TSS2])
AC_SUBST(TPM2_CFLAGS, ['$(TASN1_CFLAGS) $(TSS2_ESYS_CFLAGS)'])
AC_SUBST(TPM2_LIBS, ['$(TASN1_LIBS) $(TSS2_ESYS_LIBS)'])
tss2lib=tss2-esys],
[:])
fi
if test "$tss2lib" = "none"; then
if test "$with_gnutls_tss2" = "yes" -o "$with_gnutls_tss2" = "ibmtss" -o "$with_gnutls_tss2" = ""; then
# The Fedora 'tss2-devel' package puts headers in /usr/include/ibmtss/
# and the library is named libibmtss.so. The Ubuntu libtss-dev package
# puts headers in /usr/include/${host}/tss2/ and the library is named
# libtss.so. Neither ships a pkg-config file at the time I write this.
AC_CHECK_LIB([tss], [TSS_Create], [tss2inc=tss2
tss2lib=tss],
AC_CHECK_LIB([ibmtss], [TSS_Create],
[tss2inc=ibmtss
tss2lib=ibmtss], []))
if test "$tss2lib" != "none"; then
AC_MSG_CHECKING([For <${tss2inc}/tss.h>])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define TPM_POSIX
#include <${tss2inc}/tss.h>
],[])],
[AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED(HAVE_TSS2, $tss2inc, [TSS2 library])
AC_SUBST(TSS2_LIBS, [-l$tss2lib])
AC_SUBST(TPM2_CFLAGS, ['$(TASN1_CFLAGS) -DTPM_POSIX'])
AC_SUBST(TPM2_LIBS, ['$(TASN1_LIBS) $(TSS2_LIBS)'])],
[AC_MSG_RESULT(no)
tss2lib=none])
fi
fi
fi
fi
AC_DEFINE(OPENCONNECT_GNUTLS, 1, [Using GnuTLS])
AC_SUBST(SSL_PC, [gnutls])
AC_SUBST(SSL_LIBS, ['$(GNUTLS_LIBS) $(TPM2_LIBS) $(HPKE_LIBS)'])
AC_SUBST(SSL_CFLAGS, ['$(GNUTLS_CFLAGS) $(TPM2_CFLAGS) $(HPKE_CFLAGS)'])
;;
*)
# This should never happen
AC_MSG_ERROR([No SSL library selected])
;;
esac
case x"$with_gnutls_tss2" in
xtss2-esys)
if test "$tss2lib" != "tss2-esys"; then
AC_MSG_ERROR([tss2-esys requested but not found])
fi
;;
xibmtss|xtss)
if test "$tss2lib" != "ibmtss" -a "$tss2lib" != "tss"; then
AC_MSG_ERROR([ibmtss requested but not found: $tss2lib])
fi
;;
x|xno)
;;
xyes)
if test "$tss2lib" = "none" -a "$with_gnutls_tss2" = "yes"; then
AC_MSG_ERROR([No TSS2 library found])
fi
;;
*)
AC_MSG_ERROR([Unknown value for gnutls-tss2])
;;
esac
AM_CONDITIONAL(OPENCONNECT_SYSTEM_KEYS, [ test "$ac_cv_func_gnutls_system_key_add_x509" = "yes" ])
AM_CONDITIONAL(OPENCONNECT_TSS2_ESYS, [ test "$tss2lib" = "tss2-esys" ])
AM_CONDITIONAL(OPENCONNECT_TSS2_IBM, [ test "$tss2lib" = "ibmtss" -o "$tss2lib" = "tss" ])
AC_PATH_PROG(SWTPM, swtpm)
SWTPM_IOCTL=""
TPM2_STARTUP=""
TSSTARTUP=""
if test "$SWTPM" != ""; then
AC_PATH_PROG(SWTPM_IOCTL, swtpm_ioctl)
AC_PATH_PROG(TPM2_STARTUP, tpm2_startup)
AC_PATH_PROG(TSSTARTUP, tsstartup)
fi
# The Intel/TCG TSS can only *create* keys
AC_PATH_PROG(TPM2TSS_GENKEY, tpm2tss-genkey)
# James's one can import them too.
AC_PATH_PROG(CREATE_TPM2_KEY, create_tpm2_key)
AC_ARG_ENABLE([hwtpm-test],
AS_HELP_STRING([--enable-hwtpm-test], [Test TPM support using real TPMv2 [default=no]]),
[test_hwtpm=$enableval], [test_hwtpm=no])
if test "$test_hwtpm" = "yes" -a "$TPM2TSS_GENKEY$CREATE_TPM2_KEY" = ""; then
AC_MSG_ERROR([Hardware TPM test requires tpm2tss-genkey and/or create_tpm2_key tools])
fi
AM_CONDITIONAL(TEST_HWTPM, [ test "$test_hwtpm" = "yes" ])
AM_CONDITIONAL(TEST_SWTPM, [ test "$SWTPM_IOCTL" != "" -a \( "$TPM2_STARTUP" != "" -o "$TSSTARTUP" != "" \) ])
AM_CONDITIONAL(TEST_TPM2_CREATE, [ test "$TPM2TSS_GENKEY" != "" ])
AM_CONDITIONAL(TEST_TPM2_IMPORT, [ test "$CREATE_TPM2_KEY" != "" ])
test_pkcs11=
if test "$pkcs11_support" != ""; then
AC_CHECK_PROG(test_pkcs11, softhsm2-util, yes)
fi
AM_CONDITIONAL(TEST_PKCS11, [ test "$test_pkcs11" = "yes" ])
# The test is OpenSSL-only for now.
AM_CONDITIONAL(CHECK_DTLS, [ test "$ssl_library" = "OpenSSL" ])
AC_ARG_ENABLE([dtls-xfail],
AS_HELP_STRING([--enable-dtls-xfail], [Only for gitlab CI. Do not use]))
AM_CONDITIONAL(DTLS_XFAIL, [test "$enable_dtls_xfail" = "yes" ])
AC_ARG_ENABLE([dsa-tests],
AS_HELP_STRING([--disable-dsa-tests], [Disable DSA keys in self-test]),
[], [enable_dsa_tests=yes])
AM_CONDITIONAL(TEST_DSA, [test "$enable_dsa_tests" = "yes"])
AC_ARG_ENABLE([ppp-tests],
AS_HELP_STRING([--enable-ppp-tests], [Enable PPP tests (which require socat and pppd, and must run as root)]),
[enable_ppp_tests=yes])
AC_ARG_ENABLE([flask-tests],
AS_HELP_STRING([--disable-flask-tests], [Disable Flask-based tests (which require Python 3.6+ and the Flask module)]),
[], [enable_flask_tests=yes])
AM_CONDITIONAL(OPENCONNECT_GNUTLS, [ test "$ssl_library" = "GnuTLS" ])
AM_CONDITIONAL(OPENCONNECT_OPENSSL, [ test "$ssl_library" = "OpenSSL" ])
AM_CONDITIONAL(OPENCONNECT_ESP, [ test "$esp" != "" ])
AM_CONDITIONAL(OPENCONNECT_DTLS, [ test "$dtls" != "" ])
if test "$esp" != ""; then
AC_DEFINE(HAVE_ESP, 1, [Build with ESP support])
fi
if test "$dtls" != ""; then
AC_DEFINE(HAVE_DTLS, 1, [Build with DTLS support])
fi
if test "$hpke" != ""; then
AC_DEFINE(HAVE_HPKE_SUPPORT, 1, [Support Cisco external browser HPKE (ECDH+HKDF+AES-256-GCM)])
fi
AC_ARG_WITH(lz4,
AS_HELP_STRING([--without-lz4], [disable support for LZ4 compression]),
test_for_lz4=$withval,
test_for_lz4=yes)
lz4_pkg=no
if test "$test_for_lz4" = yes; then
PKG_CHECK_MODULES([LIBLZ4], [liblz4], [
AC_SUBST(LIBLZ4_PC, liblz4)
AC_DEFINE([HAVE_LZ4], [], [LZ4 was found])
lz4_pkg=yes
oldLIBS="$LIBS"
LIBS="$LIBLZ4_LIBS $LIBS"
oldCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $LIBLZ4_CFLAGS"
AC_MSG_CHECKING([for LZ4_compress_default()])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <lz4.h>],[
LZ4_compress_default("", (char *)0, 0, 0);])],
[AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_LZ4_COMPRESS_DEFAULT], [], [From LZ4 r129])
],
[AC_MSG_RESULT(no)])
LIBS="$oldLIBS"
CFLAGS="$oldCFLAGS"
],
[
AC_MSG_WARN([[
***
*** lz4 not found.
*** ]])
])
fi
if test "$build_nsis" = "yes"; then
case $host_os in
*mingw32*)
if test "$host_cpu" = "x86_64"; then
winsys=MinGW64
else
winsys=MinGW32
fi
;;
*mingw64*)
winsys=MinGW64
;;
*msys*)
winsys=MSYS
;;
*)
winsys=Unknown
;;
esac
AC_SUBST(INSTALLER_SUFFIX, [${winsys}-${ssl_library}])
fi
# For some bizarre reason now that we use AM_ICONV, the mingw32 build doesn't
# manage to set EGREP properly in the created ./libtool script. Make sure it's
# found.
AC_PROG_EGREP
# Needs to happen after we default to static/shared libraries based on OpenSSL
LT_INIT
if test "$use_openbsd_libtool" = "true" && test -x /usr/bin/libtool; then
echo using OpenBSD libtool
LIBTOOL=/usr/bin/libtool
fi
AM_CONDITIONAL(OPENBSD_LIBTOOL, [ test "$use_openbsd_libtool" = "true" ])
AX_CHECK_VSCRIPT
PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
AC_ARG_WITH([builtin-json],
AS_HELP_STRING([--with-builtin-json],
[Build with builtin json-parser library [default=auto]]))
json=
AS_IF([test "$with_builtin_json" != "yes"],
[PKG_CHECK_MODULES(JSON, json-parser,
[AC_SUBST(JSON_PC, [json-parser])
json=system], [:])
AC_DEFINE(HAVE_JSON, 1, [Have system json-parser package])
])
AS_IF([test "$with_builtin_json" != "no" && test "$json" = "" ],
[json=builtin
oldLIBS="$LIBS"
AC_SEARCH_LIBS(pow, [m])
LIBS="$oldLIBS"
AC_SUBST([JSON_LIBS], [$ac_cv_search_pow])
AC_SUBST([JSON_CFLAGS], ['-I$(srcdir)/json'])
AC_DEFINE(HAVE_JSON, 1, [Have builtin json-parser package])
])
AS_IF([test "$json" = ""],
AC_MSG_ERROR(No json-parser package found and --without-builtin-json specified)
)
AM_CONDITIONAL(BUILTIN_JSON, [test "$json" = "builtin"])
PKG_CHECK_MODULES(ZLIB, zlib, [AC_SUBST(ZLIB_PC, [zlib])],
[oldLIBS="$LIBS"