1#							-*- Autoconf -*-
2# This file is part of the aMule Project.
3#
4# Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5#
6# Any parts of this program derived from the xMule, lMule or eMule project,
7# or contributed by third-party developers are copyrighted by their
8# respective authors.
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
23#
24#
25# This package has been tested with GNU Autoconf 2.59, and not guaranteed to
26# work with any other version. However, you only need to worry about it if
27# you're cross-compiling.
28
29# _AC_CHECK_BUILD_PREFIX
30# -----------------------
31# Checks and sets the build prefix, if it is given by --build.
32AC_DEFUN([_AC_CHECK_BUILD_PREFIX],
33[ac_build_prefix=
34test -n "$build_alias" && ac_build_prefix=$build_alias-
35]) # AC_CHECK_BUILD_PREFIX
36
37
38# AC_PROG_BUILD_CC([COMPILER ...])
39# --------------------------
40# COMPILER ... is a space separated list of C compilers to search for.
41# This just gives the user an opportunity to specify an alternative
42# search list for the C compiler.
43#
44# IMPORTANT: Run all other compiler tests *before* calling this macro!
45#
46# This is a stripped-down check, it checks only what we need,
47# i.e. BUILD_CC and BUILD_EXEEXT
48#
49AC_DEFUN([AC_PROG_BUILD_CC],
50[AC_REQUIRE([_AC_CHECK_BUILD_PREFIX])dnl
51dnl Set new names of important variables.
52pushdef([ac_tool_prefix], [ac_build_prefix])dnl
53pushdef([CC], [BUILD_CC])dnl
54pushdef([EXEEXT], [BUILD_EXEEXT])dnl
55pushdef([ac_cv_exeext], [ac_cv_build_exeext])dnl
56pushdef([ac_exeext], [ac_build_exeext])dnl
57dnl Don't use the values for the cross-compiler
58pushdef([CPPFLAGS], [BUILD_CPPFLAGS])dnl
59pushdef([CFLAGS], [BUILD_CFLAGS])dnl
60pushdef([LDFLAGS], [BUILD_LDFLAGS])dnl
61pushdef([LIBS], [BUILD_LIBS])dnl
62
63# Even if we're cross-compiling, we want a compiler here
64# that is not a cross-compiler.
65saved_cross=$cross_compiling
66cross_compiling=no
67
68dnl From now on, this is just a mere copy of Autoconf's AC_PROG_CC macro.
69AC_LANG_PUSH(C)dnl
70m4_ifval([$1],
71      [AC_CHECK_TOOLS(CC, [$1])],
72[AC_CHECK_TOOL(CC, gcc)
73if test -z "$CC"; then
74  AC_CHECK_TOOL(CC, cc)
75fi
76if test -z "$CC"; then
77  AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
78fi
79if test -z "$CC"; then
80  AC_CHECK_TOOLS(CC, cl)
81fi
82])
83
84test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
85
86# Provide some information about the compiler.
87echo "$as_me:$LINENO:" \
88     "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
89ac_compiler=`set X $ac_compile; echo $[2]`
90_AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
91_AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
92_AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
93
94dnl Forcibly include _AC_COMPILER_EXEEXT, to determine the build exeext.
95_AC_COMPILER_EXEEXT
96dnl End of copy, here some parts are stripped out. We only want a working C
97dnl compiler, and doesn't need the objext, the preprocessor, the dependency
98dnl style, whether it's gnu or not, etc.
99
100# Restore configuration environment
101cross_compiling=$saved_cross
102
103dnl Restore variable names.
104popdef([LIBS])dnl
105popdef([LDFLAGS])dnl
106popdef([CFLAGS])dnl
107popdef([CPPFLAGS])dnl
108popdef([ac_exeext])dnl
109popdef([ac_cv_exeext])dnl
110popdef([EXEEXT])dnl
111popdef([CC])dnl
112popdef([ac_tool_prefix])dnl
113dnl
114dnl AC_LANG_POP(C) must be called after the variable names are restored, thus
115dnl it will restore the correct (host) environment, not the build environment.
116AC_LANG_POP(C)dnl
117dnl Substitute variables for the build compiler
118AC_SUBST(BUILD_EXEEXT)dnl
119AC_SUBST(BUILD_CPPFLAGS)dnl
120AC_SUBST(BUILD_CFLAGS)dnl
121AC_SUBST(BUILD_LDFLAGS)dnl
122]) # AC_PROG_BUILD_CC
123