2 # Copyright (c) 1999-2012, 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|*-*-mingw64)
35 if test "$GCC" = yes; then
38 #error This is not MinGW
39 #endif], [], AC_TRY_COMPILE([
41 #error This is not MinGW64
42 #endif], [], icu_cv_host_frag=mh-mingw64, icu_cv_host_frag=mh-mingw), icu_cv_host_frag=mh-cygwin)
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 icu_cv_host_frag=mh-aix-va
54 if test "$GCC" = yes; then
55 icu_cv_host_frag=mh-hpux-gcc
58 *aCC) icu_cv_host_frag=mh-hpux-acc ;;
61 *-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
62 *-*-os400*) icu_cv_host_frag=mh-os400 ;;
63 *-apple-rhapsody*) icu_cv_host_frag=mh-darwin ;;
64 *-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
65 *-*-beos) icu_cv_host_frag=mh-beos ;;
66 *-*-haiku) icu_cv_host_frag=mh-haiku ;;
67 *-*-irix*) icu_cv_host_frag=mh-irix ;;
68 *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
69 *-*-nto*) icu_cv_host_frag=mh-qnx ;;
70 *-ncr-*) icu_cv_host_frag=mh-mpras ;;
71 *) icu_cv_host_frag=mh-unknown ;;
77 # ICU_CONDITIONAL - similar example taken from Automake 1.4
78 AC_DEFUN(ICU_CONDITIONAL,
86 # ICU_PROG_LINK - Make sure that the linker is usable
87 AC_DEFUN(ICU_PROG_LINK,
90 *-*-cygwin*|*-*-mingw*)
91 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
92 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
93 Please follow the directions in ICU's readme.])
98 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
99 # [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
100 # Search for a library defining FUNC, then see if it's not already available.
102 AC_DEFUN(AC_SEARCH_LIBS_FIRST,
104 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
105 [ac_func_search_save_LIBS="$LIBS"
108 LIBS="-l$i $5 $ac_func_search_save_LIBS"
109 AC_TRY_LINK_FUNC([$1],
110 [ac_cv_search_$1="-l$i"
113 if test "$ac_cv_search_$1" = "no"; then
114 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
116 LIBS="$ac_func_search_save_LIBS"])
117 if test "$ac_cv_search_$1" != "no"; then
118 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
126 # Check if we can build and use 64-bit libraries
127 AC_DEFUN(AC_CHECK_64BIT_LIBS,
130 ENABLE_64BIT_LIBS=unknown
131 ## revisit this for cross-compile.
133 AC_ARG_ENABLE(64bit-libs,
134 [ --enable-64bit-libs (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
135 [echo "note, use --with-library-bits instead of --*-64bit-libs"
136 case "${enableval}" in
137 no|false|32) with_library_bits=32; ;;
138 yes|true|64) with_library_bits=64else32 ;;
139 nochange) with_library_bits=nochange; ;;
140 *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
144 AC_ARG_WITH(library-bits,
145 [ --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
146 [case "${withval}" in
147 ""|nochange) BITS_REQ=$withval ;;
148 32|64|64else32) BITS_REQ=$withval ;;
149 *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
152 # don't use these for cross compiling
153 if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
154 AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
156 AC_CHECK_SIZEOF([void *])
157 AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
158 case $ac_cv_sizeof_void_p in
159 8) DEFAULT_64BIT=yes ;;
160 4) DEFAULT_64BIT=no ;;
161 *) DEFAULT_64BIT=unknown
165 # 'OK' here means, we can exit any further checking, everything's copa
168 # do we need to check for buildable/runnable 32 or 64 bit?
172 # later, can we run the 32/64 bit binaries so made?
176 if test "$DEFAULT_64BIT" = "yes"; then
177 # we get 64 bits by default.
181 # need to look for 32 bit support.
185 # everyone else is happy.
189 elif test "$DEFAULT_64BIT" = "no"; then
190 # not 64 bit by default.
200 elif test "$DEFAULT_64BIT" = "unknown"; then
204 64|64else32) BITS_OK=no
213 AC_MSG_RESULT($DEFAULT_64BIT);
215 if test "$BITS_OK" != "yes"; then
216 # not copa. back these up.
217 CFLAGS_OLD="${CFLAGS}"
218 CXXFLAGS_OLD="${CXXFLAGS}"
219 LDFLAGS_OLD="${LDFLAGS}"
220 ARFLAGS_OLD="${ARFLAGS}"
222 CFLAGS_32="${CFLAGS}"
223 CXXFLAGS_32="${CXXFLAGS}"
224 LDFLAGS_32="${LDFLAGS}"
225 ARFLAGS_32="${ARFLAGS}"
227 CFLAGS_64="${CFLAGS}"
228 CXXFLAGS_64="${CXXFLAGS}"
229 LDFLAGS_64="${LDFLAGS}"
230 ARFLAGS_64="${ARFLAGS}"
234 # These results can't be cached because is sets compiler flags.
235 if test "$BITS_CHECK_64" = "yes"; then
236 AC_MSG_CHECKING([how to build 64-bit executables])
239 # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
240 # Note, we don't have to actually check if the options work- we'll try them before using them.
241 # So, only try actually testing the options, if you are trying to decide between multiple options.
242 # On exit from the following clauses:
243 # if CAN_BUILD_64=yes:
244 # *FLAGS are assumed to contain the right settings for 64bit
245 # else if CAN_BUILD_64=no: (default)
246 # *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
248 if test "$GCC" = yes; then
249 CFLAGS="${CFLAGS} -m64"
250 CXXFLAGS="${CXXFLAGS} -m64"
251 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
252 CAN_BUILD_64=yes, CAN_BUILD_64=no)
257 CFLAGS="${CFLAGS} -m64"
258 CXXFLAGS="${CXXFLAGS} -m64"
259 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
260 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
261 if test "$CAN_BUILD_64" != yes; then
262 # Nope. back out changes.
263 CFLAGS="${CFLAGS_OLD}"
264 CXXFLAGS="${CFLAGS_OLD}"
265 # 2. try xarch=v9 [deprecated]
266 ## TODO: cross compile: the following won't work.
267 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
268 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
269 # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
270 if test -z "$SOL64" && test -n "$SPARCV9"; then
271 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
272 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
273 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
280 CFLAGS="${CFLAGS} -m64"
281 CXXFLAGS="${CXXFLAGS} -m64"
282 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
283 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
284 if test "$CAN_BUILD_64" != yes; then
285 # Nope. back out changes.
286 CFLAGS="${CFLAGS_OLD}"
287 CXXFLAGS="${CXXFLAGS_OLD}"
288 # 2. try the older compiler option
289 ## TODO: cross compile problem
290 AMD64=`isainfo -n 2>&1 | grep amd64`
291 SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
292 if test -z "$SOL64" && test -n "$AMD64"; then
293 CFLAGS="${CFLAGS} -xtarget=generic64"
294 CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
300 # check for ecc/ecpc compiler support
301 ## TODO: cross compiler problem
302 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
303 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
309 # vcvarsamd64.bat should have been used to enable 64-bit builds.
310 # We only do this check to display the correct answer.
311 ## TODO: cross compiler problem
312 if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
316 *-*-aix*|powerpc64-*-linux*)
317 CFLAGS="${CFLAGS} -q64"
318 CXXFLAGS="${CXXFLAGS} -q64"
319 LDFLAGS="${LDFLAGS} -q64"
320 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
321 CAN_BUILD_64=yes, CAN_BUILD_64=no)
322 if test "$CAN_BUILD_64" = yes; then
323 # worked- set other options.
326 # tell AIX what executable mode to use.
327 ARFLAGS="${ARFLAGS} -X64"
332 # First we try the newer +DD64, if that doesn't work,
335 CFLAGS="${CFLAGS} +DD64"
336 CXXFLAGS="${CXXFLAGS} +DD64"
337 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
338 CAN_BUILD_64=yes, CAN_BUILD_64=no)
339 if test "$CAN_BUILD_64" != yes; then
341 CFLAGS="${CFLAGS_OLD}"
342 CXXFLAGS="${CXXFLAGS_OLD}"
344 CFLAGS="${CFLAGS} +DA2.0W"
345 CXXFLAGS="${CXXFLAGS} +DA2.0W"
346 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
347 CAN_BUILD_64=yes, CAN_BUILD_64=no)
350 *-*ibm-openedition*|*-*-os390*)
351 CFLAGS="${CFLAGS} -Wc,lp64"
352 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
353 LDFLAGS="${LDFLAGS} -Wl,lp64"
354 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
355 CAN_BUILD_64=yes, CAN_BUILD_64=no)
362 AC_MSG_RESULT($CAN_BUILD_64)
363 if test "$CAN_BUILD_64" = yes; then
364 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
365 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
366 BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
367 AC_MSG_RESULT($BITS_RUN_64);
369 CFLAGS_64="${CFLAGS}"
370 CXXFLAGS_64="${CXXFLAGS}"
371 LDFLAGS_64="${LDFLAGS}"
372 ARFLAGS_64="${ARFLAGS}"
375 CFLAGS="${CFLAGS_OLD}"
376 CXXFLAGS="${CXXFLAGS_OLD}"
377 LDFLAGS="${LDFLAGS_OLD}"
378 ARFLAGS="${ARFLAGS_OLD}"
380 if test "$BITS_CHECK_32" = "yes"; then
381 # see comment under 'if BITS_CHECK_64', above.
382 AC_MSG_CHECKING([how to build 32-bit executables])
383 if test "$GCC" = yes; then
384 CFLAGS="${CFLAGS} -m32"
385 CXXFLAGS="${CXXFLAGS} -m32"
386 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
387 CAN_BUILD_32=yes, CAN_BUILD_32=no)
389 AC_MSG_RESULT($CAN_BUILD_32)
390 if test "$CAN_BUILD_32" = yes; then
391 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
392 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
393 BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
394 AC_MSG_RESULT($BITS_RUN_32);
395 CFLAGS_32="${CFLAGS}"
396 CXXFLAGS_32="${CXXFLAGS}"
397 LDFLAGS_32="${LDFLAGS}"
398 ARFLAGS_32="${ARFLAGS}"
401 CFLAGS="${CFLAGS_OLD}"
402 CXXFLAGS="${CXXFLAGS_OLD}"
403 LDFLAGS="${LDFLAGS_OLD}"
404 ARFLAGS="${ARFLAGS_OLD}"
408 # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
411 # First, implement 64else32
412 if test "$BITS_REQ" = "64else32"; then
413 if test "$BITS_RUN_64" = "yes"; then
422 if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
423 CFLAGS="${CFLAGS_32}"
424 CXXFLAGS="${CXXFLAGS_32}"
425 LDFLAGS="${LDFLAGS_32}"
426 ARFLAGS="${ARFLAGS_32}"
428 elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
429 CFLAGS="${CFLAGS_64}"
430 CXXFLAGS="${CXXFLAGS_64}"
431 LDFLAGS="${LDFLAGS_64}"
432 ARFLAGS="${ARFLAGS_64}"
434 elif test "$BITS_OK" != "yes"; then
435 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.])
440 # Strict compilation options.
441 AC_DEFUN(AC_CHECK_STRICT_COMPILE,
443 AC_MSG_CHECKING([whether strict compiling is on])
444 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=yes]], [
445 if test "$enableval" = no
447 ac_use_strict_options=no
449 ac_use_strict_options=yes
451 ], [ac_use_strict_options=yes])
452 AC_MSG_RESULT($ac_use_strict_options)
454 if test "$ac_use_strict_options" = yes
458 # Do not use -ansi. It limits us to C90, and it breaks some platforms.
459 # We use -std=c99 to disable the gnu99 defaults and its associated warnings
460 CFLAGS="$CFLAGS -Wall -std=c99 -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
464 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
472 CXXFLAGS="$CXXFLAGS -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
476 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
478 CXXFLAGS="$CXXFLAGS /W4"