forked from erlang/otp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aclocal.m4
1872 lines (1675 loc) · 58.9 KB
/
aclocal.m4
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
dnl %CopyrightBegin%
dnl
dnl Copyright Ericsson AB 1998-2012. All Rights Reserved.
dnl
dnl The contents of this file are subject to the Erlang Public License,
dnl Version 1.1, (the "License"); you may not use this file except in
dnl compliance with the License. You should have received a copy of the
dnl Erlang Public License along with this software. If not, it can be
dnl retrieved online at http://www.erlang.org/.
dnl
dnl Software distributed under the License is distributed on an "AS IS"
dnl basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
dnl the License for the specific language governing rights and limitations
dnl under the License.
dnl
dnl %CopyrightEnd%
dnl
dnl
dnl aclocal.m4
dnl
dnl Local macros used in configure.in. The Local Macros which
dnl could/should be part of autoconf are prefixed LM_, macros specific
dnl to the Erlang system are prefixed ERL_.
dnl
AC_DEFUN(LM_PRECIOUS_VARS,
[
dnl ERL_TOP
AC_ARG_VAR(ERL_TOP, [Erlang/OTP top source directory])
dnl Tools
AC_ARG_VAR(CC, [C compiler])
AC_ARG_VAR(CFLAGS, [C compiler flags])
AC_ARG_VAR(STATIC_CFLAGS, [C compiler static flags])
AC_ARG_VAR(CFLAG_RUNTIME_LIBRARY_PATH, [runtime library path linker flag passed via C compiler])
AC_ARG_VAR(CPP, [C/C++ preprocessor])
AC_ARG_VAR(CPPFLAGS, [C/C++ preprocessor flags])
AC_ARG_VAR(CXX, [C++ compiler])
AC_ARG_VAR(CXXFLAGS, [C++ compiler flags])
AC_ARG_VAR(LD, [linker (is often overridden by configure)])
AC_ARG_VAR(LDFLAGS, [linker flags (can be risky to set since LD may be overriden by configure)])
AC_ARG_VAR(LIBS, [libraries])
AC_ARG_VAR(DED_LD, [linker for Dynamic Erlang Drivers (set all DED_LD* variables or none)])
AC_ARG_VAR(DED_LDFLAGS, [linker flags for Dynamic Erlang Drivers (set all DED_LD* variables or none)])
AC_ARG_VAR(DED_LD_FLAG_RUNTIME_LIBRARY_PATH, [runtime library path linker flag for Dynamic Erlang Drivers (set all DED_LD* variables or none)])
AC_ARG_VAR(LFS_CFLAGS, [large file support C compiler flags (set all LFS_* variables or none)])
AC_ARG_VAR(LFS_LDFLAGS, [large file support linker flags (set all LFS_* variables or none)])
AC_ARG_VAR(LFS_LIBS, [large file support libraries (set all LFS_* variables or none)])
AC_ARG_VAR(RANLIB, [ranlib])
AC_ARG_VAR(AR, [ar])
AC_ARG_VAR(GETCONF, [getconf])
dnl Cross system root
AC_ARG_VAR(erl_xcomp_sysroot, [Absolute cross system root path (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_isysroot, [Absolute cross system root include path (only used when cross compiling)])
dnl Cross compilation variables
AC_ARG_VAR(erl_xcomp_bigendian, [big endian system: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_double_middle_endian, [double-middle-endian system: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_linux_clock_gettime_correction, [clock_gettime() can be used for time correction: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_linux_nptl, [have Native POSIX Thread Library: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_linux_usable_sigusrx, [SIGUSR1 and SIGUSR2 can be used: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_linux_usable_sigaltstack, [have working sigaltstack(): yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_poll, [have working poll(): yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_kqueue, [have working kqueue(): yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_putenv_copy, [putenv() stores key-value copy: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_reliable_fpe, [have reliable floating point exceptions: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_getaddrinfo, [have working getaddrinfo() for both IPv4 and IPv6: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_gethrvtime_procfs_ioctl, [have working gethrvtime() which can be used with procfs ioctl(): yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_clock_gettime_cpu_time, [clock_gettime() can be used for retrieving process CPU time: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_after_morecore_hook, [__after_morecore_hook can track malloc()s core memory usage: yes|no (only used when cross compiling)])
AC_ARG_VAR(erl_xcomp_dlsym_brk_wrappers, [dlsym(RTLD_NEXT, _) brk wrappers can track malloc()s core memory usage: yes|no (only used when cross compiling)])
])
AC_DEFUN(ERL_XCOMP_SYSROOT_INIT,
[
erl_xcomp_without_sysroot=no
if test "$cross_compiling" = "yes"; then
test "$erl_xcomp_sysroot" != "" || erl_xcomp_without_sysroot=yes
test "$erl_xcomp_isysroot" != "" || erl_xcomp_isysroot="$erl_xcomp_sysroot"
else
erl_xcomp_sysroot=
erl_xcomp_isysroot=
fi
])
AC_DEFUN(LM_CHECK_GETCONF,
[
if test "$cross_compiling" != "yes"; then
AC_CHECK_PROG([GETCONF], [getconf], [getconf], [false])
else
dnl First check if we got a `<HOST>-getconf' in $PATH
host_getconf="$host_alias-getconf"
AC_CHECK_PROG([GETCONF], [$host_getconf], [$host_getconf], [false])
if test "$GETCONF" = "false" && test "$erl_xcomp_sysroot" != ""; then
dnl We should perhaps give up if we have'nt found it by now, but at
dnl least in one Tilera MDE `getconf' under sysroot is a bourne
dnl shell script which we can use. We try to find `<HOST>-getconf'
dnl or `getconf' under sysconf, but only under sysconf since
dnl `getconf' in $PATH is almost guaranteed to be for the build
dnl machine.
GETCONF=
prfx="$erl_xcomp_sysroot"
AC_PATH_TOOL([GETCONF], [getconf], [false],
["$prfx/usr/bin:$prfx/bin:$prfx/usr/local/bin"])
fi
fi
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_WINDOWS_ENVIRONMENT
dnl
dnl
dnl Tries to determine thw windows build environment, i.e.
dnl MIXED_CYGWIN_VC or MIXED_MSYS_VC
dnl
AC_DEFUN(LM_WINDOWS_ENVIRONMENT,
[
MIXED_CYGWIN=no
MIXED_MSYS=no
AC_MSG_CHECKING(for mixed cygwin or msys and native VC++ environment)
if test "X$host" = "Xwin32" -a "x$GCC" != "xyes"; then
if test -x /usr/bin/cygpath; then
CFLAGS="-O2"
MIXED_CYGWIN=yes
AC_MSG_RESULT([Cygwin and VC])
MIXED_CYGWIN_VC=yes
CPPFLAGS="$CPPFLAGS -DERTS_MIXED_CYGWIN_VC"
elif test -x /usr/bin/msysinfo; then
CFLAGS="-O2"
MIXED_MSYS=yes
AC_MSG_RESULT([MSYS and VC])
MIXED_MSYS_VC=yes
CPPFLAGS="$CPPFLAGS -DERTS_MIXED_MSYS_VC"
else
AC_MSG_RESULT([undeterminable])
AC_MSG_ERROR(Seems to be mixed windows but not with cygwin, cannot handle this!)
fi
else
AC_MSG_RESULT([no])
MIXED_CYGWIN_VC=no
MIXED_MSYS_VC=no
fi
AC_SUBST(MIXED_CYGWIN_VC)
AC_SUBST(MIXED_MSYS_VC)
MIXED_VC=no
if test "x$MIXED_MSYS_VC" = "xyes" -o "x$MIXED_CYGWIN_VC" = "xyes" ; then
MIXED_VC=yes
fi
AC_SUBST(MIXED_VC)
if test "x$MIXED_MSYS" != "xyes"; then
AC_MSG_CHECKING(for mixed cygwin and native MinGW environment)
if test "X$host" = "Xwin32" -a "x$GCC" = x"yes"; then
if test -x /usr/bin/cygpath; then
CFLAGS="-O2"
MIXED_CYGWIN=yes
AC_MSG_RESULT([yes])
MIXED_CYGWIN_MINGW=yes
CPPFLAGS="$CPPFLAGS -DERTS_MIXED_CYGWIN_MINGW"
else
AC_MSG_RESULT([undeterminable])
AC_MSG_ERROR(Seems to be mixed windows but not with cygwin, cannot handle this!)
fi
else
AC_MSG_RESULT([no])
MIXED_CYGWIN_MINGW=no
fi
else
MIXED_CYGWIN_MINGW=no
fi
AC_SUBST(MIXED_CYGWIN_MINGW)
AC_MSG_CHECKING(if we mix cygwin with any native compiler)
if test "X$MIXED_CYGWIN" = "Xyes"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_SUBST(MIXED_CYGWIN)
AC_MSG_CHECKING(if we mix msys with another native compiler)
if test "X$MIXED_MSYS" = "Xyes" ; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_SUBST(MIXED_MSYS)
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_FIND_EMU_CC
dnl
dnl
dnl Tries fairly hard to find a C compiler that can handle jump tables.
dnl Defines the @EMU_CC@ variable for the makefiles and
dnl inserts NO_JUMP_TABLE in the header if one cannot be found...
dnl
AC_DEFUN(LM_FIND_EMU_CC,
[AC_CACHE_CHECK(for a compiler that handles jumptables,
ac_cv_prog_emu_cc,
[
AC_TRY_COMPILE([],[
#if defined(__clang_major__) && __clang_major__ >= 3
/* clang 3.x or later is fine */
#elif defined(__llvm__)
#error "this version of llvm is unable to correctly compile beam_emu.c"
#endif
__label__ lbl1;
__label__ lbl2;
int x = magic();
static void *jtab[2];
jtab[0] = &&lbl1;
jtab[1] = &&lbl2;
goto *jtab[x];
lbl1:
return 1;
lbl2:
return 2;
],ac_cv_prog_emu_cc=$CC,ac_cv_prog_emu_cc=no)
if test $ac_cv_prog_emu_cc = no; then
for ac_progname in emu_cc.sh gcc-4.2 gcc; do
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_progname; then
ac_cv_prog_emu_cc=$ac_dir/$ac_progname
break
fi
done
IFS="$ac_save_ifs"
if test $ac_cv_prog_emu_cc != no; then
break
fi
done
fi
if test $ac_cv_prog_emu_cc != no; then
save_CC=$CC
save_CFLAGS=$CFLAGS
save_CPPFLAGS=$CPPFLAGS
CC=$ac_cv_prog_emu_cc
CFLAGS=""
CPPFLAGS=""
AC_TRY_COMPILE([],[
#if defined(__clang_major__) && __clang_major__ >= 3
/* clang 3.x or later is fine */
#elif defined(__llvm__)
#error "this version of llvm is unable to correctly compile beam_emu.c"
#endif
__label__ lbl1;
__label__ lbl2;
int x = magic();
static void *jtab[2];
jtab[0] = &&lbl1;
jtab[1] = &&lbl2;
goto *jtab[x];
lbl1:
return 1;
lbl2:
return 2;
],ac_cv_prog_emu_cc=$CC,ac_cv_prog_emu_cc=no)
CC=$save_CC
CFLAGS=$save_CFLAGS
CPPFLAGS=$save_CPPFLAGS
fi
])
if test $ac_cv_prog_emu_cc = no; then
AC_DEFINE(NO_JUMP_TABLE,[],[Defined if no found C compiler can handle jump tables])
EMU_CC=$CC
else
EMU_CC=$ac_cv_prog_emu_cc
fi
AC_SUBST(EMU_CC)
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_PROG_INSTALL_DIR
dnl
dnl This macro may be used by any OTP application.
dnl
dnl Figure out how to create directories with parents.
dnl (In my opinion INSTALL_DIR is a bad name, MKSUBDIRS or something is better)
dnl
dnl We prefer 'install -d', but use 'mkdir -p' if it exists.
dnl If none of these methods works, we give up.
dnl
AC_DEFUN(LM_PROG_INSTALL_DIR,
[AC_CACHE_CHECK(how to create a directory including parents,
ac_cv_prog_mkdir_p,
[
temp_name_base=config.$$
temp_name=$temp_name_base/x/y/z
$INSTALL -d $temp_name >/dev/null 2>&1
ac_cv_prog_mkdir_p=none
if test -d $temp_name; then
ac_cv_prog_mkdir_p="$INSTALL -d"
else
mkdir -p $temp_name >/dev/null 2>&1
if test -d $temp_name; then
ac_cv_prog_mkdir_p="mkdir -p"
fi
fi
rm -fr $temp_name_base
])
case "${ac_cv_prog_mkdir_p}" in
none) AC_MSG_ERROR(don't know how create directories with parents) ;;
*) INSTALL_DIR="$ac_cv_prog_mkdir_p" AC_SUBST(INSTALL_DIR) ;;
esac
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_PROG_PERL5
dnl
dnl Try to find perl version 5. If found set PERL to the absolute path
dnl of the program, if not found set PERL to false.
dnl
dnl On some systems /usr/bin/perl is perl 4 and e.g.
dnl /usr/local/bin/perl is perl 5. We try to handle this case by
dnl putting a couple of
dnl Tries to handle the case that there are two programs called perl
dnl in the path and one of them is perl 5 and the other isn't.
dnl
AC_DEFUN(LM_PROG_PERL5,
[AC_PATH_PROGS(PERL, perl5 perl, false,
/usr/local/bin:/opt/local/bin:/usr/local/gnu/bin:${PATH})
changequote(, )dnl
dnl[ That bracket is needed to balance the right bracket below
if test "$PERL" = "false" || $PERL -e 'exit ($] >= 5)'; then
changequote([, ])dnl
ac_cv_path_PERL=false
PERL=false
dnl AC_MSG_WARN(perl version 5 not found)
fi
])dnl
dnl ----------------------------------------------------------------------
dnl
dnl LM_DECL_SO_BSDCOMPAT
dnl
dnl Check if the system has the SO_BSDCOMPAT flag on sockets (linux)
dnl
AC_DEFUN(LM_DECL_SO_BSDCOMPAT,
[AC_CACHE_CHECK([for SO_BSDCOMPAT declaration], ac_cv_decl_so_bsdcompat,
AC_TRY_COMPILE([#include <sys/socket.h>], [int i = SO_BSDCOMPAT;],
ac_cv_decl_so_bsdcompat=yes,
ac_cv_decl_so_bsdcompat=no))
case "${ac_cv_decl_so_bsdcompat}" in
"yes" ) AC_DEFINE(HAVE_SO_BSDCOMPAT,[],
[Define if you have SO_BSDCOMPAT flag on sockets]) ;;
* ) ;;
esac
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_DECL_INADDR_LOOPBACK
dnl
dnl Try to find declaration of INADDR_LOOPBACK, if nowhere provide a default
dnl
AC_DEFUN(LM_DECL_INADDR_LOOPBACK,
[AC_CACHE_CHECK([for INADDR_LOOPBACK in netinet/in.h],
ac_cv_decl_inaddr_loopback,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>], [int i = INADDR_LOOPBACK;],
ac_cv_decl_inaddr_loopback=yes, ac_cv_decl_inaddr_loopback=no)
])
if test ${ac_cv_decl_inaddr_loopback} = no; then
AC_CACHE_CHECK([for INADDR_LOOPBACK in rpc/types.h],
ac_cv_decl_inaddr_loopback_rpc,
AC_TRY_COMPILE([#include <rpc/types.h>],
[int i = INADDR_LOOPBACK;],
ac_cv_decl_inaddr_loopback_rpc=yes,
ac_cv_decl_inaddr_loopback_rpc=no))
case "${ac_cv_decl_inaddr_loopback_rpc}" in
"yes" )
AC_DEFINE(DEF_INADDR_LOOPBACK_IN_RPC_TYPES_H,[],
[Define if you need to include rpc/types.h to get INADDR_LOOPBACK defined]) ;;
* )
AC_CACHE_CHECK([for INADDR_LOOPBACK in winsock2.h],
ac_cv_decl_inaddr_loopback_winsock2,
AC_TRY_COMPILE([#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>],
[int i = INADDR_LOOPBACK;],
ac_cv_decl_inaddr_loopback_winsock2=yes,
ac_cv_decl_inaddr_loopback_winsock2=no))
case "${ac_cv_decl_inaddr_loopback_winsock2}" in
"yes" )
AC_DEFINE(DEF_INADDR_LOOPBACK_IN_WINSOCK2_H,[],
[Define if you need to include winsock2.h to get INADDR_LOOPBACK defined]) ;;
* )
# couldn't find it anywhere
AC_DEFINE(HAVE_NO_INADDR_LOOPBACK,[],
[Define if you don't have a definition of INADDR_LOOPBACK]) ;;
esac;;
esac
fi
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_STRUCT_SOCKADDR_SA_LEN
dnl
dnl Check if the sockaddr structure has the field sa_len
dnl
AC_DEFUN(LM_STRUCT_SOCKADDR_SA_LEN,
[AC_CACHE_CHECK([whether struct sockaddr has sa_len field],
ac_cv_struct_sockaddr_sa_len,
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>], [struct sockaddr s; s.sa_len = 10;],
ac_cv_struct_sockaddr_sa_len=yes, ac_cv_struct_sockaddr_sa_len=no))
dnl FIXME convbreak
case ${ac_cv_struct_sockaddr_sa_len} in
"no" ) AC_DEFINE(NO_SA_LEN,[1],[Define if you dont have salen]) ;;
*) ;;
esac
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_STRUCT_EXCEPTION
dnl
dnl Check to see whether the system supports the matherr function
dnl and its associated type "struct exception".
dnl
AC_DEFUN(LM_STRUCT_EXCEPTION,
[AC_CACHE_CHECK([for struct exception (and matherr function)],
ac_cv_struct_exception,
AC_TRY_COMPILE([#include <math.h>],
[struct exception x; x.type = DOMAIN; x.type = SING;],
ac_cv_struct_exception=yes, ac_cv_struct_exception=no))
case "${ac_cv_struct_exception}" in
"yes" ) AC_DEFINE(USE_MATHERR,[1],[Define if you have matherr() function and struct exception type]) ;;
* ) ;;
esac
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_SYS_IPV6
dnl
dnl Check for ipv6 support and what the in6_addr structure is called.
dnl (early linux used in_addr6 insted of in6_addr)
dnl
AC_DEFUN(LM_SYS_IPV6,
[AC_MSG_CHECKING(for IP version 6 support)
AC_CACHE_VAL(ac_cv_sys_ipv6_support,
[ok_so_far=yes
AC_TRY_COMPILE([#include <sys/types.h>
#ifdef __WIN32__
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <netinet/in.h>
#endif],
[struct in6_addr a6; struct sockaddr_in6 s6;], ok_so_far=yes, ok_so_far=no)
if test $ok_so_far = yes; then
ac_cv_sys_ipv6_support=yes
else
AC_TRY_COMPILE([#include <sys/types.h>
#ifdef __WIN32__
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <netinet/in.h>
#endif],
[struct in_addr6 a6; struct sockaddr_in6 s6;],
ac_cv_sys_ipv6_support=in_addr6, ac_cv_sys_ipv6_support=no)
fi
])dnl
dnl
dnl Have to use old style AC_DEFINE due to BC with old autoconf.
dnl
case ${ac_cv_sys_ipv6_support} in
yes)
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_IN6,[1],[Define if ipv6 is present])
;;
in_addr6)
AC_MSG_RESULT([yes (but I am redefining in_addr6 to in6_addr)])
AC_DEFINE(HAVE_IN6,[1],[Define if ipv6 is present])
AC_DEFINE(HAVE_IN_ADDR6_STRUCT,[],[Early linux used in_addr6 instead of in6_addr, define if you have this])
;;
*)
AC_MSG_RESULT(no)
;;
esac
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_SYS_MULTICAST
dnl
dnl Check for multicast support. Only checks for multicast options in
dnl setsockopt(), no check is performed that multicasting actually works.
dnl If options are found defines HAVE_MULTICAST_SUPPORT
dnl
AC_DEFUN(LM_SYS_MULTICAST,
[AC_CACHE_CHECK([for multicast support], ac_cv_sys_multicast_support,
[AC_EGREP_CPP(yes,
[#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#if defined(IP_MULTICAST_TTL) && defined(IP_MULTICAST_LOOP) && defined(IP_MULTICAST_IF) && defined(IP_ADD_MEMBERSHIP) && defined(IP_DROP_MEMBERSHIP)
yes
#endif
], ac_cv_sys_multicast_support=yes, ac_cv_sys_multicast_support=no)])
if test $ac_cv_sys_multicast_support = yes; then
AC_DEFINE(HAVE_MULTICAST_SUPPORT,[1],
[Define if setsockopt() accepts multicast options])
fi
])dnl
dnl ----------------------------------------------------------------------
dnl
dnl LM_DECL_SYS_ERRLIST
dnl
dnl Define SYS_ERRLIST_DECLARED if the variable sys_errlist is declared
dnl in a system header file, stdio.h or errno.h.
dnl
AC_DEFUN(LM_DECL_SYS_ERRLIST,
[AC_CACHE_CHECK([for sys_errlist declaration in stdio.h or errno.h],
ac_cv_decl_sys_errlist,
[AC_TRY_COMPILE([#include <stdio.h>
#include <errno.h>], [char *msg = *(sys_errlist + 1);],
ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no)])
if test $ac_cv_decl_sys_errlist = yes; then
AC_DEFINE(SYS_ERRLIST_DECLARED,[],
[define if the variable sys_errlist is declared in a system header file])
fi
])
dnl ----------------------------------------------------------------------
dnl
dnl LM_CHECK_FUNC_DECL( funname, declaration [, extra includes
dnl [, action-if-found [, action-if-not-found]]] )
dnl
dnl Checks if the declaration "declaration" of "funname" conflicts
dnl with the header files idea of how the function should be
dnl declared. It is useful on systems which lack prototypes and you
dnl need to provide your own (e.g. when you want to take the address
dnl of a function). The 4'th argument is expanded if conflicting,
dnl the 5'th argument otherwise
dnl
dnl
AC_DEFUN(LM_CHECK_FUNC_DECL,
[AC_MSG_CHECKING([for conflicting declaration of $1])
AC_CACHE_VAL(ac_cv_func_decl_$1,
[AC_TRY_COMPILE([#include <stdio.h>
$3],[$2
char *c = (char *)$1;
], eval "ac_cv_func_decl_$1=no", eval "ac_cv_func_decl_$1=yes")])
if eval "test \"`echo '$ac_cv_func_decl_'$1`\" = yes"; then
AC_MSG_RESULT(yes)
ifelse([$4], , :, [$4])
else
AC_MSG_RESULT(no)
ifelse([$5], , , [$5
])dnl
fi
])
dnl ----------------------------------------------------------------------
dnl
dnl AC_DOUBLE_MIDDLE_ENDIAN
dnl
dnl Checks whether doubles are represented in "middle-endian" format.
dnl Sets ac_cv_double_middle_endian={no,yes,unknown} accordingly,
dnl as well as DOUBLE_MIDDLE_ENDIAN.
dnl
dnl
AC_DEFUN([AC_C_DOUBLE_MIDDLE_ENDIAN],
[AC_CACHE_CHECK(whether double word ordering is middle-endian, ac_cv_c_double_middle_endian,
[# It does not; compile a test program.
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[#include <stdlib.h>
int
main(void)
{
int i = 0;
int zero = 0;
int bigendian;
int zero_index = 0;
union
{
long int l;
char c[sizeof (long int)];
} u;
/* we'll use the one with 32-bit words */
union
{
double d;
unsigned int c[2];
} vint;
union
{
double d;
unsigned long c[2];
} vlong;
union
{
double d;
unsigned short c[2];
} vshort;
/* Are we little or big endian? From Harbison&Steele. */
u.l = 1;
bigendian = (u.c[sizeof (long int) - 1] == 1);
zero_index = bigendian ? 1 : 0;
vint.d = 1.0;
vlong.d = 1.0;
vshort.d = 1.0;
if (sizeof(unsigned int) == 4)
{
if (vint.c[zero_index] != 0)
zero = 1;
}
else if (sizeof(unsigned long) == 4)
{
if (vlong.c[zero_index] != 0)
zero = 1;
}
else if (sizeof(unsigned short) == 4)
{
if (vshort.c[zero_index] != 0)
zero = 1;
}
exit (zero);
}
]])],
[ac_cv_c_double_middle_endian=no],
[ac_cv_c_double_middle_endian=yes],
[ac_cv_c_double_middle=unknown])])
case $ac_cv_c_double_middle_endian in
yes)
m4_default([$1],
[AC_DEFINE([DOUBLE_MIDDLE_ENDIAN], 1,
[Define to 1 if your processor stores the words in a double in
middle-endian format (like some ARMs).])]) ;;
no)
$2 ;;
*)
m4_default([$3],
[AC_MSG_WARN([unknown double endianness
presetting ac_cv_c_double_middle_endian=no (or yes) will help])]) ;;
esac
])# AC_C_DOUBLE_MIDDLE_ENDIAN
dnl ----------------------------------------------------------------------
dnl
dnl LM_CHECK_THR_LIB
dnl
dnl This macro may be used by any OTP application.
dnl
dnl LM_CHECK_THR_LIB sets THR_LIBS, THR_DEFS, and THR_LIB_NAME. It also
dnl checks for some pthread headers which will appear in DEFS or config.h.
dnl
AC_DEFUN(LM_CHECK_THR_LIB,
[
NEED_NPTL_PTHREAD_H=no
dnl win32?
AC_MSG_CHECKING([for native win32 threads])
if test "X$host_os" = "Xwin32"; then
AC_MSG_RESULT(yes)
THR_DEFS="-DWIN32_THREADS"
THR_LIBS=
THR_LIB_NAME=win32_threads
THR_LIB_TYPE=win32_threads
else
AC_MSG_RESULT(no)
THR_DEFS=
THR_LIBS=
THR_LIB_NAME=
THR_LIB_TYPE=posix_unknown
dnl Try to find POSIX threads
dnl The usual pthread lib...
AC_CHECK_LIB(pthread, pthread_create, THR_LIBS="-lpthread")
dnl FreeBSD has pthreads in special c library, c_r...
if test "x$THR_LIBS" = "x"; then
AC_CHECK_LIB(c_r, pthread_create, THR_LIBS="-lc_r")
fi
dnl On ofs1 the '-pthread' switch should be used
if test "x$THR_LIBS" = "x"; then
AC_MSG_CHECKING([if the '-pthread' switch can be used])
saved_cflags=$CFLAGS
CFLAGS="$CFLAGS -pthread"
AC_TRY_LINK([#include <pthread.h>],
pthread_create((void*)0,(void*)0,(void*)0,(void*)0);,
[THR_DEFS="-pthread"
THR_LIBS="-pthread"])
CFLAGS=$saved_cflags
if test "x$THR_LIBS" != "x"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
if test "x$THR_LIBS" != "x"; then
THR_DEFS="$THR_DEFS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS"
THR_LIB_NAME=pthread
case $host_os in
solaris*)
THR_DEFS="$THR_DEFS -D_POSIX_PTHREAD_SEMANTICS" ;;
linux*)
THR_DEFS="$THR_DEFS -D_POSIX_THREAD_SAFE_FUNCTIONS"
LM_CHECK_GETCONF
AC_MSG_CHECKING(for Native POSIX Thread Library)
libpthr_vsn=`$GETCONF GNU_LIBPTHREAD_VERSION 2>/dev/null`
if test $? -eq 0; then
case "$libpthr_vsn" in
*nptl*|*NPTL*) nptl=yes;;
*) nptl=no;;
esac
elif test "$cross_compiling" = "yes"; then
case "$erl_xcomp_linux_nptl" in
"") nptl=cross;;
yes|no) nptl=$erl_xcomp_linux_nptl;;
*) AC_MSG_ERROR([Bad erl_xcomp_linux_nptl value: $erl_xcomp_linux_nptl]);;
esac
else
nptl=no
fi
AC_MSG_RESULT($nptl)
if test $nptl = cross; then
nptl=yes
AC_MSG_WARN([result yes guessed because of cross compilation])
fi
if test $nptl = yes; then
THR_LIB_TYPE=posix_nptl
need_nptl_incldir=no
AC_CHECK_HEADER(nptl/pthread.h,
[need_nptl_incldir=yes
NEED_NPTL_PTHREAD_H=yes])
if test $need_nptl_incldir = yes; then
# Ahh...
nptl_path="$C_INCLUDE_PATH:$CPATH"
if test X$cross_compiling != Xyes; then
nptl_path="$nptl_path:/usr/local/include:/usr/include"
else
IROOT="$erl_xcomp_isysroot"
test "$IROOT" != "" || IROOT="$erl_xcomp_sysroot"
test "$IROOT" != "" || AC_MSG_ERROR([Don't know where to search for includes! Please set erl_xcomp_isysroot])
nptl_path="$nptl_path:$IROOT/usr/local/include:$IROOT/usr/include"
fi
nptl_ws_path=
save_ifs="$IFS"; IFS=":"
for dir in $nptl_path; do
if test "x$dir" != "x"; then
nptl_ws_path="$nptl_ws_path $dir"
fi
done
IFS=$save_ifs
nptl_incldir=
for dir in $nptl_ws_path; do
AC_CHECK_HEADER($dir/nptl/pthread.h,
nptl_incldir=$dir/nptl)
if test "x$nptl_incldir" != "x"; then
THR_DEFS="$THR_DEFS -isystem $nptl_incldir"
break
fi
done
if test "x$nptl_incldir" = "x"; then
AC_MSG_ERROR(Failed to locate nptl system include directory)
fi
fi
fi
;;
*) ;;
esac
dnl We sometimes need THR_DEFS in order to find certain headers
dnl (at least for pthread.h on osf1).
saved_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $THR_DEFS"
dnl
dnl Check for headers
dnl
AC_CHECK_HEADER(pthread.h,
AC_DEFINE(HAVE_PTHREAD_H, 1, \
[Define if you have the <pthread.h> header file.]))
dnl Some Linuxes have <pthread/mit/pthread.h> instead of <pthread.h>
AC_CHECK_HEADER(pthread/mit/pthread.h, \
AC_DEFINE(HAVE_MIT_PTHREAD_H, 1, \
[Define if the pthread.h header file is in pthread/mit directory.]))
dnl restore CPPFLAGS
CPPFLAGS=$saved_cppflags
fi
fi
])
AC_DEFUN(ERL_INTERNAL_LIBS,
[
ERTS_INTERNAL_X_LIBS=
AC_CHECK_LIB(kstat, kstat_open,
[AC_DEFINE(HAVE_KSTAT, 1, [Define if you have kstat])
ERTS_INTERNAL_X_LIBS="$ERTS_INTERNAL_X_LIBS -lkstat"])
AC_SUBST(ERTS_INTERNAL_X_LIBS)
])
AC_DEFUN(ETHR_CHK_SYNC_OP,
[
AC_MSG_CHECKING([for $3-bit $1()])
case "$2" in
"1") sync_call="$1(&var);";;
"2") sync_call="$1(&var, ($4) 0);";;
"3") sync_call="$1(&var, ($4) 0, ($4) 0);";;
esac
have_sync_op=no
AC_TRY_LINK([],
[
$4 res;
volatile $4 var;
res = $sync_call
],
[have_sync_op=yes])
test $have_sync_op = yes && $5
AC_MSG_RESULT([$have_sync_op])
])
AC_DEFUN(ETHR_CHK_INTERLOCKED,
[
ilckd="$1"
AC_MSG_CHECKING([for ${ilckd}()])
case "$2" in
"1") ilckd_call="${ilckd}(var);";;
"2") ilckd_call="${ilckd}(var, ($3) 0);";;
"3") ilckd_call="${ilckd}(var, ($3) 0, ($3) 0);";;
"4") ilckd_call="${ilckd}(var, ($3) 0, ($3) 0, arr);";;
esac
have_interlocked_op=no
AC_TRY_LINK(
[
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <intrin.h>
],
[
volatile $3 *var;
volatile $3 arr[2];
$ilckd_call
return 0;
],
[have_interlocked_op=yes])
test $have_interlocked_op = yes && $4
AC_MSG_RESULT([$have_interlocked_op])
])
dnl ----------------------------------------------------------------------
dnl
dnl ERL_FIND_ETHR_LIB
dnl
dnl NOTE! This macro may be changed at any time! Should *only* be used by
dnl ERTS!
dnl
dnl Find a thread library to use. Sets ETHR_LIBS to libraries to link
dnl with, ETHR_X_LIBS to extra libraries to link with (same as ETHR_LIBS
dnl except that the ethread lib itself is not included), ETHR_DEFS to
dnl defines to compile with, ETHR_THR_LIB_BASE to the name of the
dnl thread library which the ethread library is based on, and ETHR_LIB_NAME
dnl to the name of the library where the ethread implementation is located.
dnl ERL_FIND_ETHR_LIB currently searches for 'pthreads', and
dnl 'win32_threads'. If no thread library was found ETHR_LIBS, ETHR_X_LIBS,
dnl ETHR_DEFS, ETHR_THR_LIB_BASE, and ETHR_LIB_NAME are all set to the
dnl empty string.
dnl
AC_DEFUN(ERL_FIND_ETHR_LIB,
[
LM_CHECK_THR_LIB
ERL_INTERNAL_LIBS
ethr_have_native_atomics=no
ethr_have_native_spinlock=no
ETHR_THR_LIB_BASE="$THR_LIB_NAME"
ETHR_THR_LIB_BASE_TYPE="$THR_LIB_TYPE"
ETHR_DEFS="$THR_DEFS"
ETHR_X_LIBS="$THR_LIBS $ERTS_INTERNAL_X_LIBS"
ETHR_LIBS=
ETHR_LIB_NAME=
ethr_modified_default_stack_size=
dnl Name of lib where ethread implementation is located
ethr_lib_name=ethread
case "$THR_LIB_NAME" in
win32_threads)
ETHR_THR_LIB_BASE_DIR=win
# * _WIN32_WINNT >= 0x0400 is needed for
# TryEnterCriticalSection
# * _WIN32_WINNT >= 0x0403 is needed for
# InitializeCriticalSectionAndSpinCount
# The ethread lib will refuse to build if _WIN32_WINNT < 0x0403.
#
# -D_WIN32_WINNT should have been defined in $CPPFLAGS; fetch it
# and save it in ETHR_DEFS.
found_win32_winnt=no
for cppflag in $CPPFLAGS; do
case $cppflag in
-DWINVER*)
ETHR_DEFS="$ETHR_DEFS $cppflag"
;;
-D_WIN32_WINNT*)
ETHR_DEFS="$ETHR_DEFS $cppflag"
found_win32_winnt=yes
;;
*)
;;
esac
done
if test $found_win32_winnt = no; then
AC_MSG_ERROR([-D_WIN32_WINNT missing in CPPFLAGS])
fi
AC_DEFINE(ETHR_WIN32_THREADS, 1, [Define if you have win32 threads])
ETHR_CHK_INTERLOCKED([_InterlockedDecrement], [1], [long], AC_DEFINE_UNQUOTED(ETHR_HAVE__INTERLOCKEDDECREMENT, 1, [Define if you have _InterlockedDecrement()]))
ETHR_CHK_INTERLOCKED([_InterlockedDecrement_rel], [1], [long], AC_DEFINE_UNQUOTED(ETHR_HAVE__INTERLOCKEDDECREMENT_REL, 1, [Define if you have _InterlockedDecrement_rel()]))
ETHR_CHK_INTERLOCKED([_InterlockedIncrement], [1], [long], AC_DEFINE_UNQUOTED(ETHR_HAVE__INTERLOCKEDINCREMENT, 1, [Define if you have _InterlockedIncrement()]))