-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
1801 lines (1607 loc) · 53.2 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 $Id: configure.ac,v 1.20 2010/06/05 19:56:37 fredette Exp $
dnl Copyright (c) 2001, 2003 Matt Fredette
dnl All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl 1. Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl 3. All advertising materials mentioning features or use of this software
dnl must display the following acknowledgement:
dnl This product includes software developed by Matt Fredette.
dnl 4. The name of the author may not be used to endorse or promote products
dnl derived from this software without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
dnl IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
dnl DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
dnl INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
dnl (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
dnl STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
dnl ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
dnl POSSIBILITY OF SUCH DAMAGE.
dnl Checks that we are given a good source directory.
AC_PREREQ([2.68])
m4_include(version.m4)
AC_INIT([tme], [0.12beta34])
AC_CONFIG_SRCDIR([ic/m68k/m68k-impl.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_TARGET
#AC_CONFIG_AUX_DIR([libltdl/config])
#AC_CONFIG_MACRO_DIR([libltdl/m4])
AC_CONFIG_LIBOBJ_DIR([lib])
AM_INIT_AUTOMAKE([subdir-objects])
AM_PROG_CC_C_O
dnl Write configuration out to config.h through config.h.in.
AC_CONFIG_HEADERS([config.h])
dnl Checks for programs.
AC_PROG_AWK
#AC_PROG_CC
AC_PROG_CPP
AC_PROG_YACC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_DEFINE_UNQUOTED([TARGET_ALIAS], ["${host}"], [A string representing our host])
case "${host_os}" in
netbsd*)
AC_DEFINE([TARGET_NETBSD], [1], [Are we running NetBSD?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["N"], [Target prefix])
CPPFLAGS="${CPPFLAGS-} -D_NETBSD_SOURCE"
DEV_TAP_FILENAME='"\"/dev/tap\""'
SETCAP="chmod u+s"
;;
openbsd*)
AC_DEFINE([TARGET_OPENBSD], [1], [Are we running on OpenBSD?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["O"], [Target prefix])
CPPFLAGS="${CPPFLAGS-}"
DEV_TAP_FILENAME='"\"/dev/tun\""'
SETCAP="chmod u+s"
;;
freebsd*)
AC_DEFINE([TARGET_FREEBSD], [1], [Are we running on FreeBSD?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["F"], [Target prefix])
CPPFLAGS="${CPPFLAGS-}"
DEV_TAP_FILENAME='"\"/dev/tap\""'
SETCAP="chmod u+s"
;;
dragonfly*)
AC_DEFINE([TARGET_DRAGONFLY], [1], [Are we running on DragonFlyBSD?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["D"], [Target prefix])
CPPFLAGS="${CPPFLAGS-}"
DEV_TAP_FILENAME='"\"/dev/tap\""'
SETCAP="chmod u+s"
;;
linux*)
AC_DEFINE([TARGET_LINUX], [1], [Are we running on Linux?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["L"], [Target prefix])
CPPFLAGS="${CPPFLAGS-}"
DEV_TAP_FILENAME='"\"/dev/net/tun\""'
SETCAP="chmod u+s"
# SETCAP="setcap cap_sys_nice,cap_net_admin,cap_net_raw+ep"
;;
mingw* | msys*)
AC_DEFINE([TARGET_WIN32], [1], [Are we running WIN32?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["W"], [Target prefix])
CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
CPPFLAGS="${CPPFLAGS} -DNTDDI_VERSION=NTDDI_WINXP -D_WIN32_WINNT=_WIN32_WINNT_WINXP"
WIN32=yes
SETCAP="chmod u+s"
;;
cygwin*)
WIN32=cygwin
SETCAP="chmod u+s"
;;
solaris*)
AC_DEFINE([TARGET_SOLARIS], [1], [Are we running on Solaris?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["S"], [Target prefix])
SETCAP="chmod u+s"
;;
darwin*)
AC_DEFINE([TARGET_DARWIN], [1], [Are we running on Mac OS X?])
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["M"], [Target prefix])
dnl some Mac OS X tendering (we use vararg macros...)
CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
SETCAP="chmod u+s"
have_tap_header="yes"
;;
*)
AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["X"], [Target prefix])
CPPFLAGS="${CPPFLAGS-}"
SETCAP="chmod u+s"
have_tap_header="yes"
;;
esac
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AC_SUBST(DEV_TAP_FILENAME)
AC_SUBST(SETCAP)
AC_SUBST(TGTPFX)
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lm':
#AC_CHECK_LIB([m], [main])
# Libraries required for network address translation
NATLIBS=
OLDLIBS=$LIBS
AC_SEARCH_LIBS([mnl_socket_open], [mnl])
if test "x$ac_cv_search_mnl_socket_open" != "xnone required" && test "$ac_cv_search_mnl_socket_open" != xno; then
NATLIBS="$ac_cv_search_mnl_socket_open ${NATLIBS}"
fi
AC_SEARCH_LIBS([nft_rule_alloc], [nftnl])
if test "x$ac_cv_search_nft_rule_alloc" != "xnone required" && test "x$ac_cv_search_nft_rule_alloc" != xno; then
NATLIBS="$ac_cv_search_nft_rule_alloc ${NATLIBS}"
fi
AC_SEARCH_LIBS([npf_nat_create], [npf])
if test "x$ac_cv_search_npf_nat_create" != "xnone required" && test "x$ac_cv_search_npf_nat_create" != xno; then
NATLIBS="$ac_cv_search_npf_nat_create ${NATLIBS}"
fi
AC_SEARCH_LIBS([bpf_dump], [pcap])
if test "x$ac_cv_search_bpf_dump" != "xnone required" && test "x$ac_cv_search_bpf_dump" != xno; then
NATLIBS="$ac_cv_search_bpf_dump ${NATLIBS}"
fi
LIBS=$OLDLIBS
AC_SUBST(NATLIBS)
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([unistd.h stdio.h memory.h stdarg.h stdbool.h limits.h float.h])
AC_CHECK_HEADERS([sys/ioctl.h sys/sockio.h sys/socketio.h net/if_dl.h ioctls.h netpacket/packet.h ifaddrs.h])
AC_CHECK_HEADERS([byteswap.h sys/endian.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h poll.h sys/socket.h sys/select.h sys/time.h time.h errno.h sys/mman.h sys/uio.h])
AC_CHECK_HEADERS([io.h direct.h \
ctype.h sys/types.h sys/socket.h \
signal.h unistd.h dlfcn.h])
AC_CHECK_HEADERS([linux/netfilter/nf_tables.h libmnl/libmnl.h libnftnl/table.h libnftnl/chain.h libnftnl/rule.h libnftnl/expr.h])
AC_CHECK_HEADERS([pthread_np.h sched.h])
AC_CHECK_HEADERS([sys/param.h sys/linker.h sys/sysctl.h sys/module.h npf.h net/npf_ncode.h pcap/pcap.h], [], [],
[#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
])
AC_CHECK_HEADERS([net/if.h net/if_var.h net/if_types.h net/if_arp.h netinet/in.h netinet/in_var.h netinet/if_ether.h linux/netfilter.h net/pfvar.h net/pf/pfvar.h netinet/ip_compat.h netinet/ip_fil.h netinet/ip_nat.h netinet/ip_proxy.h], [], [],
[#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
#ifdef HAVE_NET_IF_VAR_H
# include <net/if_var.h>
#endif
#ifdef HAVE_NET_IF_TYPES_H
# include <net/if_types.h>
#endif
#ifdef HAVE_NET_IF_ARP_H
# include <net/if_arp.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IN_VAR_H
# include <netinet/in_var.h>
#endif
#ifdef HAVE_NETINET_IP_COMPAT_H
# include <netinet/ip_compat.h>
#endif
#ifdef HAVE_NETINET_IP_FIL_H
# include <netinet/ip_fil.h>
#endif
#ifdef HAVE_NETINET_IP_NAT_H
# include <netinet/ip_nat.h>
#endif
])
AC_CHECK_HEADERS([netinet/in_systm.h netinet/tcp.h windows.h winsock2.h ws2tcpip.h])
AC_CHECK_HEADERS([ \
sys/stat.h \
sys/file.h sys/wait.h \
libgen.h stropts.h \
syslog.h pwd.h grp.h \
sys/sockio.h linux/sockios.h \
linux/types.h sys/poll.h sys/epoll.h err.h \
])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_BIGENDIAN
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
AC_TYPE_LONG_DOUBLE_WIDER
ac_cv_c_long_double=$ac_cv_type_long_double_wider
if test $ac_cv_c_long_double = yes; then
AC_DEFINE([HAVE_LONG_DOUBLE],[1],[Define to 1 if the type `long double' works and has more range or
precision than `double'.])
fi
AC_TYPE_LONG_LONG_INT
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINTPTR_T
AX_CPP_VARARG_MACRO_ISO
AX_CPP_VARARG_MACRO_GCC
AX_TYPE_SOCKLEN_T
AX_EMPTY_ARRAY
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
if test $ac_cv_c_long_double = yes; then
AC_CHECK_SIZEOF(long double)
fi
if test $ac_cv_type_long_long_int = yes; then
AC_CHECK_SIZEOF(long long int)
else
ac_cv_sizeof_long_long_int=$ac_cv_sizeof_long
fi
if test $ac_cv_sizeof_int != 4 && test $ac_cv_sizeof_long != 4; then
AC_MSG_ERROR([can't find a 32-bit type])
fi
if test $ac_cv_sizeof_int != 2 && test $ac_cv_sizeof_short != 2; then
AC_MSG_ERROR([can't find a 16-bit type])
fi
if test $ac_cv_sizeof_long_long_int != 8 && test $ac_cv_sizeof_long != 8; then
AC_MSG_WARN([can't find a 64-bit type])
have_int64=no
else
AC_CHECK_ALIGNOF(64)
AC_CHECK_SHIFTMAX(64)
AC_CHECK_SHIFTSIGNED(64)
have_int64=yes
fi
AC_CHECK_TYPES([__int128], [
have_int128=yes
], [ have_int128=no ])
AC_CHECK_ALIGNOF(32)
AC_CHECK_ALIGNOF(16)
AC_CHECK_SHIFTMAX(8)
AC_CHECK_SHIFTMAX(16)
AC_CHECK_SHIFTMAX(32)
AC_CHECK_SHIFTSIGNED(8)
AC_CHECK_SHIFTSIGNED(16)
AC_CHECK_SHIFTSIGNED(32)
if test "x$cross_compiling" = xyes; then
case ${host} in
i686-w64-mingw32)
ac_cv_float_format_float=IEEE754_SINGLE
ac_cv_float_format_double=IEEE754_DOUBLE
ac_cv_float_format_long_double=IEEE754_EXTENDED80_I387
;;
x86_64-w64-mingw32)
ac_cv_float_format_float=IEEE754_SINGLE
ac_cv_float_format_double=IEEE754_DOUBLE
ac_cv_float_format_long_double=NATIVE
;;
esac
fi
AC_CHECK_FLOAT_FORMAT(float)
AC_CHECK_FLOAT_LIMITS(float, FLT_MAX/FLT_MIN)
AC_CHECK_FLOAT_FORMAT(double)
AC_CHECK_FLOAT_LIMITS(double, DBL_MAX/DBL_MIN)
if test $ac_cv_c_long_double = yes; then
AC_CHECK_FLOAT_FORMAT(long double)
AC_CHECK_FLOAT_LIMITS(long double, LDBL_MAX/LDBL_MIN)
fi
AC_SYS_LARGEFILE
AC_CHECK_MEMBERS([struct stat.st_rdev, struct stat.st_blksize])
AC_CHECK_TYPES([cpuset_t, cpu_set_t],[],[],[
#define _NETBSD_SOURCE
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
])
AC_CHECK_FUNC_LONG(cpuset_create, [
cpuset_t *c;
c = cpuset_create();
], [
#define _NETBSD_SOURCE
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
#include <pthread_np.h>
#endif
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
])
AC_SYS_SOCKADDR_SA_LEN
dnl Checks for library functions and prototypes.
#AC_FUNC_MEMCMP
#AC_FUNC_MALLOC
#AC_FUNC_MMAP
#AC_FUNC_REALLOC
AC_CHECK_FUNCS([clock_gettime memmove memset munmap pow ptsname ptsname_r sqrt strchr strerror strrchr strstr strtoul devname fdevname kldfind isinff])
SOCKET_INCLUDES="
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif
#ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h>
#endif
"
AC_CHECK_HEADERS(
[net/if.h netinet/ip.h resolv.h sys/un.h net/if_utun.h sys/kern_control.h],
,
,
[[${SOCKET_INCLUDES}]]
)
AC_CHECK_TYPES(
[in_addr_t],
,
[AC_DEFINE([in_addr_t], [uint32_t], [Workaround missing in_addr_t])],
[[${SOCKET_INCLUDES}]]
)
AC_CHECK_TYPE(
[struct iphdr],
[AC_DEFINE([HAVE_IPHDR], [1], [struct iphdr needed for IPv6 support])],
,
[[${SOCKET_INCLUDES}]]
)
AC_CHECK_TYPE(
[struct sock_extended_err],
[AC_DEFINE([HAVE_SOCK_EXTENDED_ERR], [1], [struct sock_extended_err needed for extended socket error support])],
,
[[${SOCKET_INCLUDES}]]
)
AC_CHECK_TYPE(
[struct msghdr],
[AC_DEFINE([HAVE_MSGHDR], [1], [struct msghdr needed for extended socket error support])],
,
[[${SOCKET_INCLUDES}]]
)
AC_CHECK_TYPE(
[struct cmsghdr],
[AC_DEFINE([HAVE_CMSGHDR], [1], [struct cmsghdr needed for extended socket error support])],
,
[[${SOCKET_INCLUDES}]]
)
AC_CHECK_TYPE(
[struct in_pktinfo],
[AC_DEFINE([HAVE_IN_PKTINFO], [1], [struct in_pktinfo needed for IP_PKTINFO support])],
,
[[${SOCKET_INCLUDES}]]
)
AC_CHECK_TYPE(
[struct sockaddr_in6],
,
[AC_MSG_ERROR([struct sockaddr_in6 not found, needed for ipv6 transport support.])],
[[${SOCKET_INCLUDES}]]
)
AC_CHECK_DECLS(
[SO_MARK],
,
,
[[${SOCKET_INCLUDES}]]
)
dnl We emulate signals in Windows
AC_CHECK_DECLS(
[SIGHUP],
,
[AC_DEFINE([SIGHUP], [1], [SIGHUP replacement])],
[[
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
]]
)
AC_CHECK_DECLS(
[SIGINT],
,
[AC_DEFINE([SIGINT], [2], [SIGINT replacement])],
[[
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
]]
)
AC_CHECK_DECLS(
[SIGUSR1],
,
[AC_DEFINE([SIGUSR1], [10], [SIGUSR1 replacement])],
[[
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
]]
)
AC_CHECK_DECLS(
[SIGUSR2],
,
[AC_DEFINE([SIGUSR2], [12], [SIGUSR2 replacement])],
[[
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
]]
)
AC_CHECK_DECLS(
[SIGTERM],
,
[AC_DEFINE([SIGTERM], [15], [SIGTERM replacement])],
[[
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
]]
)
AC_FUNC_FORK
AC_CHECK_FUNCS([ \
chroot getpwnam setuid nice system getpid dup dup2 \
getpass syslog openlog mlockall getgrnam setgid \
setgroups stat flock readv writev time \
ctime vsnprintf strdup \
setsid chdir putenv getpeername unlink \
chsize ftruncate execve getpeereid umask access \
epoll_create sendmsg recvmsg
])
AC_CHECK_LIB(
[dl],
[dlopen],
[DL_LIBS="-ldl"]
)
AC_SUBST([DL_LIBS])
AC_CHECK_LIB(
[nsl],
[inet_ntoa],
[SOCKETS_LIBS="${SOCKETS_LIBS} -lnsl"]
)
AC_CHECK_LIB(
[socket],
[socket],
[SOCKETS_LIBS="${SOCKETS_LIBS} -lsocket"]
)
AC_CHECK_LIB(
[resolv],
[gethostbyname],
[SOCKETS_LIBS="${SOCKETS_LIBS} -lresolv"]
)
AC_SUBST([SOCKETS_LIBS])
old_LIBS="${LIBS}"
LIBS="${LIBS} ${SOCKETS_LIBS}"
AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton])
# Windows use stdcall for winsock so we cannot auto detect these
m4_define(
[SOCKET_FUNCS],
[socket recv recvfrom send sendto listen dnl
accept connect bind select gethostbyname inet_ntoa]dnl
)
m4_define(
[SOCKET_OPT_FUNCS],
[setsockopt getsockopt getsockname poll]dnl
)
if test "${WIN32}" = "yes"; then
m4_foreach(
[F],
m4_split(SOCKET_FUNCS SOCKET_OPT_FUNCS),
m4_define([UF], [[m4_join([_], [HAVE], m4_toupper(F))]])
AC_DEFINE([UF], [1], [Win32 builtin])
)
else
AC_CHECK_FUNCS(
SOCKET_FUNCS,
,
[AC_MSG_ERROR([Required library function not found])]
)
AC_CHECK_FUNCS(SOCKET_OPT_FUNCS)
fi
LIBS="${old_LIBS}"
# we assume res_init() always exist, but need to find out *where*...
AC_SEARCH_LIBS(__res_init, resolv bind, ,
AC_SEARCH_LIBS(res_9_init, resolv bind, ,
AC_SEARCH_LIBS(res_init, resolv bind, , )))
AC_REPLACE_FUNCS([basename daemon dirname gettimeofday inet_ntop inet_pton])
AC_REPLACE_FUNCS([mmap munmap mprotect msync mlock munlock])
if test -n "${SP_PLATFORM_WINDOWS}"; then
AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #"
AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
else
AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['/'], [Path separator])
AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["/"], [Path separator])
fi
TAP_WIN_COMPONENT_ID="PRODUCT_TAP_WIN_COMPONENT_ID"
TAP_WIN_MIN_MAJOR="PRODUCT_TAP_WIN_MIN_MAJOR"
TAP_WIN_MIN_MINOR="PRODUCT_TAP_WIN_MIN_MINOR"
AC_DEFINE_UNQUOTED([TAP_WIN_COMPONENT_ID], ["${TAP_WIN_COMPONENT_ID}"], [The tap-windows id])
AC_DEFINE_UNQUOTED([TAP_WIN_MIN_MAJOR], [${TAP_WIN_MIN_MAJOR}], [The tap-windows version number is required for OpenVPN])
AC_DEFINE_UNQUOTED([TAP_WIN_MIN_MINOR], [${TAP_WIN_MIN_MINOR}], [The tap-windows version number is required for OpenVPN])
AC_SUBST([TAP_WIN_COMPONENT_ID])
AC_SUBST([TAP_WIN_MIN_MAJOR])
AC_SUBST([TAP_WIN_MIN_MINOR])
AC_CHECK_FUNC_LONG(__builtin_bswap16, [
unsigned int x;
x = __builtin_bswap16(0x1122);
])
AC_CHECK_FUNC_LONG(__builtin_bswap32, [
unsigned int x;
x = __builtin_bswap32(0x11223344);
])
if test $have_int64 = yes; then
AC_CHECK_FUNC_LONG(__builtin_bswap64, [
unsigned long long int x;
x = __builtin_bswap64(0x1122334455667788);
])
fi
AC_CHECK_FUNC_LONG(bswap16, [
unsigned int x;
x = bswap16(0x1122);
], [
#include <sys/types.h>
#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#endif
])
AC_CHECK_FUNC_LONG(bswap32, [
unsigned int x;
x = bswap32(0x11223344);
], [
#include <sys/types.h>
#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#endif
])
if test $have_int64 = yes; then
AC_CHECK_FUNC_LONG(bswap64, [
unsigned long long int x;
x = bswap64(0x1122334455667788);
], [
#include <sys/types.h>
#ifdef HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#endif
])
fi
AC_CHECK_FUNC_LONG(bswap_16, [
unsigned int x;
x = bswap_16(0x1122);
], [
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
#endif
])
AC_CHECK_FUNC_LONG(bswap_32, [
unsigned int x;
x = bswap_32(0x11223344);
], [
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
#endif
])
if test $have_int64 = yes; then
AC_CHECK_FUNC_LONG(bswap_64, [
unsigned long long int x;
x = bswap_64(0x1122334455667788);
], [
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
#endif
])
fi
AC_CHECK_FUNC_LONG(swap16, [
unsigned int x;
x = swap16(0x1122);
], [
#include <sys/types.h>
])
AC_CHECK_FUNC_LONG(swap32, [
unsigned int x;
x = swap32(0x11223344);
], [
#include <sys/types.h>
])
if test $have_int64 = yes; then
AC_CHECK_FUNC_LONG(swap64, [
unsigned long long int x;
x = swap64(0x1122334455667788);
], [
#include <sys/types.h>
])
fi
dnl Checks for various library functions
AC_SEARCH_LIBS([pthread_mutex_timedlock], [pthread], [
AC_DEFINE(HAVE_PTHREAD_MUTEX_TIMEDLOCK, [], [Define if you have pthread_mutex_timedlock.])
])
AC_SEARCH_LIBS([pthread_rwlock_timedrdlock], [pthread], [
AC_DEFINE(HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK, [], [Define if you have pthread_rwlock_timedlock.])
])
AC_SEARCH_LIBS([pthread_setaffinity_np], [pthread], [
AC_DEFINE(HAVE_PTHREAD_SETAFFINITY_NP, [], [Define if you have pthread_setaffinity_np.])
])
AC_SEARCH_LIBS([pthread_setschedparam], [pthread], [
AC_DEFINE(HAVE_PTHREAD_SETSCHEDPARAM, [], [Define if you have pthread_setschedparam.])
])
dnl Checks for perl.
AC_PATH_PROGS(PERL, perl4.036 perl4 perl perl5, no)
AC_SUBST(PERL)
dnl Checks for AF_LINK.
AC_MSG_CHECKING([for AF_LINK support])
AC_EGREP_CPP(_tme_has_af_link,
[
#include <sys/socket.h>
#ifdef AF_LINK
_tme_has_af_link
#endif
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_AF_LINK, [], [Define if you have AF_LINK.])
], [
AC_MSG_RESULT(no)
])
dnl Checks for AF_PACKET.
AC_MSG_CHECKING([for AF_PACKET support])
AC_EGREP_CPP(_tme_has_af_packet,
[
#include <sys/socket.h>
#ifdef AF_PACKET
_tme_has_af_packet
#endif
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_AF_PACKET, [], [Define if you have AF_PACKET.])
], [
AC_MSG_RESULT(no)
])
dnl Start the list of host support.
TME_HOSTS=
AC_ARG_VAR([TAP_CFLAGS], [C compiler flags for tap])
old_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} ${TAP_CFLAGS}"
AC_CHECK_HEADERS(
[ \
net/if_tun.h net/tun/if_tun.h \
linux/if_tun.h \
tap-windows.h \
],
[have_tap_header="yes"]
)
AC_CHECK_DECLS(
[TUNSETPERSIST],
[AC_DEFINE([ENABLE_FEATURE_TUN_PERSIST], [1], [We have persist tun capability])],
,
[[
#ifdef HAVE_LINUX_IF_TUN_H
#include <linux/if_tun.h>
#endif
]]
)
CFLAGS="${old_CFLAGS}"
if test "x${have_tap_header}" = xyes; then
TME_HOSTS="${TME_HOSTS} openvpn"
AC_DEFINE([OPENVPN_VERSION_RESOURCE], [PRODUCT_VERSION_RESOURCE], [Version in windows resource format])
fi
have_tap_header=
AC_CHECK_HEADERS([linux/if_tun.h net/if_tap.h net/tap/if_tap.h net/if_tun.h],
[have_tap_header="yes"])
if test "x${have_tap_header}" = xyes; then
TME_HOSTS="${TME_HOSTS} tun"
fi
AC_CHECK_HEADERS([linux/filter.h net/bpf.h])
dnl Checks for Ethernet.
AC_MSG_CHECKING([for raw Ethernet access method])
AC_EGREP_CPP(found_BPFVERSION,
[
#ifdef HAVE_LINUX_FILTER_H
#include <linux/filter.h>
#elif HAVE_NET_BPF_H
#include <net/bpf.h>
#endif
#if BPF_MAJOR_VERSION == 1 && BPF_MINOR_VERSION >= 1
found_BPFVERSION
#endif
],
[TME_HOSTS="${TME_HOSTS} bsd"])
if test "x${TME_HOSTS}" != x; then
TME_HOSTS="eth ${TME_HOSTS}"
fi
AC_MSG_RESULT($TME_HOSTS)
TME_HOSTS="${TME_HOSTS} posix"
AC_SYS_POSIX_TERMIOS
AM_CONDITIONAL([USING_TERMIOS], [test "x${ac_cv_sys_posix_termios}" = xyes])
AC_MSG_CHECKING([for available network address translation methods])
# specify whether built-in NAT support should be enabled & with what NAT methods
AC_ARG_ENABLE(nat,
[ --enable-nat=NATs Enable built-in NAT support utilizing the given NAT methods (compiled-in order of usage by platform availability: 'nft','npf','pf','ipf'). Defaults to 'yes', any available. Turn off NAT with 'no' or --disable-nat.], [tme_nat_types=${enableval}], [enable_nat=yes])
if test "x${enable_nat}" = xyes; then
tme_nat_types="nft npf pf"
fi
if test "x${enable_nat}" = xno; then
tme_nat_types=
fi
NATINC=
for tme_nat_type in ${tme_nat_types}; do
case "x${tme_nat_type}" in
xnft) NATINC="${NATINC} -DTME_NAT_NFT" ;;
xnpf) NATINC="${NATINC} -DTME_NAT_NPF" ;;
xpf) NATINC="${NATINC} -DTME_NAT_PFV" ;;
xipf) NATINC="${NATINC} -DTME_NAT_IPF" ;;
esac
done
AC_MSG_RESULT($tme_nat_types)
AC_SUBST(NATINC)
dnl Checks for X11.
AC_PATH_XTRA
AM_CONDITIONAL([USING_X], [test "x${no_x}" = x])
dnl Checks for GLIB.
AM_PATH_GLIB_2_0([], have_glib=yes, have_glib=no)
if test "x$have_glib" = xyes; then
AC_DEFINE(HAVE_GLIB, [], [Define if you are compiling with GLIB.])
fi
dnl Checks for GTK.
AM_PATH_GTK_3_0([], have_gtk=yes, have_gtk=no)
if test "x$have_gtk" = xyes; then
TME_HOSTS="${TME_HOSTS} gtk"
fi
dnl Characterize any graphics displays and remember the areas of
dnl the smallest and largest screens.
TME_FB_XLAT_DST=
area_smallest=0
area_largest=0
# if --with-tme-host-displays is given, characterize those given displays:
AC_ARG_WITH(tme-host-displays,
[ --with-tme-host-displays=DISPLAYS support host displays with these display formats])
for dst_key in ${with_tme_host_displays}; do
dnl Make brackets safe to use.
changequote(<<, >>)dnl
this_width=`echo ${dst_key} | sed -e 's/^\([0-9][0-9]*\)x\([0-9][0-9]*\)\(.*\)$/\1/'`
this_height=`echo ${dst_key} | sed -e 's/^\([0-9][0-9]*\)x\([0-9][0-9]*\)\(.*\)$/\2/'`
dst_key=`echo ${dst_key} | sed -e 's/^\([0-9][0-9]*\)x\([0-9][0-9]*\)\(.*\)$/\3/'`
this_area=`expr ${this_width} \* ${this_height}`
if test ${area_smallest} = 0 || test `expr ${this_area} \< ${area_smallest}` = 1; then
area_smallest=${this_area}
fi
if test `expr ${this_area} \> ${area_largest}` = 1; then
area_largest=${this_area}
fi
# add in this destination display key:
if echo " ${TME_FB_XLAT_DST} " | grep " ${dst_key} " > /dev/null 2>&1; then :; else
TME_FB_XLAT_DST="${TME_FB_XLAT_DST} ${dst_key}"
fi
dnl Make brackets the quote characters again.
changequote([, ])dnl
done
# if DISPLAY is set and xdpyinfo appears to work, characterize this X display:
if test "x${DISPLAY}" != x && xdpyinfo >/dev/null 2>&1; then
AC_MSG_CHECKING(characteristics of X display ${DISPLAY})
dnl Make brackets safe to use.
changequote(<<, >>)dnl
# get the format this display uses for bitmaps:
bitmap_info=`xdpyinfo | grep 'bitmap unit' | sed -e 's/bitmap unit, *bit order, *padding: *\(.*\)$/\1/'`
bitmap_order=`echo ${bitmap_info} | sed -e 's/\([0-9][0-9]*\), *\([LM]\)SBFirst, *\([0-9][0-9]*\).*/\2/'`
bitmap_pad=`echo ${bitmap_info} | sed -e 's/\([0-9][0-9]*\), *\([LM]\)SBFirst, *\([0-9][0-9]*\).*/\3/'`
bitmap_order=`echo ${bitmap_order} | tr A-Z a-z`
# get the format this display uses for images at its default depth. we
# assume that the root window is at the default depth:
pixmap_order=`xdpyinfo | grep 'image byte order'`
pixmap_order=`echo ${pixmap_order} | sed -e 's/.*image byte order: *\([LM]\)SBFirst.*/\1/' | tr A-Z a-z`
pixmap_depth=`xwininfo -root | grep 'Depth:'`
pixmap_depth=`echo ${pixmap_depth} | sed -e 's/.*Depth: *\([0-9][0-9]*\).*/\1/'`
pixmap_infos=`xdpyinfo | grep bits_per_pixel | tr '\n' %`
save_IFS=$IFS
IFS=%
for pixmap_info in $pixmap_infos; do
IFS=$save_IFS
if test "x${pixmap_info}" = x; then continue; fi
this_pixmap_depth=`echo ${pixmap_info} | sed -e 's/.*depth \([0-9][0-9]*\), *bits_per_pixel \([0-9][0-9]*\), *scanline_pad \([0-9][0-9]*\).*/\1/'`
this_pixmap_bipp=`echo ${pixmap_info} | sed -e 's/.*depth \([0-9][0-9]*\), *bits_per_pixel \([0-9][0-9]*\), *scanline_pad \([0-9][0-9]*\).*/\2/'`
this_pixmap_pad=`echo ${pixmap_info} | sed -e 's/.*depth \([0-9][0-9]*\), *bits_per_pixel \([0-9][0-9]*\), *scanline_pad \([0-9][0-9]*\).*/\3/'`
if test "x${this_pixmap_depth}" = "x${pixmap_depth}"; then
pixmap_bipp=${this_pixmap_bipp}
pixmap_pad=${this_pixmap_pad}
break
fi
done
IFS=$save_IFS
# if this display's greatest depth is one, we use its
# bitmap format:
if test "x${pixmap_bipp}" = x; then
pixmap_bipp=1
pixmap_pad=${bitmap_pad}
# our translation functions can't handle the case when the bitmap
# bit order is different from the image byte order - doing so
# requires dealing with the bitmap unit size. since this
# situation is rare, just bail:
if test ${bitmap_order} != ${pixmap_order}; then
changequote([, ])dnl
AC_MSG_WARN([the X display ${DISPLAY} is monochrome and needs bitmaps with a bit order that the generic code doesn't support])
changequote(<<, >>)dnl
pixmap_bipp=
fi
fi
# if this display seems usable:
if test "x${pixmap_bipp}" != x; then
# check the dimensions of all screens on this display:
dimensions=`xdpyinfo | grep dimensions | tr '\n' %`
save_IFS=$IFS
IFS=%
for dimension in $dimensions; do
IFS=$save_IFS
if test "x${dimension}" = x; then continue; fi
this_width=`echo ${dimension} | sed -e 's/.*dimensions: *\([0-9][0-9]*\)x\([0-9][0-9]*\).*/\1/'`
this_height=`echo ${dimension} | sed -e 's/.*dimensions: *\([0-9][0-9]*\)x\([0-9][0-9]*\).*/\2/'`
this_area=`expr ${this_width} \* ${this_height}`
if test ${area_smallest} = 0 || test `expr ${this_area} \< ${area_smallest}` = 1; then
area_smallest=${this_area}
fi
if test `expr ${this_area} \> ${area_largest}` = 1; then
area_largest=${this_area}
fi
done
IFS=$save_IFS
# assume an unknown set of masks and an unknown mapping type:
dst_masks=_r0x0_g0x0_b0x0
dst_map=
value_visual=", unknown visual"
# if the depth is greater than one:
if test "x${pixmap_depth}" != 1; then
# we assume that the root window uses the default visual:
visual=`xwininfo -root | grep 'Visual Class:' | sed -e 's/^ *Visual Class: *\([A-Za-z][A-Za-z]*\).*$/\1/'`
# get any primary masks for this visual:
case "x${visual}" in
xDirectColor | xTrueColor)
dst_masks=`xdpyinfo | $EGREP '(visual id|class|blue masks):' | $EGREP -C1 $visual | grep 'blue masks' | head -1`
dst_masks=`echo ${dst_masks} | sed -e 's/^.*blue masks: *\(.*\)/\1/'`
value_visual=", rgb masks ${dst_masks}"
dst_masks=`echo ${dst_masks} | sed -e 's/^/_r/' -e 's/, /_g/' -e 's/, /_b/'`
;;
xStaticGray | xGrayScale | xStaticColor | xPseudoColor)
dst_masks=
value_visual=", no subfields"
;;
*) ;;
esac
# get the mapping type for this visual:
case "x${visual}" in
xStaticGray | xStaticColor | xPseudoColor)
dst_map="ml"
;;
xDirectColor)
dst_map="mi"
value_visual="${value_visual}, indexed"