1 # Copyright (c) 1999-2013, 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 *-*-cygwin|*-*-mingw32|*-*-mingw64)
36 if test "$GCC" = yes; then
39 #error This is not MinGW
40 #endif], [], AC_TRY_COMPILE([
42 #error This is not MinGW64
43 #endif], [], icu_cv_host_frag=mh-mingw64, icu_cv_host_frag=mh-mingw), icu_cv_host_frag=mh-cygwin)
45 icu_cv_host_frag=mh-cygwin-msvc
47 *-*-*bsd*|*-*-dragonfly*) icu_cv_host_frag=mh-bsd-gcc ;;
49 if test "$GCC" = yes; then
50 icu_cv_host_frag=mh-aix-gcc
52 icu_cv_host_frag=mh-aix-va
55 if test "$GCC" = yes; then
56 icu_cv_host_frag=mh-hpux-gcc
59 *aCC) icu_cv_host_frag=mh-hpux-acc ;;
62 *-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
63 *-*-os400*) icu_cv_host_frag=mh-os400 ;;
64 *-apple-rhapsody*) icu_cv_host_frag=mh-darwin ;;
65 *-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
66 *-*-beos) icu_cv_host_frag=mh-beos ;;
67 *-*-haiku) icu_cv_host_frag=mh-haiku ;;
68 *-*-irix*) icu_cv_host_frag=mh-irix ;;
69 *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
70 *-*-nto*) icu_cv_host_frag=mh-qnx ;;
71 *-ncr-*) icu_cv_host_frag=mh-mpras ;;
72 *) icu_cv_host_frag=mh-unknown ;;
78 # ICU_CONDITIONAL - similar example taken from Automake 1.4
79 AC_DEFUN([ICU_CONDITIONAL],
87 # ICU_PROG_LINK - Make sure that the linker is usable
88 AC_DEFUN([ICU_PROG_LINK],
91 *-*-cygwin*|*-*-mingw*)
92 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
93 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
94 Please follow the directions in ICU's readme.])
99 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
100 # [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
101 # Search for a library defining FUNC, then see if it's not already available.
103 AC_DEFUN([AC_SEARCH_LIBS_FIRST],
105 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
106 [ac_func_search_save_LIBS="$LIBS"
109 LIBS="-l$i $5 $ac_func_search_save_LIBS"
110 AC_TRY_LINK_FUNC([$1],
111 [ac_cv_search_$1="-l$i"
114 if test "$ac_cv_search_$1" = "no"; then
115 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
117 LIBS="$ac_func_search_save_LIBS"])
118 if test "$ac_cv_search_$1" != "no"; then
119 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
127 # Check if we can build and use 64-bit libraries
128 AC_DEFUN([AC_CHECK_64BIT_LIBS],
131 ENABLE_64BIT_LIBS=unknown
132 ## revisit this for cross-compile.
134 AC_ARG_ENABLE(64bit-libs,
135 [ --enable-64bit-libs (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
136 [echo "note, use --with-library-bits instead of --*-64bit-libs"
137 case "${enableval}" in
138 no|false|32) with_library_bits=32; ;;
139 yes|true|64) with_library_bits=64else32 ;;
140 nochange) with_library_bits=nochange; ;;
141 *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
145 AC_ARG_WITH(library-bits,
146 [ --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
147 [case "${withval}" in
148 ""|nochange) BITS_REQ=$withval ;;
149 32|64|64else32) BITS_REQ=$withval ;;
150 *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
153 # don't use these for cross compiling
154 if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
155 AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
157 AC_CHECK_SIZEOF([void *])
158 AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
159 case $ac_cv_sizeof_void_p in
160 8) DEFAULT_64BIT=yes ;;
161 4) DEFAULT_64BIT=no ;;
162 *) DEFAULT_64BIT=unknown
166 # 'OK' here means, we can exit any further checking, everything's copa
169 # do we need to check for buildable/runnable 32 or 64 bit?
173 # later, can we run the 32/64 bit binaries so made?
177 if test "$DEFAULT_64BIT" = "yes"; then
178 # we get 64 bits by default.
182 # need to look for 32 bit support.
186 # everyone else is happy.
190 elif test "$DEFAULT_64BIT" = "no"; then
191 # not 64 bit by default.
201 elif test "$DEFAULT_64BIT" = "unknown"; then
205 64|64else32) BITS_OK=no
214 AC_MSG_RESULT($DEFAULT_64BIT);
216 if test "$BITS_OK" != "yes"; then
217 # not copa. back these up.
218 CFLAGS_OLD="${CFLAGS}"
219 CXXFLAGS_OLD="${CXXFLAGS}"
220 LDFLAGS_OLD="${LDFLAGS}"
221 ARFLAGS_OLD="${ARFLAGS}"
223 CFLAGS_32="${CFLAGS}"
224 CXXFLAGS_32="${CXXFLAGS}"
225 LDFLAGS_32="${LDFLAGS}"
226 ARFLAGS_32="${ARFLAGS}"
228 CFLAGS_64="${CFLAGS}"
229 CXXFLAGS_64="${CXXFLAGS}"
230 LDFLAGS_64="${LDFLAGS}"
231 ARFLAGS_64="${ARFLAGS}"
235 # These results can't be cached because is sets compiler flags.
236 if test "$BITS_CHECK_64" = "yes"; then
237 AC_MSG_CHECKING([how to build 64-bit executables])
240 # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
241 # Note, we don't have to actually check if the options work- we'll try them before using them.
242 # So, only try actually testing the options, if you are trying to decide between multiple options.
243 # On exit from the following clauses:
244 # if CAN_BUILD_64=yes:
245 # *FLAGS are assumed to contain the right settings for 64bit
246 # else if CAN_BUILD_64=no: (default)
247 # *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
249 if test "$GCC" = yes; then
250 CFLAGS="${CFLAGS} -m64"
251 CXXFLAGS="${CXXFLAGS} -m64"
252 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
253 CAN_BUILD_64=yes, CAN_BUILD_64=no)
258 CFLAGS="${CFLAGS} -m64"
259 CXXFLAGS="${CXXFLAGS} -m64"
260 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
261 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
262 if test "$CAN_BUILD_64" != yes; then
263 # Nope. back out changes.
264 CFLAGS="${CFLAGS_OLD}"
265 CXXFLAGS="${CFLAGS_OLD}"
266 # 2. try xarch=v9 [deprecated]
267 ## TODO: cross compile: the following won't work.
268 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
269 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
270 # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
271 if test -z "$SOL64" && test -n "$SPARCV9"; then
272 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
273 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
274 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
281 CFLAGS="${CFLAGS} -m64"
282 CXXFLAGS="${CXXFLAGS} -m64"
283 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
284 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
285 if test "$CAN_BUILD_64" != yes; then
286 # Nope. back out changes.
287 CFLAGS="${CFLAGS_OLD}"
288 CXXFLAGS="${CXXFLAGS_OLD}"
289 # 2. try the older compiler option
290 ## TODO: cross compile problem
291 AMD64=`isainfo -n 2>&1 | grep amd64`
292 SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
293 if test -z "$SOL64" && test -n "$AMD64"; then
294 CFLAGS="${CFLAGS} -xtarget=generic64"
295 CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
301 # check for ecc/ecpc compiler support
302 ## TODO: cross compiler problem
303 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
304 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
310 # vcvarsamd64.bat should have been used to enable 64-bit builds.
311 # We only do this check to display the correct answer.
312 ## TODO: cross compiler problem
313 if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
317 *-*-aix*|powerpc64-*-linux*)
318 CFLAGS="${CFLAGS} -q64"
319 CXXFLAGS="${CXXFLAGS} -q64"
320 LDFLAGS="${LDFLAGS} -q64"
321 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
322 CAN_BUILD_64=yes, CAN_BUILD_64=no)
323 if test "$CAN_BUILD_64" = yes; then
324 # worked- set other options.
327 # tell AIX what executable mode to use.
328 ARFLAGS="${ARFLAGS} -X64"
333 # First we try the newer +DD64, if that doesn't work,
336 CFLAGS="${CFLAGS} +DD64"
337 CXXFLAGS="${CXXFLAGS} +DD64"
338 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
339 CAN_BUILD_64=yes, CAN_BUILD_64=no)
340 if test "$CAN_BUILD_64" != yes; then
342 CFLAGS="${CFLAGS_OLD}"
343 CXXFLAGS="${CXXFLAGS_OLD}"
345 CFLAGS="${CFLAGS} +DA2.0W"
346 CXXFLAGS="${CXXFLAGS} +DA2.0W"
347 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
348 CAN_BUILD_64=yes, CAN_BUILD_64=no)
351 *-*ibm-openedition*|*-*-os390*)
352 CFLAGS="${CFLAGS} -Wc,lp64"
353 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
354 LDFLAGS="${LDFLAGS} -Wl,lp64"
355 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
356 CAN_BUILD_64=yes, CAN_BUILD_64=no)
363 AC_MSG_RESULT($CAN_BUILD_64)
364 if test "$CAN_BUILD_64" = yes; then
365 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
366 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
367 BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
368 AC_MSG_RESULT($BITS_RUN_64);
370 CFLAGS_64="${CFLAGS}"
371 CXXFLAGS_64="${CXXFLAGS}"
372 LDFLAGS_64="${LDFLAGS}"
373 ARFLAGS_64="${ARFLAGS}"
376 CFLAGS="${CFLAGS_OLD}"
377 CXXFLAGS="${CXXFLAGS_OLD}"
378 LDFLAGS="${LDFLAGS_OLD}"
379 ARFLAGS="${ARFLAGS_OLD}"
381 if test "$BITS_CHECK_32" = "yes"; then
382 # see comment under 'if BITS_CHECK_64', above.
383 AC_MSG_CHECKING([how to build 32-bit executables])
384 if test "$GCC" = yes; then
385 CFLAGS="${CFLAGS} -m32"
386 CXXFLAGS="${CXXFLAGS} -m32"
387 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
388 CAN_BUILD_32=yes, CAN_BUILD_32=no)
390 AC_MSG_RESULT($CAN_BUILD_32)
391 if test "$CAN_BUILD_32" = yes; then
392 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
393 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
394 BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
395 AC_MSG_RESULT($BITS_RUN_32);
396 CFLAGS_32="${CFLAGS}"
397 CXXFLAGS_32="${CXXFLAGS}"
398 LDFLAGS_32="${LDFLAGS}"
399 ARFLAGS_32="${ARFLAGS}"
402 CFLAGS="${CFLAGS_OLD}"
403 CXXFLAGS="${CXXFLAGS_OLD}"
404 LDFLAGS="${LDFLAGS_OLD}"
405 ARFLAGS="${ARFLAGS_OLD}"
409 # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
412 # First, implement 64else32
413 if test "$BITS_REQ" = "64else32"; then
414 if test "$BITS_RUN_64" = "yes"; then
423 if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
424 CFLAGS="${CFLAGS_32}"
425 CXXFLAGS="${CXXFLAGS_32}"
426 LDFLAGS="${LDFLAGS_32}"
427 ARFLAGS="${ARFLAGS_32}"
429 elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
430 CFLAGS="${CFLAGS_64}"
431 CXXFLAGS="${CXXFLAGS_64}"
432 LDFLAGS="${LDFLAGS_64}"
433 ARFLAGS="${ARFLAGS_64}"
435 elif test "$BITS_OK" != "yes"; then
436 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.])
441 # Strict compilation options.
442 AC_DEFUN([AC_CHECK_STRICT_COMPILE],
444 AC_MSG_CHECKING([whether strict compiling is on])
445 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=yes]], [
446 if test "$enableval" = no
448 ac_use_strict_options=no
450 ac_use_strict_options=yes
452 ], [ac_use_strict_options=yes])
453 AC_MSG_RESULT($ac_use_strict_options)
455 if test "$ac_use_strict_options" = yes
461 # Don't use -std=c99 option on Solaris/GCC
464 # Do not use -ansi. It limits us to C90, and it breaks some platforms.
465 # We use -std=c99 to disable the gnu99 defaults and its associated warnings
466 CFLAGS="$CFLAGS -std=c99"
470 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
474 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
482 CXXFLAGS="$CXXFLAGS -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
486 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
488 CXXFLAGS="$CXXFLAGS /W4"