maint: update copyright year
[autoconf.git] / tests / semantics.at
blob68fe861ea0da5cc26f047aab3ae51efdc87b4878
1 #                                                       -*- Autotest -*-
3 AT_BANNER([Semantics.])
5 # Copyright (C) 2000-2002, 2004-2007, 2009-2011 Free Software
6 # Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 ## -------------------------------- ##
23 ## Members of the AC_CHECK family.  ##
24 ## -------------------------------- ##
27 # AC_CHECK_LIB
28 # ------------
29 # Well, I can't imagine a system where `cos' is neither in libc, nor
30 # in libm.  Nor can I imagine a lib more likely to exists than libm.
31 # But there are systems without libm, on which we don't want to have
32 # this test fail, so exit successfully if `cos' is in libc.
33 AT_CHECK_MACRO([AC_CHECK_LIB],
34 [AC_TRY_LINK_FUNC(cos,
35                   [AC_MSG_ERROR([`cos' is in `libc'], 77)])
37 AC_CHECK_LIB(m, cos,,
38              [AC_MSG_ERROR([cannot find `cos' in `libm'])])
40 # No kidding, using variables was broken in 2.50 :(
41 ac_sin=sin
42 AC_CHECK_LIB(m, $ac_sin,,
43       [AC_MSG_ERROR([cannot find `\$ac_sin' (= `$ac_sin') in `libm'])])
45 ac_m=m
46 AC_CHECK_LIB($ac_m, acos,,
47       [AC_MSG_ERROR([cannot find `acos' in `\$ac_m' (= `$ac_m')])])
49 ac_asin=asin
50 AC_CHECK_LIB($ac_m, $ac_asin,,
51       [AC_MSG_ERROR([cannot find `\$ac_asin' (= `$ac_asin') in `\$ac_m' (= `$ac_m')])])
53 # But if the bug is in the caching mechanism, then be sure we
54 # correctly detect failures.
56 AC_CHECK_LIB(m, cossack,
57              [AC_MSG_ERROR([found `cossack' in `libm'])])
59 # No kidding, using variables was broken in 2.50 :(
60 ac_sinner=sinner
61 AC_CHECK_LIB(m, $ac_sinner,
62       [AC_MSG_ERROR([found `\$ac_sinner' (= `$ac_sinner') in `libm'])])
64 ac_m=m
65 AC_CHECK_LIB($ac_m, acossack,
66       [AC_MSG_ERROR([found `acossack' in `\$ac_m' (= `$ac_m')])])
68 ac_asinner=asinner
69 AC_CHECK_LIB($ac_m, $ac_asinner,
70       [AC_MSG_ERROR([found `\$ac_asinner' (= `$ac_asinner') in `\$ac_m' (= `$ac_m')])])
75 # AC_SEARCH_LIBS
76 # --------------
77 AT_CHECK_MACRO([AC_SEARCH_LIBS],
79 AC_SEARCH_LIBS(cos, oser m ust,,
80              [AC_MSG_ERROR([cannot find `cos'])])
82 case "$ac_cv_search_cos" in
83   -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_cos must be a cool library!]) ;;
84 esac
88 # AC_SEARCH_LIBS (none needed)
89 # ----------------------------
90 AT_CHECK_MACRO([AC_SEARCH_LIBS (none needed)],
92 AC_SEARCH_LIBS(printf, oser c ust,,
93              [AC_MSG_ERROR([cannot find `printf'])])
95 case "$ac_cv_search_printf" in
96   -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_printf must be a cool library!]) ;;
97   -lc) AC_MSG_ERROR([huh, you need to give -lc?])
98 esac
102 # AC_CHECK_DECLS
103 # --------------
104 # Check that it performs the correct actions:
105 AT_CHECK_MACRO([AC_CHECK_DECLS],
106 [[AC_CHECK_DECLS([yes, no, myenum, mystruct, myfunc, mymacro1, mymacro2],,,
107                  [[int yes = 1;
108                    enum { myenum };
109                    struct { int x[20]; } mystruct;
110                    extern int myfunc();
111                    #define mymacro1(arg) arg
112                    #define mymacro2]])
113   # The difference in space-before-open-paren is intentional.
114   AC_CHECK_DECLS([basenam (char *), dirnam(char *),
115                   [moreargs (char, short, int, long, void *, char [], float, double)]],,,
116                  [[#ifdef __cplusplus
117                    extern "C++" char *basenam (char *);
118                    extern "C++" const char *basenam (const char *);
119                    #else
120                    extern char *basenam (const char *);
121                    #endif
122                    #ifdef __cplusplus
123                    extern "C" {
124                    #endif
125                    extern int moreargs (char, short, int, long, void *,
126                                         char [], float, double);
127                    #ifdef __cplusplus
128                    }
129                    #endif
130                    ]])
131   AC_CHECK_DECL([declared (char *)],, [AS_EXIT([1])],
132                 [[#ifdef __cplusplus
133                   extern "C++" char *declared (char *);
134                   extern "C++" const char *declared (const char *);
135                   #else
136                   extern char *declared (const char *);
137                   #endif
138                 ]])
139   AC_CHECK_DECL([undeclared (char *)], [AS_EXIT([1])],, [[]])
141 [AT_CHECK_DEFINES(
142 [#define HAVE_DECL_BASENAM 1
143 #define HAVE_DECL_DIRNAM 0
144 #define HAVE_DECL_MOREARGS 1
145 #define HAVE_DECL_MYENUM 1
146 #define HAVE_DECL_MYFUNC 1
147 #define HAVE_DECL_MYMACRO1 1
148 #define HAVE_DECL_MYMACRO2 1
149 #define HAVE_DECL_MYSTRUCT 1
150 #define HAVE_DECL_NO 0
151 #define HAVE_DECL_YES 1
152 ])])
155 # AC_CHECK_FUNCS
156 # --------------
157 # Check that it performs the correct actions:
158 # Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
159 AT_CHECK_MACRO([AC_CHECK_FUNCS],
160 [AC_CHECK_FUNCS(printf autoconf_ftnirp)],
161 [AT_CHECK_DEFINES(
162 [/* #undef HAVE_AUTOCONF_FTNIRP */
163 #define HAVE_PRINTF 1
164 ])])
167 # AC_REPLACE_FUNCS
168 # ----------------
169 # Check that it performs the correct actions: autoconf_ftnirp.c must
170 # be compiled, and must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
171 # FIXME: Maybe check the traces?
172 AT_SETUP([AC_REPLACE_FUNCS])
174 AT_DATA([config.in],
175 [@LIBOBJS@
178 AT_CONFIGURE_AC(
179 [AC_CONFIG_FILES([config.libobjs:config.in])
180 AC_REPLACE_FUNCS([printf \
181 autoconf_ftnirp])
182 funcs='fprintf autoconf_ftnirpf'
183 AH_TEMPLATE([HAVE_FPRINTF], [])
184 AH_TEMPLATE([HAVE_AUTOCONF_FTNIRPF], [])
185 AC_REPLACE_FUNCS([\
186 $funcs])
187 AS_UNSET([funcs])])
189 AT_CHECK_AUTOCONF([-W obsolete])
190 AT_CHECK_AUTOHEADER
191 AT_CHECK_CONFIGURE
192 AT_CHECK_ENV
193 AT_CHECK_DEFINES(
194 [/* #undef HAVE_AUTOCONF_FTNIRP */
195 /* #undef HAVE_AUTOCONF_FTNIRPF */
196 #define HAVE_FPRINTF 1
197 #define HAVE_PRINTF 1
200 AT_CHECK([sed 's/  */ /g;s/^ //;s/ $//' config.libobjs], [],
201          [${LIBOBJDIR}autoconf_ftnirp$U.o ${LIBOBJDIR}autoconf_ftnirpf$U.o
204 AT_CLEANUP
207 # AC_CHECK_HEADERS
208 # ----------------
209 # Check that it performs the correct actions:
210 # Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H.
211 AT_SETUP([AC_CHECK_HEADERS])
213 AT_DATA([autoconf_io.h],
214 [blah blah
217 AT_CONFIGURE_AC([AC_CHECK_HEADERS(stdio.h autoconf_io.h)])
218 AT_CHECK_AUTOCONF([-W obsolete])
219 AT_CHECK_AUTOHEADER
220 AT_CHECK_CONFIGURE([CPPFLAGS=-I.], [0], [ignore],
221 [configure: WARNING: autoconf_io.h: present but cannot be compiled
222 configure: WARNING: autoconf_io.h:     check for missing prerequisite headers?
223 configure: WARNING: autoconf_io.h: see the Autoconf documentation
224 configure: WARNING: autoconf_io.h:     section "Present But Cannot Be Compiled"
225 configure: WARNING: autoconf_io.h: proceeding with the compiler's result
227 AT_CHECK_ENV
228 AT_CHECK_DEFINES(
229 [/* #undef HAVE_AUTOCONF_IO_H */
230 #define HAVE_STDIO_H 1
233 AT_CLEANUP
236 # AC_CHECK_HEADERS_OLD
237 # --------------------
238 # Check that it performs the correct actions:
239 # Must not check prerequisites, hence define header2.h
240 AT_SETUP([AC_CHECK_HEADERS (preprocessor test)])
242 AT_DATA([header1.h],
243 [typedef int foo;
246 AT_DATA([header2.h],
247 [typedef foo bar;
250 AT_CONFIGURE_AC([AC_CHECK_HEADERS(header2.h, [], [], -)])
252 AT_CHECK_AUTOCONF([-W obsolete])
253 AT_CHECK_AUTOHEADER
254 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
255 AT_CHECK_ENV
256 AT_CHECK_DEFINES(
257 [#define HAVE_HEADER2_H 1
260 AT_CLEANUP
263 # AC_CHECK_HEADERS_NEW
264 # --------------------
265 # Check that it performs the correct actions:
266 # Must check prerequisites, hence define header2.h but not header3.h
267 AT_SETUP([AC_CHECK_HEADERS (compiler test)])
269 AT_DATA([header1.h],
270 [typedef int foo;
273 AT_DATA([header2.h],
274 [typedef foo bar;
277 AT_DATA([header3.h],
278 [typedef bar wow;
281 AT_CONFIGURE_AC(
282 [AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
284 AT_CHECK_AUTOCONF([-W obsolete])
285 AT_CHECK_AUTOHEADER
286 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
287 AT_CHECK_ENV
288 AT_CHECK_DEFINES(
289 [#define HAVE_HEADER2_H 1
290 /* #undef HAVE_HEADER3_H */
293 AT_CLEANUP
296 # AC_CHECK_MEMBER
297 # ---------------
298 # Check that it performs the correct actions.
299 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
300 AT_CHECK_MACRO([AC_CHECK_MEMBER],
301 [[AC_CHECK_MEMBER([struct yes_s.yes],
302                   [AC_DEFINE([HAVE_STRUCT_YES_S_YES], [1],
303                              [Define to 1 if `yes' is a member of `struct yes_s'.])],,
304                    [struct sub { int x; };
305                     struct yes_s { int yes; struct sub substruct; };])
306   AC_CHECK_MEMBER([struct yes_s.no],
307                   [AC_DEFINE([HAVE_STRUCT_YES_S_NO], [1],
308                              [Define to 1 if `no' is a member of `struct yes_s'.])],,
309                    [struct sub { int x; };
310                     struct yes_s { int yes; struct sub substruct; };])
311   AC_CHECK_MEMBER([struct yes_s.substruct],
312                   [AC_DEFINE([HAVE_STRUCT_YES_S_SUBSTRUCT], [1],
313                              [Define to 1 if `substruct' is a member of `struct yes_s'.])],,
314                    [struct sub { int x; };
315                     struct yes_s { int yes; struct sub substruct; };])]],
316 [AT_CHECK_DEFINES(
317 [/* #undef HAVE_STRUCT_YES_S_NO */
318 #define HAVE_STRUCT_YES_S_SUBSTRUCT 1
319 #define HAVE_STRUCT_YES_S_YES 1
320 ])])
322 # AC_CHECK_MEMBERS
323 # ----------------
324 # Check that it performs the correct actions.
325 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
326 AT_CHECK_MACRO([AC_CHECK_MEMBERS],
327 [[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no, struct yes_s.substruct],,,
328                    [struct sub { int x; };
329                     struct yes_s { int yes; struct sub substruct; };])]],
330 [AT_CHECK_DEFINES(
331 [/* #undef HAVE_STRUCT_YES_S_NO */
332 #define HAVE_STRUCT_YES_S_SUBSTRUCT 1
333 #define HAVE_STRUCT_YES_S_YES 1
335 AT_CHECK([grep 'yes.*member of.*yes_s' config.h], [], [ignore])
339 # AC_CHECK_ALIGNOF
340 # ----------------
341 AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF],
342 [[AC_CHECK_ALIGNOF(char)
343 AC_CHECK_ALIGNOF(charchar,
344 [[#include <stddef.h>
345 #include <stdio.h>
346 typedef char charchar[2];]])
347 AC_CHECK_ALIGNOF(charcharchar)
349 [AT_CHECK_DEFINES(
350 [#define ALIGNOF_CHAR 1
351 #define ALIGNOF_CHARCHAR 1
352 #define ALIGNOF_CHARCHARCHAR 0
353 ])])
356 # AC_CHECK_ALIGNOF struct
357 # -----------------------
358 AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF struct],
359 [[AC_CHECK_ALIGNOF([struct { char c; }])
360 AC_CHECK_ALIGNOF([struct nosuchstruct])
362 [AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
363          0, ignore)
364 AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
365          0, ignore)
368 # AC_CHECK_SIZEOF
369 # ---------------
370 AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF],
371 [[AC_CHECK_SIZEOF(char)
372 AC_CHECK_SIZEOF(charchar,,
373 [[#include <stdio.h>
374 typedef char charchar[2];]])
375 AC_CHECK_SIZEOF(charcharchar)
377 [AT_CHECK_DEFINES(
378 [#define SIZEOF_CHAR 1
379 #define SIZEOF_CHARCHAR 2
380 #define SIZEOF_CHARCHARCHAR 0
381 ])])
384 # AC_CHECK_SIZEOF struct
385 # ----------------------
386 AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct],
387 [[AC_C_CONST
388 AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
389 AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
390 AC_CHECK_SIZEOF([struct nosuchstruct])
391 # Taken from autoconf.texi:Generic Compiler Characteristics.
392 AC_CHECK_SIZEOF([int *])
394 [AT_CHECK([[grep "#define SIZEOF_STRUCT_X [1-9]" config.h]],
395          0, ignore)
396 AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [1-9]" config.h]],
397          0, ignore)
398 AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
399          0, ignore)
400 AT_CHECK([[grep "#define SIZEOF_INT_P [1-9]" config.h]],
401          0, ignore)
405 # AC_CHECK_TYPES
406 # --------------
407 # Check that it performs the correct actions.
408 # Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
409 # `int' and `struct yes_s' are both checked to test both the compiler
410 # builtin types, and defined types.
411 AT_CHECK_MACRO([AC_CHECK_TYPES],
412 [[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
413                  [struct yes_s { int yes ;} ;])]],
414 [AT_CHECK_DEFINES(
415 [#define HAVE_INT 1
416 /* #undef HAVE_STRUCT_NO_S */
417 #define HAVE_STRUCT_YES_S 1
418 ])])
421 # AC_CHECK_TYPES
422 # --------------
423 # Check that we properly dispatch properly to the old implementation
424 # or to the new one.
425 AT_SETUP([AC_CHECK_TYPES: backward compatibility])
427 AT_DATA([configure.ac],
428 [[AC_INIT
429 define([_AC_CHECK_TYPE_NEW], [NEW])
430 define([_AC_CHECK_TYPE_OLD], [OLD])
431 #(cut-from-here
432 AC_CHECK_TYPE(ptrdiff_t)
433 AC_CHECK_TYPE(ptrdiff_t, int)
434 AC_CHECK_TYPE(quad, long long int)
435 AC_CHECK_TYPE(table_42, [int[42]])
436 # Nice machine!
437 AC_CHECK_TYPE(uint8_t, uint65536_t)
438 AC_CHECK_TYPE(a,b,c,d)
439 #to-here)
440 AC_OUTPUT
443 AT_CHECK_AUTOCONF
444 AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
445          0,
446          [NEW
454 AT_CLEANUP
457 # AC_CHECK_FILES
458 # --------------
459 # FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
460 # open AH_TEMPLATE to `configure.ac', which is not yet the case.
461 AT_CHECK_MACRO([AC_CHECK_FILES],
462 [touch at-exists1 at-exists2
463 ac_exists2=at-exists2
464 ac_missing2=at-missing2
465 AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
466 rm at-exists1 at-exists2],
467 [AT_CHECK_DEFINES(
468 [#define HAVE_AT_EXISTS1 1
469 /* #undef HAVE_AT_MISSING1 */
470 ])])
474 ## ------------------------------ ##
475 ## AC_CHECK_PROG & AC_PATH_PROG.  ##
476 ## ------------------------------ ##
479 # AT_CHECK_PROGS_PREPARE
480 # ----------------------
481 # Create a sub directory `path' with 6 subdirs which all 7 contain
482 # an executable `tool'. `6' contains a `better' tool.
483 m4_define([AT_CHECK_PROGS_PREPARE],
484 [mkdir path
486 cat >path/tool <<\EOF
487 #! /bin/sh
488 exit 0
490 chmod +x path/tool
492 for i in 1 2 3 4 5 6
494   mkdir path/$i
495   cp path/tool path/$i
496 done
497 cp path/tool path/6/better])
500 # -------------------------------- #
501 # AC_CHECK_PROG & AC_CHECK_PROGS.  #
502 # -------------------------------- #
504 AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
506 AT_CHECK_PROGS_PREPARE
508 AT_DATA([configure.ac],
509 [[AC_INIT
510 pwd=`pwd`
511 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
512 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
513 fail=false
515 AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
516 test "$TOOL1" = found || fail=:
518 # Yes, the semantics of this macro is weird.
519 AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
520 test "$TOOL2" = not-found || fail=:
522 AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
523 test "$TOOL3" = "$pwd/path/2/tool" || fail=:
525 AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
526 test "$TOOL4" = better || fail=:
528 # When a tool is not found, and no value is given for not-found,
529 # the variable is left empty.
530 AC_CHECK_PROGS(TOOL5, missing,, $path)
531 test -z "$TOOL5" || fail=:
533 AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
534 test "$TOOL6" = tool || fail=:
536 # No AC-OUTPUT, we don't need config.status.
537 $fail &&
538   AC_MSG_ERROR([[CHECK_PROG failed]])
539 AS_EXIT(0)
542 AT_CHECK_AUTOCONF
543 AT_CHECK_CONFIGURE
545 AT_CLEANUP
549 ## ---------------- ##
550 ## AC_C_BIGENDIAN.  ##
551 ## ---------------- ##
553 AT_SETUP([AC_C_BIGENDIAN])
554 AT_KEYWORDS([cross])
556 # Make sure that AC_C_BIGENDIAN behave the same whether we are
557 # cross-compiling or not.
559 _AT_CHECK_AC_MACRO(
560   [[AC_C_BIGENDIAN(
561       [ac_endian=big],
562       [ac_endian=little],
563       [ac_endian=unknown],
564       [ac_endian=universal])
565    echo $ac_endian > at-endian
568 rm -f config.hin  # So that next run of autoheader is quiet.
569 _AT_CHECK_AC_MACRO(
570   [[# Force cross compiling.
571    cross_compiling=yes
572    ac_tool_warned=yes
573    AC_C_BIGENDIAN(
574      [ac_endian=big],
575      [ac_endian=little],
576      [ac_endian=unknown],
577      [ac_endian=universal])
578    ac_prevendian=`cat at-endian`
579    # Check that we have found the same result as in the previous run
580    # or unknown (because the cross-compiling check is allowed to fail;
581    # although it might be interesting to suppress this comparison, just
582    # to know on which system it fails if it ever does).
583    if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
584      AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
585    fi
588 # Make sure AC_C_BIGENDIAN with no argument will create a config.h template
589 # containing "WORDS_BIGENDIAN".
590 AT_CONFIGURE_AC([[AC_C_BIGENDIAN]])
591 # --force is necessary, the computer might be too fast.
592 AT_CHECK_AUTOHEADER([--force])
593 AT_CHECK([grep WORDS_BIGENDIAN config.hin], [], [ignore])
595 AT_CLEANUP
598 # ------------------------------ #
599 # AC_PATH_PROG & AC_PATH_PROGS.  #
600 # ------------------------------ #
602 AT_SETUP([AC_PATH_PROG & AC_PATH_PROGS])
604 AT_CHECK_PROGS_PREPARE
606 AT_DATA([configure.ac],
607 [[AC_INIT
608 pwd=`pwd`
609 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
610 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
611 fail=false
613 AC_PATH_PROG(TOOL1, tool, not-found, $path)
614 test "$TOOL1" = "$pwd/path/1/tool" || fail=:
616 AC_PATH_PROG(TOOL2, better, not-found, $path)
617 test "$TOOL2" = "$pwd/path/6/better" || fail=:
619 # When a tool is not found, and no value is given for not-found,
620 # the variable is left empty.
621 AC_PATH_PROGS(TOOL3, missing,, $path)
622 test -z "$TOOL3" || fail=:
624 AC_PATH_PROGS(TOOL4, missing tool better,, $path)
625 test "$TOOL4" = "$pwd/path/1/tool" || fail=:
627 # No AC-OUTPUT, we don't need config.status.
628 $fail &&
629   AC_MSG_ERROR([[PATH_PROG failed]])
630 AS_EXIT(0)
633 AT_CHECK_AUTOCONF
634 AT_CHECK_CONFIGURE
636 AT_CLEANUP
640 # ----------------------------- #
641 # AC_PATH_PROGS_FEATURE_CHECK.  #
642 # ----------------------------- #
644 AT_SETUP([AC_PATH_PROGS_FEATURE_CHECK])
646 # This test doesn't work if `pwd` contains white space
647 case `pwd` in
648   *\ * | *\     *) AT_CHECK([exit 77]) ;;
649 esac
651 AT_CHECK_PROGS_PREPARE
653 AT_DATA([configure.ac],
654 [[AC_INIT
655 pwd=`pwd`
656 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
657 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
658 fail=false
660 # Find first candidate and stop search
661 AC_PATH_PROGS_FEATURE_CHECK(TOOL1, [tool better],
662   [$ac_path_TOOL1 && ac_cv_path_TOOL1=$ac_path_TOOL1 ac_path_TOOL1_found=:],
663   fail=:, $path)
664 test -z "$TOOL1" || fail=:
665 test "$ac_cv_path_TOOL1" = "$pwd/path/1/tool" || fail=:
667 # Keep searching each candidate
668 AC_PATH_PROGS_FEATURE_CHECK(TOOL2, [tool better],
669   [$ac_path_TOOL2 && ac_cv_path_TOOL2=$ac_path_TOOL2],
670   fail=:, $path)
671 test "$ac_cv_path_TOOL2" = "$pwd/path/6/better" || fail=:
673 # Only accept better candidate
674 AC_PATH_PROGS_FEATURE_CHECK(TOOL3, [tool better],
675   [case "$ac_path_TOOL3" in #(
676     *better) ac_cv_path_TOOL3=$ac_path_TOOL3;;
677   esac],
678   fail=:, $path)
679 test "$ac_cv_path_TOOL3" = "$pwd/path/6/better" || fail=:
681 # When a tool is not found, and no action is given for not-found,
682 # the variable is left empty.
683 AC_PATH_PROGS_FEATURE_CHECK(TOOL4, missing,
684   [ac_cv_path_TOOL4=$ac_path_TOOL4], [], $path)
685 test -z "$ac_cv_path_TOOL4" || fail=:
687 # Test action when tool is not found
688 AC_PATH_PROGS_FEATURE_CHECK(TOOL5, missing, [],
689   [ac_cv_path_TOOL5='not found'], $path)
690 test "$ac_cv_path_TOOL5" = "not found" || fail=:
692 # Test that pre-set tool bypasses feature test
693 TOOL6=$pwd/path/6/better
694 AC_PATH_PROGS_FEATURE_CHECK(TOOL6, tool, fail=:, fail=:, $path)
695 test "$ac_cv_path_TOOL6" = "$pwd/path/6/better" || fail=:
697 # A blank pre-set does not bypass feature test
698 TOOL7=
699 AC_PATH_PROGS_FEATURE_CHECK(TOOL7, [tool better],
700   [$ac_path_TOOL7 && ac_cv_path_TOOL7=$ac_path_TOOL7 ac_path_TOOL7_found=:],
701   fail=:, $path)
702 test -z "$TOOL7" || fail=:
703 test "$ac_cv_path_TOOL7" = "$pwd/path/1/tool" || fail=:
705 # No AC-OUTPUT, we don't need config.status.
706 $fail &&
707   AC_MSG_ERROR([[PATH_PROG failed]])
708 AS_EXIT(0)
711 AT_CHECK_AUTOCONF
712 AT_CHECK_CONFIGURE
714 AT_CLEANUP
719 ## -------------- ##
720 ## AC_PATH_XTRA.  ##
721 ## -------------- ##
724 AT_SETUP([AC_PATH_XTRA])
726 _AT_CHECK_AC_MACRO([AC_PATH_XTRA])
728 # Check X_DISPLAY_MISSING.
729 AT_CHECK_CONFIGURE([--without-x])
730 AT_CHECK_DEFINES(
731 [#define X_DISPLAY_MISSING 1
734 AT_CLEANUP
737 ## ------------------------------- ##
738 ## Obsolete non-updatable macros.  ##
739 ## ------------------------------- ##
742 AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete])
743 AT_CHECK_MACRO([AC_FUNC_SETVBUF_REVERSED], , ,[-W no-obsolete])
744 AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete])