-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
1268 lines (1107 loc) · 37 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 Copyright (c) 2013-2024 Ruben Agin
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.71])
AC_INIT([tme],[0.12rc12])
AC_CONFIG_SRCDIR([ic/m68k/m68k-impl.h])
AC_CONFIG_MACRO_DIRS([m4])
AC_CANONICAL_TARGET
#AC_CONFIG_AUX_DIR([libltdl/config])
#AC_CONFIG_MACRO_DIR([libltdl/m4])
AM_INIT_AUTOMAKE([subdir-objects])
AM_EXTRA_RECURSIVE_TARGETS([modules])
AC_PROG_CC
AM_PROG_CC_C_O
AC_PREFIX_PROGRAM([tmesh])
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_CPP
AC_PROG_YACC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_EGREP
AC_PROG_LN_S
TME_HOST_TYPES="gtk rfb sdl tun bsd openvpn"
AC_SUBST(TME_HOST_TYPES)
AC_ARG_ENABLE(hosts,
[ --enable-hosts=hosttypes enable hosts (default="$TME_HOST_TYPES")],
[tme_enable_hosts=${enableval}], [enable_hosts=yes])
if test "x${enable_hosts}" = xyes; then
tme_enable_hosts=$TME_HOST_TYPES
fi
for tme_host_type in ${tme_enable_hosts}; do
eval enable_${tme_host_type}=yes
done
AC_CHECK_DEFINE(__EMSCRIPTEN__, [
CC=$(basename -s .bat $CC)
host=$(echo "$host" | sed "s/$host_os/emscripten/")
host_os=emscripten
],
[host_type=$host_os])
AM_CONDITIONAL([HAVE_EMSCRIPTEN], [test "${host_os}" = emscripten])
AM_CONDITIONAL([USE_NODEFS], [test "${enable_nodefs}" = yes])
AC_CHECK_PROG([CYGPATH_M], [cygpath], [cygpath -m], [echo])
AC_CHECK_PROG([CYGPATH_U], [cygpath], [cygpath -u], [echo])
if test "${host_os}" = emscripten; then
ROOT_DIR="\$(abs_top_builddir)" # /
EXEEXT=.html
else
ROOT_DIR=$(${CYGPATH_M} /)
fi
TME_DIR="\`\${CYGPATH_U} \${libdir}\`"
AC_SUBST(TME_DIR)
AC_SUBST(ROOT_DIR)
dnl Configure for libtool.
LT_PREREQ([2.4])
LT_CONFIG_LTDL_DIR([libltdl])
LT_INIT([dlopen,win32-dll])
LT_LANG([Windows Resource])
LTDL_INIT([installable recursive])
CPPFLAGS="${CPPFLAGS-} ${LTDLINCL}" # -DLT_DEBUG_LOADERS"
case "${host_os}" in
netbsd*)
CPPFLAGS="${CPPFLAGS-} -D_NETBSD_SOURCE"
DEV_TAP_FILENAME='"\"/dev/tap\""'
SETCAP="chmod u+s"
;;
openbsd*)
CPPFLAGS="${CPPFLAGS-}"
DEV_TAP_FILENAME='"\"/dev/tun\""'
SETCAP="chmod u+s"
;;
freebsd*)
CPPFLAGS="${CPPFLAGS-}"
DEV_TAP_FILENAME='"\"/dev/tap\""'
SETCAP="chmod u+s"
;;
dragonfly*)
CPPFLAGS="${CPPFLAGS-}"
DEV_TAP_FILENAME='"\"/dev/tap\""'
SETCAP="chmod u+s"
;;
linux*)
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_UNQUOTED([TME_MODULE_PATH_VAR], ["PKG_CONFIG_SYSTEM_LIBRARY_PATH"], [Use pkgconf environment variable to determine lib path in MSYS2.])
CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
CPPFLAGS="${CPPFLAGS} -DNTDDI_VERSION=NTDDI_WINXP -D_WIN32_WINNT=_WIN32_WINNT_WINXP"
WIN32=yes
SETCAP="chmod u+s"
host_type=
;;
cygwin*)
WIN32=cygwin
SETCAP="chmod u+s"
host_type=
;;
solaris*)
SETCAP="chmod u+s"
;;
darwin*)
dnl some Mac OS X tendering (we use vararg macros...)
CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
SETCAP="chmod u+s"
;;
*)
CPPFLAGS="${CPPFLAGS-}"
SETCAP="chmod u+s"
host_type=
;;
esac
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AC_SUBST(DEV_TAP_FILENAME)
AC_SUBST(SETCAP)
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}"
dnl Checks for GLIB.
PKG_CHECK_MODULES([GLIB], [glib-2.0], [AC_DEFINE([HAVE_GLIB], [], [Defined if GLIB 2.0 is found.])], [have_glib=no])
AM_CONDITIONAL([HAVE_GLIB], [test "x${have_glib}" != xno])
dnl Checks for display type support
PKG_CHECK_MODULES([GTK], [gtk4], [have_gtk=$enable_gtk], [
PKG_CHECK_MODULES([GTK], [gtk+-3.0], [have_gtk=$enable_gtk], [have_gtk=no])
])
PKG_CHECK_MODULES([SDL], [sdl2], [have_sdl=$enable_sdl], [have_sdl=no])
AX_CHECK_COMPILE_FLAG(-sUSE_SDL=2, [have_sdl=$enable_sdl])
AX_APPEND_COMPILE_FLAGS(-sUSE_SDL=2, SDL_CFLAGS)
AX_APPEND_LINK_FLAGS(-sUSE_SDL=2, SDL_LIBS)
AM_CONDITIONAL([HAVE_SDL], [test "x${have_sdl}" = xyes])
PKG_CHECK_MODULES([RFB], [libvncclient libvncserver], [have_rfb=$enable_rfb], [have_rfb=no])
if test "x${have_tap_header}" = xyes || test "x${WIN32}" != x; then
have_openvpn=$enable_openvpn
AC_DEFINE([HAVE_OPENVPN], [], [Defined if openvpn is found.])
fi
AC_CHECK_HEADERS([linux/if_tun.h net/if_tap.h net/tap/if_tap.h net/if_tun.h],
[have_tun=$enable_tun])
AC_CHECK_HEADERS([linux/filter.h net/bpf.h])
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
],
[have_bsd=$enable_bsd])
for tme_host in $TME_HOST_TYPES; do
if eval test "x\$have_${tme_host}" = xyes; then
TME_HOST=`echo ${tme_host} | tr '[a-z]' '[A-Z]'`
TME_HOST_CFLAGS="\$(${TME_HOST}_CFLAGS) ${TME_HOST_CFLAGS}"
TME_HOST_LIBS="-dlopen \$(tme_host_${tme_host})/tme_host_${tme_host}.la ${TME_HOST_LIBS}"
TME_HOST_DIRS="\$(tme_host_${tme_host}) ${TME_HOST_DIRS}"
fi
done
dnl Checks for host support.
AC_MSG_CHECKING([for enabled host types])
dnl The list of ethernet host support is finished.
AC_SUBST(TME_HOST_CFLAGS)
AC_SUBST(TME_HOST_LIBS)
AC_SUBST(TME_HOST_DIRS)
AC_MSG_RESULT($TME_HOST_DIRS)
# 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_CHECK_HEADERS([unistd.h stdio.h memory.h stdarg.h stdbool.h limits.h float.h curses.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([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([X11/keysym.h rfb/keysym.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([netinet/in_systm.h netinet/tcp.h windows.h winsock2.h ws2tcpip.h])
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
])
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
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
AX_TYPE_SOCKLEN_T
AX_EMPTY_ARRAY
dnl Checks for library functions and prototypes.
#AC_FUNC_MEMCMP
#AC_FUNC_MALLOC
#AC_FUNC_MMAP
#AC_FUNC_REALLOC
AC_CHECK_FUNCS([gmtime_r gmtime_s gmtime clock_gettime memmove memset munmap pow ptsname ptsname_r sqrt strchr strerror strrchr strstr strtoul devname fdevname kldfind isinff])
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 Invoke compatibility library in LIBOBJDIR
AC_CHECK_FUNCS([basename daemon dirname gettimeofday inet_ntop inet_pton])
AC_CHECK_FUNCS([mmap munmap mprotect msync mlock munlock])
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 display host support.
TME_FB_XLAT_DST="d32b32s0p32olml_r0xffff0000_g0xff00ff00_b0xff0000ff d24b32s0p32olml_r0xff0000_g0xff00_b0xff"
# 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],
[ TME_FB_XLAT_DST=$withval $TME_FB_XLAT_DST], [])
AC_SUBST(TME_FB_XLAT_DST)
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=no])
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)
AC_MSG_CHECKING([for available threading models])
# specify whether preemptive thread support should be enabled & with what thread models
AC_ARG_ENABLE(threads,
[ --enable-threads=THRs Enable preemptive thread support utilizing the given threading models (compiled-in order of usage by platform availability: 'pthreads (or posix)','glib'). Defaults to 'no'; this will use a singled thread with setjmp/longjmp or fibers on platforms that support them. Turn on threads with --enable-threads=<thr>; no value given is 'yes' which defaults to best threading model for platform.], [tme_thread_types=${enableval}], [enable_threads=no])
if test "x${enable_threads}" = xyes; then
dnl Make brackets safe to use.
changequote(<<, >>)dnl
dnl set the default threads based on platform
case "${host_os}" in
mingw* | msys* | cygwin*)
tme_thread_types=glib
;;
*)
tme_thread_types=pthreads
;;
esac
dnl Make brackets the quote characters again.
changequote([, ])dnl
recode=no
fi
if test "x${enable_threads}" = xno; then
dnl Make brackets safe to use.
changequote(<<, >>)dnl
dnl set the default threads based on platform
case "${host_os}" in
emscripten)
recode=no
;;
*)
recode=i686
;;
esac
dnl Make brackets the quote characters again.
changequote([, ])dnl
tme_thread_types=fiber
fi
for tme_thread_type in ${tme_thread_types}; do
case "x${tme_thread_type}" in
xpthreads| xposix) CPPFLAGS="${CPPFLAGS-} -DTME_THREADS_POSIX"
CFLAGS="${CFLAGS-} -pthread"
LDFLAGS="${LDFLAGS-} -pthread"
;;
xglib) CPPFLAGS="${CPPFLAGS-} -DTME_THREADS_GLIB -DUSE_GLIB_TIME ${GLIB_CFLAGS}"
LDFLAGS="${LDFLAGS-} ${GLIB_LIBS}"
;;
xfiber) CPPFLAGS="${CPPFLAGS-} -DTME_THREADS_FIBER"
;;
esac
done
CPPFLAGS="${CPPFLAGS-} -D_GNU_SOURCE"
AM_CONDITIONAL([THREADS_POSIX], [test "x${tme_thread_types}" = xpthreads || test "x${tme_thread_types}" = xposix])
AM_CONDITIONAL([THREADS_GLIB], [test "x${tme_thread_type}" = xglib])
AM_CONDITIONAL([THREADS_FIBER], [test "x${tme_thread_types}" = xfiber])
AC_MSG_RESULT($tme_thread_types)
dnl Configures for the system(s) to emulate.
bus_size_max=64
recode_size_guest_max=64
TME_FB_XLAT_SRC="1152x900d1b1s0p32om 1152x900d8b8s0p32ommi8 1152x900d1b1s0p32omccmi8"
AC_SUBST(TME_FB_XLAT_SRC)
dnl Checks for X11.
AC_PATH_XTRA
AX_PERL_MODULE_VERSION([X11::Protocol 0.56],[],[no_x=yes])
AM_CONDITIONAL([USING_X], [test "x${no_x}" = x])
dnl Configure recode.
dnl Make brackets safe to use.
changequote(<<, >>)dnl
dnl Make brackets the quote characters again.
changequote([, ])dnl
AC_ARG_ENABLE(recode,
[ --enable-recode enable recode (dynamic binary translation) (default=if host supports)],
[ ], [enable_recode=$recode])
AC_MSG_CHECKING([for host recode support])
dnl Make brackets safe to use.
changequote(<<, >>)dnl
# get the host maximum guest size:
case "${host_cpu}" in
i[3456789]86)
recode_hosts="mmap x86"
recode_size_guest_max_host=64
;;
x86_64)
recode_hosts="mmap x86"
recode_size_guest_max_host=128
;;
*)
recode_hosts=
recode_size_guest_max_host=1 ;;
esac
dnl Make brackets the quote characters again.
changequote([, ])dnl
keep_recode=$enable_recode
for tme_recode_type in ${enable_recode}; do
if test "x${host_cpu}" = "x${tme_recode_type}"; then
keep_recode=yes
break
fi
done
if test "x${keep_recode}" != xyes; then
recode_hosts=
recode_size_guest_max=1
fi
if test "x${recode_hosts}" = x; then
AC_MSG_RESULT([no])
if test "x${enable_recode}" = xrequired; then
AC_MSG_ERROR([recode required but not supported on ${host}])
fi
else
if test "x${recode_size_guest_max_host}" = x; then
AC_MSG_ERROR([internal error - no maximum recode guest size for ${host_cpu}])
fi
if test `expr ${recode_size_guest_max} \< ${recode_size_guest_max_host}` = 1; then
recode_size_guest_max=$recode_size_guest_max_host
fi
AC_MSG_RESULT([up to ${recode_size_guest_max}-bit guests using ${recode_hosts}])
# get the host maximum guest size:
changequote(<<, >>)dnl
case "${host_cpu}" in
i[3456789]86)
bus_size_max_host=32
;;
x86_64)
bus_size_max_host=64
;;
*)
bus_size_max_host=
;;
esac
changequote([, ])dnl
dnl Configure miscellaneous host support.
AC_MSG_CHECKING([for host recode bus size])
if test `expr ${bus_size_max} \< ${bus_size_max_host}` = 1; then
bus_size_max=$bus_size_max_host
fi
AC_MSG_RESULT([using ${bus_size_max}-bit bus for guests using ${host_cpu}])
fi
dnl Configure miscellaneous host support.
AC_MSG_CHECKING([for host miscellaneous support])
changequote(<<, >>)dnl
case "${host_cpu}" in
i[3456789]86 | x86_64) misc_hosts="x86" ;;
*) misc_hosts= ;;
esac
changequote([, ])dnl
if test "${host_os}" = emscripten; then
misc_hosts=
fi
AC_MSG_RESULT([${misc_hosts}])
if test "x${misc_hosts}" = "xx86"; then
AC_CHECK_FUNC_LONG(__rdtsc, [
unsigned long long int x;
// _mm_lfence(); // optionally wait for earlier insns to retire before reading the clock
x = __rdtsc();
// _mm_lfence(); // optionally block later instructions until rdtsc retires
],[
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <x86intrin.h>
#endif
])
fi
dnl Configure debugging and/or warnings.
AC_MSG_CHECKING([for gcc --version >= 4.8])
AC_EGREP_CPP(_gcc_has_Og,
[
#if (__GNUC__ > 3 && __GNUC_MINOR__ > 7) || __GNUC__ > 4
_gcc_has_Og
#endif
], [
AC_MSG_RESULT(yes)
have_Og=yes
], [ AC_MSG_RESULT(no) ])
AC_MSG_CHECKING([for clang])
AC_EGREP_CPP(_gcc_is_clang,
[
#if __clang__
_gcc_is_clang
#endif
], [
AC_MSG_RESULT(yes)
have_clang=yes
], [ AC_MSG_RESULT(no) ])
AC_ARG_ENABLE(debug,
[ --enable-debug compile debuggable libraries and programs (default=don't)],
[ ], [enable_debug=no])
if test "x${enable_debug}" = "xyes"; then
CPPFLAGS="${CPPFLAGS-} -DENABLE_DEBUG -DTME_NO_DEBUG_LOCKS -D_TME_SPARC_STATS -DGTK_DISABLE_SINGLE_INCLUDES -DNDEBUG" # -DTME_RECODE_DEBUG
if test "x${have_Og}" = xyes; then
CFLAGS="${CFLAGS-} -Og"
CXXFLAGS="${CXXFLAGS-} -g3 -Og"
fi
else
CPPFLAGS="${CPPFLAGS-} -DTME_NO_LOG -DTME_NO_DEBUG_LOCKS -DTME_NO_AUDIT_ATOMICS -DNDEBUG"
fi
AC_ARG_ENABLE(warnings,
[ --disable-warnings don't compile with warnings turned on (default=don't)],
[ ], [enable_warnings=no])
if test "x${enable_warnings}" = "xyes" -a "x${GCC}" = "xyes"; then
CFLAGS="${CFLAGS-} -Wno-unused -Wno-sign-compare -Wundef -Wall -Wextra"
CXXFLAGS="${CXXFLAGS-} -W"
else
CFLAGS="${CFLAGS-} -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable"
if test "x${have_clang}" = xyes; then
CFLAGS="${CFLAGS-} -Wno-tautological-compare -Wno-sometimes-uninitialized \
-Wno-sign-compare -Wno-incompatible-pointer-types \
-Wno-implicit-function-declaration -Wno-int-conversion \
-Wno-cpp -Wno-compound-token-split-by-macro -fbracket-depth=1024"
fi
if test "x${have_Og}" = xyes; then
CFLAGS="${CFLAGS-} -Wno-unused-but-set-variable -Wno-array-bounds -Wno-type-limits -Wno-incompatible-pointer-types \
-Wno-discarded-qualifiers -Wno-implicit-function-declaration -Wno-cpp -fno-strict-aliasing"
fi
CXXFLAGS="${CXXFLAGS-} -W"
fi
if test "x${enable_shared}" = "xno" || test "x${host_cpu}" = "xi686"; then
lto=${GCC}
else
lto=no
fi
AC_ARG_ENABLE(lto,
[ --enable-lto compile with link-time optimizations (default=supported)],
[ ],[ enable_lto=$lto ])
if test "x${enable_lto}" = "xyes"; then
CFLAGS="${CFLAGS-} -flto"
LDFLAGS="${LDFLAGS-} -flto"
fi
dnl Some code isn't alias-clean.
CFLAGS_NO_STRICT_ALIASING=
if test "x${GCC}" = "xyes"; then
CFLAGS_NO_STRICT_ALIASING=" -fno-strict-aliasing"
fi
AC_SUBST(CFLAGS_NO_STRICT_ALIASING)
dnl For platforms, like Windows, where libraries must have all their symbols resolved
LDFLAGS="${LDFLAGS-} -no-undefined"
dnl Generate tmeconfig.h. The whether-to-generate logic is cribbed
dnl from glib-1.2.1's configure.ac.
dnl See that file for an explanation.
AC_CONFIG_COMMANDS([default-1],[[
## Generate our configure-time sources in two
## cases:
## 1. `config.status' is run either explicitly, or via configure.
## Esp. not when it is run in `Makefile' to generate makefiles and
## config.h
## 2. CONFIG_OTHER is set explicitly
##
## Case 1 is difficult. We know that `automake' sets one of
## CONFIG_FILES or CONFIG_HEADERS to empty. This heuristic works
## only when AM_CONFIG_HEADER is set, however.
case "x${CONFIG_OTHER}" in
*tmeconfig.h) gen_tmeconfig_h=yes
;;
esac
if test -n "${CONFIG_FILES}" && test -n "${CONFIG_HEADERS}"; then
# Both CONFIG_FILES and CONFIG_HEADERS are non-empty ==> Case 1
if test "x${CONFIG_OTHER}" = x; then
gen_tmeconfig_h=yes
fi
fi
## If we're generating tmeconfig.h:
if test "x${gen_tmeconfig_h}" = xyes; then
outfile=tmeconfig.h
echo "$as_me: creating $outfile"
cat <<TMEEOF > ${outfile}-tmp
/* tmeconfig.h
*
* This is an automatically generated file - please modify 'configure.ac'.
*/
#ifndef _TMECONFIG_H
#define _TMECONFIG_H
TMEEOF
(for word in HAVE_ TIME_ PROTO_ ALIGNOF_ SIZEOF_ AC_APPLE_UNIVERSAL_BUILD; do \
grep $word config.h | sed -e 's/#define[ ]\{1,\}/&_TME_/' -e 's/#if.*//g' ; \
done) | sort | uniq >> ${outfile}-tmp
echo '#if defined _TME_AC_APPLE_UNIVERSAL_BUILD' >> ${outfile}-tmp
echo '# if defined __BIG_ENDIAN__' >> ${outfile}-tmp
echo '# define _TME_WORDS_BIGENDIAN 1' >> ${outfile}-tmp
echo '# endif' >> ${outfile}-tmp
echo '#else' >> ${outfile}-tmp
echo '# ifndef _TME_WORDS_BIGENDIAN' >> ${outfile}-tmp
words_be_num=`grep -c "undef WORDS_BIGENDIAN" config.h`
if test $words_be_num = 0; then
echo '# define _TME_WORDS_BIGENDIAN 1' >> ${outfile}-tmp
fi
echo '# endif' >> ${outfile}-tmp
echo '#endif' >> ${outfile}-tmp
grep FLOAT_FORMAT config.h | \
sed 's/#define[ ]\{1,\}\([A-Za-z0-9_]\{1,\}\)[ ]\{1,\}\([A-Za-z0-9_]\{1,\}\)/#define TME_\1 TME_FLOAT_FORMAT_\2/' >> ${outfile}-tmp
echo '#define TME_BUSMAX_LOG2 TME_BUS'${bus_size_max}'_LOG2' >> ${outfile}-tmp
echo '#define TME_HAVE_RECODE (' \
`if test "x${recode_hosts}" = x; then echo 0; else echo 1; fi` ')' >> ${outfile}-tmp
echo '#define TME_RECODE_SIZE_GUEST_MAX TME_RECODE_SIZE_'${recode_size_guest_max} >> ${outfile}-tmp
echo '#define TME_RELEASE_MAJOR (' \
`echo $VERSION | sed -e 's,^\([0-9][0-9]*\)\.[0-9][0-9]*$,\1,'` ')' >> ${outfile}-tmp
echo '#define TME_RELEASE_MINOR (' \
`echo $VERSION | sed -e 's,^[0-9][0-9]*\.\([0-9][0-9]*\)$,\1,'` ')' >> ${outfile}-tmp