2
0

semantics.at 19 KB

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