2 dnl Copyright (c) 1999-2006, International Business Machines Corporation and
3 dnl others. All Rights Reserved.
9 AC_DEFUN(ICU_CHECK_MH_FRAG, [
11 [which Makefile fragment to use],
16 if test "$GCC" = yes; then
17 icu_cv_host_frag=mh-solaris-gcc
19 icu_cv_host_frag=mh-solaris
22 if test "$GCC" = yes; then
23 icu_cv_host_frag=mh-alpha-linux-gcc
25 icu_cv_host_frag=mh-alpha-linux-cc
28 if test "$GCC" = yes; then
29 icu_cv_host_frag=mh-linux
31 icu_cv_host_frag=mh-linux-va
33 *-*-linux*) icu_cv_host_frag=mh-linux ;;
35 if test "$GCC" = yes; then
36 icu_cv_host_frag=mh-cygwin
38 icu_cv_host_frag=mh-cygwin-msvc
41 if test "$GCC" = yes; then
42 icu_cv_host_frag=mh-mingw
44 icu_cv_host_frag=mh-cygwin-msvc
46 *-*-*bsd*|*-*-dragonfly*) icu_cv_host_frag=mh-bsd-gcc ;;
48 if test "$GCC" = yes; then
49 icu_cv_host_frag=mh-aix-gcc
51 if test -n "`$CXX --help 2>&1 | grep 'IBM C and C++ Compilers$'`"; then
52 icu_cv_host_frag=mh-aix
54 icu_cv_host_frag=mh-aix-va
58 if test "$GCC" = yes; then
59 icu_cv_host_frag=mh-hpux-gcc
62 *aCC) icu_cv_host_frag=mh-hpux-acc ;;
63 *CC) icu_cv_host_frag=mh-hpux-cc ;;
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 ;;
70 *-*-beos) icu_cv_host_frag=mh-beos ;;
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 ;;
74 *-ncr-*) icu_cv_host_frag=mh-mpras ;;
75 *) icu_cv_host_frag=mh-unknown ;;
81 dnl ICU_CONDITIONAL - similar example taken from Automake 1.4
82 AC_DEFUN(ICU_CONDITIONAL,
90 dnl ICU_PROG_LINK - Make sure that the linker is usable
91 AC_DEFUN(ICU_PROG_LINK,
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.])
102 dnl AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
103 dnl [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
104 dnl Search for a library defining FUNC, then see if it's not already available.
106 AC_DEFUN(AC_SEARCH_LIBS_FIRST,
108 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
109 [ac_func_search_save_LIBS="$LIBS"
112 LIBS="-l$i $5 $ac_func_search_save_LIBS"
113 AC_TRY_LINK_FUNC([$1],
114 [ac_cv_search_$1="-l$i"
117 if test "$ac_cv_search_$1" = "no"; then
118 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
120 LIBS="$ac_func_search_save_LIBS"])
121 if test "$ac_cv_search_$1" != "no"; then
122 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
128 dnl Check if we can build and use 64-bit libraries
129 AC_DEFUN(AC_CHECK_64BIT_LIBS,
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]
136 dnl These results can't be cached because is sets compiler flags.
137 AC_MSG_CHECKING([for 64-bit executable support])
138 if test "$ENABLE_64BIT_LIBS" != no; then
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.
146 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
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
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
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
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
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
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}"
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}"
231 ARFLAGS="${ARFLAGS} -X64"
237 dnl First we try the newer +DD64, if that doesn't work,
238 dnl try other options.
240 OLD_CFLAGS="${CFLAGS}"
241 OLD_CXXFLAGS="${CXXFLAGS}"
242 CFLAGS="${CFLAGS} +DD64"
243 CXXFLAGS="${CXXFLAGS} +DD64"
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}"
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}"
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}"
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}"
292 dnl Individual tests that fail should reset their own flags.
293 AC_MSG_RESULT($ENABLE_64BIT_LIBS)
296 dnl Strict compilation options.
297 AC_DEFUN(AC_CHECK_STRICT_COMPILE,
299 AC_MSG_CHECKING([whether strict compiling is on])
300 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=no]], [
301 if test "$enableval" = no
303 ac_use_strict_options=no
305 ac_use_strict_options=yes
307 ], [ac_use_strict_options=no])
308 AC_MSG_RESULT($ac_use_strict_options)
310 if test "$ac_use_strict_options" = yes
314 CFLAGS="$CFLAGS -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long"
317 CFLAGS="$CFLAGS -D__STDC__=0";;
322 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
330 CXXFLAGS="$CXXFLAGS -W -Wall -ansi -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
333 CXXFLAGS="$CXXFLAGS -D__STDC__=0";;
338 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
340 CXXFLAGS="$CXXFLAGS /W4"
347 dnl Define a sizeof checking macro that is a bit better than autoconf's
348 dnl builtin (and heavily based on it, of course). The new macro is
349 dnl AC_DO_CHECK_SIZEOF(TYPE [, CROSS_SIZE [, INCLUDES])
350 AC_DEFUN(AC_DO_CHECK_SIZEOF,
351 [changequote(<<, >>)dnl
352 dnl The name to #define.
353 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
354 dnl The cache variable name.
355 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
357 AC_MSG_CHECKING(size of $1)
358 AC_CACHE_VAL(AC_CV_NAME,
363 FILE *f=fopen("conftestval", "w");
365 fprintf(f, "%d\n", sizeof($1));
367 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
368 AC_MSG_RESULT($AC_CV_NAME)
369 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
370 undefine([AC_TYPE_NAME])dnl
371 undefine([AC_CV_NAME])dnl