]> git.saurik.com Git - apple/icu.git/blame - icuSources/aclocal.m4
ICU-8.11.1.tar.gz
[apple/icu.git] / icuSources / aclocal.m4
CommitLineData
b75a7d8f 1dnl aclocal.m4 for ICU
73c04bcf 2dnl Copyright (c) 1999-2006, International Business Machines Corporation and
b75a7d8f
A
3dnl others. All Rights Reserved.
4dnl Stephen F. Booth
5
6dnl @TOP@
7
8dnl ICU_CHECK_MH_FRAG
9AC_DEFUN(ICU_CHECK_MH_FRAG, [
10 AC_CACHE_CHECK(
11 [which Makefile fragment to use],
12 [icu_cv_host_frag],
13 [
14case "${host}" in
15*-*-solaris*)
374ca955 16 if test "$GCC" = yes; then
b75a7d8f
A
17 icu_cv_host_frag=mh-solaris-gcc
18 else
19 icu_cv_host_frag=mh-solaris
20 fi ;;
21alpha*-*-linux-gnu)
374ca955 22 if test "$GCC" = yes; then
b75a7d8f
A
23 icu_cv_host_frag=mh-alpha-linux-gcc
24 else
25 icu_cv_host_frag=mh-alpha-linux-cc
26 fi ;;
374ca955
A
27powerpc*-*-linux*)
28 if test "$GCC" = yes; then
29 icu_cv_host_frag=mh-linux
30 else
31 icu_cv_host_frag=mh-linux-va
32 fi ;;
b75a7d8f
A
33*-*-linux*) icu_cv_host_frag=mh-linux ;;
34*-*-cygwin)
374ca955 35 if test "$GCC" = yes; then
b75a7d8f
A
36 icu_cv_host_frag=mh-cygwin
37 else
38 icu_cv_host_frag=mh-cygwin-msvc
39 fi ;;
374ca955
A
40*-*-mingw32)
41 if test "$GCC" = yes; then
42 icu_cv_host_frag=mh-mingw
43 else
44 icu_cv_host_frag=mh-cygwin-msvc
45 fi ;;
73c04bcf 46*-*-*bsd*|*-*-dragonfly*) icu_cv_host_frag=mh-bsd-gcc ;;
b75a7d8f 47*-*-aix*)
374ca955
A
48 if test "$GCC" = yes; then
49 icu_cv_host_frag=mh-aix-gcc
b75a7d8f 50 else
374ca955
A
51 if test -n "`$CXX --help 2>&1 | grep 'IBM C and C++ Compilers$'`"; then
52 icu_cv_host_frag=mh-aix
53 else
54 icu_cv_host_frag=mh-aix-va
55 fi
b75a7d8f
A
56 fi ;;
57*-*-hpux*)
374ca955 58 if test "$GCC" = yes; then
b75a7d8f
A
59 icu_cv_host_frag=mh-hpux-gcc
60 else
61 case "$CXX" in
62 *aCC) icu_cv_host_frag=mh-hpux-acc ;;
63 *CC) icu_cv_host_frag=mh-hpux-cc ;;
64 esac
65 fi ;;
66*-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
67*-*-os400*) icu_cv_host_frag=mh-os400 ;;
68*-apple-rhapsody*) icu_cv_host_frag=mh-darwin ;;
69*-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
374ca955 70*-*-beos) icu_cv_host_frag=mh-beos ;;
b75a7d8f
A
71*-*-irix*) icu_cv_host_frag=mh-irix ;;
72*-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
73*-*-nto*) icu_cv_host_frag=mh-qnx ;;
374ca955 74*-ncr-*) icu_cv_host_frag=mh-mpras ;;
b75a7d8f
A
75*) icu_cv_host_frag=mh-unknown ;;
76esac
77 ]
78 )
79])
80
374ca955 81dnl ICU_CONDITIONAL - similar example taken from Automake 1.4
b75a7d8f
A
82AC_DEFUN(ICU_CONDITIONAL,
83[AC_SUBST($1_TRUE)
b75a7d8f
A
84if $2; then
85 $1_TRUE=
b75a7d8f
A
86else
87 $1_TRUE='#'
b75a7d8f
A
88fi])
89
73c04bcf
A
90dnl ICU_PROG_LINK - Make sure that the linker is usable
91AC_DEFUN(ICU_PROG_LINK,
92[
93case "${host}" in
94 *-*-cygwin*|*-*-mingw*)
95 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
96 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
97 Please follow the directions in ICU's readme.])
98 fi;;
99 *);;
100esac])
101
b75a7d8f
A
102dnl AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
103dnl [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
104dnl Search for a library defining FUNC, then see if it's not already available.
105
106AC_DEFUN(AC_SEARCH_LIBS_FIRST,
107[AC_PREREQ([2.13])
108AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
109[ac_func_search_save_LIBS="$LIBS"
110ac_cv_search_$1="no"
111for i in $2; do
112LIBS="-l$i $5 $ac_func_search_save_LIBS"
113AC_TRY_LINK_FUNC([$1],
114[ac_cv_search_$1="-l$i"
115break])
116done
117if test "$ac_cv_search_$1" = "no"; then
118AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
119fi
120LIBS="$ac_func_search_save_LIBS"])
121if test "$ac_cv_search_$1" != "no"; then
122 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
123 $3
124else :
125 $4
126fi])
127
128dnl Check if we can build and use 64-bit libraries
129AC_DEFUN(AC_CHECK_64BIT_LIBS,
130[
131 AC_ARG_ENABLE(64bit-libs,
132 [ --enable-64bit-libs build 64-bit libraries [default=yes]],
133 [ENABLE_64BIT_LIBS=${enableval}],
134 [ENABLE_64BIT_LIBS=yes]
135 )
136 dnl These results can't be cached because is sets compiler flags.
137 AC_MSG_CHECKING([for 64-bit executable support])
374ca955 138 if test "$ENABLE_64BIT_LIBS" != no; then
b75a7d8f
A
139 case "${host}" in
140 *-*-solaris*)
374ca955
A
141 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
142 if test "$GCC" = yes; then
143 # We could add a check for -m64 depending on the gcc version.
144 ENABLE_64BIT_LIBS=no
145 else
b75a7d8f 146 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
b75a7d8f
A
147 if test -z "$SOL64" && test -n "$SPARCV9"; then
148 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
149 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
150 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
151 ENABLE_64BIT_LIBS=yes
152 else
153 ENABLE_64BIT_LIBS=no
154 fi
374ca955
A
155 fi
156 ;;
157 ia64-*-linux*)
158 if test "$GCC" = yes; then
159 # gcc compiler support
160 if test -n "`$CXX -dumpspecs 2>&1 && $CC -dumpspecs 2>&1 | grep -v __LP64__`"; then
161 ENABLE_64BIT_LIBS=yes
162 else
163 ENABLE_64BIT_LIBS=no
164 fi
b75a7d8f 165 else
374ca955
A
166 # check for ecc/ecpc compiler support
167 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
168 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
169 ENABLE_64BIT_LIBS=yes
170 else
171 ENABLE_64BIT_LIBS=no
172 fi
173 else
174 # unknown
175 ENABLE_64BIT_LIBS=no
176 fi
b75a7d8f
A
177 fi
178 ;;
374ca955
A
179 x86_64-*-linux*)
180 if test "$GCC" = yes; then
181 if test -n "`$CXX -dumpspecs 2>&1 && $CC -dumpspecs 2>&1 | grep -v __LP64__`"; then
182 ENABLE_64BIT_LIBS=yes
183 else
184 ENABLE_64BIT_LIBS=no
185 fi
b75a7d8f 186 else
374ca955
A
187 # unknown
188 ENABLE_64BIT_LIBS=no
189 fi
190 ;;
73c04bcf
A
191 x86_64-*-cygwin)
192 if test "$GCC" = yes; then
193 if test -n "`$CXX -dumpspecs 2>&1 && $CC -dumpspecs 2>&1 | grep -v __LP64__`"; then
194 ENABLE_64BIT_LIBS=yes
195 else
196 ENABLE_64BIT_LIBS=no
197 fi
198 else
199 ENABLE_64BIT_LIBS=no
200 OLD_CPPFLAGS="${CPPFLAGS}"
201 OLD_LDFLAGS="${LDFLAGS}"
202 CPPFLAGS="${CPPFLAGS} /DWIN64"
203 LDFLAGS="${LDFLAGS} /MACHINE:AMD64"
204 AC_TRY_RUN(int main(void) {return 0;},
205 ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
206 if test "$ENABLE_64BIT_LIBS" = no; then
207 CPPFLAGS="${OLD_CPPFLAGS}"
208 LDFLAGS="${OLD_LDFLAGS}"
209 fi
210 fi
211 ;;
374ca955
A
212 *-*-aix*|powerpc64-*-linux*)
213 if test "$ac_cv_prog_gcc" = no; then
214 # Note: Have not tested 64-bitness with gcc.
215 # Maybe the flag "-maix64" could be used with gcc?
216 OLD_CFLAGS="${CFLAGS}"
217 OLD_CXXFLAGS="${CXXFLAGS}"
218 OLD_LDFLAGS="${LDFLAGS}"
219 CFLAGS="${CFLAGS} -q64"
220 CXXFLAGS="${CXXFLAGS} -q64"
221 LDFLAGS="${LDFLAGS} -q64"
222 AC_TRY_RUN(int main(void) {return 0;},
223 ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
224 if test "$ENABLE_64BIT_LIBS" = no; then
225 CFLAGS="${OLD_CFLAGS}"
226 CXXFLAGS="${OLD_CXXFLAGS}"
227 LDFLAGS="${OLD_LDFLAGS}"
228 else
229 case "${host}" in
230 *-*-aix*)
231 ARFLAGS="${ARFLAGS} -X64"
232 esac
233 fi
b75a7d8f
A
234 fi
235 ;;
236 *-*-hpux*)
374ca955
A
237 dnl First we try the newer +DD64, if that doesn't work,
238 dnl try other options.
239
b75a7d8f
A
240 OLD_CFLAGS="${CFLAGS}"
241 OLD_CXXFLAGS="${CXXFLAGS}"
374ca955
A
242 CFLAGS="${CFLAGS} +DD64"
243 CXXFLAGS="${CXXFLAGS} +DD64"
b75a7d8f
A
244 AC_TRY_RUN(int main(void) {return 0;},
245 ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
246 if test "$ENABLE_64BIT_LIBS" = no; then
247 CFLAGS="${OLD_CFLAGS}"
248 CXXFLAGS="${OLD_CXXFLAGS}"
374ca955
A
249 CFLAGS="${CFLAGS} +DA2.0W"
250 CXXFLAGS="${CXXFLAGS} +DA2.0W"
251 AC_TRY_RUN(int main(void) {return 0;},
252 ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
253 if test "$ENABLE_64BIT_LIBS" = no; then
254 CFLAGS="${OLD_CFLAGS}"
255 CXXFLAGS="${OLD_CXXFLAGS}"
256 fi
b75a7d8f
A
257 fi
258 ;;
73c04bcf
A
259 *-*ibm-openedition*|*-*-os390*)
260 OLD_CFLAGS="${CFLAGS}"
261 OLD_CXXFLAGS="${CXXFLAGS}"
262 OLD_LDFLAGS="${LDFLAGS}"
263 CFLAGS="${CFLAGS} -Wc,lp64"
264 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
265 LDFLAGS="${LDFLAGS} -Wl,lp64"
266 AC_TRY_RUN(int main(void) {return 0;},
267 ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
268 if test "$ENABLE_64BIT_LIBS" = no; then
269 CFLAGS="${OLD_CFLAGS}"
270 CXXFLAGS="${OLD_CXXFLAGS}"
271 LDFLAGS="${OLD_LDFLAGS}"
272 fi
273 ;;
b75a7d8f
A
274 *)
275 ENABLE_64BIT_LIBS=no
276 ;;
277 esac
73c04bcf
A
278 else
279 if test "$GCC" = yes; then
280 OLD_CFLAGS="${CFLAGS}"
281 OLD_CXXFLAGS="${CXXFLAGS}"
282 CFLAGS="${CFLAGS} -m32"
283 CXXFLAGS="${CXXFLAGS} -m32"
284 AC_TRY_RUN(int main(void) {return 0;},
285 ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=yes)
286 if test "$ENABLE_64BIT_LIBS" = yes; then
287 CFLAGS="${OLD_CFLAGS}"
288 CXXFLAGS="${OLD_CXXFLAGS}"
289 fi
290 fi
b75a7d8f
A
291 fi
292 dnl Individual tests that fail should reset their own flags.
293 AC_MSG_RESULT($ENABLE_64BIT_LIBS)
294])
295
296dnl Strict compilation options.
297AC_DEFUN(AC_CHECK_STRICT_COMPILE,
298[
299 AC_MSG_CHECKING([whether strict compiling is on])
300 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=no]], [
374ca955
A
301 if test "$enableval" = no
302 then
303 ac_use_strict_options=no
b75a7d8f 304 else
374ca955 305 ac_use_strict_options=yes
b75a7d8f
A
306 fi
307 ], [ac_use_strict_options=no])
308 AC_MSG_RESULT($ac_use_strict_options)
309
310 if test "$ac_use_strict_options" = yes
311 then
312 if test "$GCC" = yes
313 then
73c04bcf 314 CFLAGS="$CFLAGS -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long"
b75a7d8f
A
315 case "${host}" in
316 *-*-solaris*)
317 CFLAGS="$CFLAGS -D__STDC__=0";;
318 esac
374ca955
A
319 else
320 case "${host}" in
321 *-*-cygwin)
322 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
323 then
324 CFLAGS="$CFLAGS /W4"
325 fi
326 esac
b75a7d8f
A
327 fi
328 if test "$GXX" = yes
329 then
73c04bcf 330 CXXFLAGS="$CXXFLAGS -W -Wall -ansi -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
b75a7d8f
A
331 case "${host}" in
332 *-*-solaris*)
333 CXXFLAGS="$CXXFLAGS -D__STDC__=0";;
334 esac
374ca955
A
335 else
336 case "${host}" in
337 *-*-cygwin)
338 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
339 then
340 CXXFLAGS="$CXXFLAGS /W4"
341 fi
342 esac
b75a7d8f
A
343 fi
344 fi
345])
346
347dnl Define a sizeof checking macro that is a bit better than autoconf's
348dnl builtin (and heavily based on it, of course). The new macro is
349dnl AC_DO_CHECK_SIZEOF(TYPE [, CROSS_SIZE [, INCLUDES])
350AC_DEFUN(AC_DO_CHECK_SIZEOF,
351[changequote(<<, >>)dnl
352dnl The name to #define.
353define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
354dnl The cache variable name.
355define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
356changequote([, ])dnl
357AC_MSG_CHECKING(size of $1)
358AC_CACHE_VAL(AC_CV_NAME,
359[AC_TRY_RUN($3
360[#include <stdio.h>
361main()
362{
363 FILE *f=fopen("conftestval", "w");
364 if (!f) exit(1);
365 fprintf(f, "%d\n", sizeof($1));
366 exit(0);
367}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
368AC_MSG_RESULT($AC_CV_NAME)
369AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
370undefine([AC_TYPE_NAME])dnl
371undefine([AC_CV_NAME])dnl
372])
374ca955 373