1 # Copyright (c) 1999-2014, International Business Machines Corporation and
2 # others. All Rights Reserved.
4 # Don't edit aclocal.m4, do edit acinclude.m4
10 AC_DEFUN([ICU_CHECK_MH_FRAG], [
12 [which Makefile fragment to use for ${host}],
17 if test "$GCC" = yes; then
18 icu_cv_host_frag=mh-solaris-gcc
20 icu_cv_host_frag=mh-solaris
23 if test "$GCC" = yes; then
24 icu_cv_host_frag=mh-alpha-linux-gcc
26 icu_cv_host_frag=mh-alpha-linux-cc
29 if test "$GCC" = yes; then
30 icu_cv_host_frag=mh-linux
32 icu_cv_host_frag=mh-linux-va
34 *-*-linux*|*-*-gnu|*-*-k*bsd*-gnu|*-*-kopensolaris*-gnu) icu_cv_host_frag=mh-linux ;;
35 i[[34567]]86-*-cygwin)
36 if test "$GCC" = yes; then
37 icu_cv_host_frag=mh-cygwin
39 icu_cv_host_frag=mh-cygwin-msvc
42 if test "$GCC" = yes; then
43 icu_cv_host_frag=mh-cygwin64
45 icu_cv_host_frag=mh-cygwin-msvc
48 if test "$GCC" = yes; then
49 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
51 #error This is not MinGW64
52 #endif]])], [icu_cv_host_frag=mh-mingw64],
53 [icu_cv_host_frag=mh-mingw])
56 *-*-mingw*) icu_cv_host_frag=mh-msys-msvc ;;
57 *-*-cygwin) icu_cv_host_frag=mh-cygwin-msvc ;;
60 *-*-*bsd*|*-*-dragonfly*) icu_cv_host_frag=mh-bsd-gcc ;;
62 if test "$GCC" = yes; then
63 icu_cv_host_frag=mh-aix-gcc
65 icu_cv_host_frag=mh-aix-va
68 if test "$GCC" = yes; then
69 icu_cv_host_frag=mh-hpux-gcc
72 *aCC) icu_cv_host_frag=mh-hpux-acc ;;
75 *-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
76 *-*-os400*) icu_cv_host_frag=mh-os400 ;;
77 *-apple-rhapsody*) icu_cv_host_frag=mh-darwin ;;
78 *-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
79 *-*-beos) icu_cv_host_frag=mh-beos ;;
80 *-*-haiku) icu_cv_host_frag=mh-haiku ;;
81 *-*-irix*) icu_cv_host_frag=mh-irix ;;
82 *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
83 *-*-nto*) icu_cv_host_frag=mh-qnx ;;
84 *-ncr-*) icu_cv_host_frag=mh-mpras ;;
85 *) icu_cv_host_frag=mh-unknown ;;
91 # ICU_CONDITIONAL - similar example taken from Automake 1.4
92 AC_DEFUN([ICU_CONDITIONAL],
100 # ICU_PROG_LINK - Make sure that the linker is usable
101 AC_DEFUN([ICU_PROG_LINK],
104 *-*-cygwin*|*-*-mingw*)
105 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
106 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
107 Please follow the directions in ICU's readme.])
112 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
113 # [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
114 # Search for a library defining FUNC, then see if it's not already available.
116 AC_DEFUN([AC_SEARCH_LIBS_FIRST],
118 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
119 [ac_func_search_save_LIBS="$LIBS"
122 LIBS="-l$i $5 $ac_func_search_save_LIBS"
123 AC_TRY_LINK_FUNC([$1],
124 [ac_cv_search_$1="-l$i"
127 if test "$ac_cv_search_$1" = "no"; then
128 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
130 LIBS="$ac_func_search_save_LIBS"])
131 if test "$ac_cv_search_$1" != "no"; then
132 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
140 # Check if we can build and use 64-bit libraries
141 AC_DEFUN([AC_CHECK_64BIT_LIBS],
144 ENABLE_64BIT_LIBS=unknown
145 ## revisit this for cross-compile.
147 AC_ARG_ENABLE(64bit-libs,
148 [ --enable-64bit-libs (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
149 [echo "note, use --with-library-bits instead of --*-64bit-libs"
150 case "${enableval}" in
151 no|false|32) with_library_bits=32; ;;
152 yes|true|64) with_library_bits=64else32 ;;
153 nochange) with_library_bits=nochange; ;;
154 *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
158 AC_ARG_WITH(library-bits,
159 [ --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
160 [case "${withval}" in
161 ""|nochange) BITS_REQ=$withval ;;
162 32|64|64else32) BITS_REQ=$withval ;;
163 *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
166 # don't use these for cross compiling
167 if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
168 AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
170 AC_CHECK_SIZEOF([void *])
171 AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
172 case $ac_cv_sizeof_void_p in
173 8) DEFAULT_64BIT=yes ;;
174 4) DEFAULT_64BIT=no ;;
175 *) DEFAULT_64BIT=unknown
179 # 'OK' here means, we can exit any further checking, everything's copa
182 # do we need to check for buildable/runnable 32 or 64 bit?
186 # later, can we run the 32/64 bit binaries so made?
190 if test "$DEFAULT_64BIT" = "yes"; then
191 # we get 64 bits by default.
195 # need to look for 32 bit support.
199 # everyone else is happy.
203 elif test "$DEFAULT_64BIT" = "no"; then
204 # not 64 bit by default.
214 elif test "$DEFAULT_64BIT" = "unknown"; then
218 64|64else32) BITS_OK=no
227 AC_MSG_RESULT($DEFAULT_64BIT);
229 if test "$BITS_OK" != "yes"; then
230 # not copa. back these up.
231 CFLAGS_OLD="${CFLAGS}"
232 CXXFLAGS_OLD="${CXXFLAGS}"
233 LDFLAGS_OLD="${LDFLAGS}"
234 ARFLAGS_OLD="${ARFLAGS}"
236 CFLAGS_32="${CFLAGS}"
237 CXXFLAGS_32="${CXXFLAGS}"
238 LDFLAGS_32="${LDFLAGS}"
239 ARFLAGS_32="${ARFLAGS}"
241 CFLAGS_64="${CFLAGS}"
242 CXXFLAGS_64="${CXXFLAGS}"
243 LDFLAGS_64="${LDFLAGS}"
244 ARFLAGS_64="${ARFLAGS}"
248 # These results can't be cached because is sets compiler flags.
249 if test "$BITS_CHECK_64" = "yes"; then
250 AC_MSG_CHECKING([how to build 64-bit executables])
253 # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
254 # Note, we don't have to actually check if the options work- we'll try them before using them.
255 # So, only try actually testing the options, if you are trying to decide between multiple options.
256 # On exit from the following clauses:
257 # if CAN_BUILD_64=yes:
258 # *FLAGS are assumed to contain the right settings for 64bit
259 # else if CAN_BUILD_64=no: (default)
260 # *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
262 if test "$GCC" = yes; then
263 CFLAGS="${CFLAGS} -m64"
264 CXXFLAGS="${CXXFLAGS} -m64"
265 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
266 CAN_BUILD_64=yes, CAN_BUILD_64=no)
271 CFLAGS="${CFLAGS} -m64"
272 CXXFLAGS="${CXXFLAGS} -m64"
273 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
274 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
275 if test "$CAN_BUILD_64" != yes; then
276 # Nope. back out changes.
277 CFLAGS="${CFLAGS_OLD}"
278 CXXFLAGS="${CXXFLAGS_OLD}"
279 # 2. try xarch=v9 [deprecated]
280 ## TODO: cross compile: the following won't work.
281 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
282 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
283 # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
284 if test -z "$SOL64" && test -n "$SPARCV9"; then
285 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
286 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
287 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
294 CFLAGS="${CFLAGS} -m64"
295 CXXFLAGS="${CXXFLAGS} -m64"
296 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
297 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
298 if test "$CAN_BUILD_64" != yes; then
299 # Nope. back out changes.
300 CFLAGS="${CFLAGS_OLD}"
301 CXXFLAGS="${CXXFLAGS_OLD}"
302 # 2. try the older compiler option
303 ## TODO: cross compile problem
304 AMD64=`isainfo -n 2>&1 | grep amd64`
305 SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
306 if test -z "$SOL64" && test -n "$AMD64"; then
307 CFLAGS="${CFLAGS} -xtarget=generic64"
308 CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
314 # check for ecc/ecpc compiler support
315 ## TODO: cross compiler problem
316 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
317 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
323 # vcvarsamd64.bat should have been used to enable 64-bit builds.
324 # We only do this check to display the correct answer.
325 ## TODO: cross compiler problem
326 if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
330 *-*-aix*|powerpc64-*-linux*)
331 CFLAGS="${CFLAGS} -q64"
332 CXXFLAGS="${CXXFLAGS} -q64"
333 LDFLAGS="${LDFLAGS} -q64"
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
337 # worked- set other options.
340 # tell AIX what executable mode to use.
341 ARFLAGS="${ARFLAGS} -X64"
346 # First we try the newer +DD64, if that doesn't work,
349 CFLAGS="${CFLAGS} +DD64"
350 CXXFLAGS="${CXXFLAGS} +DD64"
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)
353 if test "$CAN_BUILD_64" != yes; then
355 CFLAGS="${CFLAGS_OLD}"
356 CXXFLAGS="${CXXFLAGS_OLD}"
358 CFLAGS="${CFLAGS} +DA2.0W"
359 CXXFLAGS="${CXXFLAGS} +DA2.0W"
360 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
361 CAN_BUILD_64=yes, CAN_BUILD_64=no)
364 *-*ibm-openedition*|*-*-os390*)
365 CFLAGS="${CFLAGS} -Wc,lp64"
366 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
367 LDFLAGS="${LDFLAGS} -Wl,lp64"
368 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
369 CAN_BUILD_64=yes, CAN_BUILD_64=no)
376 AC_MSG_RESULT($CAN_BUILD_64)
377 if test "$CAN_BUILD_64" = yes; then
378 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
379 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
380 BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
381 AC_MSG_RESULT($BITS_RUN_64);
383 CFLAGS_64="${CFLAGS}"
384 CXXFLAGS_64="${CXXFLAGS}"
385 LDFLAGS_64="${LDFLAGS}"
386 ARFLAGS_64="${ARFLAGS}"
389 CFLAGS="${CFLAGS_OLD}"
390 CXXFLAGS="${CXXFLAGS_OLD}"
391 LDFLAGS="${LDFLAGS_OLD}"
392 ARFLAGS="${ARFLAGS_OLD}"
394 if test "$BITS_CHECK_32" = "yes"; then
395 # see comment under 'if BITS_CHECK_64', above.
396 AC_MSG_CHECKING([how to build 32-bit executables])
397 if test "$GCC" = yes; then
398 CFLAGS="${CFLAGS} -m32"
399 CXXFLAGS="${CXXFLAGS} -m32"
400 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
401 CAN_BUILD_32=yes, CAN_BUILD_32=no)
403 AC_MSG_RESULT($CAN_BUILD_32)
404 if test "$CAN_BUILD_32" = yes; then
405 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
406 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
407 BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
408 AC_MSG_RESULT($BITS_RUN_32);
409 CFLAGS_32="${CFLAGS}"
410 CXXFLAGS_32="${CXXFLAGS}"
411 LDFLAGS_32="${LDFLAGS}"
412 ARFLAGS_32="${ARFLAGS}"
415 CFLAGS="${CFLAGS_OLD}"
416 CXXFLAGS="${CXXFLAGS_OLD}"
417 LDFLAGS="${LDFLAGS_OLD}"
418 ARFLAGS="${ARFLAGS_OLD}"
422 # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
425 # First, implement 64else32
426 if test "$BITS_REQ" = "64else32"; then
427 if test "$BITS_RUN_64" = "yes"; then
436 if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
437 CFLAGS="${CFLAGS_32}"
438 CXXFLAGS="${CXXFLAGS_32}"
439 LDFLAGS="${LDFLAGS_32}"
440 ARFLAGS="${ARFLAGS_32}"
442 elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
443 CFLAGS="${CFLAGS_64}"
444 CXXFLAGS="${CXXFLAGS_64}"
445 LDFLAGS="${LDFLAGS_64}"
446 ARFLAGS="${ARFLAGS_64}"
448 elif test "$BITS_OK" != "yes"; then
449 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.])
454 # Strict compilation options.
455 AC_DEFUN([AC_CHECK_STRICT_COMPILE],
457 AC_MSG_CHECKING([whether strict compiling is on])
458 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=yes]], [
459 if test "$enableval" = no
461 ac_use_strict_options=no
463 ac_use_strict_options=yes
465 ], [ac_use_strict_options=yes])
466 AC_MSG_RESULT($ac_use_strict_options)
468 if test "$ac_use_strict_options" = yes
474 # Do not use -ansi. It limits us to C90, and it breaks some platforms.
475 # We use -std=c99 to disable the gnu99 defaults and its associated warnings
476 CFLAGS="$CFLAGS -std=c99"
480 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
484 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
489 CFLAGS="$CFLAGS -W4" ;;
494 CXXFLAGS="$CXXFLAGS -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
498 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
500 CXXFLAGS="$CXXFLAGS /W4"
503 CFLAGS="$CFLAGS -W4" ;;