forked from pikelang/Pike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaclocal.m4
2190 lines (2025 loc) · 59.5 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 Some compatibility with Autoconf 2.50+. Not complete.
dnl newer Autoconf calls substr m4_substr
ifdef([substr], ,[m4_copy([m4_substr],[substr])])
dnl newer Autoconf calls changequote m4_changequote
ifdef([changequote], ,[m4_copy([m4_changequote],[changequote])])
dnl Autoconf 2.53+ hides their version numbers in m4_PACKAGE_VERSION.
ifdef([AC_ACVERSION], ,[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])
dnl Old autoconf doesn't have _AC_OUTPUT_SUBDIRS.
ifdef([_AC_OUTPUT_SUBDIRS], ,
[define([_AC_OUTPUT_SUBDIRS],
[AC_OUTPUT_SUBDIRS(AC_LIST_SUBDIRS)])])
dnl Autoconf 2.71+ has put AC_REQUIRE[AC_CANONICAL_HOST] everywhere...
m4_copy([AC_CANONICAL_HOST], [ORIG_AC_CANONICAL_HOST])
m4_defun([AC_CANONICAL_HOST], [])
dnl Not really a prerequisite, but suggest the use of Autoconf 2.50 to
dnl autoconf-wrapper if it is used. dnl can't be used since the wrapper
dnl checks for it, so just store it in a dummy define.
define([require_autoconf_2_50],[AC_PREREQ(2.50)])
dnl major, minor, on_ge, on_lt
define([if_autoconf],
[ifelse(ifelse(index(AC_ACVERSION,.),-1,0,[m4_eval(
translit(substr(AC_ACVERSION, 0, index(AC_ACVERSION,.)),[A-Za-z])-0 >= $1 &&
(
translit(substr(AC_ACVERSION, 0, index(AC_ACVERSION,.)),[A-Za-z])-0 > $1 ||
translit(substr(AC_ACVERSION, index(+AC_ACVERSION,.)),[A-Za-z])-0 >= $2
)
)]),1,[$3],[$4])])
dnl Autoconf 2.60 is the first version that supports C99.
dnl C99-compilers complain about implicit declarations.
dnl For autoconf 2.59 and earlier: Make sure at least
dnl exit(3C) is declared.
dnl
dnl NB: Simply always including <stdlib.h> causes some
dnl AC_HAVE_FUNC tests to fail due to mismatching
dnl prototypes.
dnl
dnl We overload _AC_PROG_CC_STDC to insert an extra
dnl call of _AC_PROG_CXX_EXIT_DECLARATION due to it
dnl usually only being used for C++.
if_autoconf(2,60,,[
m4_copy([_AC_PROG_CC_STDC], [ORIG__AC_PROG_CC_STDC])
m4_define([_AC_PROG_CC_STDC], [
ORIG__AC_PROG_CC_STDC
# Some C99 compilers default to -Werror,-Wimplicit-function-declaration
# Attempt to find a suitable prototype for exit(3C).
_AC_COMPILE_IFELSE([@%:@ifdef __cplusplus
choke me
@%:@endif], [
patsubst(_AC_PROG_CXX_EXIT_DECLARATION, [ifdef], [ifndef])
])
])
])
pushdef([AC_PROG_CC_WORKS],
[
popdef([AC_PROG_CC_WORKS])
if test "x$enable_binary" != "xno"; then
if test "${ac_prog_cc_works_this_run-}" != "yes" ; then
AC_PROG_CC_WORKS
ac_prog_cc_works_this_run="${ac_cv_prog_cc_works-no}"
export ac_prog_cc_works_this_run
else
AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) works])
AC_MSG_RESULT([(cached) yes])
fi
fi
])
pushdef([AC_PROG_CC],
[
popdef([AC_PROG_CC])
AC_PROG_CC
if test "$ac_cv_prog_cc_g" = no; then
# The -g test is broken for some compilers (eg ecc), since
# they always have output (they echo the name of the source file).
AC_MSG_CHECKING(if -g might not be ok after all)
AC_CACHE_VAL(pike_cv_prog_cc_g, [
echo 'void f(){}' > conftest.c
if test "`${CC-cc} -g -c conftest.c 2>&1`" = \
"`${CC-cc} -c conftest.c 2>&1`"; then
pike_cv_prog_cc_g=yes
else
pike_cv_prog_cc_g=no
fi
rm -f conftest*
])
if test "$pike_cv_prog_cc_g" = "yes"; then
AC_MSG_RESULT(yes)
ac_cv_prog_cc_g=yes
else
AC_MSG_RESULT(no)
fi
fi
if test "$ac_test_CFLAGS"; then :; else
if test "$GCC" = yes; then
# Remove -O2, and use a real test to restore it.
if test "$ac_cv_prog_cc_g" = yes; then
CFLAGS="-g"
else
CFLAGS=
fi
else :; fi
fi
AC_MSG_CHECKING([if we are using ICC (Intel C Compiler)])
AC_CACHE_VAL(pike_cv_prog_icc, [
if $CC -V 2>&1 | grep -i Intel >/dev/null; then
pike_cv_prog_icc="yes"
else
pike_cv_prog_icc="no"
fi
])
if test "x$pike_cv_prog_icc" = "xyes"; then
AC_MSG_RESULT(yes)
ICC="yes"
# Make sure libimf et al are linked statically.
# NB: icc 6, 7 and 8 only have static versions.
AC_MSG_CHECKING([if it is ICC 9.0 or later])
icc_version="`$CC -V 2>&1 | sed -e '/^Version /s/Version \([0-9]*\)\..*/\1/p' -ed`"
if test "0$icc_version" -ge 9; then
if echo "$CC $LDFLAGS $LIBS" | grep " -i-" >/dev/null; then
AC_MSG_RESULT(yes - $icc_version)
else
AC_MSG_RESULT(yes - $icc_version - Adding -i-static)
LDFLAGS="-i-static $LDFLAGS"
fi
else
if test "x$icc_version" = x; then
AC_MSG_RESULT(no - no version information)
else
AC_MSG_RESULT(no - $icc_version)
fi
fi
else
AC_MSG_RESULT(no)
ICC=no
fi
])
# Check for libgcc.
define([PIKE_CHECK_LIBGCC],[
if test $ac_cv_prog_gcc = yes; then
AC_MSG_CHECKING(for libgcc file name)
if test -f "$pike_cv_libgcc_filename"; then :; else
# libgcc has gone away probably due to gcc having been upgraded.
# Invalidate the entry.
unset pike_cv_libgcc_filename
fi
AC_CACHE_VAL(pike_cv_libgcc_filename,
[
pike_cv_libgcc_filename="`${CC-cc} $CCSHARED -print-libgcc-file-name`"
if test -z "$pike_cv_libgcc_filename"; then
pike_cv_libgcc_filename=no
else
if test -f "$pike_cv_libgcc_filename"; then
pic_name=`echo "$pike_cv_libgcc_filename"|sed -e 's/\.a$/_pic.a/'`
if test -f "$pic_name"; then
pike_cv_libgcc_filename="$pic_name"
fi
else
pike_cv_libgcc_filename=no
fi
fi
])
AC_MSG_RESULT($pike_cv_libgcc_filename)
if test x"$pike_cv_libgcc_filename" = xno; then
LIBGCC=""
else
LIBGCC="$pike_cv_libgcc_filename"
fi
else
LIBGCC=""
fi
AC_SUBST(LIBGCC)
])
dnl Like AC_PATH_PROG but if $2 isn't found and $RNTANY is set, tries
dnl to execute "$RNTANY $2 /?" and defines $1 to "$RNTANY $2" if that
dnl succeeds.
define([PIKE_NT_PROG], [
AC_PATH_PROG([$1], [$2], , [$4])
if test "x$$1" = x; then
if test "x$RNTANY" != x; then
AC_MSG_CHECKING([if $RNTANY $2 /? can be executed])
AC_CACHE_VAL(pike_cv_exec_rntany_$1, [
if $RNTANY $2 '/?' >/dev/null 2>&1; then
pike_cv_exec_rntany_$1=yes
else
pike_cv_exec_rntany_$1=no
fi
])
if test "x$pike_cv_exec_rntany_$1" = xyes; then
AC_MSG_RESULT(yes)
$1="$RNTANY $2"
else
AC_MSG_RESULT(no)
$1="$3"
fi
else
$1="$3"
fi
fi
])
define([ORIG_AC_FUNC_MMAP], defn([AC_FUNC_MMAP]))
define([AC_FUNC_MMAP], [
if_autoconf(2,50,[],[
cat >>confdefs.h <<\EOF
/* KLUDGE for broken prototype in the autoconf 1.13 version of the test. */
#include <stdlib.h> /* KLUDGE */
char *my_malloc(sz) unsigned long sz; { return malloc(sz); } /* KLUDGE */
#define malloc my_malloc /* KLUDGE */
EOF
])
ORIG_AC_FUNC_MMAP
if_autoconf(2,50,[],[
sed -e '/\/\* KLUDGE /d' <confdefs.h >confdefs.h.tmp
mv confdefs.h.tmp confdefs.h
])
])
dnl option, descr, with, without, default
define([MY_AC_ARG_WITH], [
AC_ARG_WITH([$1], [$2], [
if test "x$withval" = "xno"; then
ifelse([$4], , :, [$4])
else
ifelse([$3], , :, [$3])
fi
], [$5])
])
dnl flag, descr
define([MY_DESCR],
[ substr([$1][ ],0,33) [$2]])
define([MY_AC_PROG_CC],
[
dnl Note: It's tricky to speed this up by only doing it once when
dnl the modules are configured with the base - different autoconfs
dnl set different variables that might not get propagated, e.g.
dnl $ac_exeext in 2.59.
define(ac_cv_prog_CC,pike_cv_prog_CC)
AC_PROG_CC
undefine([ac_cv_prog_CC])
AC_PROG_CPP
if test "x$enable_binary" = x"no"; then
# Do the check above even when --disable-binary is used, since we
# need a real $CPP, and AC_PROG_CPP wants AC_PROG_CC to be called
# earlier.
CC="$BINDIR/nobinary_dummy cc"
ac_cv_c_undeclared_builtin_options='none needed'
fi
])
dnl Not available before Autoconf 2.60.
ifdef([AC_USE_SYSTEM_EXTENSIONS],[],[
m4_defun([AC_USE_SYSTEM_EXTENSIONS], [
AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
[/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable non-POSIX declarations on Darwin. */
#ifndef _DARWIN_C_SOURCE
# undef _DARWIN_C_SOURCE
#endif
/* Enable non-POSIX declarations on NetBSD. */
#ifndef _NETBSD_SOURCE
# undef _NETBSD_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
])
AC_DEFINE(_GNU_SOURCE)
AC_DEFINE(_DARWIN_C_SOURCE)
AC_DEFINE(_NETBSD_SOURCE)
AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
AC_DEFINE(_TANDEM_SOURCE)
])
])
AC_DEFUN([PIKE_USE_SYSTEM_EXTENSIONS],
[
dnl Autoconf default extensions macro.
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
AH_VERBATIM([USE_POSIX_C_EXTENSIONS],
[
#ifndef POSIX_SOURCE
/* We must define this *always* */
# define POSIX_SOURCE 1
#endif
#ifndef _POSIX_C_SOURCE
/* Version of POSIX that we want to support.
* Note that POSIX.1-2001 and later require C99, and the earlier
* require C89.
* undef Not POSIX.
* 1 POSIX.1-1990
* 2 POSIX.2-1992
* 199309L POSIX.1b-1993 (Real Time)
* 199506L POSIX.1c-1995 (POSIX Threads)
* 200112L POSIX.1-2001 (Austin Group Revision)
* 200809L POSIX.1-2008
*/
# undef _POSIX_C_SOURCE
#endif
#ifndef _XOPEN_SOURCE
/* Version of XPG that we want to support.
* Note that this interacts with _POSIX_C_SOURCE above.
* undef Not XPG (X Open Group).
* 1 XPG 3 or 4 or 4v2 (see below).
* 500 XPG 5 (POSIX.1c-1995).
* 600 XPG 6 (POSIX.1-2001).
* 700 XPG 7 (POSIX.1-2008).
*/
# undef _XOPEN_SOURCE
# if defined(_XOPEN_SOURCE) && ((_XOPEN_SOURCE + 0) < 500)
/* Define to 4 for XPG 4. NB: Overrides _XOPEN_SOURCE_EXTENDED below. */
# undef _XOPEN_VERSION
/* Define to 1 (and do NOT define _XOPEN_VERSION) for XPG 4v2. */
# undef _XOPEN_SOURCE_EXTENDED
# endif
#endif
#ifndef _DARWIN_C_SOURCE
#undef _DARWIN_C_SOURCE
#endif
#ifndef _NETBSD_SOURCE
#undef _NETBSD_SOURCE
#endif
#ifndef __BSD_VISIBLE
#undef __BSD_VISIBLE
#endif
])
AC_DEFINE(POSIX_SOURCE, 1)
AC_MSG_CHECKING(for level of POSIX to support)
AC_CACHE_VAL(pike_cv_posix_c_source, [
ORIG_CPPFLAGS="$CPPFLAGS"
# NB: Older Solaris fails on attempts to enable newer POSIX
# than supported.
for pike_cv_posix_c_source in 200809L 200112L 199506L 199309L 2 1; do
CPPFLAGS="$ORIG_CPPFLAGS -D_POSIX_C_SOURCE=$pike_cv_posix_c_source"
AC_TRY_CPP([
#include <stdio.h>
#include <stdlib.h>
],break;)
done
CPPFLAGS="$ORIG_CPPFLAGS"
])
AC_MSG_RESULT($pike_cv_posix_c_source)
AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE, $pike_cv_posix_c_source)
# NB: _XOPEN_SOURCE overrides _POSIX_C_SOURCE on FreeBSD 10.3.
if test "$pike_cv_posix_c_source" = "200809L"; then
AC_DEFINE(_XOPEN_SOURCE, 700)
elif test "$pike_cv_posix_c_source" = "200112L"; then
AC_DEFINE(_XOPEN_SOURCE, 600)
elif test "$pike_cv_posix_c_source" = "199506L"; then
AC_DEFINE(_XOPEN_SOURCE, 500)
else
# Attempt XPG 4v2.
AC_DEFINE(_XOPEN_SOURCE, 1)
AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1)
fi
AC_DEFINE(_DARWIN_C_SOURCE)
AC_DEFINE(_NETBSD_SOURCE)
# Enable non-POSIX types in <sys/types.h> on FreeBSD 10.3.
AC_DEFINE(__BSD_VISIBLE, 1)
])
dnl Use before the first AC_CHECK_HEADER/AC_CHECK_FUNC call if the
dnl proper declarations are required to test function presence in
dnl AC_CHECK_FUNC. Necessary on Windows since various attributes cause
dnl name mangling there (e.g. __stdcall and __declspec(dllimport)).
dnl
dnl This test method is more correct (it e.g. detects functions that
dnl are implemented as macros) than the standard AC_CHECK_FUNC
dnl implementation and could perhaps be used all the time. It's
dnl however more fragile since AC_CHECK_HEADER must check all
dnl candidate headers before AC_CHECK_FUNC is used, and there might be
dnl conflicts between headers that can't be used simultaneously. It
dnl can also be quite a bit slower than the standard autoconf method.
AC_DEFUN([PIKE_FUNCS_NEED_DECLS],
[
test "x$1" != x && pike_cv_funcs_need_decls="$1"
if test "x$pike_cv_funcs_need_decls" = xyes; then
cat > hdrlist.h <<EOF
/* Some C89 header files. */
#include <math.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
EOF
fi
])
pushdef([AC_CONFIG_HEADER],
[
CONFIG_HEADERS="$1"
popdef([AC_CONFIG_HEADER])
AC_CONFIG_HEADER($1)
])
# The CHECK_HEADERS_ONCE macro gets broken if CHECK_HEADER gets redefined.
# We redefine it to do an ordinary CHECK_HEADERS.
ifdef([AC_CHECK_HEADERS_ONCE],[
define([ORIG_AC_CHECK_HEADERS_ONCE], defn([AC_CHECK_HEADERS_ONCE]))
AC_DEFUN([AC_CHECK_HEADERS_ONCE],[
dnl ORIG_AC_CHECK_HEADERS_ONCE([$1])
AC_CHECK_HEADERS([$1])
])
])
define([ORIG_AC_CHECK_HEADER], defn([AC_CHECK_HEADER]))
AC_DEFUN([AC_CHECK_HEADER],
[
AC_REQUIRE([PIKE_FUNCS_NEED_DECLS])
ORIG_AC_CHECK_HEADER([$1], [
if test x$pike_cv_funcs_need_decls = xyes; then
def=HAVE_`echo "$1" | tr '[[a-z]]' '[[A-Z]]' | sed -e 's,[[-./]],_,g'`
cat >> hdrlist.h <<EOF
#ifdef $def
#include <$1>
#endif
EOF
fi
$2
], [$3], [$4])
])
AC_DEFUN([PIKE_CHECK_GNU_STUBS_H],[
AC_CHECK_HEADERS([gnu/stubs.h])
])
# Note: Check headers with AC_CHECK_HEADERS before using this one; see
# blurb at PIKE_FUNCS_NEED_DECLS.
define([ORIG_AC_CHECK_FUNC], defn([AC_CHECK_FUNC]))
AC_DEFUN([AC_CHECK_FUNC],
[AC_REQUIRE([PIKE_CHECK_GNU_STUBS_H])dnl
AC_REQUIRE([PIKE_FUNCS_NEED_DECLS])
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_func_$1,
[
if test x$pike_cv_funcs_need_decls = xyes; then
AC_TRY_LINK([
#include "hdrlist.h"
#ifndef $1
void *f = (void *) $1;
#endif
], [
#ifdef $1
/* If there's a macro with this name we assume it takes the place of the function. */
return 0;
#else
return f != $1;
#endif
], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")
else
AC_TRY_LINK([
#ifdef HAVE_GNU_STUBS_H
/* This file contains __stub_ defines for broken functions. */
#include <gnu/stubs.h>
#else
/* Define $1 to an innocuous variant, in case <limits.h> declares $1.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $1 innocuous_$1
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $1 (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef $1
#endif
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $1 ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$1) || defined (__stub___$1)
choke me
#else
char (*f) () = $1;
#endif
#ifdef __cplusplus
}
#endif
], [return f != $1;], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")
fi
])
if eval "test \"`echo '$ac_cv_func_'$1`\" = yes"; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
ifelse([$3], , , [$3
])dnl
fi
])
AC_DEFUN([PIKE_IS_CROSS_COMPILING], [[${ac_cv_prog_cc_cross:-${cross_compiling}}]])
AC_DEFUN([PIKE_OVERRIDE_CROSS_COMPILING], [[
if [ -n "${ac_cv_prog_cc_cross}" -o -z "${cross_compiling}" ]; then
ac_cv_prog_cc_cross=$1; else cross_compiling=$1; fi
]])
dnl PIKE_SEARCH_LIBS(FUNCTION, CALL-CODE, SEARCH-LIBS,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
dnl [OTHER-LIBRARIES])
dnl
dnl This is like AC_SEARCH_LIBS except that the added argument
dnl CALL-CODE is a complete code snippet that should make a typewise
dnl correct call to the function. It can be necessary in some cases
dnl where we have name mangling, e.g. in Windows libs that use
dnl __stdcall.
dnl
dnl Only applicable if PIKE_FUNCS_NEED_DECLS is enabled, otherwise it
dnl just wraps AC_SEARCH_LIBS.
define([PIKE_SEARCH_LIBS], [
if test x$pike_cv_funcs_need_decls = xyes; then
dnl FIXME: Should use AC_LANG_CONFTEST and AC_LINK_IFELSE available
dnl in more modern autoconfs.
AC_MSG_CHECKING([for library containing $1])
AC_CACHE_VAL(pike_cv_search_$1, [
pike_lib_search_save_LIBS=$LIBS
test -f hdrlist.h || echo > hdrlist.h
for pike_lib in '' $3; do
if test -z "$pike_lib"; then
pike_cv_search_$1="none required"
else
pike_cv_search_$1=-l$pike_lib
LIBS="-l$pike_lib $6 $pike_lib_search_save_LIBS"
fi
AC_TRY_LINK([
#include "hdrlist.h"], [
$2], break, pike_cv_search_$1=no)
done
LIBS=$pike_lib_search_save_LIBS
])
if test "$pike_cv_search_$1" = no; then
AC_MSG_RESULT(no)
$5
else
AC_MSG_RESULT($pike_cv_search_$1)
test "$pike_cv_search_$1" = "none required" || LIBS="$pike_cv_search_$1 $LIBS"
$4
fi
else
AC_SEARCH_LIBS([$1],[$3],[
dnl Since ACTION-IF-FOUND should refer to the pike_cv_search_* variable
dnl rather than to the ac_cv_search_* variable.
pike_cv_search_$1=$ac_cv_search_$1
$4],[$5],[$6])
fi
])
AC_DEFUN([PIKE_AC_CC_IS_RNT],
[
if test "x$pike_cc_is_rnt" = "x"; then
if echo foo "$CC" | $EGREP 'rntc.|rnt.cl' >/dev/null; then
pike_cc_is_rnt=yes
else
pike_cc_is_rnt=no
fi
fi
])
AC_DEFUN([PIKE_REQUIRE_AC_CC_IS_RNT], [AC_REQUIRE([PIKE_AC_CC_IS_RNT])])
define([ORIG_AC_CHECK_SIZEOF], defn([AC_CHECK_SIZEOF]))
pushdef([AC_CHECK_SIZEOF],
[
changequote(<<, >>)dnl
define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
changequote([, ])dnl
PIKE_REQUIRE_AC_CC_IS_RNT()dnl
if test x"PIKE_IS_CROSS_COMPILING" = x"yes" -o "x$pike_cc_is_rnt" = "xyes"; then
AC_MSG_CHECKING(size of $1 ... crosscompiling or rnt)
AC_CACHE_VAL(AC_CV_NAME,[
cat > conftest.$ac_ext <<EOF
dnl This sometimes fails to find confdefs.h, for some reason.
dnl [#]line __oline__ "[$]0"
[#]line __oline__ "configure"
#include "confdefs.h"
[$3]
#include <stdio.h>
char size_info[[]] = {
0, 'S', 'i', 'Z', 'e', '_', 'I', 'n', 'F', 'o', '_',
'0' + sizeof([$1]), 0
};
EOF
if AC_TRY_EVAL(ac_compile); then
if test -f "conftest.$ac_objext"; then
AC_CV_NAME=`strings "conftest.$ac_objext" | sed -e '/^SiZe_InFo_[[0-9]]$/s/SiZe_InFo_//p' -ed | head -n 1`
if test "x$AC_CV_NAME" = "x"; then
AC_MSG_WARN([Magic cookie not found.])
AC_CV_NAME=ifelse([$2], , 0, [$2])
else :; fi
else
AC_MSG_WARN([Object file not found.])
AC_CV_NAME=ifelse([$2], , 0, [$2])
fi
else
AC_CV_NAME=0
fi
rm -rf conftest*
])
AC_MSG_RESULT($AC_CV_NAME)
elif test "x$enable_binary" = "xno"; then
AC_CV_NAME=ifelse([$2], , 0, [$2])
fi
undefine([AC_CV_NAME])dnl
ORIG_AC_CHECK_SIZEOF([$1],[$2],[$3])
])
m4_copy([AC_CHECK_HEADERS], [ORIG_CHECK_HEADERS])
ifdef([_AC_CHECK_HEADERS],
[m4_copy([_AC_CHECK_HEADERS], [_ORIG_CHECK_HEADERS])])
define([AC_CHECK_HEADERS],
[
if test "x$enable_binary" != "xno"; then
ORIG_CHECK_HEADERS($1,$2,$3,$4)
else
for ac_hdr in $1
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
eval "ac_cv_header_$ac_safe=yes"
done
fi
])
AC_DEFUN(AC_MY_CHECK_TYPE,
[
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_type_$1,
[
AC_TRY_COMPILE([
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
$3
],[
$1 tmp;
],ac_cv_type_$1=yes,ac_cv_type_$1=no)
])
if test $ac_cv_type_$1 = no; then
AC_DEFINE($1,$2)
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
])
AC_DEFUN(AC_TRY_ASSEMBLE,
[ac_c_ext=$ac_ext
ac_ext=${ac_s_ext-s}
cat > conftest.$ac_ext <<EOF
.file "configure"
[$1]
EOF
if AC_TRY_EVAL(ac_compile); then
ac_ext=$ac_c_ext
ifelse([$2], , :, [ $2
rm -rf conftest*])
else
echo "configure: failed program was:" >&AC_FD_CC
cat conftest.$ac_ext >&AC_FD_CC
ac_ext=$ac_c_ext
ifelse([$3], , , [ rm -rf conftest*
$3
])dnl
fi
rm -rf conftest*])
dnl PIKE_CHECK_CONSTANTS(checking_message, constant_names, includes, define_name)
dnl
dnl define_name will be defined to the first constant in
dnl constant_names that exists. It will remain undefined if none of
dnl them exists.
AC_DEFUN(PIKE_CHECK_CONSTANTS,
[
AC_MSG_CHECKING([$1])
AC_CACHE_VAL(pike_cv_$4_value, [
pike_cv_$4_value=""
for const in $2
do
AC_TRY_COMPILE([$3], [int tmp = (int) $const;], [
pike_cv_$4_value="$const"
break
])
done
])
if test x"$pike_cv_$4_value" != x; then
AC_MSG_RESULT($pike_cv_$4_value)
AC_DEFINE_UNQUOTED([$4], $pike_cv_$4_value)
else
AC_MSG_RESULT(none)
fi
])
dnl PIKE_AC_CHECK_OS()
dnl
dnl Check the operating system
AC_DEFUN(PIKE_AC_CHECK_OS, [
AC_PATH_PROG(uname_prog,uname,no)
AC_MSG_CHECKING(operating system)
AC_CACHE_VAL(pike_cv_sys_os, [
if test "PIKE_IS_CROSS_COMPILING" = "yes"; then
case "$host_alias" in
*amigaos*) pike_cv_sys_os="AmigaOS";;
*linux*) pike_cv_sys_os="Linux";;
*solaris*) pike_cv_sys_os="Solaris";;
*sunos*) pike_cv_sys_os="SunOS";;
*windows*) pike_cv_sys_os="Windows_NT";;
*mingw*|*MINGW*)
pike_cv_sys_os="Windows_NT"
pike_cv_is_mingw="yes";;
*) pike_cv_sys_os="Unknown";;
esac
elif test "$uname_prog" != "no"; then
# uname on UNICOS doesn't work like other people's uname...
if getconf CRAY_RELEASE >/dev/null 2>&1; then
pike_cv_sys_os="UNICOS"
else
pike_cv_sys_os="`uname`"
fi
case "$pike_cv_sys_os" in
SunOS)
case "`uname -r`" in
5.*) pike_cv_sys_os="Solaris" ;;
esac
;;
Monterey64)
# According to the release notes, the string "Monterey64"
# will be changed to "AIX" in the final release.
# (Monterey 64 is also known as AIX 5L).
pike_cv_sys_os="AIX"
;;
*Windows*|*windows*)
pike_cv_sys_os="Windows_NT"
;;
*MINGW*|*mingw*)
pike_cv_is_mingw="yes"
pike_cv_sys_os="Windows_NT"
;;
esac
else
pike_cv_sys_os="Not Solaris"
fi
])
AC_MSG_RESULT($pike_cv_sys_os)
])
dnl
dnl PIKE_FEATURE_CLEAR()
dnl PIKE_FEATURE(feature,text)
dnl
define(PIKE_FEATURE_CLEAR,[
rm pike_*.feature 2>/dev/null
])
define(PIKE_FEATURE_RAW,[
cat >pike_[$1].feature <<EOF
[$2]
EOF])
define([PAD_FEATURE],[substr([$1][................................],0,20) ])
define(PIKE_FEATURE_3,[
cat >pike_[$1].feature <<EOF
PAD_FEATURE([$2])[$3]
EOF])
define(PIKE_FEATURE,[
PIKE_FEATURE_3(translit([[$1]],[. ()],[____]),[$1],[$2])
])
define(PIKE_FEATURE_WITHOUT,[
PIKE_FEATURE([$1],[no (forced without)])
])
define(PIKE_FEATURE_NODEP,[
PIKE_FEATURE([$1],[no (dependencies failed)])
])
define(PIKE_FEATURE_OK,[
PIKE_FEATURE([$1],ifelse([$2], ,[yes],[$2]))
if test x"$MODULE_NAME" = "x[$2]"; then
MODULE_OK=yes
fi
])
define([PIKE_RETAIN_VARIABLES],
[
if test -f propagated_variables; then
# Retain values for propagated variables; see make_variables.in.
sed -e 's/'"'"'/'"'"'"'"'"'"'"'"'/g' -e 's/^\([[^=]]*\)=\(.*\)$/\1=${\1='"'"'\2'"'"'};export \1/' < propagated_variables > propvars.sh
. ./propvars.sh && rm propvars.sh
fi
# This allows module configure scripts to extend these variables.
CFLAGS=$BASE_CFLAGS
CXXFLAGS=$BASE_CXXFLAGS
CPPFLAGS=$BASE_CPPFLAGS
LDFLAGS=$BASE_LDFLAGS
# Since BASE_LDFLAGS contains the libs too, we start with an empty LIBS.
LIBS=
# Make these known under their old configure script names.
BUILDDIR=$TMP_BUILDDIR
BINDIR=$TMP_BINDIR
])
define([AC_LOW_MODULE_INIT],
[
MY_AC_PROG_CC
AC_PROG_EGREP
PIKE_SELECT_ABI
PIKE_USE_SYSTEM_EXTENSIONS
dnl The following shouldn't be necessary; it comes from the core
dnl machine.h via global.h anyway. Defining it here makes the
dnl compiler complain about redefinition.
dnl AC_DEFINE([POSIX_SOURCE], [], [This should always be defined.])
AC_SUBST(CONFIG_HEADERS)
AC_SUBST_FILE(dependencies)
dependencies=$srcdir/dependencies
AC_SUBST_FILE(dynamic_module_makefile)
AC_SUBST_FILE(static_module_makefile)
AC_ARG_WITH(root, MY_DESCR([--with-root=path],[specify a cross-compilation root-directory]),[
case "$with_root" in
/)
with_root=""
;;
/*)
;;
no)
with_root=""
;;
*)
AC_MSG_WARN([Root path $with_root is not absolute. Ignored.])
with_root=""
;;
esac
],[with_root=""])
if test "x$enable_binary" = "xno"; then
# Fix makefile rules as if we're cross compiling, to use pike
# fallbacks etc. Do this without setting $ac_cv_prog_cc_cross to yes
# since autoconf macros like AC_TRY_RUN will complain bitterly then.
CROSS=yes
else
CROSS="PIKE_IS_CROSS_COMPILING"
fi
AC_SUBST(CROSS)
if test "x$enable_binary" = "xno"; then
RUNPIKE="USE_PIKE"
else
if test x"PIKE_IS_CROSS_COMPILING" = x"yes"; then
RUNPIKE="USE_PIKE"
else
RUNPIKE="DEFAULT_RUNPIKE"
fi
fi
AC_SUBST(RUNPIKE)
PIKE_CHECK_LIBGCC
])
dnl module_name
define([AC_MODULE_INIT],
[
PIKE_RETAIN_VARIABLES()
# Initialize the MODULE_{NAME,PATH,DIR} variables
#
# MODULE_NAME Name of module as available from Pike.
# MODULE_PATH Module indexing path including the last '.'.
# MODULE_DIR Directory where the module should be installed
# including the last '/'.
# MODULE_OK Initialized to 'no'. Set to 'yes' by FEATURE_OK.
# Checked against with at OUTPUT.
ifelse([$1], , [
MODULE_NAME="`pwd|sed -e 's@.*/@@g'`"
MODULE_PATH=""
MODULE_DIR=""
], [
MODULE_NAME="regexp([$1], [\([^\.]*\)$], [\1])"
MODULE_PATH="regexp([$1], [\(.*\.\)*], [\&])"
MODULE_DIR="patsubst(regexp([$1], [\(.*\.\)*], [\&]), [\.], [\.pmod/])"
])
MODULE_OK=no
AC_SUBST(MODULE_NAME)dnl
AC_SUBST(MODULE_PATH)dnl
AC_SUBST(MODULE_DIR)dnl
echo
echo '###################################################'
echo '## Configuring module:' "$MODULE_PATH$MODULE_NAME"
echo '## Installation dir: ' "$MODULE_DIR"
echo
AC_LOW_MODULE_INIT()
PIKE_FEATURE_CLEAR()
if (test -f "$srcdir/module.pmod.in" || test -d "$srcdir/module.pmod.in"); then
MODULE_PMOD_IN="$srcdir/module.pmod.in"
MODULE_WRAPPER_PREFIX="___"
else
MODULE_PMOD_IN=""
MODULE_WRAPPER_PREFIX=""
fi
AC_SUBST(MODULE_PMOD_IN)
AC_SUBST(MODULE_WRAPPER_PREFIX)
if test -d $BUILD_BASE/modules/. ; then
dynamic_module_makefile=$BUILD_BASE/modules/dynamic_module_makefile
static_module_makefile=$BUILD_BASE/modules/static_module_makefile
else
dynamic_module_makefile=$BUILD_BASE/dynamic_module_makefile
static_module_makefile=$BUILD_BASE/dynamic_module_makefile
fi
PIKE_AC_CHECK_OS()
if test x"$pike_cv_sys_os" = xWindows_NT ; then
PIKE_FUNCS_NEED_DECLS(yes)
fi
])
pushdef([AC_OUTPUT],
[
AC_SET_MAKE
AC_CONFIG_FILES([stamp-h], [echo foo >stamp-h])
PMOD_TARGETS=`echo $srcdir/*.cmod | sed -e "s/\.cmod/\.c/g" | sed -e "s|$srcdir/|\\$(SRCDIR)/|g"`
test "$PMOD_TARGETS" = '$(SRCDIR)/*.c' && PMOD_TARGETS=
AC_SUBST(PMOD_TARGETS)