Tizen 2.1 base
[external/libgpg-error.git] / m4 / ac_prog_cc_for_build.m4
1 dnl Available from the GNU Autoconf Macro Archive at:
2 dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_cc_for_build.html
3 dnl
4 dnl All content of this archive is free software;
5 dnl you can redistribute it and/or modify it under the terms of the GNU
6 dnl General Public License as published by the Free Software Foundation;
7 dnl either version 2, or (at your option) any later version.
8 dnl
9 dnl As a special exception, the respective Autoconf Macro's copyright
10 dnl owner gives unlimited permission to copy, distribute and modify the
11 dnl configure scripts that are the output of Autoconf when processing the
12 dnl Macro. You need not follow the terms of the GNU General Public License
13 dnl when using or distributing such scripts, even though portions of the
14 dnl text of the Macro appear in them. The GNU General Public License (GPL)
15 dnl does govern all other use of the material that constitutes the
16 dnl Autoconf Macro.
17 dnl 
18 dnl This special exception to the GPL applies to versions of the Autoconf
19 dnl Macro released by the GNU Autoconf Macro Archive. When you make and
20 dnl distribute a modified version of the Autoconf Macro, you may extend
21 dnl this special exception to the GPL to apply to your modified version as
22 dnl well.
23
24 dnl Synopsis AC_PROG_CC_FOR_BUILD
25 dnl
26 dnl This macro searches for a C compiler that generates native
27 dnl executables, that is a C compiler that surely is not a cross-compiler.
28 dnl This can be useful if you have to generate source code at compile-time
29 dnl like for example GCC does.
30 dnl
31 dnl The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
32 dnl needed to compile or link (CC_FOR_BUILD) and preprocess
33 dnl (CPP_FOR_BUILD).  The value of these variables can be overridden by
34 dnl the user by specifying a compiler with an environment variable (like
35 dnl you do for standard CC).
36 dnl
37 dnl It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and
38 dnl object file extensions for the build platform, and GCC_FOR_BUILD
39 dnl to `yes' if the compiler we found is GCC.  All these variables but
40 dnl GCC_FOR_BUILD are substituted in the Makefile.
41 dnl
42 dnl Author Paolo Bonzini <bonzini@gnu.org>
43 dnl
44 AC_DEFUN([AC_PROG_CC_FOR_BUILD], [dnl
45 AC_REQUIRE([AC_PROG_CC])dnl
46 AC_REQUIRE([AC_PROG_CPP])dnl
47 AC_REQUIRE([AC_EXEEXT])dnl
48 AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl
49 dnl
50 pushdef([AC_TRY_COMPILER], [
51 cat > conftest.$ac_ext << EOF
52 #line __oline__ "configure"
53 #include "confdefs.h"
54 [$1]
55 EOF
56 # If we can't run a trivial program, we are probably using a cross
57 compiler.
58 # Fail miserably.
59 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./conftest;
60 exit) 2>/dev/null; then
61   [$2]=yes
62 else
63   echo "configure: failed program was:" >&AC_FD_CC
64   cat conftest.$ac_ext >&AC_FD_CC
65   [$2]=no
66 fi
67 [$3]=no
68 rm -fr conftest*])dnl
69
70 dnl Use the standard macros, but make them use other variable names
71 dnl
72 pushdef([cross_compiling], [#])dnl
73 pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
74 pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
75 pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
76 pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
77 pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
78 pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
79 pushdef([ac_cv_objext], ac_cv_build_objext)dnl
80 pushdef([ac_exeext], ac_build_exeext)dnl
81 pushdef([ac_objext], ac_build_objext)dnl
82 pushdef([CC], CC_FOR_BUILD)dnl
83 pushdef([CPP], CPP_FOR_BUILD)dnl
84 pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
85 pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
86 pushdef([host], build)dnl
87 pushdef([host_alias], build_alias)dnl
88 pushdef([host_cpu], build_cpu)dnl
89 pushdef([host_vendor], build_vendor)dnl
90 pushdef([host_os], build_os)dnl
91 pushdef([ac_cv_host], ac_cv_build)dnl
92 pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
93 pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
94 pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
95 pushdef([ac_cv_host_os], ac_cv_build_os)dnl
96 pushdef([ac_cpp], ac_build_cpp)dnl
97 pushdef([ac_compile], ac_build_compile)dnl
98 pushdef([ac_link], ac_build_link)dnl
99
100 dnl Defeat the anti-duplication mechanism
101 dnl
102 dnl undefine([AC_PROVIDE_AC_PROG_CPP])dnl
103 dnl undefine([AC_PROVIDE_AC_PROG_C])dnl
104 dnl undefine([AC_PROVIDE_AC_EXEEXT])dnl
105
106 AC_PROG_CC
107 AC_PROG_CPP
108 AC_EXEEXT
109
110 dnl Restore the old definitions
111 dnl
112 popdef([AC_TRY_COMPILER])dnl
113 popdef([ac_link])dnl
114 popdef([ac_compile])dnl
115 popdef([ac_cpp])dnl
116 popdef([ac_cv_host_os])dnl
117 popdef([ac_cv_host_vendor])dnl
118 popdef([ac_cv_host_cpu])dnl
119 popdef([ac_cv_host_alias])dnl
120 popdef([ac_cv_host])dnl
121 popdef([host_os])dnl
122 popdef([host_vendor])dnl
123 popdef([host_cpu])dnl
124 popdef([host_alias])dnl
125 popdef([host])dnl
126 popdef([CPPFLAGS])dnl
127 popdef([CFLAGS])dnl
128 popdef([CPP])dnl
129 popdef([CC])dnl
130 popdef([ac_objext])dnl
131 popdef([ac_exeext])dnl
132 popdef([ac_cv_objext])dnl
133 popdef([ac_cv_exeext])dnl
134 popdef([ac_cv_prog_cc_g])dnl
135 popdef([ac_cv_prog_cc_works])dnl
136 popdef([ac_cv_prog_cc_cross])dnl
137 popdef([ac_cv_prog_gcc])dnl
138 popdef([ac_cv_prog_CPP])dnl
139 popdef([cross_compiling])dnl
140
141 dnl Finally, set Makefile variables
142 dnl
143 BUILD_EXEEXT=$ac_build_exeext
144 BUILD_OBJEXT=$ac_build_objext
145 AC_SUBST(BUILD_EXEEXT)dnl
146 AC_SUBST(BUILD_OBJEXT)dnl
147 AC_SUBST([CFLAGS_FOR_BUILD])dnl
148 AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
149 ])