-
Notifications
You must be signed in to change notification settings - Fork 37
/
configure.ac
2183 lines (1818 loc) · 70.5 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
dnl Process this file with autoconf to produce a configure script.
dnl There are two types of comments in this file.
dnl Comments that refer to Autoconf macros begin with "dnl", and m4
dnl discards them. Other comments begin with "#", and they get copied
dnl to the configure script, hopefully making it easier to read.
dnl Autoconf 2.13 generates an incomplete config.h.in; see ELinks bug 936.
dnl Autoconf 2.61 is installed in the computer that generates our nightly
dnl snapshots, so we need to be compatible with that. (Also, some files
dnl in Autoconf 2.62 and 2.63 sources are not GPLv2 compatible.)
AC_PREREQ(2.61)
AC_INIT
AC_CONFIG_SRCDIR([src/main/main.c])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR([config/m4])
PACKAGE=elinks
VERSION=0.18.GIT
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Package version])
AC_CONFIG_HEADERS(config.h)
AC_CHECK_PROG(ACLOCAL,[aclocal],[aclocal],[config/missing aclocal])
AC_CHECK_PROG(AUTOCONF,[autoconf],[autoconf],[config/missing autoconf])
AC_CHECK_PROG(AUTOHEADER,[autoheader],[autoheader],[config/missing autoheader])
AC_USE_SYSTEM_EXTENSIONS
MAKE=
for make in gnumake gmake make false; do
if test "x$MAKE" = x; then
AC_PATH_PROGS(MAKE, "$make")
fi
done
builddir="`pwd`"
# Cleanup if we are configuring with a previous build in the tree
if test -e Makefile.config; then
AC_MSG_CHECKING([for previous build to clean])
"$MAKE" -C "$builddir/src" cleanall >/dev/null 2>/dev/null
AC_MSG_RESULT(done)
fi
# ===================================================================
# Load feature configuration file and start logging features.
# ===================================================================
features="features.conf"
test -f "$srcdir/$features" && . "$srcdir/$features"
test -f "$builddir/$features" && . "$builddir/$features"
echo "Feature summary:" > features.log
# ===================================================================
# Checks for programs.
# ===================================================================
AC_PROG_CC
AC_PROG_CXX
AC_CHECK_TOOL([LD], [ld])
AC_PROG_AWK
AC_PATH_PROGS(AWK, "$AWK")
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PATH_PROGS(GIT, "git")
AC_PATH_PROGS(SPARSE, "sparse")
PKG_PROG_PKG_CONFIG
CONFIG_ASCIIDOC="no"
CONFIG_POD2HTML="no"
CONFIG_XMLTO="no"
CONFIG_DBLATEX="no"
if test "x$CONFIG_DOC" != xno; then
AC_PATH_PROGS(PYTHON3, "python3")
if test "x$PYTHON3" != "x"; then
EL_CONFIG(CONFIG_ASCIIDOC, [AsciiDoc])
EL_CONFIG(MANUAL_ASCIIDOC, [HTML (one file)])
EL_CONFIG(MAN_ASCIIDOC, [HTML])
fi
AC_PATH_PROGS(XMLTO, "xmlto")
if test "x$XMLTO" != "x"; then
EL_CONFIG(CONFIG_XMLTO, [XmlTo])
EL_CONFIG(MANUAL_XMLTO, [HTML (multiple files)])
EL_CONFIG(MAN_XMLTO, [man (groff)])
fi
AC_PATH_PROGS(DBLATEX, "dblatex")
if test "x$DBLATEX" != "x"; then
EL_CONFIG(CONFIG_DBLATEX, [dblatex])
EL_CONFIG(MANUAL_DBLATEX, [PDF])
fi
AC_PATH_PROGS(POD2HTML, "pod2html")
if test "x$POD2HTML" != "x"; then
EL_CONFIG(CONFIG_POD2HTML, [Pod2HTML])
fi
AC_PATH_PROGS(DOXYGEN, "doxygen")
if test "x$DOXYGEN" != "x"; then
EL_CONFIG(CONFIG_DOXYGEN, [Doxygen])
api_srcdir="$(cd "$srcdir" && pwd)/src"
AC_SUBST(api_srcdir)
fi
fi
AC_SUBST(CONFIG_ASCIIDOC)
AC_SUBST(CONFIG_DOXYGEN)
AC_SUBST(CONFIG_POD2HTML)
AC_SUBST(CONFIG_XMLTO)
AC_SUBST(CONFIG_DBLATEX)
EL_CONFIG_DEPENDS(CONFIG_DOC, [CONFIG_ASCIIDOC CONFIG_XMLTO CONFIG_DBLATEX CONFIG_POD2HTML], [Documentation Tools])
EL_CONFIG_DEPENDS(CONFIG_MANUAL, [MANUAL_ASCIIDOC MANUAL_XMLTO MANUAL_DBLATEX], [Manual Formats])
EL_CONFIG_DEPENDS(CONFIG_MANPAGE, [MAN_ASCIIDOC MAN_XMLTO], [Man Page Formats])
EL_CONFIG_DEPENDS(CONFIG_APIDOCS, [CONFIG_DOXYGEN], [API Documentation])
# gcc specific options (to be continued at the bottom of configure)
if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
# We want to see all warnings and live with none.
# We can't set up -Werror here as there may be some warnings in test
# suite of configure, and we don't want to fail them.
CFLAGS="$CFLAGS -Wall"
fi
# ===================================================================
# static binary
# ===================================================================
enable_static=no
pkg_config_static=
AC_ARG_WITH(static, [ --with-static enable build of static binary],
[ if test "x$withval" != xno; then enable_static=yes; fi ])
if test "$enable_static" = yes; then
CFLAGS="$CFLAGS -static"
pkg_config_static="--static"
fi
# ===================================================================
# Checks for special OSes.
# ===================================================================
dnl EL_CHECK_COMPILER_MACRO(define, name, flagname)
AC_DEFUN([EL_CHECK_COMPILER_MACROS],
[
AC_MSG_CHECKING([for $2])
for flag in $3; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef $flag
kill me!
#endif ]])],[$1=yes],[$1=no])
if test "[$]$1" = yes; then
EL_CONFIG([$1], [$2])
break
fi
done
AC_MSG_RESULT([$]$1)
])
EL_CHECK_COMPILER_MACROS(CONFIG_OS_BEOS, [BEOS], [__BEOS__])
AC_SUBST(CONFIG_OS_BEOS)
EL_CHECK_COMPILER_MACROS(CONFIG_OS_DOS, [DOS], [__DJGPP])
AC_SUBST(CONFIG_OS_DOS)
EL_CHECK_COMPILER_MACROS(CONFIG_OS_RISCOS, [RISCOS], [__riscos__])
AC_SUBST(CONFIG_OS_RISCOS)
EL_CHECK_COMPILER_MACROS(CONFIG_OS_WIN32, [WIN32], [_WIN32 __WIN32__])
AC_SUBST(CONFIG_OS_WIN32)
EL_CHECK_COMPILER_MACROS(CONFIG_OS_OS2, [EMX], [__EMX__])
AC_SUBST(CONFIG_OS_OS2)
test "$CONFIG_OS_OS2" = yes && LDFLAGS=`echo "$LDFLAGS" | sed "s/-Zexe//g"`
AC_MSG_CHECKING([for UNIX])
dnl FIXME: some depend kind of mechanism
if test "$CONFIG_OS_BEOS" = no && \
test "$CONFIG_OS_DOS" = no && \
test "$CONFIG_OS_RISCOS" = no && \
test "$CONFIG_OS_WIN32" = no && \
test "$CONFIG_OS_OS2" = no; then
EL_CONFIG(CONFIG_OS_UNIX, [UNIX])
else
CONFIG_OS_UNIX=no
fi
AC_MSG_RESULT($CONFIG_OS_UNIX)
AC_SUBST(CONFIG_OS_UNIX)
# ===================================================================
# Checks for header files.
# ===================================================================
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_CHECK_HEADERS(wchar.h wctype.h)
AC_CHECK_HEADERS(fcntl.h time.h unistd.h)
AC_CHECK_HEADERS(libgen.h)
AC_CHECK_HEADERS(sigaction.h)
AC_CHECK_HEADERS(arpa/inet.h)
AC_CHECK_HEADERS(netinet/in_systm.h netinet/in_system.h netinet/ip.h)
AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/in6_var.h)
AC_CHECK_HEADERS(ifaddrs.h)
AC_CHECK_HEADERS(sys/cygwin.h io.h)
AC_CHECK_HEADERS(sys/fmutex.h)
AC_CHECK_HEADERS(sys/ioctl.h sys/sockio.h)
AC_CHECK_HEADERS(sys/kd.h)
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_HEADERS(sys/select.h)
AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_HEADERS([net/if.h], [], [],
[[#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> /* <net/if.h> on Mac OS X 10.5.4 needs this */
#endif
]])
AC_CHECK_HEADERS(stdint.h inttypes.h)
AC_CHECK_HEADERS(pwd.h)
AC_CHECK_HEADERS(termios.h)
AC_CHECK_HEADERS(poll.h)
AC_CHECK_HEADERS(stdalign.h)
if test "$CONFIG_OS_DOS" = no; then
AC_CHECK_HEADERS(sys/un.h,
[CONFIG_INTERLINK=yes
EL_CONFIG([CONFIG_INTERLINK], [interlinking])],
[CONFIG_INTERLINK=no])
else
CONFIG_INTERLINK=no
fi
AC_SUBST(CONFIG_INTERLINK)
# ===================================================================
# Checks for typedefs, structures, and compiler characteristics.
# ===================================================================
AC_STRUCT_TM
AC_C_CONST
AC_C_INLINE
AC_MSG_CHECKING([[for C99-conforming inline]])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef __cplusplus
#error noinline
#endif
int add(int change);
static int sum;
inline int
add(int change)
{
sum += change;
return sum;
}
int
sub(int change)
{
return add(-change);
}]])],
[AC_MSG_RESULT([[yes]])
AC_DEFINE([NONSTATIC_INLINE], [inline],
[Define as inline if the compiler lets you declare a function without inline, then define it with inline, and have that definition refer to identifiers with internal linkage. This is allowed by C99 6.7.4p6 and 6.7.4p3 together. Otherwise define as nothing.])],
[AC_MSG_RESULT([[no]])
AC_DEFINE([NONSTATIC_INLINE], [])])
EL_CHECK_CODE(typeof, HAVE_TYPEOF, [], [int a; typeof(a) b;])
AC_SYS_LARGEFILE
AC_TYPE_SIZE_T
AC_TYPE_OFF_T
EL_CHECK_TYPE(ssize_t, int)
EL_CHECK_SYS_TYPE(long long, HAVE_LONG_LONG, [])
EL_CHECK_SYS_TYPE(off_t, HAVE_OFF_T, [])
EL_CHECK_INT_TYPE(int32_t, HAVE_INT32_T)
EL_CHECK_INT_TYPE(uint32_t, HAVE_UINT32_T)
EL_CHECK_INT_TYPE(uint16_t, HAVE_UINT16_T)
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
test "x$HAVE_LONG_LONG" = xyes && AC_CHECK_SIZEOF(long long, 8)
test "x$HAVE_OFF_T" = xyes && AC_CHECK_SIZEOF(off_t, 4)
AC_CHECK_SIZEOF(intptr_t, 8, [#include <stdint.h> ])
# Check for variadic macros
EL_CHECK_CODE([variadic macros], HAVE_VARIADIC_MACROS,
[#include <stdio.h>
#define a(b,c...) printf(b,##c)],
[a("foo");a("%s","bar");a("%s%s","baz","quux");])
# ===================================================================
# Checks for library functions.
# ===================================================================
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_STRFTIME
AC_CHECK_FUNCS(strptime)
AC_CHECK_FUNCS(atoll gethostbyaddr herror strerror)
AC_CHECK_FUNCS(popen uname access chmod alarm timegm mremap)
AC_CHECK_FUNCS(strcasecmp strncasecmp strcasestr strstr strchr strrchr)
AC_CHECK_FUNCS(memmove bcopy stpcpy strdup index isdigit mempcpy memrchr)
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
AC_CHECK_FUNCS(getifaddrs getpwnam inet_aton inet_pton inet_ntop)
AC_CHECK_FUNCS(fflush fsync fseeko ftello sigaction)
AC_CHECK_FUNCS(gettimeofday clock_gettime)
AC_CHECK_FUNCS(setitimer, HAVE_SETITIMER=yes)
AC_CHECK_FUNCS([cygwin_conv_to_full_win32_path])
AC_CHECK_FUNCS(setenv putenv, HAVE_SETENV_OR_PUTENV=yes)
AC_CHECK_FUNCS(unsetenv)
AC_CHECK_FUNCS(getuid, HAVE_GETUID=yes)
AC_CHECK_FUNCS(geteuid, HAVE_GETEUID=yes)
AC_CHECK_FUNCS(wcwidth, HAVE_WCWIDTH=yes)
AC_CHECK_FUNCS(fork)
AC_CHECK_FUNCS(mkstemps)
# These aren't probably needed now, as they are commented in links.h.
# I've no idea about their historical background, but I keep them here
# just in the case they will help later. --pasky
AC_CHECK_FUNCS(setpgid getpgid setpgrp getpgrp)
AC_CHECK_FUNCS(raise, HAVE_RAISE=yes)
AC_CHECK_FUNCS(kill, HAVE_KILL=yes)
AC_CHECK_FUNCS(fpathconf, HAVE_FPATHCONF=yes)
AC_CHECK_FUNCS(poll, HAVE_POLL=yes)
if test x"$HAVE_RAISE" = x; then
if test x"$HAVE_KILL" = x; then
AC_MSG_ERROR([Unable to emulate raise()])
fi
fi
AC_CACHE_CHECK([for sysconf(_SC_PAGE_SIZE)],el_cv_HAVE_SC_PAGE_SIZE,[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
]], [[int page_size = sysconf(_SC_PAGE_SIZE);]])],[el_cv_HAVE_SC_PAGE_SIZE=yes],[el_cv_HAVE_SC_PAGE_SIZE=no])])
if test x"$el_cv_HAVE_SC_PAGE_SIZE" = x"yes"; then
EL_DEFINE(HAVE_SC_PAGE_SIZE, _SC_PAGE_SIZE)
fi
AC_CACHE_CHECK([for C99 vsnprintf],el_cv_HAVE_C99_VSNPRINTF,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
char buf[8];
int bar(char *buf, const char *format, va_list ap)
{
return vsnprintf(buf, 0, format, ap);
}
void foo(const char *format, ...) {
va_list ap;
int len;
va_start(ap, format);
len = bar(buf, format, ap);
va_end(ap);
if ((len != 6) && (len != 7)) exit(1); /* \n -> \r\n */
va_start(ap, format);
len = bar(buf, format, ap);
va_end(ap);
if ((len != 6) && (len != 7)) exit(1);
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
exit(0);
}
int main() { foo("hello\n"); }
]])],[el_cv_HAVE_C99_VSNPRINTF=yes],[el_cv_HAVE_C99_VSNPRINTF=no],[el_cv_HAVE_C99_VSNPRINTF=cross])])
if test x"$el_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
EL_DEFINE(HAVE_C99_VSNPRINTF, [C99 compliant vsnprintf()])
fi
# OpenSSL and Lua frequently need dlopen
AC_CHECK_LIB(dl, dlopen)
# ===================================================================
# Checks for libraries.
# ===================================================================
AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
if test "$cf_result" = no; then
AC_CHECK_LIB(socket, socket)
fi
AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
if test "$cf_result" = no; then
AC_CHECK_LIB(socket, setsockopt)
fi
AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
if test "$cf_result" = no; then
AC_CHECK_LIB(socket, gethostbyname, cf_result=yes, cf_result=no)
if test "$cf_result" = no; then
AC_CHECK_LIB(nsl, gethostbyname)
else
test -z "`echo $LIBS | grep -- -lsocket`" && LIBS="$LIBS -lsocket"
fi
fi
# ===================================================================
# Checks for packaging specific options.
# ===================================================================
AC_ARG_WITH(xterm, [ --with-xterm how to invoke the X terminal emulator],
[ if test "$withval" != no && test "$withval" != yes; then
AC_DEFINE_UNQUOTED(XTERM, "$withval", [How to invoke XTerm])
fi ])
# ===================================================================
# Checks for a libraries, optional even if installed.
# ===================================================================
dnl EL_CHECK_OPTIONAL_LIBRARY(define, name, header, lib, function)
AC_DEFUN([EL_CHECK_OPTIONAL_LIBRARY],
[
AC_MSG_CHECKING([for $2 support])
if test "[$]$1" != no; then
AC_MSG_RESULT(yes)
EL_SAVE_FLAGS
if test -n "$withval" && test -d "$withval"; then
# Be a little more careful when setting
# include and lib directories. This way
# $withval will work when includes are
# there but the library is in the common
# /usr/lib ... Does the right thing when
# looking for gc on Debian.
if test -d "$withval/include"; then
CFLAGS="$CFLAGS -I$withval/include"
CPPFLAGS="$CPPFLAGS -I$withval/include"
else
CFLAGS="$CFLAGS -I$withval"
CPPFLAGS="$CPPFLAGS -I$withval"
fi
if test -d "$withval/lib"; then
LDFLAGS="$LDFLAGS -L$withval/lib"
fi
fi
AC_CHECK_HEADERS([$3], [$1=yes], [$1=no; break;])
if test "[$]$1" = yes; then
AC_CHECK_LIB([$4], [$5], [$1=yes], [$1=no])
fi
if test "[$]$1" = yes; then
EL_CONFIG([$1], [$2])
LIBS="-l$4 $LIBS"
else
if test -n "[$]WITHVAL_$1" &&
test "x[$]WITHVAL_$1" != xno; then
AC_MSG_ERROR([$2 not found])
fi
EL_RESTORE_FLAGS
fi
else
AC_MSG_RESULT(disabled)
fi
])
dnl EL_CONFIG_OPTIONAL_LIBRARY(define, name, header, lib, function, confhelp)
AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
[
if test "x[$]$1" != xno; then $1=yes; fi
WITHVAL_$1=
AC_ARG_WITH([$2], [$6], [WITHVAL_$1="[$]withval"])
if test "x[$]WITHVAL_$1" = xno; then $1=no; fi
if test "x[$]WITHVAL_$1" = xyes; then $1=yes; fi
EL_CHECK_OPTIONAL_LIBRARY([$1], [$2], [$3], [$4], [$5])
EL_LOG_CONFIG([$1], [$2], [])
])
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
[ --without-gpm disable gpm (mouse) support])
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_TERMINFO, terminfo, term.h, tinfo, setupterm,
[ --with-terminfo enable terminfo support])
# ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
# enable automatic decoding of both zlib and gzip headers. This
# feature was added in zlib 1.2.0.2; earlier versions return an error.
# The gzclearerr function was also added in zlib 1.2.0.2, so check for
# that, even though ELinks does not actually call gzclearerr.
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GZIP, zlib, zlib.h, z, gzclearerr,
[ --without-zlib disable zlib support])
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_BZIP2, bzlib, bzlib.h, bz2, BZ2_bzReadOpen,
[ --without-bzlib disable bzlib support])
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_ZSTD, zstd, zstd.h, zstd, ZSTD_createDCtx,
[ --with-zstd enable experimental zstd support])
# ===================================================================
# brotli
# ===================================================================
BROTLI_CFLAGS=
BROTLI_LIBS=
CONFIG_BROTLI=no
enable_brotli=no
AC_ARG_WITH(brotli, [ --with-brotli enable brotli],
[ if test "x$withval" != xno; then enable_brotli=yes; fi ])
if test "$enable_brotli" = no; then
AC_MSG_CHECKING([[for brotli]])
AC_MSG_RESULT([[disabled]])
else
AC_MSG_CHECKING([[for brotli in pkg-config]])
if $PKG_CONFIG $pkg_config_static libbrotlidec; then
BROTLI_CFLAGS=`$PKG_CONFIG $pkg_config_static --cflags libbrotlidec`
BROTLI_LIBS=`$PKG_CONFIG $pkg_config_static --libs libbrotlidec`
LIBS="$BROTLI_LIBS $LIBS"
CONFIG_BROTLI=yes
AC_DEFINE([CONFIG_BROTLI], [1], [Define as 1 to use the libbrotli library.])
AC_MSG_RESULT([[yes]])
else
enable_brotli=no
fi
fi
AC_SUBST(BROTLI_CFLAGS)
AC_SUBST(BROTLI_LIBS)
EL_LOG_CONFIG([CONFIG_BROTLI], [[brotli]], [[$enable_brotli]])
# LZMA disabled by default, because of little usability and compilation problems
# with new xz
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_LZMA, lzma, lzma.h, lzma, lzma_code,
[ --with-lzma enable lzma encoding support])
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_IDN2, idn2, idn2.h, idn2, idn2_lookup_ul,
[ --without-idn2 disable international domain names support])
# ===================================================================
# Check for GSSAPI, optional even if installed.
# ===================================================================
enable_gssapi="no";
AC_ARG_WITH(gssapi, [ --with-gssapi enable GSSAPI support],
[ if test "x$withval" != xno; then enable_gssapi=yes; fi ])
AC_MSG_CHECKING([for GSSAPI])
if test "$enable_gssapi" = "yes"; then
AC_MSG_RESULT(yes)
GSSAPI_CFLAGS=`krb5-config --cflags gssapi`
GSSAPI_LIBS=`krb5-config --libs gssapi`
CFLAGS="$GSSAPI_CFLAGS $CFLAGS"
LIBS="$GSSAPI_LIBS $LIBS"
EL_CONFIG(CONFIG_GSSAPI, [GssApi])
else
AC_MSG_RESULT(no)
fi
AC_SUBST(CONFIG_GSSAPI)
# ===================================================================
# Bookmark and XBEL support
# ===================================================================
EL_SAVE_FLAGS
EL_ARG_ENABLE(CONFIG_BOOKMARKS, bookmarks, [Bookmarks],
[ --disable-bookmarks disable bookmark support])
# Check whether --enable-xbel or --disable-xbel was given.
if test "x${enable_xbel}" != xno; then
AC_CHECK_HEADERS(expat.h, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
if test "$HAVE_LIBEXPAT" = yes; then
AC_CHECK_LIB(expat, XML_ParserCreate, HAVE_LIBEXPAT=yes, HAVE_LIBEXPAT=no)
if test "$HAVE_LIBEXPAT" = yes; then
LIBS="$LIBS -lexpat"
fi
fi
fi
EL_ARG_DEPEND(CONFIG_XBEL_BOOKMARKS, xbel, [CONFIG_BOOKMARKS:yes HAVE_LIBEXPAT:yes],
[XBEL bookmarks],
[ --disable-xbel disable XBEL bookmark support (requires expat)])
if test "$CONFIG_XBEL_BOOKMARKS" != yes; then
EL_RESTORE_FLAGS
fi
# ===================================================================
# Checks for BSD sysmouse
# ===================================================================
HAVE_SYSMOUSE_HEADER="no"
# Either of these header files provides the (same) sysmouse interface
AC_CHECK_HEADERS(sys/consio.h machine/console.h, [HAVE_SYSMOUSE_HEADER="yes"])
# ===================================================================
# Checks for OS/2
# ===================================================================
if test "$CONFIG_OS_OS2" = yes; then
EL_CONFIG_OS_OS2
fi
# ===================================================================
# Checks for Win32
# ===================================================================
if test "$CONFIG_OS_WIN32" = yes; then
EL_CONFIG_OS_WIN32
fi
# ===================================================================
# Check for MuJS
# ===================================================================
AC_ARG_WITH([mujs],
[AS_HELP_STRING([--with-mujs],
[enable MuJS engine])])
CONFIG_MUJS=
CONFIG_LIBCURL=
case "$with_mujs" in
"" | no)
# The user specified --without-mujs.
AC_MSG_CHECKING([for MuJS])
AC_MSG_RESULT([disabled])
CONFIG_MUJS="no"
;;
yes)
;;
*)
;;
esac
if test "x$CONFIG_MUJS" = x; then
AC_MSG_CHECKING([for MuJS in pkg-config])
if $PKG_CONFIG $pkg_config_static --cflags --libs mujs > /dev/null 2>&AS_MESSAGE_LOG_FD; then
DB_LOCALSTORAGE_LIBS="$($PKG_CONFIG $pkg_config_static --libs sqlite3)"
CURL_LIBS="$($PKG_CONFIG $pkg_config_static --libs libcurl)"
MUJS_LIBS="$($PKG_CONFIG $pkg_config_static --libs mujs) $DB_LOCALSTORAGE_LIBS $XMLPLUSPLUS_LIBS $CURL_LIBS"
DB_LOCALSTORAGE_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags sqlite3)"
CURL_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags libcurl)"
MUJS_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags mujs) $DB_LOCALSTORAGE_CFLAGS $XMLPLUSPLUS_CFLAGS $CURL_CFLAGS"
LIBS="$LIBS $MUJS_LIBS"
CPPFLAGS="$CPPFLAGS_X $MUJS_CFLAGS"
CFLAGS="$CFLAGS $MUJS_CFLAGS"
CONFIG_MUJS=yes
CONFIG_LIBCURL=yes
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
# ===================================================================
# Check for QuickJS
# ===================================================================
AC_ARG_WITH([quickjs],
[AS_HELP_STRING([--with-quickjs],
[enable Quickjs engine])])
CONFIG_QUICKJS=
case "$with_quickjs" in
"" | no)
# The user specified --without-quickjs.
AC_MSG_CHECKING([for QuickJS])
AC_MSG_RESULT([disabled])
CONFIG_QUICKJS="no"
;;
yes)
;;
*)
;;
esac
if test "x$CONFIG_QUICKJS" = x; then
AC_MSG_CHECKING([for QuickJS])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
#include <quickjs/quickjs.h>
]], [])],
[CONFIG_QUICKJS=yes
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([not found])]
)
if test "x$CONFIG_QUICKJS" = xyes; then
DB_LOCALSTORAGE_LIBS="$($PKG_CONFIG $pkg_config_static --libs sqlite3)"
CURL_LIBS="$($PKG_CONFIG $pkg_config_static --libs libcurl)"
DB_LOCALSTORAGE_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags sqlite3)"
CURL_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags libcurl)"
CFLAGS="$CFLAGS $DB_LOCALSTORAGE_CFLAGS $XMLPLUSPLUS_CFLAGS $CURL_CFLAGS"
QUICKJS_LIB="/usr/local/lib/quickjs/libquickjs.a"
for p in $(echo "$LIBRARY_PATH" | tr ':' '\n'); do
if test -f "$p/quickjs/libquickjs.a" ; then
QUICKJS_LIB="$p/quickjs/libquickjs.a"
break
fi
done
LIBS="$LIBS $DB_LOCALSTORAGE_LIBS $XMLPLUSPLUS_LIBS $QUICKJS_LIB $CURL_LIBS"
CONFIG_LIBCURL=yes
else
AC_MSG_RESULT([no])
fi
fi
# ===================================================================
# Check for SpiderMonkey, optional even if installed.
# ===================================================================
# This option sets the $with_spidermonkey variable.
AC_ARG_WITH([spidermonkey],
[AS_HELP_STRING([--with-spidermonkey],
[enable SpiderMonkey Mozilla Javascript engine])])
# CONFIG_SPIDERMONKEY is initially blank. We change it to "yes" or "no"
# when we know for sure whether we're going to use SpiderMonkey or not.
# (features.conf is not supposed to define it.)
CONFIG_SPIDERMONKEY=
CONFIG_LIBDOM=
CONFIG_SCRIPTING_SPIDERMONKEY=
EL_SAVE_FLAGS
# ===================================================================
# Optional Spidermonkey-based ECMAScript browser scripting
# ===================================================================
AC_ARG_ENABLE(sm-scripting,
[ --enable-sm-scripting enable ECMAScript browser scripting],
[if test "$enableval" != no; then enableval="yes"; fi
CONFIG_SCRIPTING_SPIDERMONKEY="$enableval";])
case "$with_spidermonkey" in
"" | no)
# The user specified --without-spidermonkey.
# That overrides the other SpiderMonkey options.
AC_MSG_CHECKING([for SpiderMonkey])
AC_MSG_RESULT([disabled])
CONFIG_SPIDERMONKEY="no"
;;
yes)
CONFIG_SPIDERMONKEY="yes"
;;
*)
AC_MSG_WARN([This version of ELinks does not support --with-spidermonkey=DIRECTORY.])
;;
esac
SPIDERMONKEY_FOUND=
if test "x$CONFIG_SPIDERMONKEY" = xyes ||
test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
package=mozjs-128
AC_MSG_CHECKING([for SpiderMonkey (mozjs-128) in pkg-config $package])
if $PKG_CONFIG $pkg_config_static --cflags --libs $package > /dev/null 2>&AS_MESSAGE_LOG_FD; then
DB_LOCALSTORAGE_LIBS="$($PKG_CONFIG $pkg_config_static --libs sqlite3)"
CURL_LIBS="$($PKG_CONFIG $pkg_config_static --libs libcurl)"
SPIDERMONKEY_LIBS="$($PKG_CONFIG $pkg_config_static --libs $package) $DB_LOCALSTORAGE_LIBS $XMLPLUSPLUS_LIBS $CURL_LIBS"
DB_LOCALSTORAGE_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags sqlite3)"
CURL_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags libcurl)"
SPIDERMONKEY_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags $package) $DB_LOCALSTORAGE_CFLAGS $XMLPLUSPLUS_CFLAGS $CURL_CFLAGS"
LIBS="$SPIDERMONKEY_LIBS $LIBS_X"
CPPFLAGS="$CPPFLAGS_X $SPIDERMONKEY_CFLAGS"
SPIDERMONKEY_FOUND=yes
CONFIG_LIBCURL=yes
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
if test -z "$SPIDERMONKEY_FOUND"; then
# Didn't find SpiderMonkey anywhere.
CONFIG_SPIDERMONKEY=no
CONFIG_SCRIPTING_SPIDERMONKEY=no
fi
EL_RESTORE_FLAGS
if test "x$CONFIG_SPIDERMONKEY" = xyes; then
CONFIG_LIBDOM=yes
EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
else
CONFIG_ECMASCRIPT_SMJS=no
fi
EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SMJS CONFIG_MUJS CONFIG_QUICKJS CONFIG_SCRIPTING_SPIDERMONKEY], [ECMAScript (JavaScript)])
AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes &&
test "x$HAVE_JS_TRIGGEROPERATIONCALLBACK" = xyes &&
test "x$HAVE_SETITIMER" = xyes; then
EL_CONFIG(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT, [ECMAScript heartbeat support])
else
CONFIG_ECMASCRIPT_SMJS_HEARTBEAT=no
fi
AC_SUBST(CONFIG_ECMASCRIPT_SMJS_HEARTBEAT)
if test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
EL_CONFIG(CONFIG_SCRIPTING_SPIDERMONKEY, [SpiderMonkey])
else
CONFIG_SCRIPTING_SPIDERMONKEY=no
fi
CXXFLAGS="$CXXFLAGS -fpermissive -Wno-sign-compare"
if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes ||
test "x$CONFIG_SCRIPTING_SPIDERMONKEY" = xyes; then
LIBS="$LIBS $SPIDERMONKEY_LIBS"
EL_CONFIG(CONFIG_LIBCURL, [libcurl])
AC_SUBST(SPIDERMONKEY_LIBS)
AC_SUBST(SPIDERMONKEY_CFLAGS)
AC_SUBST(CONFIG_SPIDERMONKEY)
AC_SUBST(CONFIG_LIBCURL)
CXXFLAGS="$CXXFLAGS $SPIDERMONKEY_CFLAGS"
fi
if test "x$CONFIG_MUJS" = xyes; then
CONFIG_LIBDOM=yes
EL_CONFIG(CONFIG_MUJS, [mujs])
EL_CONFIG(CONFIG_LIBCURL, [libcurl])
AC_SUBST(MUJS_LIBS)
AC_SUBST(MUJS_CFLAGS)
AC_SUBST(CONFIG_MUJS)
AC_SUBST(CONFIG_LIBCURL)
fi
if test "x$CONFIG_QUICKJS" = xyes; then
CONFIG_LIBDOM=yes
EL_CONFIG(CONFIG_QUICKJS, [quickjs])
EL_CONFIG(CONFIG_LIBCURL, [libcurl])
AC_SUBST(CONFIG_QUICKJS)
AC_SUBST(CONFIG_LIBCURL)
fi
# ===================================================================
# Check for libcurl
# ===================================================================
AC_ARG_WITH([libcurl],
[AS_HELP_STRING([--with-libcurl],
[enable curl])])
if test "x$CONFIG_LIBCURL" = x; then
case "$with_libcurl" in
"" | no)
# The user specified --without-libcurl.
AC_MSG_CHECKING([for libcurl])
AC_MSG_RESULT([disabled])
CONFIG_LIBCURL="no"
;;
yes | *)
AC_MSG_CHECKING([for libcurl])
CURL_LIBS="$($PKG_CONFIG $pkg_config_static --libs libcurl)"
CURL_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags libcurl)"
CONFIG_LIBCURL=yes
LIBS="$LIBS $CURL_LIBS"
CFLAGS="$CFLAGS $CURL_CFLAGS"
EL_CONFIG(CONFIG_LIBCURL, [libcurl])
AC_MSG_RESULT([yes])
;;
esac
AC_SUBST(CONFIG_LIBCURL)
fi
# ===================================================================
# Check for libcss
# ===================================================================
AC_ARG_WITH([libcss],
[AS_HELP_STRING([--with-libcss],
[compile with libcss])])
CONFIG_LIBCSS=
case "$with_libcss" in
"" | no)
;;
yes)
CONFIG_LIBDOM=yes
;;
*)
;;
esac
if test "x$CONFIG_LIBDOM" = xyes; then
LIBCSS_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags libcss)"
LIBCSS_LIBS="$($PKG_CONFIG $pkg_config_static --libs libcss)"
LIBS="$LIBCSS_LIBS $LIBS"
CFLAGS="$CFLAGS $LIBCSS_CFLAGS"
CONFIG_LIBCSS=yes
EL_CONFIG(CONFIG_LIBCSS, [libcss])
AC_SUBST(LIBCSS_CFLAGS)
AC_SUBST(LIBCSS_LIBS)
AC_SUBST(CONFIG_LIBCSS)
fi
# ===================================================================
# Check for libdom
# ===================================================================
if test "x$CONFIG_LIBDOM" = xyes; then
LIBDOM_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags libdom)"
LIBDOM_LIBS="$($PKG_CONFIG $pkg_config_static --libs libdom)"
LIBS="$LIBDOM_LIBS $LIBS"
CFLAGS="$CFLAGS $LIBDOM_CFLAGS"
CONFIG_LIBDOM=yes
EL_CONFIG(CONFIG_LIBDOM, [libdom])
AC_SUBST(LIBDOM_CFLAGS)
AC_SUBST(LIBDOM_LIBS)
AC_SUBST(CONFIG_LIBDOM)
fi
# ===================================================================
# Check for libsixel
# ===================================================================
AC_ARG_WITH([libsixel],
[AS_HELP_STRING([--with-libsixel],
[enable sixel graphics])])
CONFIG_LIBSIXEL=
case "$with_libsixel" in
"" | no)
# The user specified --without-libsixel.
AC_MSG_CHECKING([for libsixel])
AC_MSG_RESULT([disabled])
CONFIG_LIBSIXEL="no"
;;
yes)
;;
*)
;;
esac
if test "x$CONFIG_LIBSIXEL" = x; then
LIBSIXEL_CFLAGS="$($PKG_CONFIG $pkg_config_static --cflags libsixel)"
LIBSIXEL_LIBS="$($PKG_CONFIG $pkg_config_static --libs libsixel)"
LIBS="$LIBSIXEL_LIBS $LIBS"
CFLAGS="$CFLAGS $LIBSIXEL_CFLAGS"
CONFIG_LIBSIXEL=yes
EL_CONFIG(CONFIG_LIBSIXEL, [libsixel])
AC_SUBST(CONFIG_LIBSIXEL)
fi
# ===================================================================
# Check for Guile, optional even if installed.
# ===================================================================
enable_guile="no";
AC_ARG_WITH(guile, [ --with-guile enable Guile support],
[ if test "x$withval" != xno; then enable_guile=yes; fi ])
# The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
# GUILE_FLAGS but I really don't want to require people to have Guile in order
# to compile CVS. Also, the macro seems to be really stupid regarding searching
# for Guile in $PATH etc. --pasky
AC_MSG_CHECKING([for Guile])