1 dnl GMP specific autoconf macros
4 dnl Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
7 dnl This file is part of the GNU MP Library.
9 dnl The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl it under the terms of the GNU Lesser General Public License as published
11 dnl by the Free Software Foundation; either version 2.1 of the License, or (at
12 dnl your option) any later version.
14 dnl The GNU MP Library is distributed in the hope that it will be useful, but
15 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 dnl License for more details.
19 dnl You should have received a copy of the GNU Lesser General Public License
20 dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write to
21 dnl the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 dnl MA 02110-1301, USA.
24 dnl GMP_PROG_CC_FOR_BUILD
25 dnl ---------------------
26 dnl Establish CC_FOR_BUILD, a C compiler for the build system.
28 dnl If CC_FOR_BUILD is set then it's expected to work, likewise the old
29 dnl style HOST_CC, otherwise some likely candidates are tried, the same as
32 AC_DEFUN([GMP_PROG_CC_FOR_BUILD],
33 [AC_REQUIRE([AC_PROG_CC])
34 if test -n "$CC_FOR_BUILD"; then
35 GMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,,
36 [AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])])
37 elif test -n "$HOST_CC"; then
38 GMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC,
39 [CC_FOR_BUILD=$HOST_CC],
40 [AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])])
42 for i in "$CC" "$CC $CFLAGS $CPPFLAGS" cc gcc c89 c99; do
43 GMP_PROG_CC_FOR_BUILD_WORKS($i,
47 if test -z "$CC_FOR_BUILD"; then
48 AC_MSG_ERROR([Cannot find a build system compiler])
52 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
53 AC_SUBST(CC_FOR_BUILD)
57 dnl GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]])
58 dnl -------------------------------------------------------------------------
59 dnl See if the given cc/cflags works on the build system.
61 dnl It seems easiest to just use the default compiler output, rather than
62 dnl figuring out the .exe or whatever at this stage.
64 AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS],
65 [AC_MSG_CHECKING([build system compiler $1])
66 # remove anything that might look like compiler output to our "||" expression
67 rm -f conftest* a.out b.out a.exe a_out.exe
75 gmp_compile="$1 conftest.c"
77 if AC_TRY_EVAL(gmp_compile); then
78 if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; then
79 cc_for_build_works=yes
82 rm -f conftest* a.out b.out a.exe a_out.exe
83 AC_MSG_RESULT($cc_for_build_works)
84 if test "$cc_for_build_works" = yes; then
92 dnl GMP_PROG_CPP_FOR_BUILD
93 dnl ---------------------
94 dnl Establish CPP_FOR_BUILD, the build system C preprocessor.
95 dnl The choices tried here are the same as AC_PROG_CPP, but with
98 AC_DEFUN([GMP_PROG_CPP_FOR_BUILD],
99 [AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])
100 AC_MSG_CHECKING([for build system preprocessor])
101 if test -z "$CPP_FOR_BUILD"; then
102 AC_CACHE_VAL(gmp_cv_prog_cpp_for_build,
103 [cat >conftest.c <<EOF
106 for i in "$CC_FOR_BUILD -E" "$CC_FOR_BUILD -E -traditional-cpp" "/lib/cpp"; do
107 gmp_compile="$i conftest.c"
108 if AC_TRY_EVAL(gmp_compile) >&AC_FD_CC 2>&1; then
109 gmp_cv_prog_cpp_for_build=$i
113 rm -f conftest* a.out b.out a.exe a_out.exe
114 if test -z "$gmp_cv_prog_cpp_for_build"; then
115 AC_MSG_ERROR([Cannot find build system C preprocessor.])
118 CPP_FOR_BUILD=$gmp_cv_prog_cpp_for_build
120 AC_MSG_RESULT([$CPP_FOR_BUILD])
122 AC_ARG_VAR(CPP_FOR_BUILD,[build system C preprocessor])
123 AC_SUBST(CPP_FOR_BUILD)
127 dnl GMP_PROG_EXEEXT_FOR_BUILD
128 dnl -------------------------
129 dnl Determine EXEEXT_FOR_BUILD, the build system executable suffix.
131 dnl The idea is to find what "-o conftest$foo" will make it possible to run
132 dnl the program with ./conftest. On Unix-like systems this is of course
133 dnl nothing, for DOS it's ".exe", or for a strange RISC OS foreign file
134 dnl system cross compile it can be ",ff8" apparently. Not sure if the
135 dnl latter actually applies to a build-system executable, maybe it doesn't,
136 dnl but it won't hurt to try.
138 AC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD],
139 [AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])
140 AC_CACHE_CHECK([for build system executable suffix],
141 gmp_cv_prog_exeext_for_build,
142 [cat >conftest.c <<EOF
149 for i in .exe ,ff8 ""; do
150 gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"
151 if AC_TRY_EVAL(gmp_compile); then
152 if (./conftest) 2>&AC_FD_CC; then
153 gmp_cv_prog_exeext_for_build=$i
159 if test "${gmp_cv_prog_exeext_for_build+set}" != set; then
160 AC_MSG_ERROR([Cannot determine executable suffix])
163 AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build)