xref: /netbsd-src/external/gpl3/autoconf/dist/tests/semantics.at (revision d874e91932377fc40d53f102e48fc3ee6f4fe9de)
1#							-*- Autotest -*-
2
3AT_BANNER([Semantics.])
4
5# Copyright (C) 2000-2002, 2004-2007, 2009-2012 Free Software
6# Foundation, Inc.
7#
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.
12#
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.
17#
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/>.
20
21
22## -------------------------------- ##
23## Members of the AC_CHECK family.  ##
24## -------------------------------- ##
25
26
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.
33AT_CHECK_MACRO([AC_CHECK_LIB],
34[AC_TRY_LINK_FUNC(cos,
35		  [AC_MSG_ERROR([`cos' is in `libc'], 77)])
36
37AC_CHECK_LIB(m, cos,,
38	     [AC_MSG_ERROR([cannot find `cos' in `libm'])])
39
40# No kidding, using variables was broken in 2.50 :(
41ac_sin=sin
42AC_CHECK_LIB(m, $ac_sin,,
43      [AC_MSG_ERROR([cannot find `\$ac_sin' (= `$ac_sin') in `libm'])])
44
45ac_m=m
46AC_CHECK_LIB($ac_m, acos,,
47      [AC_MSG_ERROR([cannot find `acos' in `\$ac_m' (= `$ac_m')])])
48
49ac_asin=asin
50AC_CHECK_LIB($ac_m, $ac_asin,,
51      [AC_MSG_ERROR([cannot find `\$ac_asin' (= `$ac_asin') in `\$ac_m' (= `$ac_m')])])
52
53# But if the bug is in the caching mechanism, then be sure we
54# correctly detect failures.
55
56AC_CHECK_LIB(m, cossack,
57	     [AC_MSG_ERROR([found `cossack' in `libm'])])
58
59# No kidding, using variables was broken in 2.50 :(
60ac_sinner=sinner
61AC_CHECK_LIB(m, $ac_sinner,
62      [AC_MSG_ERROR([found `\$ac_sinner' (= `$ac_sinner') in `libm'])])
63
64ac_m=m
65AC_CHECK_LIB($ac_m, acossack,
66      [AC_MSG_ERROR([found `acossack' in `\$ac_m' (= `$ac_m')])])
67
68ac_asinner=asinner
69AC_CHECK_LIB($ac_m, $ac_asinner,
70      [AC_MSG_ERROR([found `\$ac_asinner' (= `$ac_asinner') in `\$ac_m' (= `$ac_m')])])
71
72])
73
74
75# AC_SEARCH_LIBS
76# --------------
77AT_CHECK_MACRO([AC_SEARCH_LIBS],
78[
79AC_SEARCH_LIBS(cos, oser m ust,,
80	     [AC_MSG_ERROR([cannot find `cos'])])
81
82case "$ac_cv_search_cos" in
83  -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_cos must be a cool library!]) ;;
84esac
85])
86
87
88# AC_SEARCH_LIBS (none needed)
89# ----------------------------
90AT_CHECK_MACRO([AC_SEARCH_LIBS (none needed)],
91[
92AC_SEARCH_LIBS(printf, oser c ust,,
93	     [AC_MSG_ERROR([cannot find `printf'])])
94
95case "$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?])
98esac
99])
100
101
102# AC_CHECK_DECLS
103# --------------
104# Check that it performs the correct actions:
105AT_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])],, [[]])
140]],
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])])
153
154
155# AC_CHECK_FUNCS
156# --------------
157# Check that it performs the correct actions:
158# Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
159AT_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])])
165
166
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?
172AT_SETUP([AC_REPLACE_FUNCS])
173
174AT_DATA([config.in],
175[@LIBOBJS@
176])
177
178AT_CONFIGURE_AC(
179[AC_CONFIG_FILES([config.libobjs:config.in])
180AC_REPLACE_FUNCS([printf \
181autoconf_ftnirp])
182funcs='fprintf fopen autoconf_ftnirpf'
183AH_TEMPLATE([HAVE_FOPEN], [])
184AH_TEMPLATE([HAVE_FPRINTF], [])
185AH_TEMPLATE([HAVE_AUTOCONF_FTNIRPF], [])
186AC_REPLACE_FUNCS([\
187$funcs])
188AS_UNSET([funcs])])
189
190AT_CHECK_AUTOCONF([-W obsolete])
191AT_CHECK_AUTOHEADER
192AT_CHECK_CONFIGURE
193AT_CHECK_ENV
194AT_CHECK_DEFINES(
195[/* #undef HAVE_AUTOCONF_FTNIRP */
196/* #undef HAVE_AUTOCONF_FTNIRPF */
197#define HAVE_FOPEN 1
198#define HAVE_FPRINTF 1
199#define HAVE_PRINTF 1
200])
201
202AT_CHECK([sed 's/  */ /g;s/^ //;s/ $//' config.libobjs], [],
203	 [${LIBOBJDIR}autoconf_ftnirp$U.o ${LIBOBJDIR}autoconf_ftnirpf$U.o
204])
205
206AT_CLEANUP
207
208
209# AC_CHECK_HEADERS
210# ----------------
211# Check that it performs the correct actions:
212# Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H.
213AT_SETUP([AC_CHECK_HEADERS])
214
215AT_DATA([autoconf_io.h],
216[blah blah
217])
218
219AT_CONFIGURE_AC([AC_CHECK_HEADERS(stdio.h autoconf_io.h)])
220AT_CHECK_AUTOCONF([-W obsolete])
221AT_CHECK_AUTOHEADER
222AT_CHECK_CONFIGURE([CPPFLAGS=-I.], [0], [ignore],
223[configure: WARNING: autoconf_io.h: present but cannot be compiled
224configure: WARNING: autoconf_io.h:     check for missing prerequisite headers?
225configure: WARNING: autoconf_io.h: see the Autoconf documentation
226configure: WARNING: autoconf_io.h:     section "Present But Cannot Be Compiled"
227configure: WARNING: autoconf_io.h: proceeding with the compiler's result
228])
229AT_CHECK_ENV
230AT_CHECK_DEFINES(
231[/* #undef HAVE_AUTOCONF_IO_H */
232#define HAVE_STDIO_H 1
233])
234
235AT_CLEANUP
236
237
238# AC_CHECK_HEADERS_OLD
239# --------------------
240# Check that it performs the correct actions:
241# Must not check prerequisites, hence define header2.h
242AT_SETUP([AC_CHECK_HEADERS (preprocessor test)])
243
244AT_DATA([header1.h],
245[typedef int foo;
246])
247
248AT_DATA([header2.h],
249[typedef foo bar;
250])
251
252AT_CONFIGURE_AC([AC_CHECK_HEADERS(header2.h, [], [], -)])
253
254AT_CHECK_AUTOCONF([-W obsolete])
255AT_CHECK_AUTOHEADER
256AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
257AT_CHECK_ENV
258AT_CHECK_DEFINES(
259[#define HAVE_HEADER2_H 1
260])
261
262AT_CLEANUP
263
264
265# AC_CHECK_HEADERS_NEW
266# --------------------
267# Check that it performs the correct actions:
268# Must check prerequisites, hence define header2.h but not header3.h
269AT_SETUP([AC_CHECK_HEADERS (compiler test)])
270
271AT_DATA([header1.h],
272[typedef int foo;
273])
274
275AT_DATA([header2.h],
276[typedef foo bar;
277])
278
279AT_DATA([header3.h],
280[typedef bar wow;
281])
282
283AT_CONFIGURE_AC(
284[AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
285
286AT_CHECK_AUTOCONF([-W obsolete])
287AT_CHECK_AUTOHEADER
288AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
289AT_CHECK_ENV
290AT_CHECK_DEFINES(
291[#define HAVE_HEADER2_H 1
292/* #undef HAVE_HEADER3_H */
293])
294
295AT_CLEANUP
296
297
298# AC_CHECK_MEMBER
299# ---------------
300# Check that it performs the correct actions.
301# Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
302AT_CHECK_MACRO([AC_CHECK_MEMBER],
303[[AC_CHECK_MEMBER([struct yes_s.yes],
304		  [AC_DEFINE([HAVE_STRUCT_YES_S_YES], [1],
305			     [Define to 1 if `yes' is a member of `struct yes_s'.])],,
306		   [struct sub { int x; };
307		    struct yes_s { int yes; struct sub substruct; };])
308  AC_CHECK_MEMBER([struct yes_s.no],
309		  [AC_DEFINE([HAVE_STRUCT_YES_S_NO], [1],
310			     [Define to 1 if `no' is a member of `struct yes_s'.])],,
311		   [struct sub { int x; };
312		    struct yes_s { int yes; struct sub substruct; };])
313  AC_CHECK_MEMBER([struct yes_s.substruct],
314		  [AC_DEFINE([HAVE_STRUCT_YES_S_SUBSTRUCT], [1],
315			     [Define to 1 if `substruct' is a member of `struct yes_s'.])],,
316		   [struct sub { int x; };
317		    struct yes_s { int yes; struct sub substruct; };])]],
318[AT_CHECK_DEFINES(
319[/* #undef HAVE_STRUCT_YES_S_NO */
320#define HAVE_STRUCT_YES_S_SUBSTRUCT 1
321#define HAVE_STRUCT_YES_S_YES 1
322])])
323
324# AC_CHECK_MEMBERS
325# ----------------
326# Check that it performs the correct actions.
327# Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
328AT_CHECK_MACRO([AC_CHECK_MEMBERS],
329[[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no, struct yes_s.substruct],,,
330		   [struct sub { int x; };
331		    struct yes_s { int yes; struct sub substruct; };])]],
332[AT_CHECK_DEFINES(
333[/* #undef HAVE_STRUCT_YES_S_NO */
334#define HAVE_STRUCT_YES_S_SUBSTRUCT 1
335#define HAVE_STRUCT_YES_S_YES 1
336])
337AT_CHECK([grep 'yes.*member of.*yes_s' config.h], [], [ignore])
338])
339
340
341# AC_CHECK_ALIGNOF
342# ----------------
343AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF],
344[[AC_CHECK_ALIGNOF(char)
345AC_CHECK_ALIGNOF(charchar,
346[[#include <stddef.h>
347#include <stdio.h>
348typedef char charchar[2];]])
349AC_CHECK_ALIGNOF(charcharchar)
350]],
351[AT_CHECK_DEFINES(
352[#define ALIGNOF_CHAR 1
353#define ALIGNOF_CHARCHAR 1
354#define ALIGNOF_CHARCHARCHAR 0
355])])
356
357
358# AC_CHECK_ALIGNOF struct
359# -----------------------
360AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF struct],
361[[AC_CHECK_ALIGNOF([struct { char c; }])
362AC_CHECK_ALIGNOF([struct nosuchstruct])
363]],
364[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
365	 0, ignore)
366AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
367	 0, ignore)
368])
369
370# AC_CHECK_SIZEOF
371# ---------------
372AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF],
373[[AC_CHECK_SIZEOF(char)
374AC_CHECK_SIZEOF(charchar,,
375[[#include <stdio.h>
376typedef char charchar[2];]])
377AC_CHECK_SIZEOF(charcharchar)
378]],
379[AT_CHECK_DEFINES(
380[#define SIZEOF_CHAR 1
381#define SIZEOF_CHARCHAR 2
382#define SIZEOF_CHARCHARCHAR 0
383])])
384
385
386# AC_CHECK_SIZEOF struct
387# ----------------------
388AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct],
389[[AC_C_CONST
390AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
391AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
392AC_CHECK_SIZEOF([struct nosuchstruct])
393# Taken from autoconf.texi:Generic Compiler Characteristics.
394AC_CHECK_SIZEOF([int *])
395]],
396[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [1-9]" config.h]],
397	 0, ignore)
398AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [1-9]" config.h]],
399	 0, ignore)
400AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
401	 0, ignore)
402AT_CHECK([[grep "#define SIZEOF_INT_P [1-9]" config.h]],
403	 0, ignore)
404])
405
406
407# AC_CHECK_TYPES
408# --------------
409# Check that it performs the correct actions.
410# Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
411# `int' and `struct yes_s' are both checked to test both the compiler
412# builtin types, and defined types.
413AT_CHECK_MACRO([AC_CHECK_TYPES],
414[[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
415		 [struct yes_s { int yes ;} ;])]],
416[AT_CHECK_DEFINES(
417[#define HAVE_INT 1
418/* #undef HAVE_STRUCT_NO_S */
419#define HAVE_STRUCT_YES_S 1
420])])
421
422
423# AC_CHECK_TYPES
424# --------------
425# Check that we properly dispatch properly to the old implementation
426# or to the new one.
427AT_SETUP([AC_CHECK_TYPES: backward compatibility])
428
429AT_DATA([configure.ac],
430[[AC_INIT
431define([_AC_CHECK_TYPE_NEW], [NEW])
432define([_AC_CHECK_TYPE_OLD], [OLD])
433#(cut-from-here
434AC_CHECK_TYPE(ptrdiff_t)
435AC_CHECK_TYPE(ptrdiff_t, int)
436AC_CHECK_TYPE(quad, long long int)
437AC_CHECK_TYPE(table_42, [int[42]])
438# Nice machine!
439AC_CHECK_TYPE(uint8_t, uint65536_t)
440AC_CHECK_TYPE(a,b,c,d)
441#to-here)
442AC_OUTPUT
443]])
444
445AT_CHECK_AUTOCONF
446AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
447	 0,
448	 [NEW
449OLD
450OLD
451OLD
452OLD
453NEW
454])
455
456AT_CLEANUP
457
458
459# AC_CHECK_FILES
460# --------------
461# FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
462# open AH_TEMPLATE to `configure.ac', which is not yet the case.
463AT_CHECK_MACRO([AC_CHECK_FILES],
464[touch at-exists1 at-exists2
465ac_exists2=at-exists2
466ac_missing2=at-missing2
467AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
468rm at-exists1 at-exists2],
469[AT_CHECK_DEFINES(
470[#define HAVE_AT_EXISTS1 1
471/* #undef HAVE_AT_MISSING1 */
472])])
473
474
475
476## ------------------------------ ##
477## AC_CHECK_PROG & AC_PATH_PROG.  ##
478## ------------------------------ ##
479
480
481# AT_CHECK_PROGS_PREPARE
482# ----------------------
483# Create a sub directory `path' with 6 subdirs which all 7 contain
484# an executable `tool'. `6' contains a `better' tool.
485m4_define([AT_CHECK_PROGS_PREPARE],
486[mkdir path
487
488cat >path/tool <<\EOF
489#! /bin/sh
490exit 0
491EOF
492chmod +x path/tool
493
494for i in 1 2 3 4 5 6
495do
496  mkdir path/$i
497  cp path/tool path/$i
498done
499cp path/tool path/6/better])
500
501
502# -------------------------------- #
503# AC_CHECK_PROG & AC_CHECK_PROGS.  #
504# -------------------------------- #
505
506AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
507
508AT_CHECK_PROGS_PREPARE
509
510AT_DATA([configure.ac],
511[[AC_INIT
512pwd=`pwd`
513p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
514path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
515fail=false
516
517AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
518test "$TOOL1" = found || fail=:
519
520# Yes, the semantics of this macro is weird.
521AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
522test "$TOOL2" = not-found || fail=:
523
524AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
525test "$TOOL3" = "$pwd/path/2/tool" || fail=:
526
527AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
528test "$TOOL4" = better || fail=:
529
530# When a tool is not found, and no value is given for not-found,
531# the variable is left empty.
532AC_CHECK_PROGS(TOOL5, missing,, $path)
533test -z "$TOOL5" || fail=:
534
535AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
536test "$TOOL6" = tool || fail=:
537
538# No AC-OUTPUT, we don't need config.status.
539$fail &&
540  AC_MSG_ERROR([[CHECK_PROG failed]])
541AS_EXIT(0)
542]])
543
544AT_CHECK_AUTOCONF
545AT_CHECK_CONFIGURE
546
547AT_CLEANUP
548
549
550
551## ---------------- ##
552## AC_C_BIGENDIAN.  ##
553## ---------------- ##
554
555AT_SETUP([AC_C_BIGENDIAN])
556AT_KEYWORDS([cross])
557
558# Make sure that AC_C_BIGENDIAN behave the same whether we are
559# cross-compiling or not.
560
561_AT_CHECK_AC_MACRO(
562  [[AC_C_BIGENDIAN(
563      [ac_endian=big],
564      [ac_endian=little],
565      [ac_endian=unknown],
566      [ac_endian=universal])
567   echo $ac_endian > at-endian
568]])
569
570rm -f config.hin  # So that next run of autoheader is quiet.
571_AT_CHECK_AC_MACRO(
572  [[# Force cross compiling.
573   cross_compiling=yes
574   ac_tool_warned=yes
575   AC_C_BIGENDIAN(
576     [ac_endian=big],
577     [ac_endian=little],
578     [ac_endian=unknown],
579     [ac_endian=universal])
580   ac_prevendian=`cat at-endian`
581   # Check that we have found the same result as in the previous run
582   # or unknown (because the cross-compiling check is allowed to fail;
583   # although it might be interesting to suppress this comparison, just
584   # to know on which system it fails if it ever does).
585   if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
586     AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
587   fi
588]])
589
590# Make sure AC_C_BIGENDIAN with no argument will create a config.h template
591# containing "WORDS_BIGENDIAN".
592AT_CONFIGURE_AC([[AC_C_BIGENDIAN]])
593# --force is necessary, the computer might be too fast.
594AT_CHECK_AUTOHEADER([--force])
595AT_CHECK([grep WORDS_BIGENDIAN config.hin], [], [ignore])
596
597AT_CLEANUP
598
599
600# ------------------------------ #
601# AC_PATH_PROG & AC_PATH_PROGS.  #
602# ------------------------------ #
603
604AT_SETUP([AC_PATH_PROG & AC_PATH_PROGS])
605
606AT_CHECK_PROGS_PREPARE
607
608AT_DATA([configure.ac],
609[[AC_INIT
610pwd=`pwd`
611p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
612path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
613fail=false
614
615AC_PATH_PROG(TOOL1, tool, not-found, $path)
616test "$TOOL1" = "$pwd/path/1/tool" || fail=:
617
618AC_PATH_PROG(TOOL2, better, not-found, $path)
619test "$TOOL2" = "$pwd/path/6/better" || fail=:
620
621# When a tool is not found, and no value is given for not-found,
622# the variable is left empty.
623AC_PATH_PROGS(TOOL3, missing,, $path)
624test -z "$TOOL3" || fail=:
625
626AC_PATH_PROGS(TOOL4, missing tool better,, $path)
627test "$TOOL4" = "$pwd/path/1/tool" || fail=:
628
629# No AC-OUTPUT, we don't need config.status.
630$fail &&
631  AC_MSG_ERROR([[PATH_PROG failed]])
632AS_EXIT(0)
633]])
634
635AT_CHECK_AUTOCONF
636AT_CHECK_CONFIGURE
637
638AT_CLEANUP
639
640
641
642# ----------------------------- #
643# AC_PATH_PROGS_FEATURE_CHECK.  #
644# ----------------------------- #
645
646AT_SETUP([AC_PATH_PROGS_FEATURE_CHECK])
647
648# This test doesn't work if `pwd` contains white space
649case `pwd` in
650  *\ * | *\	*) AT_CHECK([exit 77]) ;;
651esac
652
653AT_CHECK_PROGS_PREPARE
654
655AT_DATA([configure.ac],
656[[AC_INIT
657pwd=`pwd`
658p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
659path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
660fail=false
661
662# Find first candidate and stop search
663AC_PATH_PROGS_FEATURE_CHECK(TOOL1, [tool better],
664  [$ac_path_TOOL1 && ac_cv_path_TOOL1=$ac_path_TOOL1 ac_path_TOOL1_found=:],
665  fail=:, $path)
666test -z "$TOOL1" || fail=:
667test "$ac_cv_path_TOOL1" = "$pwd/path/1/tool" || fail=:
668
669# Keep searching each candidate
670AC_PATH_PROGS_FEATURE_CHECK(TOOL2, [tool better],
671  [$ac_path_TOOL2 && ac_cv_path_TOOL2=$ac_path_TOOL2],
672  fail=:, $path)
673test "$ac_cv_path_TOOL2" = "$pwd/path/6/better" || fail=:
674
675# Only accept better candidate
676AC_PATH_PROGS_FEATURE_CHECK(TOOL3, [tool better],
677  [case "$ac_path_TOOL3" in #(
678    *better) ac_cv_path_TOOL3=$ac_path_TOOL3;;
679  esac],
680  fail=:, $path)
681test "$ac_cv_path_TOOL3" = "$pwd/path/6/better" || fail=:
682
683# When a tool is not found, and no action is given for not-found,
684# the variable is left empty.
685AC_PATH_PROGS_FEATURE_CHECK(TOOL4, missing,
686  [ac_cv_path_TOOL4=$ac_path_TOOL4], [], $path)
687test -z "$ac_cv_path_TOOL4" || fail=:
688
689# Test action when tool is not found
690AC_PATH_PROGS_FEATURE_CHECK(TOOL5, missing, [],
691  [ac_cv_path_TOOL5='not found'], $path)
692test "$ac_cv_path_TOOL5" = "not found" || fail=:
693
694# Test that pre-set tool bypasses feature test
695TOOL6=$pwd/path/6/better
696AC_PATH_PROGS_FEATURE_CHECK(TOOL6, tool, fail=:, fail=:, $path)
697test "$ac_cv_path_TOOL6" = "$pwd/path/6/better" || fail=:
698
699# A blank pre-set does not bypass feature test
700TOOL7=
701AC_PATH_PROGS_FEATURE_CHECK(TOOL7, [tool better],
702  [$ac_path_TOOL7 && ac_cv_path_TOOL7=$ac_path_TOOL7 ac_path_TOOL7_found=:],
703  fail=:, $path)
704test -z "$TOOL7" || fail=:
705test "$ac_cv_path_TOOL7" = "$pwd/path/1/tool" || fail=:
706
707# No AC-OUTPUT, we don't need config.status.
708$fail &&
709  AC_MSG_ERROR([[PATH_PROG failed]])
710AS_EXIT(0)
711]])
712
713AT_CHECK_AUTOCONF
714AT_CHECK_CONFIGURE
715
716AT_CLEANUP
717
718
719
720
721## -------------- ##
722## AC_PATH_XTRA.  ##
723## -------------- ##
724
725
726AT_SETUP([AC_PATH_XTRA])
727
728_AT_CHECK_AC_MACRO([AC_PATH_XTRA])
729
730# Check X_DISPLAY_MISSING.
731AT_CHECK_CONFIGURE([--without-x])
732AT_CHECK_DEFINES(
733[#define X_DISPLAY_MISSING 1
734])
735
736AT_CLEANUP
737
738
739## ------------------------------- ##
740## Obsolete non-updatable macros.  ##
741## ------------------------------- ##
742
743
744AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete])
745AT_CHECK_MACRO([AC_FUNC_SETVBUF_REVERSED], , ,[-W no-obsolete])
746AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete])
747