Fix previous commit.
[pwmd.git] / m4 / ax_cc_for_build.m4
blobc880fd0e1ddbbba4c8072ca8776adbed37a55fcc
1 # ===========================================================================
2 #      http://www.gnu.org/software/autoconf-archive/ax_cc_for_build.html
3 # ===========================================================================
5 # SYNOPSIS
7 #   AX_CC_FOR_BUILD
9 # DESCRIPTION
11 #   Find a build-time compiler. Sets CC_FOR_BUILD and EXEEXT_FOR_BUILD.
13 # LICENSE
15 #   Copyright (c) 2010 Reuben Thomas <rrt@sc3d.org>
16 #   Copyright (c) 1999 Richard Henderson <rth@redhat.com>
18 #   This program is free software: you can redistribute it and/or modify it
19 #   under the terms of the GNU General Public License as published by the
20 #   Free Software Foundation, either version 3 of the License, or (at your
21 #   option) any later version.
23 #   This program is distributed in the hope that it will be useful, but
24 #   WITHOUT ANY WARRANTY; without even the implied warranty of
25 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
26 #   Public License for more details.
28 #   You should have received a copy of the GNU General Public License along
29 #   with this program. If not, see <http://www.gnu.org/licenses/>.
31 #   As a special exception, the respective Autoconf Macro's copyright owner
32 #   gives unlimited permission to copy, distribute and modify the configure
33 #   scripts that are the output of Autoconf when processing the Macro. You
34 #   need not follow the terms of the GNU General Public License when using
35 #   or distributing such scripts, even though portions of the text of the
36 #   Macro appear in them. The GNU General Public License (GPL) does govern
37 #   all other use of the material that constitutes the Autoconf Macro.
39 #   This special exception to the GPL applies to versions of the Autoconf
40 #   Macro released by the Autoconf Archive. When you make and distribute a
41 #   modified version of the Autoconf Macro, you may extend this special
42 #   exception to the GPL to apply to your modified version as well.
44 #serial 2
46 dnl Get a default for CC_FOR_BUILD to put into Makefile.
47 AC_DEFUN([AX_CC_FOR_BUILD],
48 [# Put a plausible default for CC_FOR_BUILD in Makefile.
49 if test -z "$CC_FOR_BUILD"; then
50   if test "x$cross_compiling" = "xno"; then
51     CC_FOR_BUILD='$(CC)'
52   else
53     CC_FOR_BUILD=gcc
54   fi
56 AC_SUBST(CC_FOR_BUILD)
57 # Also set EXEEXT_FOR_BUILD.
58 if test "x$cross_compiling" = "xno"; then
59   EXEEXT_FOR_BUILD='$(EXEEXT)'
60 else
61   AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
62     [rm -f conftest*
63      echo 'int main () { return 0; }' > conftest.c
64      bfd_cv_build_exeext=
65      ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
66      for file in conftest.*; do
67        case $file in
68        *.c | *.o | *.obj | *.ilk | *.pdb) ;;
69        *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
70        esac
71      done
72      rm -f conftest*
73      test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
74   EXEEXT_FOR_BUILD=""
75   test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
77 AC_SUBST(EXEEXT_FOR_BUILD)])dnl