| 1 |
# -*- autoconf -*- |
| 2 |
|
| 3 |
AT_BANNER([Semantics.]) |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
## -------------------------------- ## |
| 9 |
## Members of the AC_CHECK family. ## |
| 10 |
## -------------------------------- ## |
| 11 |
|
| 12 |
|
| 13 |
# AC_CHECK_LIB |
| 14 |
# ------------ |
| 15 |
# Well, I can't imagine a system where `cos' is neither in libc, nor |
| 16 |
# in libm. Nor can I imagine a lib more likely to exists than libm. |
| 17 |
# But there are systems without libm, on which we don't want to have |
| 18 |
# this test fail, so exit successfully if `cos' is in libc. |
| 19 |
AT_CHECK_MACRO([AC_CHECK_LIB], |
| 20 |
[AC_TRY_LINK_FUNC(cos, |
| 21 |
[AC_MSG_ERROR([`cos' is in `libc'], 77)]) |
| 22 |
|
| 23 |
AC_CHECK_LIB(m, cos,, |
| 24 |
[AC_MSG_ERROR([cannot find `cos' in `libm'])]) |
| 25 |
|
| 26 |
# No kidding, using variables was broken in 2.50 :( |
| 27 |
ac_sin=sin |
| 28 |
AC_CHECK_LIB(m, $ac_sin,, |
| 29 |
[AC_MSG_ERROR([cannot find `\$ac_sin' (= `$ac_sin') in `libm'])]) |
| 30 |
|
| 31 |
ac_m=m |
| 32 |
AC_CHECK_LIB($ac_m, acos,, |
| 33 |
[AC_MSG_ERROR([cannot find `acos' in `\$ac_m' (= `$ac_m')])]) |
| 34 |
|
| 35 |
ac_asin=asin |
| 36 |
AC_CHECK_LIB($ac_m, $ac_asin,, |
| 37 |
[AC_MSG_ERROR([cannot find `\$ac_asin' (= `$ac_asin') in `\$ac_m' (= `$at_m')])]) |
| 38 |
|
| 39 |
# But if the bug is in the caching mechanism, then be sure we |
| 40 |
# correctly detect failures. |
| 41 |
|
| 42 |
AC_CHECK_LIB(m, cossack, |
| 43 |
[AC_MSG_ERROR([found `cossack' in `libm'])]) |
| 44 |
|
| 45 |
# No kidding, using variables was broken in 2.50 :( |
| 46 |
ac_sinner=sinner |
| 47 |
AC_CHECK_LIB(m, $ac_sinner, |
| 48 |
[AC_MSG_ERROR([found `\$ac_sinner' (= `$ac_sinner') in `libm'])]) |
| 49 |
|
| 50 |
ac_m=m |
| 51 |
AC_CHECK_LIB($ac_m, acossack, |
| 52 |
[AC_MSG_ERROR([found `acossack' in `\$ac_m' (= `$ac_m')])]) |
| 53 |
|
| 54 |
ac_asinner=asinner |
| 55 |
AC_CHECK_LIB($ac_m, $ac_asinner, |
| 56 |
[AC_MSG_ERROR([found `\$ac_asinner' (= `$ac_asinner') in `\$ac_m' (= `$at_m')])]) |
| 57 |
|
| 58 |
]) |
| 59 |
|
| 60 |
|
| 61 |
# AC_CHECK_DECLS |
| 62 |
# -------------- |
| 63 |
# Check that it performs the correct actions: |
| 64 |
# Must define NEED_NO_DECL, but not NEED_YES_DECL. |
| 65 |
AT_CHECK_MACRO([AC_CHECK_DECLS], |
| 66 |
[[AC_CHECK_DECLS([yes, no],,, |
| 67 |
[int yes = 1;])]], |
| 68 |
[AT_CHECK_DEFINES( |
| 69 |
[#define HAVE_DECL_NO 0 |
| 70 |
#define HAVE_DECL_YES 1 |
| 71 |
])]) |
| 72 |
|
| 73 |
|
| 74 |
# AC_CHECK_FUNCS |
| 75 |
# -------------- |
| 76 |
# Check that it performs the correct actions: |
| 77 |
# Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP |
| 78 |
AT_CHECK_MACRO([AC_CHECK_FUNCS], |
| 79 |
[AC_CHECK_FUNCS(printf autoconf_ftnirp)], |
| 80 |
[AT_CHECK_DEFINES( |
| 81 |
[/* #undef HAVE_AUTOCONF_FTNIRP */ |
| 82 |
#define HAVE_PRINTF 1 |
| 83 |
])]) |
| 84 |
|
| 85 |
|
| 86 |
# AC_REPLACE_FUNCS |
| 87 |
# ---------------- |
| 88 |
# Check that it performs the correct actions: autoconf_ftnirp.c must |
| 89 |
# be compiled, and must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP |
| 90 |
# FIXME: Maybe check the traces? |
| 91 |
AT_SETUP([AC_REPLACE_FUNCS]) |
| 92 |
|
| 93 |
AT_DATA([config.in], |
| 94 |
[@LIBOBJS@ |
| 95 |
]) |
| 96 |
|
| 97 |
AT_CONFIGURE_AC( |
| 98 |
[AC_CONFIG_FILES(config.libobjs:config.in) |
| 99 |
AC_REPLACE_FUNCS(printf autoconf_ftnirp)]) |
| 100 |
|
| 101 |
AT_CHECK_AUTOCONF([-W obsolete]) |
| 102 |
AT_CHECK_AUTOHEADER |
| 103 |
AT_CHECK_CONFIGURE |
| 104 |
AT_CHECK_ENV |
| 105 |
AT_CHECK_DEFINES( |
| 106 |
[/* #undef HAVE_AUTOCONF_FTNIRP */ |
| 107 |
#define HAVE_PRINTF 1 |
| 108 |
]) |
| 109 |
|
| 110 |
AT_CHECK([sed 's/ */ /g;s/^ //;s/ $//' config.libobjs], [], |
| 111 |
[autoconf_ftnirp.o |
| 112 |
]) |
| 113 |
|
| 114 |
AT_CLEANUP([config.libobjs]) |
| 115 |
|
| 116 |
|
| 117 |
# AC_CHECK_HEADERS |
| 118 |
# ---------------- |
| 119 |
# Check that it performs the correct actions: |
| 120 |
# Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H. |
| 121 |
AT_CHECK_MACRO([AC_CHECK_HEADERS], |
| 122 |
[AC_CHECK_HEADERS(stdio.h autoconf_io.h)], |
| 123 |
[AT_CHECK_DEFINES( |
| 124 |
[/* #undef HAVE_AUTOCONF_IO_H */ |
| 125 |
#define HAVE_STDIO_H 1 |
| 126 |
])]) |
| 127 |
|
| 128 |
|
| 129 |
# AC_CHECK_MEMBERS |
| 130 |
# ---------------- |
| 131 |
# Check that it performs the correct actions. |
| 132 |
# Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO. |
| 133 |
AT_CHECK_MACRO([AC_CHECK_MEMBERS], |
| 134 |
[[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no],,, |
| 135 |
[struct yes_s { int yes ;} ;])]], |
| 136 |
[AT_CHECK_DEFINES( |
| 137 |
[/* #undef HAVE_STRUCT_YES_S_NO */ |
| 138 |
#define HAVE_STRUCT_YES_S_YES 1 |
| 139 |
])]) |
| 140 |
|
| 141 |
|
| 142 |
# AC_CHECK_SIZEOF |
| 143 |
# --------------- |
| 144 |
AT_CHECK_MACRO([AC_CHECK_SIZEOF], |
| 145 |
[[AC_CHECK_SIZEOF(char) |
| 146 |
AC_CHECK_SIZEOF(charchar,, |
| 147 |
[[#include <stdio.h> |
| 148 |
typedef char charchar[2];]]) |
| 149 |
AC_CHECK_SIZEOF(charcharchar) |
| 150 |
|
| 151 |
# Exercise the code used when cross-compiling |
| 152 |
cross_compiling=yes |
| 153 |
AC_CHECK_SIZEOF(unsigned char) |
| 154 |
AC_CHECK_SIZEOF(ucharchar,, |
| 155 |
[[#include <stdio.h> |
| 156 |
typedef unsigned char ucharchar[2];]]) |
| 157 |
AC_CHECK_SIZEOF(ucharcharchar)]], |
| 158 |
[AT_CHECK_DEFINES( |
| 159 |
[#define SIZEOF_CHAR 1 |
| 160 |
#define SIZEOF_CHARCHAR 2 |
| 161 |
#define SIZEOF_CHARCHARCHAR 0 |
| 162 |
#define SIZEOF_UCHARCHAR 2 |
| 163 |
#define SIZEOF_UCHARCHARCHAR 0 |
| 164 |
#define SIZEOF_UNSIGNED_CHAR 1 |
| 165 |
])]) |
| 166 |
|
| 167 |
|
| 168 |
# AC_CHECK_TYPES |
| 169 |
# -------------- |
| 170 |
# Check that it performs the correct actions. |
| 171 |
# Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S. |
| 172 |
# `int' and `struct yes_s' are both checked to test both the compiler |
| 173 |
# builtin types, and defined types. |
| 174 |
AT_CHECK_MACRO([AC_CHECK_TYPES], |
| 175 |
[[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,, |
| 176 |
[struct yes_s { int yes ;} ;])]], |
| 177 |
[AT_CHECK_DEFINES( |
| 178 |
[#define HAVE_INT 1 |
| 179 |
/* #undef HAVE_STRUCT_NO_S */ |
| 180 |
#define HAVE_STRUCT_YES_S 1 |
| 181 |
])]) |
| 182 |
|
| 183 |
|
| 184 |
# AC_CHECK_TYPES |
| 185 |
# -------------- |
| 186 |
# Check that we properly dispatch properly to the old implementation |
| 187 |
# or to the new one. |
| 188 |
AT_SETUP([AC_CHECK_TYPES: backward compatibility]) |
| 189 |
|
| 190 |
AT_DATA(configure.ac, |
| 191 |
[[AC_INIT |
| 192 |
define([_AC_CHECK_TYPE_NEW], [NEW]) |
| 193 |
define([_AC_CHECK_TYPE_OLD], [OLD]) |
| 194 |
#(cut-from-here |
| 195 |
AC_CHECK_TYPE(ptrdiff_t) |
| 196 |
AC_CHECK_TYPE(ptrdiff_t, int) |
| 197 |
AC_CHECK_TYPE(quad, long long) |
| 198 |
AC_CHECK_TYPE(table_42, [int[42]]) |
| 199 |
# Nice machine! |
| 200 |
AC_CHECK_TYPE(uint8_t, uint65536_t) |
| 201 |
AC_CHECK_TYPE(a,b,c,d) |
| 202 |
#to-here) |
| 203 |
AC_OUTPUT |
| 204 |
]]) |
| 205 |
|
| 206 |
AT_CHECK_AUTOCONF |
| 207 |
AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]], |
| 208 |
0, |
| 209 |
[NEW |
| 210 |
OLD |
| 211 |
OLD |
| 212 |
OLD |
| 213 |
OLD |
| 214 |
NEW |
| 215 |
]) |
| 216 |
|
| 217 |
AT_CLEANUP |
| 218 |
|
| 219 |
|
| 220 |
# AC_CHECK_FILES |
| 221 |
# -------------- |
| 222 |
# FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to |
| 223 |
# open AH_TEMPLATE to `configure.ac', which is not yet the case. |
| 224 |
AT_CHECK_MACRO([AC_CHECK_FILES], |
| 225 |
[touch at-exists1 at-exists2 |
| 226 |
ac_exists2=at-exists2 |
| 227 |
ac_missing2=at-missing2 |
| 228 |
AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2) |
| 229 |
rm at-exists1 at-exists2], |
| 230 |
[AT_CHECK_DEFINES( |
| 231 |
[#define HAVE_AT_EXISTS1 1 |
| 232 |
/* #undef HAVE_AT_MISSING1 */ |
| 233 |
])]) |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
## ------------------------------ ## |
| 238 |
## AC_CHECK_PROG & AC_PATH_PROG. ## |
| 239 |
## ------------------------------ ## |
| 240 |
|
| 241 |
|
| 242 |
# AT_CHECK_PROGS_PREPARE |
| 243 |
# ---------------------- |
| 244 |
# Create a sub directory `path' with 6 subdirs which all 7 contain |
| 245 |
# an executable `tool'. `6' contains a `better' tool. |
| 246 |
m4_define([AT_CHECK_PROGS_PREPARE], |
| 247 |
[mkdir path |
| 248 |
|
| 249 |
cat >path/tool <<\EOF |
| 250 |
#! /bin/sh |
| 251 |
exit 0 |
| 252 |
EOF |
| 253 |
chmod +x path/tool |
| 254 |
|
| 255 |
for i in 1 2 3 4 5 6 |
| 256 |
do |
| 257 |
mkdir path/$i |
| 258 |
cp path/tool path/$i |
| 259 |
done |
| 260 |
cp path/tool path/6/better]) |
| 261 |
|
| 262 |
|
| 263 |
# -------------------------------- # |
| 264 |
# AC_CHECK_PROG & AC_CHECK_PROGS. # |
| 265 |
# -------------------------------- # |
| 266 |
|
| 267 |
AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS]) |
| 268 |
|
| 269 |
AT_CHECK_PROGS_PREPARE |
| 270 |
|
| 271 |
AT_DATA(configure.ac, |
| 272 |
[[AC_INIT |
| 273 |
pwd=`pwd` |
| 274 |
p="1${ac_path_separator}2${ac_path_separator}3${ac_path_separator}4${ac_path_separator}5${ac_path_separator}6" |
| 275 |
path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'` |
| 276 |
fail=false |
| 277 |
|
| 278 |
AC_CHECK_PROG(TOOL1, tool, found, not-found, $path) |
| 279 |
test "$TOOL1" = found || fail=: |
| 280 |
|
| 281 |
# Yes, the semantics of this macro is weird. |
| 282 |
AC_CHECK_PROG(TOOL2, tool,, not-found, $path) |
| 283 |
test "$TOOL2" = not-found || fail=: |
| 284 |
|
| 285 |
AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool) |
| 286 |
test "$TOOL3" = $pwd/path/2/tool || fail=: |
| 287 |
|
| 288 |
AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool) |
| 289 |
test "$TOOL4" = better || fail=: |
| 290 |
|
| 291 |
# When a tool is not found, and no value is given for not-found, |
| 292 |
# the variable is left empty. |
| 293 |
AC_CHECK_PROGS(TOOL5, missing,, $path) |
| 294 |
test -z "$TOOL5" || fail=: |
| 295 |
|
| 296 |
AC_CHECK_PROGS(TOOL6, missing tool better,, $path) |
| 297 |
test "$TOOL6" = tool || fail=: |
| 298 |
|
| 299 |
# No AC-OUTPUT, we don't need config.status. |
| 300 |
$fail && |
| 301 |
AC_MSG_ERROR([[CHECK_PROG failed]]) |
| 302 |
AS_EXIT(0) |
| 303 |
]]) |
| 304 |
|
| 305 |
AT_CHECK_AUTOCONF |
| 306 |
AT_CHECK_CONFIGURE |
| 307 |
|
| 308 |
AT_CLEANUP(path) |
| 309 |
|
| 310 |
|
| 311 |
# ------------------------------ # |
| 312 |
# AC_PATH_PROG & AC_PATH_PROGS. # |
| 313 |
# ------------------------------ # |
| 314 |
|
| 315 |
AT_SETUP(AC_PATH_PROG & AC_PATH_PROGS) |
| 316 |
|
| 317 |
AT_CHECK_PROGS_PREPARE |
| 318 |
|
| 319 |
AT_DATA(configure.ac, |
| 320 |
[[AC_INIT |
| 321 |
pwd=`pwd` |
| 322 |
p="1${ac_path_separator}2${ac_path_separator}3${ac_path_separator}4${ac_path_separator}5${ac_path_separator}6" |
| 323 |
path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'` |
| 324 |
fail=false |
| 325 |
|
| 326 |
AC_PATH_PROG(TOOL1, tool, not-found, $path) |
| 327 |
test "$TOOL1" = $pwd/path/1/tool || fail=: |
| 328 |
|
| 329 |
AC_PATH_PROG(TOOL2, better, not-found, $path) |
| 330 |
test "$TOOL2" = $pwd/path/6/better || fail=: |
| 331 |
|
| 332 |
# When a tool is not found, and no value is given for not-found, |
| 333 |
# the variable is left empty. |
| 334 |
AC_PATH_PROGS(TOOL3, missing,, $path) |
| 335 |
test -z "$TOOL3" || fail=: |
| 336 |
|
| 337 |
AC_PATH_PROGS(TOOL4, missing tool better,, $path) |
| 338 |
test "$TOOL4" = $pwd/path/1/tool || fail=: |
| 339 |
|
| 340 |
# No AC-OUTPUT, we don't need config.status. |
| 341 |
$fail && |
| 342 |
AC_MSG_ERROR([[PATH_PROG failed]]) |
| 343 |
AS_EXIT(0) |
| 344 |
]]) |
| 345 |
|
| 346 |
AT_CHECK_AUTOCONF |
| 347 |
AT_CHECK_CONFIGURE |
| 348 |
|
| 349 |
AT_CLEANUP(path) |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
## -------------- ## |
| 355 |
## AC_PATH_XTRA. ## |
| 356 |
## -------------- ## |
| 357 |
|
| 358 |
|
| 359 |
AT_SETUP([AC_PATH_XTRA]) |
| 360 |
|
| 361 |
_AT_CHECK_AC_MACRO([AC_PATH_XTRA]) |
| 362 |
|
| 363 |
# Check X_DISPLAY_MISSING. |
| 364 |
AT_CHECK_CONFIGURE([--without-x]) |
| 365 |
AT_CHECK_DEFINES( |
| 366 |
[#define X_DISPLAY_MISSING 1 |
| 367 |
]) |
| 368 |
|
| 369 |
AT_CLEANUP |
| 370 |
|
| 371 |
|
| 372 |
## ------------------------------- ## |
| 373 |
## Obsolete non-updatable macros. ## |
| 374 |
## ------------------------------- ## |
| 375 |
|
| 376 |
|
| 377 |
AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete]) |
| 378 |
AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete]) |