1 # tl_CHECK_TOOL_PREFIX will work _BEFORE_ AC_CANONICAL_HOST, etc., has been
2 # called. It should be called again after these have been called.
4 # Basically we want to check if the host alias specified by the user is
5 # different from the build alias. The rules work like this:-
7 # If host is not specified, it defaults to NONOPT
8 # If build is not specified, it defaults to NONOPT
9 # If nonopt is not specified, we guess all other values
11 dnl Replace AC_CHECK_TOOL_PREFIX
12 undefine([AC_CHECK_TOOL_PREFIX])
13 define([AC_CHECK_TOOL_PREFIX], [tl_CHECK_TOOL_PREFIX])
15 AC_DEFUN(tl_CHECK_TOOL_PREFIX,
16 [AC_PROVIDE([AC_CHECK_TOOL_PREFIX])
17 AC_BEFORE([AC_CANONICAL_HOST])
18 AC_BEFORE([AC_CANONICAL_BUILD])
20 if test "$host_alias" = ""; then
21 if test $host = NONE; then
26 if test $thost != $build -a $thost != NONE; then
27 ac_tool_prefix=${thost}-
34 if test $host != $build; then
35 ac_tool_prefix=${host_alias}-
36 ac_tool_dir=${host_alias}
44 dnl replacement for AC_CHECK_TOOL
45 undefine([AC_CHECK_TOOL])
46 define([AC_CHECK_TOOL], [tl_CHECK_TOOL($1, $2, $3, $4)])
48 dnl tl_CHECK_TOOL - AC_CHECK_TOOL, with a couple of extra checks
49 dnl tl_CHECK_TOOL(VARIABLE, PROG-TO-CHECK-FOR[, VALUE-IF-NOT-FOUND [, PATH
51 AC_DEFUN(tl_CHECK_TOOL,
52 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
53 AC_CHECK_PROG($1, ${ac_tool_prefix}$2, ${ac_tool_prefix}$2,
54 ifelse([$3], , [$2], ), $4, $5)
55 if test -z "$ac_cv_prog_$1_dir";then ac_cv_prog_$1_dir=""; fi
56 if test "$ac_tool_dir" != ""; then
57 if test -z "$ac_cv_prog_$1" -a "$5" != "/usr/${ac_tool_dir}/bin/$2" -a \
58 "$5" != "/usr/local/${ac_tool_dir}/bin/$2"; then
59 if test -f /usr/${ac_tool_dir}/bin/$2; then $1="/usr/${ac_tool_dir}/bin/$2"; ac_cv_prog_$1_dir=/usr/${ac_tool_dir}
60 elif test -f /usr/local/${ac_tool_dir}/bin/$2; then $1="/usr/local/${ac_tool_dir}/bin/$2"; ac_cv_prog_$1_dir=/usr/local/${ac_tool_dir}
65 if test -z "$ac_cv_prog_$1"; then
66 if test -n "$ac_tool_prefix"; then
67 AC_CHECK_PROG($1, $2, $2, $3, $4, $5)
75 dnl do a tl_CHECK_TOOL for multiple tools (like AC_CHECK_PROGS)
76 dnl tl_CHECK_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND
78 AC_DEFUN(tl_CHECK_TOOLS,
81 tl_CHECK_TOOL($1, [$]ac_tool, [$]ac_tool, , $4)
82 test -n "[$]$1" && break
84 ifelse([$3], , , [test -n "[$]$1" || $1="$3"
87 dnl replace AC_PROG_CC and AC_PROG_CXX
88 undefine([AC_PROG_CC])
89 define([AC_PROG_CC], [tl_PROG_CC])
90 undefine([AC_PROG_CXX])
91 define([AC_PROG_CXX], [tl_PROG_CXX])
93 dnl tl_PROG_CC, tl_PROG_CXX - same as old AC_PROG_CC and AC_PROG_CXX, but
94 dnl use AC_CHECK_TOOL/tl_CHECK_TOOLS instead of AC_CHECK_PROG, etc.
96 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
97 AC_PROVIDE([AC_PROG_CC])dnl
98 tl_CHECK_TOOL(CC, gcc, gcc)
99 if test -z "$CC"; then
100 AC_CHECK_TOOL(CC, cc, cc, , , /usr/ucb/cc)
101 test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
103 if test -n "$ac_tool_prefix" -a "`echo $CC | grep '$ac_tool_prefix'`" = "" \
104 -a "`echo $CC | grep -- '-b'`" = ""; then
105 if test -z "$ac_cv_prog_CC_dir" && $CC -v 2>&1 | grep -q gcc; then
106 AC_CACHE_CHECK([if $CC -b${ac_tool_dir} works], tl_cv_prog_cc_bhost,[
108 CC="${CC} -b${ac_tool_dir}"
111 AC_TRY_COMPILER([main(){return(0);}], tl_cv_prog_cc_bhost, ac_cv_prog_cc_cross)
113 if test $tl_cv_prog_cc_bhost = "yes"; then
114 ac_cv_prog_cc_works=yes
122 if test "$cctest" != "yes"; then
127 if test $ac_cv_prog_gcc = yes; then
129 dnl Check whether -g works, even if CFLAGS is set, in case the package
130 dnl plays around with CFLAGS (such as to build both debugging and
131 dnl normal versions of a library), tasteless as that idea is.
132 ac_test_CFLAGS="${CFLAGS+set}"
133 ac_save_CFLAGS="$CFLAGS"
136 if test "$ac_test_CFLAGS" = set; then
137 CFLAGS="$ac_save_CFLAGS"
138 elif test $ac_cv_prog_cc_g = yes; then
145 test "${CFLAGS+set}" = set || CFLAGS="-g"
149 AC_DEFUN(tl_PROG_CXX,
150 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
151 AC_PROVIDE([AC_PROG_CXX])dnl
152 tl_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
153 if test -n "$CXX"; then
154 if test -n "$ac_tool_prefix" -a "`echo $CXX | grep '$ac_tool_prefix'`" = "" \
155 -a "`echo $CXX | grep -- '-b'`" = ""; then
156 if test -z "$ac_cv_prog_CXX_dir" && $CXX -v 2>&1 | grep -q gcc; then
157 AC_CACHE_CHECK([if $CXX -b${ac_tool_dir} works], tl_cv_prog_cxx_bhost,[
159 CXX="${CXX} -b${ac_tool_dir}"
162 AC_TRY_COMPILER([main(){return(0);}], tl_cv_prog_cxx_bhost, ac_cv_prog_cxx_cross)
164 if test $tl_cv_prog_cxx_bhost = "yes"; then
165 ac_cv_prog_cxx_works=yes
173 if test "$cxxtest" != "yes"; then
178 if test $ac_cv_prog_gxx = yes; then
180 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
181 dnl plays around with CXXFLAGS (such as to build both debugging and
182 dnl normal versions of a library), tasteless as that idea is.
183 ac_test_CXXFLAGS="${CXXFLAGS+set}"
184 ac_save_CXXFLAGS="$CXXFLAGS"
187 if test "$ac_test_CXXFLAGS" = set; then
188 CXXFLAGS="$ac_save_CXXFLAGS"
189 elif test $ac_cv_prog_cxx_g = yes; then
196 test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
201 AC_DEFUN(tl_PROG_CC_WORKS,
202 [AC_PROVIDE(AC_PROG_CC_WORKS)
203 AC_CACHE_CHECK([whether the C compiler ($CC $CFLAGS $LDFLAGS) works],
204 ac_cv_prog_cc_works, [
207 AC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross)
209 if test $ac_cv_prog_cc_works = no; then
210 AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.])
212 AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler])
213 AC_MSG_RESULT($ac_cv_prog_cc_cross)
214 cross_compiling=$ac_cv_prog_cc_cross
217 AC_DEFUN(tl_PROG_CXX_WORKS,
218 [AC_PROVIDE(AC_PROG_CXX_WORKS)
219 AC_CACHE_CHECK([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works],
220 ac_cv_prog_cxx_works, [
223 AC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
225 if test $ac_cv_prog_cxx_works = no; then
226 AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.])
228 AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
229 AC_MSG_RESULT($ac_cv_prog_cxx_cross)
230 cross_compiling=$ac_cv_prog_cxx_cross