| 1 |
# C O M P I L E R . M 4 |
| 2 |
# BRL-CAD |
| 3 |
# |
| 4 |
# Copyright (c) 2005-2010 United States Government as represented by |
| 5 |
# the U.S. Army Research Laboratory. |
| 6 |
# |
| 7 |
# Redistribution and use in source and binary forms, with or without |
| 8 |
# modification, are permitted provided that the following conditions |
| 9 |
# are met: |
| 10 |
# |
| 11 |
# 1. Redistributions of source code must retain the above copyright |
| 12 |
# notice, this list of conditions and the following disclaimer. |
| 13 |
# |
| 14 |
# 2. Redistributions in binary form must reproduce the above |
| 15 |
# copyright notice, this list of conditions and the following |
| 16 |
# disclaimer in the documentation and/or other materials provided |
| 17 |
# with the distribution. |
| 18 |
# |
| 19 |
# 3. The name of the author may not be used to endorse or promote |
| 20 |
# products derived from this software without specific prior written |
| 21 |
# permission. |
| 22 |
# |
| 23 |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 24 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 25 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 26 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 27 |
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 28 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 29 |
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 30 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 31 |
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 32 |
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 33 |
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 |
# |
| 35 |
### |
| 36 |
# |
| 37 |
# BC_COMPILER_AND_LINKER_RECOGNIZES |
| 38 |
# checks if the compiler will work with the specified flags |
| 39 |
# |
| 40 |
# BC_COMPILER_RECOGNIZES |
| 41 |
# checks if the compiler will work with the specified cflags |
| 42 |
# |
| 43 |
# BC_LINKER_RECOGNIZES |
| 44 |
# checks if the linker will work with the specified ldflags |
| 45 |
# |
| 46 |
# BC_PREPROCESSOR_RECOGNIZES |
| 47 |
# checks if the preprocessor will work with the specified cppflags |
| 48 |
# |
| 49 |
# BC_SANITY_CHECK |
| 50 |
# make sure the compiler actually builds executables that run |
| 51 |
# |
| 52 |
### |
| 53 |
|
| 54 |
AC_DEFUN([BC_COMPILER_AND_LINKER_RECOGNIZES], [ |
| 55 |
__flag="$1" |
| 56 |
bc_[$2]_works=yes |
| 57 |
__keep="$3" |
| 58 |
AC_MSG_CHECKING([if compiler and linker recognize $__flag]) |
| 59 |
PRECFLAGS="$CFLAGS" |
| 60 |
PRECXXFLAGS="$CXXFLAGS" |
| 61 |
PRELDFLAGS="$LDFLAGS" |
| 62 |
CFLAGS="$CFLAGS $__flag" |
| 63 |
CXXFLAGS="$CXXFLAGS $__flag" |
| 64 |
LDFLAGS="$LDFLAGS $__flag" |
| 65 |
m4_pushdef([AC_TRY_EVAL], [_AC_EVAL_STDERR]($$[1])) |
| 66 |
AC_TRY_COMPILE( [], [int i;], [if AC_TRY_COMMAND([grep "nrecognize" conftest.err >/dev/null 2>&1]) ; then bc_[$2]_works=no ; fi], [bc_[$2]_works=no]) |
| 67 |
m4_popdef([AC_TRY_EVAL]) |
| 68 |
rm -f conftest.err |
| 69 |
AC_TRY_RUN( [ |
| 70 |
#include <stdlib.h> |
| 71 |
int main(){exit(0);} |
| 72 |
], [], [bc_[$2]_works=no], [bc_[$2]_works=maybe]) |
| 73 |
AC_MSG_RESULT($bc_[$2]_works) |
| 74 |
if test "x$bc_[$2]_works" = "xno" -o "x$__keep" != "x" ; then |
| 75 |
CFLAGS="$PRECFLAGS" |
| 76 |
CXXFLAGS="$PRECXXFLAGS" |
| 77 |
LDFLAGS="$PRELDFLAGS" |
| 78 |
fi |
| 79 |
]) |
| 80 |
|
| 81 |
AC_DEFUN([BC_COMPILER_AND_LINKER_RECOGNIZE], [ |
| 82 |
AC_REQUIRE([BC_COMPILER_AND_LINKER_RECOGNIZES]) |
| 83 |
BC_COMPILER_AND_LINKER_RECOGNIZES([$1], [$2], [$3]) |
| 84 |
]) |
| 85 |
|
| 86 |
|
| 87 |
AC_DEFUN([BC_COMPILER_RECOGNIZES], [ |
| 88 |
__flag="$1" |
| 89 |
AC_MSG_CHECKING([if compiler recognizes $__flag]) |
| 90 |
bc_[$2]_works=yes |
| 91 |
__keep="$3" |
| 92 |
PRECFLAGS="$CFLAGS" |
| 93 |
PRECXXFLAGS="$CXXFLAGS" |
| 94 |
CFLAGS="$CFLAGS $__flag" |
| 95 |
CXXFLAGS="$CXXFLAGS $__flag" |
| 96 |
m4_pushdef([AC_TRY_EVAL], [_AC_EVAL_STDERR]($$[1])) |
| 97 |
AC_TRY_COMPILE( [], [int i;], [if AC_TRY_COMMAND([grep "nrecognize" conftest.err >/dev/null 2>&1]) ; then bc_[$2]_works=no ; fi], [bc_[$2]_works=no]) |
| 98 |
m4_popdef([AC_TRY_EVAL]) |
| 99 |
rm -f conftest.err |
| 100 |
AC_MSG_RESULT($bc_[$2]_works) |
| 101 |
if test "x$bc_[$2]_works" = "xno" -o "x$__keep" != "x" ; then |
| 102 |
CFLAGS="$PRECFLAGS" |
| 103 |
CXXFLAGS="$PRECXXFLAGS" |
| 104 |
fi |
| 105 |
]) |
| 106 |
|
| 107 |
AC_DEFUN([BC_COMPILER_RECOGNIZE], [ |
| 108 |
AC_REQUIRE([BC_COMPILER_RECOGNIZES]) |
| 109 |
BC_COMPILER_RECOGNIZES([$1], [$2], [$3]) |
| 110 |
]) |
| 111 |
|
| 112 |
|
| 113 |
AC_DEFUN([BC_LINKER_RECOGNIZES], [ |
| 114 |
__flag="$1" |
| 115 |
AC_MSG_CHECKING([if linker recognizes $__flag]) |
| 116 |
bc_[$2]_works=yes |
| 117 |
__keep="$3" |
| 118 |
PRELDFLAGS="$LDFLAGS" |
| 119 |
LDFLAGS="$LDFLAGS $__flag" |
| 120 |
m4_pushdef([AC_TRY_EVAL], [_AC_EVAL_STDERR]($$[1])) |
| 121 |
AC_TRY_LINK( [], [int i;], [if AC_TRY_COMMAND([grep "nrecognize" conftest.err >/dev/null 2>&1]) ; then bc_[$2]_works=no ; fi], [bc_[$2]_works=no]) |
| 122 |
m4_popdef([AC_TRY_EVAL]) |
| 123 |
rm -f conftest.err |
| 124 |
AC_MSG_RESULT($bc_[$2]_works) |
| 125 |
if test "x$bc_[$2]_works" = "xno" -o "x$__keep" != "x" ; then |
| 126 |
LDFLAGS="$PRELDFLAGS" |
| 127 |
fi |
| 128 |
]) |
| 129 |
|
| 130 |
AC_DEFUN([BC_LINKER_RECOGNIZE], [ |
| 131 |
AC_REQUIRE([BC_COMPILER_RECOGNIZES]) |
| 132 |
BC_LINKER_RECOGNIZES([$1], [$2], [$3]) |
| 133 |
]) |
| 134 |
|
| 135 |
|
| 136 |
AC_DEFUN([BC_PREPROCESSOR_RECOGNIZES], [ |
| 137 |
__flag="$1" |
| 138 |
AC_MSG_CHECKING([if preprocesser recognizes $__flag]) |
| 139 |
bc_[$2]_works=yes |
| 140 |
__keep="$3" |
| 141 |
PRECPPFLAGS="$CPPFLAGS" |
| 142 |
PRECXXCPPFLAGS="$CXXCPPFLAGS" |
| 143 |
CPPFLAGS="$CPPFLAGS $__flag" |
| 144 |
CXXCPPFLAGS="$CXXCPPFLAGS $__flag" |
| 145 |
m4_pushdef([AC_TRY_EVAL], [_AC_EVAL_STDERR]($$[1])) |
| 146 |
AC_TRY_COMPILE( [], [int i;], [if AC_TRY_COMMAND([grep "nrecognize" conftest.err >/dev/null 2>&1]) ; then bc_[$2]_works=no ; fi], [bc_[$2]_works=no]) |
| 147 |
m4_popdef([AC_TRY_EVAL]) |
| 148 |
rm -f conftest.err |
| 149 |
AC_MSG_RESULT($bc_[$2]_works) |
| 150 |
if test "x$bc_[$2]_works" = "xno" -o "x$__keep" = "x" ; then |
| 151 |
CPPFLAGS="$PRECPPFLAGS" |
| 152 |
CXXCPPFLAGS="$PRECXXCPPFLAGS" |
| 153 |
fi |
| 154 |
]) |
| 155 |
|
| 156 |
AC_DEFUN([BC_PREPROCESSOR_RECOGNIZE], [ |
| 157 |
AC_REQUIRE([BC_PREPROCESSOR_RECOGNIZES]) |
| 158 |
BC_PREPROCESSOR_RECOGNIZES([$1], [$2], [$3]) |
| 159 |
]) |
| 160 |
|
| 161 |
AC_DEFUN([BC_SANITY_CHECK], [ |
| 162 |
__msg="$1" |
| 163 |
if test "x$__msg" = "x" ; then |
| 164 |
__msg="compiler and flags for sanity" |
| 165 |
fi |
| 166 |
AC_MSG_CHECKING([$__msg]) |
| 167 |
AC_TRY_RUN([ |
| 168 |
#include <stdlib.h> |
| 169 |
int main(){exit(0);} |
| 170 |
], |
| 171 |
[ AC_MSG_RESULT(yes) ], |
| 172 |
[ |
| 173 |
AC_MSG_RESULT(no) |
| 174 |
AC_MSG_NOTICE([}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]) |
| 175 |
AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***]) |
| 176 |
], |
| 177 |
[ AC_MSG_RESULT(dunno, cross-compiling)] |
| 178 |
) |
| 179 |
]) |
| 180 |
|
| 181 |
# Local Variables: |
| 182 |
# mode: m4 |
| 183 |
# tab-width: 8 |
| 184 |
# standard-indent: 4 |
| 185 |
# indent-tabs-mode: t |
| 186 |
# End: |
| 187 |
# ex: shiftwidth=4 tabstop=8 |