2 # Copyright (c) 1999-2011, International Business Machines Corporation and
3 # others. All Rights Reserved.
9 AC_DEFUN(ICU_CHECK_MH_FRAG, [
11 [which Makefile fragment to use for ${host}],
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*|*-*-gnu|*-*-k*bsd*-gnu|*-*-kopensolaris*-gnu) icu_cv_host_frag=mh-linux ;;
34 *-*-cygwin|*-*-mingw32)
35 if test "$GCC" = yes; then
38 #error This is not MinGW
39 #endif], [], icu_cv_host_frag=mh-mingw, icu_cv_host_frag=mh-cygwin)
41 icu_cv_host_frag=mh-cygwin-msvc
43 *-*-*bsd*|*-*-dragonfly*) icu_cv_host_frag=mh-bsd-gcc ;;
45 if test "$GCC" = yes; then
46 icu_cv_host_frag=mh-aix-gcc
48 icu_cv_host_frag=mh-aix-va
51 if test "$GCC" = yes; then
52 icu_cv_host_frag=mh-hpux-gcc
55 *aCC) icu_cv_host_frag=mh-hpux-acc ;;
58 *-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
59 *-*-os400*) icu_cv_host_frag=mh-os400 ;;
60 *-apple-rhapsody*) icu_cv_host_frag=mh-darwin ;;
61 *-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
62 *-*-beos) icu_cv_host_frag=mh-beos ;;
63 *-*-haiku) icu_cv_host_frag=mh-haiku ;;
64 *-*-irix*) icu_cv_host_frag=mh-irix ;;
65 *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
66 *-*-nto*) icu_cv_host_frag=mh-qnx ;;
67 *-ncr-*) icu_cv_host_frag=mh-mpras ;;
68 *) icu_cv_host_frag=mh-unknown ;;
74 # ICU_CONDITIONAL - similar example taken from Automake 1.4
75 AC_DEFUN(ICU_CONDITIONAL,
83 # ICU_PROG_LINK - Make sure that the linker is usable
84 AC_DEFUN(ICU_PROG_LINK,
87 *-*-cygwin*|*-*-mingw*)
88 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
89 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
90 Please follow the directions in ICU's readme.])
95 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
96 # [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
97 # Search for a library defining FUNC, then see if it's not already available.
99 AC_DEFUN(AC_SEARCH_LIBS_FIRST,
101 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
102 [ac_func_search_save_LIBS="$LIBS"
105 LIBS="-l$i $5 $ac_func_search_save_LIBS"
106 AC_TRY_LINK_FUNC([$1],
107 [ac_cv_search_$1="-l$i"
110 if test "$ac_cv_search_$1" = "no"; then
111 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
113 LIBS="$ac_func_search_save_LIBS"])
114 if test "$ac_cv_search_$1" != "no"; then
115 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
123 # Check if we can build and use 64-bit libraries
124 AC_DEFUN(AC_CHECK_64BIT_LIBS,
127 ENABLE_64BIT_LIBS=unknown
128 ## revisit this for cross-compile.
130 AC_ARG_ENABLE(64bit-libs,
131 [ --enable-64bit-libs (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
132 [echo "note, use --with-library-bits instead of --*-64bit-libs"
133 case "${enableval}" in
134 no|false|32) with_library_bits=32; ;;
135 yes|true|64) with_library_bits=64else32 ;;
136 nochange) with_library_bits=nochange; ;;
137 *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
141 AC_ARG_WITH(library-bits,
142 [ --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
143 [case "${withval}" in
144 ""|nochange) BITS_REQ=$withval ;;
145 32|64|64else32) BITS_REQ=$withval ;;
146 *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
149 # don't use these for cross compiling
150 if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
151 AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
153 AC_CHECK_SIZEOF([void *])
154 AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
155 case $ac_cv_sizeof_void_p in
156 8) DEFAULT_64BIT=yes ;;
157 4) DEFAULT_64BIT=no ;;
158 *) DEFAULT_64BIT=unknown
162 # 'OK' here means, we can exit any further checking, everything's copa
165 # do we need to check for buildable/runnable 32 or 64 bit?
169 # later, can we run the 32/64 bit binaries so made?
173 if test "$DEFAULT_64BIT" = "yes"; then
174 # we get 64 bits by default.
178 # need to look for 32 bit support.
182 # everyone else is happy.
186 elif test "$DEFAULT_64BIT" = "no"; then
187 # not 64 bit by default.
197 elif test "$DEFAULT_64BIT" = "unknown"; then
201 64|64else32) BITS_OK=no
210 AC_MSG_RESULT($DEFAULT_64BIT);
212 if test "$BITS_OK" != "yes"; then
213 # not copa. back these up.
214 CFLAGS_OLD="${CFLAGS}"
215 CXXFLAGS_OLD="${CXXFLAGS}"
216 LDFLAGS_OLD="${LDFLAGS}"
217 ARFLAGS_OLD="${ARFLAGS}"
219 CFLAGS_32="${CFLAGS}"
220 CXXFLAGS_32="${CXXFLAGS}"
221 LDFLAGS_32="${LDFLAGS}"
222 ARFLAGS_32="${ARFLAGS}"
224 CFLAGS_64="${CFLAGS}"
225 CXXFLAGS_64="${CXXFLAGS}"
226 LDFLAGS_64="${LDFLAGS}"
227 ARFLAGS_64="${ARFLAGS}"
231 # These results can't be cached because is sets compiler flags.
232 if test "$BITS_CHECK_64" = "yes"; then
233 AC_MSG_CHECKING([how to build 64-bit executables])
236 # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
237 # Note, we don't have to actually check if the options work- we'll try them before using them.
238 # So, only try actually testing the options, if you are trying to decide between multiple options.
239 # On exit from the following clauses:
240 # if CAN_BUILD_64=yes:
241 # *FLAGS are assumed to contain the right settings for 64bit
242 # else if CAN_BUILD_64=no: (default)
243 # *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
245 if test "$GCC" = yes; then
246 CFLAGS="${CFLAGS} -m64"
247 CXXFLAGS="${CXXFLAGS} -m64"
248 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
249 CAN_BUILD_64=yes, CAN_BUILD_64=no)
254 CFLAGS="${CFLAGS} -m64"
255 CXXFLAGS="${CXXFLAGS} -m64"
256 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
257 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
258 if test "$CAN_BUILD_64" != yes; then
259 # Nope. back out changes.
260 CFLAGS="${CFLAGS_OLD}"
261 CXXFLAGS="${CFLAGS_OLD}"
262 # 2. try xarch=v9 [deprecated]
263 ## TODO: cross compile: the following won't work.
264 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
265 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
266 # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
267 if test -z "$SOL64" && test -n "$SPARCV9"; then
268 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
269 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
270 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
277 CFLAGS="${CFLAGS} -m64"
278 CXXFLAGS="${CXXFLAGS} -m64"
279 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
280 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
281 if test "$CAN_BUILD_64" != yes; then
282 # Nope. back out changes.
283 CFLAGS="${CFLAGS_OLD}"
284 CXXFLAGS="${CXXFLAGS_OLD}"
285 # 2. try the older compiler option
286 ## TODO: cross compile problem
287 AMD64=`isainfo -n 2>&1 | grep amd64`
288 SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
289 if test -z "$SOL64" && test -n "$AMD64"; then
290 CFLAGS="${CFLAGS} -xtarget=generic64"
291 CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
297 # check for ecc/ecpc compiler support
298 ## TODO: cross compiler problem
299 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
300 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
306 # vcvarsamd64.bat should have been used to enable 64-bit builds.
307 # We only do this check to display the correct answer.
308 ## TODO: cross compiler problem
309 if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
313 *-*-aix*|powerpc64-*-linux*)
314 CFLAGS="${CFLAGS} -q64"
315 CXXFLAGS="${CXXFLAGS} -q64"
316 LDFLAGS="${LDFLAGS} -q64"
317 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
318 CAN_BUILD_64=yes, CAN_BUILD_64=no)
319 if test "$CAN_BUILD_64" = yes; then
320 # worked- set other options.
323 # tell AIX what executable mode to use.
324 ARFLAGS="${ARFLAGS} -X64"
329 # First we try the newer +DD64, if that doesn't work,
332 CFLAGS="${CFLAGS} +DD64"
333 CXXFLAGS="${CXXFLAGS} +DD64"
334 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
335 CAN_BUILD_64=yes, CAN_BUILD_64=no)
336 if test "$CAN_BUILD_64" != yes; then
338 CFLAGS="${CFLAGS_OLD}"
339 CXXFLAGS="${CXXFLAGS_OLD}"
341 CFLAGS="${CFLAGS} +DA2.0W"
342 CXXFLAGS="${CXXFLAGS} +DA2.0W"
343 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
344 CAN_BUILD_64=yes, CAN_BUILD_64=no)
347 *-*ibm-openedition*|*-*-os390*)
348 CFLAGS="${CFLAGS} -Wc,lp64"
349 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
350 LDFLAGS="${LDFLAGS} -Wl,lp64"
351 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
352 CAN_BUILD_64=yes, CAN_BUILD_64=no)
359 AC_MSG_RESULT($CAN_BUILD_64)
360 if test "$CAN_BUILD_64" = yes; then
361 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
362 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
363 BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
364 AC_MSG_RESULT($BITS_RUN_64);
366 CFLAGS_64="${CFLAGS}"
367 CXXFLAGS_64="${CXXFLAGS}"
368 LDFLAGS_64="${LDFLAGS}"
369 ARFLAGS_64="${ARFLAGS}"
372 CFLAGS="${CFLAGS_OLD}"
373 CXXFLAGS="${CXXFLAGS_OLD}"
374 LDFLAGS="${LDFLAGS_OLD}"
375 ARFLAGS="${ARFLAGS_OLD}"
377 if test "$BITS_CHECK_32" = "yes"; then
378 # see comment under 'if BITS_CHECK_64', above.
379 AC_MSG_CHECKING([how to build 32-bit executables])
380 if test "$GCC" = yes; then
381 CFLAGS="${CFLAGS} -m32"
382 CXXFLAGS="${CXXFLAGS} -m32"
383 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
384 CAN_BUILD_32=yes, CAN_BUILD_32=no)
386 AC_MSG_RESULT($CAN_BUILD_32)
387 if test "$CAN_BUILD_32" = yes; then
388 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
389 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
390 BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
391 AC_MSG_RESULT($BITS_RUN_32);
392 CFLAGS_32="${CFLAGS}"
393 CXXFLAGS_32="${CXXFLAGS}"
394 LDFLAGS_32="${LDFLAGS}"
395 ARFLAGS_32="${ARFLAGS}"
398 CFLAGS="${CFLAGS_OLD}"
399 CXXFLAGS="${CXXFLAGS_OLD}"
400 LDFLAGS="${LDFLAGS_OLD}"
401 ARFLAGS="${ARFLAGS_OLD}"
405 # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
408 # First, implement 64else32
409 if test "$BITS_REQ" = "64else32"; then
410 if test "$BITS_RUN_64" = "yes"; then
419 if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
420 CFLAGS="${CFLAGS_32}"
421 CXXFLAGS="${CXXFLAGS_32}"
422 LDFLAGS="${LDFLAGS_32}"
423 ARFLAGS="${ARFLAGS_32}"
425 elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
426 CFLAGS="${CFLAGS_64}"
427 CXXFLAGS="${CXXFLAGS_64}"
428 LDFLAGS="${LDFLAGS_64}"
429 ARFLAGS="${ARFLAGS_64}"
431 elif test "$BITS_OK" != "yes"; then
432 AC_MSG_ERROR([Requested $BITS_REQ bit binaries but could not compile and execute them. See readme.html for help with cross compilation., and set compiler options manually.])
437 # Strict compilation options.
438 AC_DEFUN(AC_CHECK_STRICT_COMPILE,
440 AC_MSG_CHECKING([whether strict compiling is on])
441 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=yes]], [
442 if test "$enableval" = no
444 ac_use_strict_options=no
446 ac_use_strict_options=yes
448 ], [ac_use_strict_options=yes])
449 AC_MSG_RESULT($ac_use_strict_options)
451 if test "$ac_use_strict_options" = yes
457 CFLAGS="$CFLAGS -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long"
458 CFLAGS="$CFLAGS -D__STDC__=0";;
460 echo "# Note: We are not using '-ansi' with HP/UX GCC because int64_t broke, see <http://bugs.icu-project.org/trac/ticket/8493>"
461 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long";;
463 CFLAGS="$CFLAGS -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long";;
468 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
476 CXXFLAGS="$CXXFLAGS -W -Wall -ansi -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
479 CXXFLAGS="$CXXFLAGS -D__STDC__=0";;
484 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
486 CXXFLAGS="$CXXFLAGS /W4"