Prefer HTTPS to FTP and HTTP
[autoconf.git] / tests / semantics.at
blobec44af3ad0e03d2f3ab0e85ef89fd92b78ee8bb4
1 #                                                       -*- Autotest -*-
3 AT_BANNER([Semantics.])
5 # Copyright (C) 2000-2002, 2004-2007, 2009-2017 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 <https://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 # For the benefit of _AC_UNDECLARED_WARNING compilers, these INCLUDES sections
105 # should not elicit warnings.
106 AT_CHECK_MACRO([AC_CHECK_DECLS],
107 [[AC_CHECK_DECLS([yes, no, myenum, mystruct, myfunc, mymacro1, mymacro2],,,
108                  [[extern int yes;
109                    enum { myenum };
110                    extern struct { int x[20]; } mystruct;
111                    extern int myfunc();
112                    #define mymacro1(arg) arg
113                    #define mymacro2]])
114   # Clang reports a warning for an undeclared builtin.
115   AC_CHECK_DECLS([strerror],,, [[]])
116   # The difference in space-before-open-paren is intentional.
117   AC_CHECK_DECLS([basenam (char *), dirnam(char *),
118                   [moreargs (char, short, int, long, void *, char [], float, double)]],,,
119                  [[#ifdef __cplusplus
120                    extern "C++" char *basenam (char *);
121                    extern "C++" const char *basenam (const char *);
122                    #else
123                    extern char *basenam (const char *);
124                    #endif
125                    #ifdef __cplusplus
126                    extern "C" {
127                    #endif
128                    extern int moreargs (char, short, int, long, void *,
129                                         char [], float, double);
130                    #ifdef __cplusplus
131                    }
132                    #endif
133                    ]])
134   AC_CHECK_DECL([declared (char *)],, [AS_EXIT([1])],
135                 [[#ifdef __cplusplus
136                   extern "C++" char *declared (char *);
137                   extern "C++" const char *declared (const char *);
138                   #else
139                   extern char *declared (const char *);
140                   #endif
141                 ]])
142   AC_CHECK_DECL([undeclared (char *)], [AS_EXIT([1])],, [[]])
144 [AT_CHECK_DEFINES(
145 [#define HAVE_DECL_BASENAM 1
146 #define HAVE_DECL_DIRNAM 0
147 #define HAVE_DECL_MOREARGS 1
148 #define HAVE_DECL_MYENUM 1
149 #define HAVE_DECL_MYFUNC 1
150 #define HAVE_DECL_MYMACRO1 1
151 #define HAVE_DECL_MYMACRO2 1
152 #define HAVE_DECL_MYSTRUCT 1
153 #define HAVE_DECL_NO 0
154 #define HAVE_DECL_STRERROR 0
155 #define HAVE_DECL_YES 1
156 ])])
159 # AC_CHECK_FUNCS
160 # --------------
161 # Check that it performs the correct actions:
162 # Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
163 AT_CHECK_MACRO([AC_CHECK_FUNCS],
164 [AC_CHECK_FUNCS(printf autoconf_ftnirp)],
165 [AT_CHECK_DEFINES(
166 [/* #undef HAVE_AUTOCONF_FTNIRP */
167 #define HAVE_PRINTF 1
168 ])])
171 # AC_REPLACE_FUNCS
172 # ----------------
173 # Check that it performs the correct actions: autoconf_ftnirp.c must
174 # be compiled, and must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
175 # FIXME: Maybe check the traces?
176 AT_SETUP([AC_REPLACE_FUNCS])
178 AT_DATA([config.in],
179 [@LIBOBJS@
182 AT_CONFIGURE_AC(
183 [AC_CONFIG_FILES([config.libobjs:config.in])
184 AC_REPLACE_FUNCS([printf \
185 autoconf_ftnirp])
186 funcs='fprintf fopen autoconf_ftnirpf'
187 AH_TEMPLATE([HAVE_FOPEN], [])
188 AH_TEMPLATE([HAVE_FPRINTF], [])
189 AH_TEMPLATE([HAVE_AUTOCONF_FTNIRPF], [])
190 AC_REPLACE_FUNCS([\
191 $funcs])
192 AS_UNSET([funcs])])
194 AT_CHECK_AUTOCONF([-W obsolete])
195 AT_CHECK_AUTOHEADER
196 AT_CHECK_CONFIGURE
197 AT_CHECK_ENV
198 AT_CHECK_DEFINES(
199 [/* #undef HAVE_AUTOCONF_FTNIRP */
200 /* #undef HAVE_AUTOCONF_FTNIRPF */
201 #define HAVE_FOPEN 1
202 #define HAVE_FPRINTF 1
203 #define HAVE_PRINTF 1
206 AT_CHECK([sed 's/  */ /g;s/^ //;s/ $//' config.libobjs], [],
207          [${LIBOBJDIR}autoconf_ftnirp$U.o ${LIBOBJDIR}autoconf_ftnirpf$U.o
210 AT_CLEANUP
213 # AC_CHECK_HEADERS
214 # ----------------
215 # Check that it performs the correct actions:
216 # Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H.
217 AT_SETUP([AC_CHECK_HEADERS])
219 AT_DATA([autoconf_io.h],
220 [blah blah
223 AT_CONFIGURE_AC([AC_CHECK_HEADERS(stdio.h autoconf_io.h)])
224 AT_CHECK_AUTOCONF([-W obsolete])
225 AT_CHECK_AUTOHEADER
226 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
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], [], [], [stderr])
253 AT_CHECK([[grep '^configure\.ac' stderr]], [0],
254 [configure.ac:4: warning: Checking for headers with the preprocessor is
255 configure.ac:4: deprecated. Specify prerequisite code to AC_CHECK_HEADER
256 configure.ac:4: instead of using fourth argument `-'. (Many headers need
257 configure.ac:4: no prerequisites. If you truly need to test whether
258 configure.ac:4: something passes the preprocessor but not the compiler,
259 configure.ac:4: use AC_PREPROC_IFELSE.)
260 configure.ac:4: the top level
262 AT_CHECK_AUTOHEADER
263 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
264 AT_CHECK_ENV
265 AT_CHECK_DEFINES(
266 [#define HAVE_HEADER2_H 1
269 AT_CLEANUP
272 # AC_CHECK_HEADERS_NEW
273 # --------------------
274 # Check that it performs the correct actions:
275 # Must check prerequisites, hence define header2.h but not header3.h
276 AT_SETUP([AC_CHECK_HEADERS (compiler test)])
278 AT_DATA([header1.h],
279 [typedef int foo;
282 AT_DATA([header2.h],
283 [typedef foo bar;
286 AT_DATA([header3.h],
287 [typedef bar wow;
290 AT_CONFIGURE_AC(
291 [AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
293 AT_CHECK_AUTOCONF([-W obsolete])
294 AT_CHECK_AUTOHEADER
295 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
296 AT_CHECK_ENV
297 AT_CHECK_DEFINES(
298 [#define HAVE_HEADER2_H 1
299 /* #undef HAVE_HEADER3_H */
302 AT_CLEANUP
305 # AC_CHECK_MEMBER
306 # ---------------
307 # Check that it performs the correct actions.
308 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
309 AT_CHECK_MACRO([AC_CHECK_MEMBER],
310 [[AC_CHECK_MEMBER([struct yes_s.yes],
311                   [AC_DEFINE([HAVE_STRUCT_YES_S_YES], [1],
312                              [Define to 1 if `yes' is a member of `struct yes_s'.])],,
313                    [struct sub { int x; };
314                     struct yes_s { int yes; struct sub substruct; };])
315   AC_CHECK_MEMBER([struct yes_s.no],
316                   [AC_DEFINE([HAVE_STRUCT_YES_S_NO], [1],
317                              [Define to 1 if `no' is a member of `struct yes_s'.])],,
318                    [struct sub { int x; };
319                     struct yes_s { int yes; struct sub substruct; };])
320   AC_CHECK_MEMBER([struct yes_s.substruct],
321                   [AC_DEFINE([HAVE_STRUCT_YES_S_SUBSTRUCT], [1],
322                              [Define to 1 if `substruct' is a member of `struct yes_s'.])],,
323                    [struct sub { int x; };
324                     struct yes_s { int yes; struct sub substruct; };])]],
325 [AT_CHECK_DEFINES(
326 [/* #undef HAVE_STRUCT_YES_S_NO */
327 #define HAVE_STRUCT_YES_S_SUBSTRUCT 1
328 #define HAVE_STRUCT_YES_S_YES 1
329 ])])
331 # AC_CHECK_MEMBERS
332 # ----------------
333 # Check that it performs the correct actions.
334 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
335 AT_CHECK_MACRO([AC_CHECK_MEMBERS],
336 [[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no, struct yes_s.substruct],,,
337                    [struct sub { int x; };
338                     struct yes_s { int yes; struct sub substruct; };])]],
339 [AT_CHECK_DEFINES(
340 [/* #undef HAVE_STRUCT_YES_S_NO */
341 #define HAVE_STRUCT_YES_S_SUBSTRUCT 1
342 #define HAVE_STRUCT_YES_S_YES 1
344 AT_CHECK([grep 'yes.*member of.*yes_s' config.h], [], [ignore])
348 # AC_CHECK_ALIGNOF
349 # ----------------
350 AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF],
351 [[AC_CHECK_ALIGNOF(char)
352 AC_CHECK_ALIGNOF(charchar,
353 [[#include <stddef.h>
354 #include <stdio.h>
355 typedef char charchar[2];]])
356 AC_CHECK_ALIGNOF(charcharchar)
358 [AT_CHECK_DEFINES(
359 [#define ALIGNOF_CHAR 1
360 #define ALIGNOF_CHARCHAR 1
361 #define ALIGNOF_CHARCHARCHAR 0
362 ])])
365 # AC_CHECK_ALIGNOF struct
366 # -----------------------
367 AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF struct],
368 [[AC_CHECK_ALIGNOF([struct { char c; }])
369 AC_CHECK_ALIGNOF([struct nosuchstruct])
371 [AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
372          0, ignore)
373 AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
374          0, ignore)
377 # AC_CHECK_SIZEOF
378 # ---------------
379 AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF],
380 [[AC_CHECK_SIZEOF(char)
381 AC_CHECK_SIZEOF(charchar,,
382 [[#include <stdio.h>
383 typedef char charchar[2];]])
384 AC_CHECK_SIZEOF(charcharchar)
386 [AT_CHECK_DEFINES(
387 [#define SIZEOF_CHAR 1
388 #define SIZEOF_CHARCHAR 2
389 #define SIZEOF_CHARCHARCHAR 0
390 ])])
393 # AC_CHECK_SIZEOF struct
394 # ----------------------
395 AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct],
396 [[AC_C_CONST
397 AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
398 AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
399 AC_CHECK_SIZEOF([struct nosuchstruct])
400 # Taken from autoconf.texi:Generic Compiler Characteristics.
401 AC_CHECK_SIZEOF([int *])
403 [AT_CHECK([[grep "#define SIZEOF_STRUCT_X [1-9]" config.h]],
404          0, ignore)
405 AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [1-9]" config.h]],
406          0, ignore)
407 AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
408          0, ignore)
409 AT_CHECK([[grep "#define SIZEOF_INT_P [1-9]" config.h]],
410          0, ignore)
414 # AC_CHECK_TYPES
415 # --------------
416 # Check that it performs the correct actions.
417 # Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
418 # `int' and `struct yes_s' are both checked to test both the compiler
419 # builtin types, and defined types.
420 AT_CHECK_MACRO([AC_CHECK_TYPES],
421 [[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
422                  [struct yes_s { int yes ;} ;])]],
423 [AT_CHECK_DEFINES(
424 [#define HAVE_INT 1
425 /* #undef HAVE_STRUCT_NO_S */
426 #define HAVE_STRUCT_YES_S 1
427 ])])
430 # AC_CHECK_TYPES
431 # --------------
432 # Check that we properly dispatch properly to the old implementation
433 # or to the new one.
434 AT_SETUP([AC_CHECK_TYPES: backward compatibility])
436 AT_DATA([configure.ac],
437 [[AC_INIT
438 define([_AC_CHECK_TYPE_NEW], [NEW])
439 define([_AC_CHECK_TYPE_OLD], [OLD])
440 #(cut-from-here
441 AC_CHECK_TYPE(ptrdiff_t)
442 AC_CHECK_TYPE(ptrdiff_t, int)
443 AC_CHECK_TYPE(quad, long long int)
444 AC_CHECK_TYPE(table_42, [int[42]])
445 # Nice machine!
446 AC_CHECK_TYPE(uint8_t, uint65536_t)
447 AC_CHECK_TYPE(a,b,c,d)
448 #to-here)
449 AC_OUTPUT
452 AT_CHECK_AUTOCONF
453 AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
454          0,
455          [NEW
463 AT_CLEANUP
466 # AC_CHECK_FILES
467 # --------------
468 # FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
469 # open AH_TEMPLATE to `configure.ac', which is not yet the case.
470 AT_CHECK_MACRO([AC_CHECK_FILES],
471 [touch at-exists1 at-exists2
472 ac_exists2=at-exists2
473 ac_missing2=at-missing2
474 AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
475 rm at-exists1 at-exists2],
476 [AT_CHECK_DEFINES(
477 [#define HAVE_AT_EXISTS1 1
478 /* #undef HAVE_AT_MISSING1 */
479 ])])
483 ## ------------------------------ ##
484 ## AC_CHECK_PROG & AC_PATH_PROG.  ##
485 ## ------------------------------ ##
488 # AT_CHECK_PROGS_PREPARE
489 # ----------------------
490 # Create a sub directory `path' with 6 subdirs which all 7 contain
491 # an executable `tool'. `6' contains a `better' tool.
492 m4_define([AT_CHECK_PROGS_PREPARE],
493 [mkdir path
495 cat >path/tool <<\EOF
496 #! /bin/sh
497 exit 0
499 chmod +x path/tool
501 for i in 1 2 3 4 5 6
503   mkdir path/$i
504   cp path/tool path/$i
505 done
506 cp path/tool path/6/better])
509 # -------------------------------- #
510 # AC_CHECK_PROG & AC_CHECK_PROGS.  #
511 # -------------------------------- #
513 AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
515 AT_CHECK_PROGS_PREPARE
517 AT_DATA([configure.ac],
518 [[AC_INIT
519 pwd=`pwd`
520 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
521 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
522 fail=false
524 AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
525 test "$TOOL1" = found || fail=:
527 # Yes, the semantics of this macro is weird.
528 AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
529 test "$TOOL2" = not-found || fail=:
531 AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
532 test "$TOOL3" = "$pwd/path/2/tool" || fail=:
534 AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
535 test "$TOOL4" = better || fail=:
537 # When a tool is not found, and no value is given for not-found,
538 # the variable is left empty.
539 AC_CHECK_PROGS(TOOL5, missing,, $path)
540 test -z "$TOOL5" || fail=:
542 AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
543 test "$TOOL6" = tool || fail=:
545 # No AC-OUTPUT, we don't need config.status.
546 $fail &&
547   AC_MSG_ERROR([[CHECK_PROG failed]])
548 AS_EXIT(0)
551 AT_CHECK_AUTOCONF
552 AT_CHECK_CONFIGURE
554 AT_CLEANUP
558 ## ---------------- ##
559 ## AC_C_BIGENDIAN.  ##
560 ## ---------------- ##
562 AT_SETUP([AC_C_BIGENDIAN])
563 AT_KEYWORDS([cross])
565 # Make sure that AC_C_BIGENDIAN behave the same whether we are
566 # cross-compiling or not.
568 _AT_CHECK_AC_MACRO(
569   [[AC_C_BIGENDIAN(
570       [ac_endian=big],
571       [ac_endian=little],
572       [ac_endian=unknown],
573       [ac_endian=universal])
574    echo $ac_endian > at-endian
577 rm -f config.hin  # So that next run of autoheader is quiet.
578 _AT_CHECK_AC_MACRO(
579   [[# Force cross compiling.
580    cross_compiling=yes
581    ac_tool_warned=yes
582    AC_C_BIGENDIAN(
583      [ac_endian=big],
584      [ac_endian=little],
585      [ac_endian=unknown],
586      [ac_endian=universal])
587    ac_prevendian=`cat at-endian`
588    # Check that we have found the same result as in the previous run
589    # or unknown (because the cross-compiling check is allowed to fail;
590    # although it might be interesting to suppress this comparison, just
591    # to know on which system it fails if it ever does).
592    if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
593      AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
594    fi
597 # Make sure AC_C_BIGENDIAN with no argument will create a config.h template
598 # containing "WORDS_BIGENDIAN".
599 AT_CONFIGURE_AC([[AC_C_BIGENDIAN]])
600 # --force is necessary, the computer might be too fast.
601 AT_CHECK_AUTOHEADER([--force])
602 AT_CHECK([grep WORDS_BIGENDIAN config.hin], [], [ignore])
604 AT_CLEANUP
607 # ------------------------------ #
608 # AC_PATH_PROG & AC_PATH_PROGS.  #
609 # ------------------------------ #
611 AT_SETUP([AC_PATH_PROG & AC_PATH_PROGS])
613 AT_CHECK_PROGS_PREPARE
615 AT_DATA([configure.ac],
616 [[AC_INIT
617 pwd=`pwd`
618 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
619 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
620 fail=false
622 AC_PATH_PROG(TOOL1, tool, not-found, $path)
623 test "$TOOL1" = "$pwd/path/1/tool" || fail=:
625 AC_PATH_PROG(TOOL2, better, not-found, $path)
626 test "$TOOL2" = "$pwd/path/6/better" || fail=:
628 # When a tool is not found, and no value is given for not-found,
629 # the variable is left empty.
630 AC_PATH_PROGS(TOOL3, missing,, $path)
631 test -z "$TOOL3" || fail=:
633 AC_PATH_PROGS(TOOL4, missing tool better,, $path)
634 test "$TOOL4" = "$pwd/path/1/tool" || fail=:
636 # No AC-OUTPUT, we don't need config.status.
637 $fail &&
638   AC_MSG_ERROR([[PATH_PROG failed]])
639 AS_EXIT(0)
642 AT_CHECK_AUTOCONF
643 AT_CHECK_CONFIGURE
645 AT_CLEANUP
649 # ----------------------------- #
650 # AC_PATH_PROGS_FEATURE_CHECK.  #
651 # ----------------------------- #
653 AT_SETUP([AC_PATH_PROGS_FEATURE_CHECK])
655 # This test doesn't work if `pwd` contains white space
656 case `pwd` in
657   *\ * | *\     *) AT_CHECK([exit 77]) ;;
658 esac
660 AT_CHECK_PROGS_PREPARE
662 AT_DATA([configure.ac],
663 [[AC_INIT
664 pwd=`pwd`
665 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
666 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
667 fail=false
669 # Find first candidate and stop search
670 AC_PATH_PROGS_FEATURE_CHECK(TOOL1, [tool better],
671   [$ac_path_TOOL1 && ac_cv_path_TOOL1=$ac_path_TOOL1 ac_path_TOOL1_found=:],
672   fail=:, $path)
673 test -z "$TOOL1" || fail=:
674 test "$ac_cv_path_TOOL1" = "$pwd/path/1/tool" || fail=:
676 # Keep searching each candidate
677 AC_PATH_PROGS_FEATURE_CHECK(TOOL2, [tool better],
678   [$ac_path_TOOL2 && ac_cv_path_TOOL2=$ac_path_TOOL2],
679   fail=:, $path)
680 test "$ac_cv_path_TOOL2" = "$pwd/path/6/better" || fail=:
682 # Only accept better candidate
683 AC_PATH_PROGS_FEATURE_CHECK(TOOL3, [tool better],
684   [case "$ac_path_TOOL3" in #(
685     *better) ac_cv_path_TOOL3=$ac_path_TOOL3;;
686   esac],
687   fail=:, $path)
688 test "$ac_cv_path_TOOL3" = "$pwd/path/6/better" || fail=:
690 # When a tool is not found, and no action is given for not-found,
691 # the variable is left empty.
692 AC_PATH_PROGS_FEATURE_CHECK(TOOL4, missing,
693   [ac_cv_path_TOOL4=$ac_path_TOOL4], [], $path)
694 test -z "$ac_cv_path_TOOL4" || fail=:
696 # Test action when tool is not found
697 AC_PATH_PROGS_FEATURE_CHECK(TOOL5, missing, [],
698   [ac_cv_path_TOOL5='not found'], $path)
699 test "$ac_cv_path_TOOL5" = "not found" || fail=:
701 # Test that pre-set tool bypasses feature test
702 TOOL6=$pwd/path/6/better
703 AC_PATH_PROGS_FEATURE_CHECK(TOOL6, tool, fail=:, fail=:, $path)
704 test "$ac_cv_path_TOOL6" = "$pwd/path/6/better" || fail=:
706 # A blank pre-set does not bypass feature test
707 TOOL7=
708 AC_PATH_PROGS_FEATURE_CHECK(TOOL7, [tool better],
709   [$ac_path_TOOL7 && ac_cv_path_TOOL7=$ac_path_TOOL7 ac_path_TOOL7_found=:],
710   fail=:, $path)
711 test -z "$TOOL7" || fail=:
712 test "$ac_cv_path_TOOL7" = "$pwd/path/1/tool" || fail=:
714 # No AC-OUTPUT, we don't need config.status.
715 $fail &&
716   AC_MSG_ERROR([[PATH_PROG failed]])
717 AS_EXIT(0)
720 AT_CHECK_AUTOCONF
721 AT_CHECK_CONFIGURE
723 AT_CLEANUP
728 ## -------------- ##
729 ## AC_PATH_XTRA.  ##
730 ## -------------- ##
733 AT_SETUP([AC_PATH_XTRA])
735 _AT_CHECK_AC_MACRO([AC_PATH_XTRA])
737 # Check X_DISPLAY_MISSING.
738 AT_CHECK_CONFIGURE([--without-x])
739 AT_CHECK_DEFINES(
740 [#define X_DISPLAY_MISSING 1
743 AT_CLEANUP
746 ## ------------------------------- ##
747 ## Obsolete non-updatable macros.  ##
748 ## ------------------------------- ##
751 AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete])
752 AT_CHECK_MACRO([AC_FUNC_SETVBUF_REVERSED], , ,[-W no-obsolete])
753 AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete])