]>
Commit | Line | Data |
---|---|---|
d7bccc73 AL |
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. | |
3 | # | |
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:- | |
6 | # | |
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 | |
10 | ||
11 | dnl Replace AC_CHECK_TOOL_PREFIX | |
12 | undefine([AC_CHECK_TOOL_PREFIX]) | |
13 | define([AC_CHECK_TOOL_PREFIX], [tl_CHECK_TOOL_PREFIX]) | |
14 | ||
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]) | |
19 | dnl Quick check | |
20 | if test "$host_alias" = ""; then | |
21 | if test $host = NONE; then | |
22 | thost=$nonopt | |
23 | else | |
24 | thost=$host | |
25 | fi | |
26 | if test $thost != $build -a $thost != NONE; then | |
27 | ac_tool_prefix=${thost}- | |
28 | ac_tool_dir=${thost} | |
29 | else | |
30 | ac_tool_prefix= | |
31 | ac_tool_dir= | |
32 | fi | |
33 | else | |
34 | if test $host != $build; then | |
35 | ac_tool_prefix=${host_alias}- | |
36 | ac_tool_dir=${host_alias} | |
37 | else | |
38 | ac_tool_prefix= | |
39 | ac_tool_dir= | |
40 | fi | |
41 | fi | |
42 | ]) | |
43 | ||
44 | dnl replacement for AC_CHECK_TOOL | |
45 | undefine([AC_CHECK_TOOL]) | |
46 | define([AC_CHECK_TOOL], [tl_CHECK_TOOL($1, $2, $3, $4)]) | |
47 | ||
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 | |
50 | dnl [, REJECT]]) | |
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} | |
61 | fi | |
62 | fi | |
63 | fi | |
64 | ifelse([$3], , , [ | |
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) | |
68 | else | |
69 | $1="$3" | |
70 | fi | |
71 | fi]) | |
72 | ]) | |
73 | ||
74 | dnl tl_CHECK_TOOLS - | |
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 | |
77 | dnl [, PATH]]) | |
78 | AC_DEFUN(tl_CHECK_TOOLS, | |
79 | [for ac_tool in $2 | |
80 | do | |
81 | tl_CHECK_TOOL($1, [$]ac_tool, [$]ac_tool, , $4) | |
82 | test -n "[$]$1" && break | |
83 | done | |
84 | ifelse([$3], , , [test -n "[$]$1" || $1="$3" | |
85 | ])]) | |
86 | ||
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]) | |
92 | ||
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. | |
95 | AC_DEFUN(tl_PROG_CC, | |
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]) | |
102 | fi | |
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,[ | |
107 | old_cc="${CC}" | |
108 | CC="${CC} -b${ac_tool_dir}" | |
109 | AC_LANG_SAVE | |
110 | AC_LANG_C | |
111 | AC_TRY_COMPILER([main(){return(0);}], tl_cv_prog_cc_bhost, ac_cv_prog_cc_cross) | |
112 | AC_LANG_RESTORE]) | |
113 | if test $tl_cv_prog_cc_bhost = "yes"; then | |
114 | ac_cv_prog_cc_works=yes | |
115 | cctest=yes | |
116 | else | |
117 | CC="${old_cc}" | |
118 | fi | |
119 | fi | |
120 | fi | |
121 | ||
122 | if test "$cctest" != "yes"; then | |
123 | tl_PROG_CC_WORKS | |
124 | fi | |
125 | AC_PROG_CC_GNU | |
126 | ||
127 | if test $ac_cv_prog_gcc = yes; then | |
128 | GCC=yes | |
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" | |
134 | CFLAGS= | |
135 | AC_PROG_CC_G | |
136 | if test "$ac_test_CFLAGS" = set; then | |
137 | CFLAGS="$ac_save_CFLAGS" | |
138 | elif test $ac_cv_prog_cc_g = yes; then | |
139 | CFLAGS="-g -O2" | |
140 | else | |
141 | CFLAGS="-O2" | |
142 | fi | |
143 | else | |
144 | GCC= | |
145 | test "${CFLAGS+set}" = set || CFLAGS="-g" | |
146 | fi | |
147 | ]) | |
148 | ||
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,[ | |
158 | old_cxx="${CXX}" | |
159 | CXX="${CXX} -b${ac_tool_dir}" | |
160 | AC_LANG_SAVE | |
161 | AC_LANG_CPLUSPLUS | |
162 | AC_TRY_COMPILER([main(){return(0);}], tl_cv_prog_cxx_bhost, ac_cv_prog_cxx_cross) | |
163 | AC_LANG_RESTORE]) | |
164 | if test $tl_cv_prog_cxx_bhost = "yes"; then | |
165 | ac_cv_prog_cxx_works=yes | |
166 | cxxtest=yes | |
167 | else | |
168 | CXX="${old_cxx}" | |
169 | fi | |
170 | fi | |
171 | fi | |
172 | ||
173 | if test "$cxxtest" != "yes"; then | |
174 | tl_PROG_CXX_WORKS | |
175 | fi | |
176 | AC_PROG_CXX_GNU | |
177 | ||
178 | if test $ac_cv_prog_gxx = yes; then | |
179 | GXX=yes | |
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" | |
185 | CXXFLAGS= | |
186 | AC_PROG_CXX_G | |
187 | if test "$ac_test_CXXFLAGS" = set; then | |
188 | CXXFLAGS="$ac_save_CXXFLAGS" | |
189 | elif test $ac_cv_prog_cxx_g = yes; then | |
190 | CXXFLAGS="-g -O2" | |
191 | else | |
192 | CXXFLAGS="-O2" | |
193 | fi | |
194 | else | |
195 | GXX= | |
196 | test "${CXXFLAGS+set}" = set || CXXFLAGS="-g" | |
197 | fi | |
198 | fi | |
199 | ]) | |
200 | ||
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, [ | |
205 | AC_LANG_SAVE | |
206 | AC_LANG_C | |
207 | AC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) | |
208 | AC_LANG_RESTORE | |
209 | if test $ac_cv_prog_cc_works = no; then | |
210 | AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.]) | |
211 | fi]) | |
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 | |
215 | ]) | |
216 | ||
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, [ | |
221 | AC_LANG_SAVE | |
222 | AC_LANG_CPLUSPLUS | |
223 | AC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) | |
224 | AC_LANG_RESTORE | |
225 | if test $ac_cv_prog_cxx_works = no; then | |
226 | AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.]) | |
227 | fi]) | |
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 | |
231 | ]) |