| 1 | # -*- Autotest -*-
|
|---|
| 2 |
|
|---|
| 3 | AT_BANNER([C low level compiling/preprocessing macros.])
|
|---|
| 4 |
|
|---|
| 5 | # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 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 2, or (at your option)
|
|---|
| 11 | # 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, write to the Free Software
|
|---|
| 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|---|
| 21 | # 02110-1301, USA.
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | # Since the macros which compile are required by most tests, check
|
|---|
| 25 | # them first. But remember that looking for a compiler is even more
|
|---|
| 26 | # primitive, so check those first.
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 | ## ------------ ##
|
|---|
| 30 | ## Extensions. ##
|
|---|
| 31 | ## ------------ ##
|
|---|
| 32 |
|
|---|
| 33 | # As far as we know only `foo', `foo.exe' are possible executable,
|
|---|
| 34 | # and `foo.o', `foo.obj' are possible object files. Autoconf must not
|
|---|
| 35 | # know that, but it is OK for the test suite to take this into account.
|
|---|
| 36 | AT_CHECK_MACRO([Extensions],
|
|---|
| 37 | [[AC_PROG_CC
|
|---|
| 38 | case $ac_exeext in
|
|---|
| 39 | '' | '.exe' ) ;;
|
|---|
| 40 | * ) AC_MSG_ERROR([suspicious executable suffix: $ac_exeext]);;
|
|---|
| 41 | esac
|
|---|
| 42 |
|
|---|
| 43 | case $ac_objext in
|
|---|
| 44 | 'o' | 'obj' ) ;;
|
|---|
| 45 | * ) AC_MSG_ERROR([suspicious object suffix: $ac_objext]);;
|
|---|
| 46 | esac
|
|---|
| 47 | ]])
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | ## -------------------------- ##
|
|---|
| 52 | ## Broken/missing compilers. ##
|
|---|
| 53 | ## -------------------------- ##
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | # Check that Autoconf correctly diagnoses broken compilers, and in
|
|---|
| 57 | # particular, if it does not exit 77, the test suite is in trouble...
|
|---|
| 58 | # FIXME: Once a precise message decided, check stderr of configure.
|
|---|
| 59 | AT_SETUP([Broken/missing compilers])
|
|---|
| 60 |
|
|---|
| 61 | AT_DATA([configure.ac],
|
|---|
| 62 | [[AC_INIT
|
|---|
| 63 | CC=no-such-compiler
|
|---|
| 64 | AC_PROG_CC
|
|---|
| 65 | ]])
|
|---|
| 66 |
|
|---|
| 67 | AT_CHECK_AUTOCONF
|
|---|
| 68 | AT_CHECK_CONFIGURE([], 77, ignore, ignore)
|
|---|
| 69 |
|
|---|
| 70 | AT_CLEANUP
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | ## ------------ ##
|
|---|
| 74 | ## C keywords. ##
|
|---|
| 75 | ## ------------ ##
|
|---|
| 76 |
|
|---|
| 77 | # GCC supports `const', `typeof', and `volatile'.
|
|---|
| 78 | AT_CHECK_MACRO([C keywords],
|
|---|
| 79 | [[AC_PROG_CC
|
|---|
| 80 | AC_C_CONST
|
|---|
| 81 | AC_C_TYPEOF
|
|---|
| 82 | AC_C_VOLATILE
|
|---|
| 83 | case $GCC,$ac_cv_c_const,$ac_cv_c_typeof,$ac_cv_c_volatile in
|
|---|
| 84 | yes,*no*)
|
|---|
| 85 | AC_MSG_ERROR([failed to detect `const', `typeof', or `volatile' support]);;
|
|---|
| 86 | esac
|
|---|
| 87 | ]])
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | ## --------------------------------- ##
|
|---|
| 92 | ## AC_PROG_CPP requires AC_PROG_CC. ##
|
|---|
| 93 | ## --------------------------------- ##
|
|---|
| 94 |
|
|---|
| 95 | # Must invoke AC_PROG_CC.
|
|---|
| 96 | AT_CHECK_MACRO([AC_PROG_CPP requires AC_PROG_CC],
|
|---|
| 97 | [[AC_PROG_CPP
|
|---|
| 98 | test -z "$CC" &&
|
|---|
| 99 | AC_MSG_ERROR([looked for a C preprocessor without looking for a compiler])
|
|---|
| 100 | ]])
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 | ## --------------------------- ##
|
|---|
| 105 | ## AC_PROG_CPP with warnings. ##
|
|---|
| 106 | ## --------------------------- ##
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 | # It's Ok for strict preprocessors to produce warnings.
|
|---|
| 110 |
|
|---|
| 111 | AT_SETUP([AC_PROG_CPP with warnings])
|
|---|
| 112 |
|
|---|
| 113 | AT_DATA([mycpp],
|
|---|
| 114 | [[#! /bin/sh
|
|---|
| 115 | echo noise >&2
|
|---|
| 116 | exec "$@"
|
|---|
| 117 | ]])
|
|---|
| 118 |
|
|---|
| 119 | chmod +x mycpp
|
|---|
| 120 |
|
|---|
| 121 | _AT_CHECK_AC_MACRO(
|
|---|
| 122 | [[AC_PROG_CPP
|
|---|
| 123 | # If the preprocessor is not strict, just ignore
|
|---|
| 124 | test "x$ac_c_preproc_warn_flag" = xyes &&
|
|---|
| 125 | AC_MSG_ERROR([preprocessor has no warning option], 77)
|
|---|
| 126 | CPP="./mycpp $CPP"
|
|---|
| 127 | AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
|
|---|
| 128 |
|
|---|
| 129 | AT_CHECK_DEFINES(
|
|---|
| 130 | [/* #undef HAVE_AUTOCONF_IO_H */
|
|---|
| 131 | #define HAVE_STDIO_H 1
|
|---|
| 132 | ])
|
|---|
| 133 |
|
|---|
| 134 | AT_CLEANUP
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 | ## ------------------------------ ##
|
|---|
| 138 | ## AC_PROG_CPP without warnings. ##
|
|---|
| 139 | ## ------------------------------ ##
|
|---|
| 140 |
|
|---|
| 141 | AT_SETUP([AC_PROG_CPP without warnings])
|
|---|
| 142 |
|
|---|
| 143 | # Ignore if /lib/cpp doesn't work
|
|---|
| 144 | AT_CHECK([echo '#include <stdio.h>' | /lib/cpp || exit 77],
|
|---|
| 145 | [], [ignore], [ignore])
|
|---|
| 146 |
|
|---|
| 147 | # A cpp which exit status is meaningless.
|
|---|
| 148 | AT_DATA([mycpp],
|
|---|
| 149 | [[#! /bin/sh
|
|---|
| 150 | /lib/cpp "$@"
|
|---|
| 151 | exit 0
|
|---|
| 152 | ]])
|
|---|
| 153 |
|
|---|
| 154 | chmod +x mycpp
|
|---|
| 155 |
|
|---|
| 156 | _AT_CHECK_AC_MACRO(
|
|---|
| 157 | [[CPP=./mycpp
|
|---|
| 158 | AC_PROG_CPP
|
|---|
| 159 | test "x$ac_c_preproc_warn_flag" != xyes &&
|
|---|
| 160 | AC_MSG_ERROR([failed to detect preprocessor warning option])
|
|---|
| 161 | AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
|
|---|
| 162 |
|
|---|
| 163 | AT_CHECK_DEFINES(
|
|---|
| 164 | [/* #undef HAVE_AUTOCONF_IO_H */
|
|---|
| 165 | #define HAVE_STDIO_H 1
|
|---|
| 166 | ])
|
|---|
| 167 |
|
|---|
| 168 | AT_CLEANUP
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 | ## -------------------- ##
|
|---|
| 173 | ## AC_PROG_CPP via CC. ##
|
|---|
| 174 | ## -------------------- ##
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 | # It's Ok for strict preprocessors to produce warnings.
|
|---|
| 178 |
|
|---|
| 179 | AT_SETUP([AC_PROG_CPP via CC])
|
|---|
| 180 |
|
|---|
| 181 | # Ignore if /lib/cpp doesn't work
|
|---|
| 182 | AT_CHECK([echo '#include <stdio.h>' | /lib/cpp || exit 77],
|
|---|
| 183 | [], [ignore], [ignore])
|
|---|
| 184 |
|
|---|
| 185 | AT_DATA([mycc],
|
|---|
| 186 | [[#! /bin/sh
|
|---|
| 187 | echo "Annoying copyright message" >&2
|
|---|
| 188 | exec "$@"
|
|---|
| 189 | ]])
|
|---|
| 190 |
|
|---|
| 191 | chmod +x mycc
|
|---|
| 192 |
|
|---|
| 193 | # We go through the following contortions, in order to have the
|
|---|
| 194 | # configure script go down the same codepaths as it would during a
|
|---|
| 195 | # normal CPP selection check. If we explicitly set CPP, it goes down
|
|---|
| 196 | # a different codepath.
|
|---|
| 197 | _AT_CHECK_AC_MACRO(
|
|---|
| 198 | [[AC_PROG_CC
|
|---|
| 199 | CC="./mycc $CC"
|
|---|
| 200 | AC_PROG_CPP
|
|---|
| 201 | # The test $CC compiler should have been selected.
|
|---|
| 202 | test "$CPP" != "$CC -E" &&
|
|---|
| 203 | AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to fail])
|
|---|
| 204 |
|
|---|
| 205 | # Exercise CPP.
|
|---|
| 206 | AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
|
|---|
| 207 |
|
|---|
| 208 | AT_CHECK_DEFINES(
|
|---|
| 209 | [/* #undef HAVE_AUTOCONF_IO_H */
|
|---|
| 210 | #define HAVE_STDIO_H 1
|
|---|
| 211 | ])
|
|---|
| 212 |
|
|---|
| 213 | AT_CLEANUP
|
|---|