-
Notifications
You must be signed in to change notification settings - Fork 0
/
acinclude.m4
1446 lines (1352 loc) · 38.3 KB
/
acinclude.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 ## GNU Pth - The GNU Portable Threads
dnl ## Copyright (c) 1999-2006 Ralf S. Engelschall <[email protected]>
dnl ##
dnl ## This file is part of GNU Pth, a non-preemptive thread scheduling
dnl ## library which can be found at http://www.gnu.org/software/pth/.
dnl ##
dnl ## This library is free software; you can redistribute it and/or
dnl ## modify it under the terms of the GNU Lesser General Public
dnl ## License as published by the Free Software Foundation; either
dnl ## version 2.1 of the License, or (at your option) any later version.
dnl ##
dnl ## This library is distributed in the hope that it will be useful,
dnl ## but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl ## Lesser General Public License for more details.
dnl ##
dnl ## You should have received a copy of the GNU Lesser General Public
dnl ## License along with this library; if not, write to the Free Software
dnl ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dnl ## USA, or contact Ralf S. Engelschall <[email protected]>.
dnl ##
dnl ## aclocal.m4: Pth Autoconf macros
dnl ##
dnl # ``"Reuse an expert's code" is the right
dnl # advice for most people. But it's a useless
dnl # advice for the experts writing the code
dnl # in the first place.'
dnl # -- Dan J. Bernstein
dnl ##
dnl ## Display Configuration Headers
dnl ##
dnl ## configure.ac:
dnl ## AC_MSG_PART(<text>)
dnl ##
m4_define(AC_MSG_PART,[dnl
if test ".$enable_subdir" != .yes; then
AC_MSG_RESULT()
AC_MSG_RESULT(${TB}$1:${TN})
fi
])dnl
dnl ##
dnl ## Display a message under --verbose
dnl ##
dnl ## configure.ac:
dnl ## AC_MSG_VERBOSE(<text>)
dnl ##
m4_define(AC_MSG_VERBOSE,[dnl
if test ".$verbose" = .yes; then
AC_MSG_RESULT([ $1])
fi
])
dnl ##
dnl ## Do not display message for a command
dnl ##
dnl ## configure.ac:
dnl ## AC_MSG_SILENT(...)
dnl ##
m4_define(AC_FD_TMP, 9)
m4_define(AC_MSG_SILENT,[dnl
exec AC_FD_TMP>&AC_FD_MSG AC_FD_MSG>/dev/null
$1
exec AC_FD_MSG>&AC_FD_TMP AC_FD_TMP>&-
])
dnl ##
dnl ## Perform something only once
dnl ##
dnl ## configure.ac:
dnl ## AC_ONCE(<action>)
dnl ##
m4_define(AC_ONCE,[
ifelse(ac_once_$1, already_done, ,[
m4_define(ac_once_$1, already_done)
$2
])dnl
])
dnl ##
dnl ## Support for --enable-subdir (for use with pth.m4)
dnl ##
dnl ## configure.ac:
dnl ## AC_ENABLESUBDIR
dnl ##
AC_DEFUN(AC_ENABLESUBDIR,[
AC_ARG_ENABLE(subdir,dnl
[ --enable-subdir enable local building as subdirectory (default=no)],[dnl
],[dnl
enable_subdir=no
])dnl
if test ".$enable_subdir" = .yes; then
enable_shared=no
fi
])dnl
dnl ##
dnl ## Support for Configuration Headers
dnl ##
dnl ## configure.ac:
dnl ## AC_HEADLINE(<short-name>, <long-name>,
dnl ## <vers-var>, <vers-str>, <vers-hex>,
dnl ## <copyright>)
dnl ##
AC_DEFUN(AC_HEADLINE,[dnl
# configuration header
if test ".`echo dummy [$]@ | grep enable-subdir`" != .; then
enable_subdir=yes
fi
if test ".`echo dummy [$]@ | grep help`" = .; then
# bootstrapping shtool
ac_prog=[$]0
changequote(, )dnl
ac_srcdir=`echo $ac_prog | sed -e 's%/[^/][^/]*$%%' -e 's%\([^/]\)/*$%\1%'`
changequote([, ])dnl
test ".$ac_srcdir" = ".$ac_prog" && ac_srcdir=.
ac_shtool="${CONFIG_SHELL-/bin/sh} $ac_srcdir/shtool"
# find out terminal sequences
if test ".$enable_subdir" != .yes; then
TB=`$ac_shtool echo -n -e %B 2>/dev/null`
TN=`$ac_shtool echo -n -e %b 2>/dev/null`
else
TB=''
TN=''
fi
# find out package version
$3_STR="$4"
AC_SUBST($3_STR)
# friendly header ;)
if test ".$enable_subdir" != .yes; then
echo "Configuring ${TB}$1${TN} ($2), Version ${TB}${$3_STR}${TN}"
echo "$6"
fi
# additionally find out hex version
$3_HEX="$5"
AC_SUBST($3_HEX)
fi
])dnl
dnl ##
dnl ## Support for Platform IDs
dnl ##
dnl ## configure.ac:
dnl ## AC_PLATFORM(<variable>)
dnl ##
AC_DEFUN(AC_PLATFORM,[
if test ".$host" != .; then
$1="$host"
else
$1=`${CONFIG_SHELL-/bin/sh} $srcdir/config.guess`
fi
$1=`${CONFIG_SHELL-/bin/sh} $srcdir/config.sub $$1` || exit 1
AC_SUBST($1)
if test ".$enable_subdir" != .yes; then
echo "Platform: ${TB}${$1}${TN}"
fi
])dnl
dnl ##
dnl ## Support for config.param files
dnl ##
dnl ## configure.ac:
dnl ## AC_CONFIG_PARAM(<file>)
dnl ##
AC_DEFUN(AC_CONFIG_PARAM,[
AC_DIVERT_PUSH(-1)
AC_ARG_WITH(param,[ --with-param=ID[[,ID,..]] load parameters from $1])
AC_DIVERT_POP()
AC_DIVERT_PUSH(NOTICE)
ac_prev=""
ac_param=""
if test -f $1; then
ac_param="$1:common"
fi
for ac_option
do
if test ".$ac_prev" != .; then
eval "$ac_prev=\$ac_option"
ac_prev=""
continue
fi
case "$ac_option" in
-*=*) ac_optarg=`echo "$ac_option" | sed 's/[[-_a-zA-Z0-9]]*=//'` ;;
*) ac_optarg="" ;;
esac
case "$ac_option" in
--with-param=* )
case $ac_optarg in
*:* )
ac_from=`echo $ac_optarg | sed -e 's/:.*//'`
ac_what=`echo $ac_optarg | sed -e 's/.*://'`
;;
* )
ac_from="$1"
ac_what="$ac_optarg"
;;
esac
if test ".$ac_param" = .; then
ac_param="$ac_from:$ac_what"
else
ac_param="$ac_param,$ac_from:$ac_what"
fi
;;
esac
done
if test ".$ac_param" != .; then
# echo "loading parameters"
OIFS="$IFS"
IFS=","
pconf="/tmp/autoconf.$$"
echo "ac_options=''" >$pconf
ac_from="$1"
for ac_section in $ac_param; do
changequote(, )
case $ac_section in
*:* )
ac_from=`echo "$ac_section" | sed -e 's/:.*//'`
ac_section=`echo "$ac_section" | sed -e 's/.*://'`
;;
esac
(echo ''; cat $ac_from; echo '') |\
sed -e "1,/[ ]*[ ]*${ac_section}[ ]*{[ ]*/d" \
-e '/[ ]*}[ ]*/,$d' \
-e ':join' -e '/\\[ ]*$/N' -e 's/\\[ ]*\n[ ]*//' -e 'tjoin' \
-e 's/^[ ]*//g' \
-e 's/^\([^-].*=.*\) IF \(.*\)$/if \2; then \1; fi/' \
-e 's/^\(--.*=.*\) IF \(.*\)$/if \2; then ac_options="$ac_options \1"; fi/' \
-e 's/^\(--.*\) IF \(.*\)$/if \2; then ac_options="$ac_options \1"; fi/' \
-e 's/^\(--.*=.*\)$/ac_options="$ac_options \1"/' \
-e 's/^\(--.*\)$/ac_options="$ac_options \1"/' \
>>$pconf
changequote([, ])
done
IFS="$OIFS"
. $pconf
rm -f $pconf >/dev/null 2>&1
if test ".[$]*" = .; then
set -- $ac_options
else
set -- "[$]@" $ac_options
fi
fi
AC_DIVERT_POP()
])dnl
dnl ##
dnl ## Check whether compiler option works
dnl ##
dnl ## configure.ac:
dnl ## AC_COMPILER_OPTION(<name>, <display>, <option>,
dnl ## <action-success>, <action-failure>)
dnl ##
AC_DEFUN(AC_COMPILER_OPTION,[dnl
AC_MSG_CHECKING(for compiler option $2)
AC_CACHE_VAL(ac_cv_compiler_option_$1,[
cat >conftest.$ac_ext <<EOF
int main() { return 0; }
EOF
${CC-cc} -c $CFLAGS $CPPFLAGS $3 conftest.$ac_ext 1>conftest.out 2>conftest.err
if test $? -ne 0 -o -s conftest.err; then
ac_cv_compiler_option_$1=no
else
ac_cv_compiler_option_$1=yes
fi
rm -f conftest.$ac_ext conftest.out conftest.err
])dnl
if test ".$ac_cv_compiler_option_$1" = .yes; then
ifelse([$4], , :, [$4])
else
ifelse([$5], , :, [$5])
fi
AC_MSG_RESULT([$ac_cv_compiler_option_$1])
])dnl
dnl ##
dnl ## Check whether `long long' and `long double' type exists
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_LONGLONG
dnl ## AC_CHECK_LONGDOUBLE
dnl ##
AC_DEFUN(AC_CHECK_LONGLONG,[dnl
AC_MSG_CHECKING(for built-in type long long)
AC_CACHE_VAL(ac_cv_type_longlong,[dnl
AC_TRY_LINK([
#include <sys/types.h>
],[
long long X = 2, Y = 1, Z;
Z = X / Y;
],
ac_cv_type_longlong=yes,
ac_cv_type_longlong=no
)dnl
])dnl
AC_MSG_RESULT([$ac_cv_type_longlong])
if test ".$ac_cv_type_longlong" = .yes; then
AC_DEFINE(HAVE_LONGLONG, 1, [define if "long long" type exists])
fi
])dnl
AC_DEFUN(AC_CHECK_LONGDOUBLE,[dnl
AC_MSG_CHECKING(for built-in type long double)
AC_CACHE_VAL(ac_cv_type_longdouble,[dnl
AC_TRY_LINK([
#include <sys/types.h>
],[
long double X = 2, Y = 1, Z;
Z = X / Y;
],
ac_cv_type_longdouble=yes,
ac_cv_type_longdouble=no
)dnl
])dnl
AC_MSG_RESULT([$ac_cv_type_longdouble])
if test ".$ac_cv_type_longdouble" = .yes; then
AC_DEFINE(HAVE_LONGDOUBLE, 1, [define if "long double" type exists])
fi
])dnl
dnl ##
dnl ## Debugging Support
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_DEBUGGING
dnl ##
AC_DEFUN(AC_CHECK_DEBUGGING,[dnl
AC_ARG_ENABLE(debug,dnl
[ --enable-debug build for debugging (default=no)],
[dnl
if test ".$ac_cv_prog_gcc" = ".yes"; then
case $PLATFORM in
*-*-freebsd*|*-*-solaris* ) CFLAGS="$CFLAGS -pedantic" ;;
esac
CFLAGS="$CFLAGS -Wall"
WMORE="-Wshadow -Wpointer-arith -Wcast-align -Winline"
WMORE="$WMORE -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
AC_COMPILER_OPTION(wmore, -W<xxx>, $WMORE, CFLAGS="$CFLAGS $WMORE")
AC_COMPILER_OPTION(wnolonglong, -Wno-long-long, -Wno-long-long, CFLAGS="$CFLAGS -Wno-long-long")
AC_COMPILER_OPTION(fnostrictaliasing, -fno-strict-aliasing, -fno-strict-aliasing, CFLAGS="$CFLAGS -fno-strict-aliasing")
fi
msg="enabled"
AC_DEFINE(PTH_DEBUG, 1, [define to enable Pth debugging])
],[
msg="disabled"
])dnl
AC_MSG_CHECKING(for compilation debug mode)
AC_MSG_RESULT([$msg])
if test ".$msg" = .enabled; then
enable_shared=no
fi
])
dnl ##
dnl ## Check for a pre-processor define in a header
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_DEFINE(<define>, <header>)
dnl ## acconfig.h:
dnl ## #undef HAVE_<define>
dnl ##
AC_DEFUN(AC_CHECK_DEFINE,[dnl
AC_MSG_CHECKING(for define $1 in $2)
AC_CACHE_VAL(ac_cv_define_$1,
[AC_EGREP_CPP([YES_IS_DEFINED], [
#include <$2>
#ifdef $1
YES_IS_DEFINED
#endif
], ac_cv_define_$1=yes, ac_cv_define_$1=no)])dnl
AC_MSG_RESULT($ac_cv_define_$1)
if test $ac_cv_define_$1 = yes; then
AC_DEFINE(HAVE_[]translit($1, [a-z], [A-Z]), 1,
[define if pre-processor define $1 exists in header $2])
fi
])
dnl ##
dnl ## Check for an ANSI C typedef in a header
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_TYPEDEF(<typedef>, <header>)
dnl ## acconfig.h:
dnl ## #undef HAVE_<typedef>
dnl ##
AC_DEFUN(AC_CHECK_TYPEDEF,[dnl
AC_REQUIRE([AC_HEADER_STDC])dnl
AC_MSG_CHECKING(for typedef $1)
AC_CACHE_VAL(ac_cv_typedef_$1,
[AC_EGREP_CPP(dnl
changequote(<<,>>)dnl
<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
changequote([,]), [
#include <$2>
], ac_cv_typedef_$1=yes, ac_cv_typedef_$1=no)])dnl
AC_MSG_RESULT($ac_cv_typedef_$1)
if test $ac_cv_typedef_$1 = yes; then
AC_DEFINE(HAVE_[]translit($1, [a-z], [A-Z]), 1,
[define if typedef $1 exists in header $2])
fi
])
dnl ##
dnl ## Check for an ANSI C struct attribute in a structure defined in a header
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_STRUCTATTR(<attr>, <struct>, <header>)
dnl ## acconfig.h:
dnl ## #undef HAVE_<attr>
dnl ##
AC_DEFUN(AC_CHECK_STRUCTATTR,[dnl
AC_REQUIRE([AC_HEADER_STDC])dnl
AC_MSG_CHECKING(for attribute $1 in struct $2 from $3)
AC_CACHE_VAL(ac_cv_structattr_$1,[dnl
AC_TRY_LINK([
#include <sys/types.h>
#include <$3>
],[
struct $2 *sp1;
struct $2 *sp2;
sp1->$1 = sp2->$1;
], ac_cv_structattr_$1=yes, ac_cv_structattr_$1=no)])dnl
AC_MSG_RESULT($ac_cv_structattr_$1)
if test $ac_cv_structattr_$1 = yes; then
AC_DEFINE(HAVE_[]translit($1, [a-z], [A-Z]), 1,
[define if attribute $1 exists in struct $2 from header $3])
fi
])
dnl ##
dnl ## Check for argument type of a function
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_ARGTYPE(<header> [...], <func>, <arg-number>,
dnl ## <max-arg-number>, <action-with-${ac_type}>)
dnl ##
AC_DEFUN(AC_CHECK_ARGTYPE,[dnl
AC_REQUIRE_CPP()dnl
AC_MSG_CHECKING([for type of argument $3 for $2()])
AC_CACHE_VAL([ac_cv_argtype_$2$3],[
cat >conftest.$ac_ext <<EOF
[#]line __oline__ "configure"
#include "confdefs.h"
EOF
for ifile in $1; do
echo "#include <$ifile>" >>conftest.$ac_ext
done
gpat=''
spat=''
i=1
changequote(, )dnl
while test $i -le $4; do
gpat="$gpat[^,]*"
if test $i -eq $3; then
spat="$spat\\([^,]*\\)"
else
spat="$spat[^,]*"
fi
if test $i -lt $4; then
gpat="$gpat,"
spat="$spat,"
fi
i=`expr $i + 1`
done
changequote([, ])dnl
(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |\
changequote(, )dnl
sed -e ':join' \
-e '/,[ ]*$/N' \
-e 's/,[ ]*\n[ ]*/, /' \
-e 'tjoin' |\
egrep "[^a-zA-Z0-9_]$2[ ]*\\($gpat\\)" | head -1 |\
sed -e "s/.*[^a-zA-Z0-9_]$2[ ]*($spat).*/\\1/" \
-e 's/(\*[a-zA-Z_][a-zA-Z_0-9]*)/(*)/' \
-e 's/^[ ]*//' -e 's/[ ]*$//' \
-e 's/^/arg:/' \
-e 's/^arg:\([^ ]*\)$/type:\1/' \
-e 's/^arg:\(.*_t\)*$/type:\1/' \
-e 's/^arg:\(.*\*\)$/type:\1/' \
-e 's/^arg:\(.*[ ]\*\)[_a-zA-Z][_a-zA-Z0-9]*$/type:\1/' \
-e 's/^arg:\(.*[ ]char\)$/type:\1/' \
-e 's/^arg:\(.*[ ]short\)$/type:\1/' \
-e 's/^arg:\(.*[ ]int\)$/type:\1/' \
-e 's/^arg:\(.*[ ]long\)$/type:\1/' \
-e 's/^arg:\(.*[ ]float\)$/type:\1/' \
-e 's/^arg:\(.*[ ]double\)$/type:\1/' \
-e 's/^arg:\(.*[ ]unsigned\)$/type:\1/' \
-e 's/^arg:\(.*[ ]signed\)$/type:\1/' \
-e 's/^arg:\(.*struct[ ][_a-zA-Z][_a-zA-Z0-9]*\)$/type:\1/' \
-e 's/^arg:\(.*\)[ ]_[_a-zA-Z0-9]*$/type:\1/' \
-e 's/^arg:\(.*\)[ ]\([^ ]*\)$/type:\1/' \
-e 's/^type://' >conftest.output
ac_cv_argtype_$2$3=`cat conftest.output`
changequote([, ])dnl
rm -f conftest*
])
AC_MSG_RESULT([$ac_cv_argtype_$2$3])
ac_type="$ac_cv_argtype_$2$3"
[$5]
])
dnl ##
dnl ## Decision Hierachy
dnl ##
m4_define(AC_IFALLYES,[dnl
ac_rc=yes
for ac_spec in $1; do
ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'`
ac_item=`echo "$ac_spec" | sed -e 's/^.*://'`
case $ac_type in
header [)]
ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'`
ac_var="ac_cv_header_$ac_item"
;;
file [)]
ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'`
ac_var="ac_cv_file_$ac_item"
;;
func [)] ac_var="ac_cv_func_$ac_item" ;;
lib [)] ac_var="ac_cv_lib_$ac_item" ;;
define [)] ac_var="ac_cv_define_$ac_item" ;;
typedef [)] ac_var="ac_cv_typedef_$ac_item" ;;
custom [)] ac_var="$ac_item" ;;
esac
eval "ac_val=\$$ac_var"
if test ".$ac_val" != .yes; then
ac_rc=no
break
fi
done
if test ".$ac_rc" = .yes; then
:
$2
else
:
$3
fi
])
m4_define(AC_BEGIN_DECISION,[dnl
ac_decision_item='$1'
ac_decision_msg='FAILED'
ac_decision=''
])
m4_define(AC_DECIDE,[dnl
ac_decision='$1'
ac_decision_msg='$2'
ac_decision_$1=yes
ac_decision_$1_msg='$2'
])
m4_define(AC_DECISION_OVERRIDE,[dnl
ac_decision=''
for ac_item in $1; do
eval "ac_decision_this=\$ac_decision_${ac_item}"
if test ".$ac_decision_this" = .yes; then
ac_decision=$ac_item
eval "ac_decision_msg=\$ac_decision_${ac_item}_msg"
fi
done
])
m4_define(AC_DECISION_FORCE,[dnl
ac_decision="$1"
eval "ac_decision_msg=\"\$ac_decision_${ac_decision}_msg\""
])
m4_define(AC_END_DECISION,[dnl
if test ".$ac_decision" = .; then
echo "[$]0:Error: decision on $ac_decision_item failed." 1>&2
echo "[$]0:Hint: see config.log for more details!" 1>&2
exit 1
else
if test ".$ac_decision_msg" = .; then
ac_decision_msg="$ac_decision"
fi
AC_MSG_RESULT([decision on $ac_decision_item... ${TB}$ac_decision_msg${TN}])
fi
])
dnl ##
dnl ## Check for existance of a file
dnl ##
dnl ## configure.ac:
dnl ## AC_TEST_FILE(<file>, <success-action>, <failure-action>)
dnl ##
AC_DEFUN(AC_TEST_FILE, [
ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_file_$ac_safe, [
if test -r $1; then
eval "ac_cv_file_$ac_safe=yes"
else
eval "ac_cv_file_$ac_safe=no"
fi
])dnl
if eval "test \"`echo '$ac_cv_file_'$ac_safe`\" = yes"; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
ifelse([$3], , :, [$3])
fi
])
dnl ##
dnl ## Check for socket/network size type
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_SOCKLENTYPE(<action-with-${ac_type}>)
dnl ##
dnl # Background:
dnl # this exists because of shortsightedness on the POSIX committee.
dnl # BSD systems used "int *" as the parameter to accept(2),
dnl # getsockname(2), getpeername(2) et al. Consequently many Unix
dnl # flavors took an "int *" for that parameter. The POSIX committee
dnl # decided that "int" was just too generic and had to be replaced
dnl # with "size_t" almost everywhere. There's no problem with that
dnl # when you're passing by value. But when you're passing by
dnl # reference (as it is the case for accept(2) and friends) this
dnl # creates a gross source incompatibility with existing programs.
dnl # On 32-bit architectures it creates only a warning. On 64-bit
dnl # architectures it creates broken code -- because "int *" is a
dnl # pointer to a 64-bit quantity and "size_t *" is usually a pointer
dnl # to a 32-bit quantity. Some Unix flavors adopted "size_t *" for
dnl # the sake of POSIX compliance. Others ignored it because it was
dnl # such a broken interface. Chaos ensued. POSIX finally woke up
dnl # and decided that it was wrong and created a new type socklen_t.
dnl # The only useful value for socklen_t is "int", and that's how
dnl # everyone who has a clue implements it. It is almost always the
dnl # case that this type should be defined to be an "int", unless the
dnl # system being compiled for was created in the window of POSIX
dnl # madness.
AC_DEFUN(AC_CHECK_SOCKLENTYPE,[dnl
AC_CHECK_TYPEDEF(socklen_t, sys/socket.h)
AC_CHECK_ARGTYPE(sys/types.h sys/socket.h, accept, 3, 3, [:])
AC_MSG_CHECKING(for fallback socklen_t)
AC_CACHE_VAL(ac_cv_check_socklentype, [
if test ".$ac_cv_typedef_socklen_t" = .yes; then
ac_cv_check_socklentype='socklen_t'
elif test ".$ac_type" != .; then
ac_cv_check_socklentype=`echo "$ac_type" | sed -e 's/[ ]*\*$//'`
else
ac_cv_check_socklentype='int'
fi
])
AC_MSG_RESULT([$ac_cv_check_socklentype])
ac_type="$ac_cv_check_socklentype"
ifelse([$1], , :, [$1])
])
dnl ##
dnl ## Check for filedescriptor number type
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_NFDSTYPE(<action-with-${ac_type}>)
dnl ##
AC_DEFUN(AC_CHECK_NFDSTYPE,[dnl
AC_CHECK_TYPEDEF(nfds_t, poll.h)
AC_CHECK_ARGTYPE(sys/types.h poll.h, poll, 2, 3, [:])
AC_MSG_CHECKING(for fallback nfds_t)
AC_CACHE_VAL(ac_cv_check_nfdstype, [
if test ".$ac_cv_typedef_nfds_t" = .yes; then
ac_cv_check_nfdstype='nfds_t'
elif test ".$ac_type" != .; then
ac_cv_check_nfdstype=`echo "$ac_type" | sed -e 's/[ ]*\*$//'`
else
ac_cv_check_nfdstype='unsigned int'
fi
])
AC_MSG_RESULT([$ac_cv_check_nfdstype])
ac_type="$ac_cv_check_nfdstype"
ifelse([$1], , :, [$1])
])
dnl ##
dnl ## Check for direction of stack growth
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_STACKGROWTH(<define>)
dnl ## acconfig.h:
dnl ## #undef <define>
dnl ## source.c:
dnl ## #include "config.h"
dnl ## #if <define> < 0
dnl ## ...stack grow down...
dnl ## #else
dnl ## ...stack grow up...
dnl ## #endif
dnl ##
AC_DEFUN(AC_CHECK_STACKGROWTH,[dnl
AC_MSG_CHECKING(for direction of stack growth)
AC_CACHE_VAL(ac_cv_check_stackgrowth, [
cross_compiling=no
AC_TRY_RUN(
changequote(<<, >>)dnl
<<
#include <stdio.h>
#include <stdlib.h>
static int iterate = 10;
static int growsdown(int *x)
{
auto int y;
y = (x > &y);
if (--iterate > 0)
y = growsdown(&y);
if (y != (x > &y))
exit(1);
return y;
}
int main(int argc, char *argv[])
{
FILE *f;
auto int x;
if ((f = fopen("conftestval", "w")) == NULL)
exit(1);
fprintf(f, "%s\n", growsdown(&x) ? "down" : "up");;
fclose(f);
exit(0);
}
>>
changequote([, ])dnl
,
ac_cv_check_stackgrowth=`cat conftestval`,
ac_cv_check_stackgrowth=down,
ac_cv_check_stackgrowth=down
)dnl
])dnl
AC_MSG_RESULT([$ac_cv_check_stackgrowth])
if test ".$ac_cv_check_stackgrowth" = ".down"; then
val="-1"
else
val="+1"
fi
AC_DEFINE_UNQUOTED($1, $val, [define for stack growth])
])
dnl ##
dnl ## Check whether and how a POSIX compliant sigsetjmp(3) can be achieved
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_SJLJ(<success-action>, <failure-action>, <type-var>)
dnl ##
AC_DEFUN(AC_CHECK_SJLJ,[dnl
AC_MSG_CHECKING(for signal-mask aware setjmp(3)/longjmp(3))
AC_CACHE_VAL(ac_cv_check_sjlj, [
AC_IFALLYES(func:setjmp func:longjmp, ac_cv_check_sjlj=sjlje, ac_cv_check_sjlj=none)
cross_compiling=no
for testtype in ssjlj sjlj usjlj; do
OCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -DTEST_${testtype}"
AC_TRY_RUN(
changequote(<<, >>)dnl
<<
#if defined(TEST_ssjlj)
#define __JMP_BUF sigjmp_buf
#define __SETJMP(buf) sigsetjmp(buf,1)
#define __LONGJMP(buf,val) siglongjmp(buf,val)
#elif defined(TEST_sjlj)
#define __JMP_BUF jmp_buf
#define __SETJMP(buf) setjmp(buf)
#define __LONGJMP(buf,val) longjmp(buf,val)
#elif defined(TEST_usjlj)
#define __JMP_BUF jmp_buf
#define __SETJMP(buf) _setjmp(buf)
#define __LONGJMP(buf,val) _longjmp(buf,val)
#endif
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <setjmp.h>
#include <unistd.h>
static __JMP_BUF jb;
static void sighandler(int sig)
{
sigset_t sigs;
/* get signal mask */
sigprocmask(SIG_SETMASK, NULL, &sigs);
/* make sure USR1 is still blocked */
if (!sigismember(&sigs, SIGUSR1))
exit(1);
/* block USR2 for us */
sigaddset(&sigs, SIGUSR2);
sigprocmask(SIG_SETMASK, &sigs, NULL);
/* jump back to main */
__LONGJMP(jb, 1);
exit(1);
}
int main(int argc, char *argv[])
{
FILE *fp;
sigset_t sigs;
struct sigaction sa;
/* the default is that it fails */
if ((fp = fopen("conftestval", "w")) == NULL)
exit(1);
fprintf(fp, "failed\n");
fclose(fp);
/* block USR1 and unblock USR2 signal */
sigprocmask(SIG_SETMASK, NULL, &sigs);
sigaddset(&sigs, SIGUSR1);
sigdelset(&sigs, SIGUSR2);
sigprocmask(SIG_SETMASK, &sigs, NULL);
/* set jump buffer */
if (__SETJMP(jb) == 0) {
/* install signal handler for USR1 */
memset((void *)&sa, 0, sizeof(struct sigaction));
sigemptyset(&sa.sa_mask);
sa.sa_handler = sighandler;
sa.sa_flags = 0;
sigaction(SIGUSR1, &sa, NULL);
/* send USR1 signal (which is still blocked) */
kill(getpid(), SIGUSR1);
/* unblock USR1 and wait for it */
sigprocmask(SIG_SETMASK, NULL, &sigs);
sigdelset(&sigs, SIGUSR1);
sigsuspend(&sigs);
exit(1);
}
/* get signal mask again */
sigprocmask(SIG_SETMASK, NULL, &sigs);
/* make sure USR2 is again unblocked */
if (sigismember(&sigs, SIGUSR2))
exit(1);
/* Fine... */
if ((fp = fopen("conftestval", "w")) == NULL)
exit(1);
fprintf(fp, "ok\n");
fclose(fp);
exit(0);
}
>>
changequote([, ]),
rc=`cat conftestval`,
rc=failed,
rc=failed
)
CFLAGS="$OCFLAGS"
if test ".$rc" = .ok; then
ac_cv_check_sjlj=$testtype
break
fi
done
case $PLATFORM in
*-*-linux* )
braindead=no
case "x`uname -r`" in
changequote(, )dnl
x2.[23456789]* ) ;;
changequote([, ])
* ) braindead=yes ;;
esac
case `grep __GLIBC_MINOR /usr/include/features.h | grep '#define' |\
awk '{ printf("%s", [$]3 >= 1 ? "yes" : "no"); }'` in
yes ) ;;
* ) braindead=yes ;;
esac
case $braindead in
yes ) ac_cv_check_sjlj=sjljlx ;;
no ) ac_cv_check_sjlj=ssjlj ;;
esac
;;
*86-*-gnu0* )
# GNU/Hurd is similar to linux 2.0 in that it has
# non-functional stubs for sigstack and sigaltstack.
ac_cv_check_sjlj=sjljlx
;;
*-*-isc* )
ac_cv_check_sjlj=sjljisc
;;
*-*-interix )
# Interix is a POSIX sub-system on Windows-NT which
# can use the Interactive UNIX dispatching code.
ac_cv_check_sjlj=sjljisc
;;
*-*-cygwin* )
ac_cv_check_sjlj=sjljw32
;;
esac
])dnl
$3="$ac_cv_check_sjlj"
if test ".$ac_cv_check_sjlj" != .none; then
AC_MSG_RESULT([yes: $ac_cv_check_sjlj])
ifelse([$1], , :, [$1])
else
AC_MSG_RESULT([no])
ifelse([$2], , :, [$2])
fi
])dnl
dnl ##
dnl ## Check for number of signals (NSIG)
dnl ##
dnl ## configure.ac:
dnl ## AC_CHECK_NSIG(<define>)
dnl ## acconfig.h:
dnl ## #undef <define>
dnl ## source.c:
dnl ## #include "config.h"
dnl ## ...<define>...
AC_DEFUN(AC_CHECK_NSIG,[dnl
AC_MSG_CHECKING(for number of signals)
cross_compiling=no
AC_TRY_RUN(
changequote(<<, >>)dnl
<<
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
int main(int argc, char *argv[])
{
FILE *fp;
int nsig;
#if defined(NSIG)
nsig = NSIG;
#elif defined(_NSIG)
nsig = _NSIG;
#else
nsig = (sizeof(sigset_t)*8);
if (nsig < 32)
nsig = 32;
#endif
if ((fp = fopen("conftestval", "w")) == NULL)
exit(1);
fprintf(fp, "%d\n", nsig);
fclose(fp);
exit(0);
}
>>
changequote([, ])dnl
,
nsig=`cat conftestval`,
nsig=32,
nsig=32
)
AC_MSG_RESULT([$nsig])
AC_DEFINE_UNQUOTED($1, $nsig, [define for number of signals])
])
dnl ##
dnl ## Check for FD_SETSIZE
dnl ##
dnl ## configure.in:
dnl ## AC_CHECK_FDSETSIZE(<varname>)
AC_DEFUN(AC_CHECK_FDSETSIZE,[dnl
dnl # 1. determine default value
AC_MSG_CHECKING(for default value of FD_SETSIZE)
cross_compiling=no
AC_TRY_RUN(
changequote(<<, >>)dnl
<<