1 # Copyright (c) 1999-2015, 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_PROG_LINK - Make sure that the linker is usable
92 AC_DEFUN([ICU_PROG_LINK],
95 *-*-cygwin*|*-*-mingw*)
96 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
97 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
98 Please follow the directions in ICU's readme.])
103 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
104 # [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
105 # Search for a library defining FUNC, then see if it's not already available.
107 AC_DEFUN([AC_SEARCH_LIBS_FIRST],
109 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
110 [ac_func_search_save_LIBS="$LIBS"
113 LIBS="-l$i $5 $ac_func_search_save_LIBS"
114 AC_TRY_LINK_FUNC([$1],
115 [ac_cv_search_$1="-l$i"
118 if test "$ac_cv_search_$1" = "no"; then
119 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
121 LIBS="$ac_func_search_save_LIBS"])
122 if test "$ac_cv_search_$1" != "no"; then
123 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
131 # Check if we can build and use 64-bit libraries
132 AC_DEFUN([AC_CHECK_64BIT_LIBS],
135 ENABLE_64BIT_LIBS=unknown
136 ## revisit this for cross-compile.
138 AC_ARG_ENABLE(64bit-libs,
139 [ --enable-64bit-libs (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
140 [echo "note, use --with-library-bits instead of --*-64bit-libs"
141 case "${enableval}" in
142 no|false|32) with_library_bits=32; ;;
143 yes|true|64) with_library_bits=64else32 ;;
144 nochange) with_library_bits=nochange; ;;
145 *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
149 AC_ARG_WITH(library-bits,
150 [ --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
151 [case "${withval}" in
152 ""|nochange) BITS_REQ=$withval ;;
153 32|64|64else32) BITS_REQ=$withval ;;
154 *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
157 # don't use these for cross compiling
158 if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
159 AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
161 AC_CHECK_SIZEOF([void *])
162 AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
163 case $ac_cv_sizeof_void_p in
164 8) DEFAULT_64BIT=yes ;;
165 4) DEFAULT_64BIT=no ;;
166 *) DEFAULT_64BIT=unknown
170 # 'OK' here means, we can exit any further checking, everything's copa
173 # do we need to check for buildable/runnable 32 or 64 bit?
177 # later, can we run the 32/64 bit binaries so made?
181 if test "$DEFAULT_64BIT" = "yes"; then
182 # we get 64 bits by default.
186 # need to look for 32 bit support.
190 # everyone else is happy.
194 elif test "$DEFAULT_64BIT" = "no"; then
195 # not 64 bit by default.
205 elif test "$DEFAULT_64BIT" = "unknown"; then
209 64|64else32) BITS_OK=no
218 AC_MSG_RESULT($DEFAULT_64BIT);
220 if test "$BITS_OK" != "yes"; then
221 # not copa. back these up.
222 CFLAGS_OLD="${CFLAGS}"
223 CXXFLAGS_OLD="${CXXFLAGS}"
224 LDFLAGS_OLD="${LDFLAGS}"
225 ARFLAGS_OLD="${ARFLAGS}"
227 CFLAGS_32="${CFLAGS}"
228 CXXFLAGS_32="${CXXFLAGS}"
229 LDFLAGS_32="${LDFLAGS}"
230 ARFLAGS_32="${ARFLAGS}"
232 CFLAGS_64="${CFLAGS}"
233 CXXFLAGS_64="${CXXFLAGS}"
234 LDFLAGS_64="${LDFLAGS}"
235 ARFLAGS_64="${ARFLAGS}"
239 # These results can't be cached because is sets compiler flags.
240 if test "$BITS_CHECK_64" = "yes"; then
241 AC_MSG_CHECKING([how to build 64-bit executables])
244 # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
245 # Note, we don't have to actually check if the options work- we'll try them before using them.
246 # So, only try actually testing the options, if you are trying to decide between multiple options.
247 # On exit from the following clauses:
248 # if CAN_BUILD_64=yes:
249 # *FLAGS are assumed to contain the right settings for 64bit
250 # else if CAN_BUILD_64=no: (default)
251 # *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
253 if test "$GCC" = yes; then
254 CFLAGS="${CFLAGS} -m64"
255 CXXFLAGS="${CXXFLAGS} -m64"
256 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
257 CAN_BUILD_64=yes, CAN_BUILD_64=no)
262 CFLAGS="${CFLAGS} -m64"
263 CXXFLAGS="${CXXFLAGS} -m64"
264 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
265 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
266 if test "$CAN_BUILD_64" != yes; then
267 # Nope. back out changes.
268 CFLAGS="${CFLAGS_OLD}"
269 CXXFLAGS="${CXXFLAGS_OLD}"
270 # 2. try xarch=v9 [deprecated]
271 ## TODO: cross compile: the following won't work.
272 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
273 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
274 # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
275 if test -z "$SOL64" && test -n "$SPARCV9"; then
276 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
277 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
278 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
285 CFLAGS="${CFLAGS} -m64"
286 CXXFLAGS="${CXXFLAGS} -m64"
287 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
288 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
289 if test "$CAN_BUILD_64" != yes; then
290 # Nope. back out changes.
291 CFLAGS="${CFLAGS_OLD}"
292 CXXFLAGS="${CXXFLAGS_OLD}"
293 # 2. try the older compiler option
294 ## TODO: cross compile problem
295 AMD64=`isainfo -n 2>&1 | grep amd64`
296 SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
297 if test -z "$SOL64" && test -n "$AMD64"; then
298 CFLAGS="${CFLAGS} -xtarget=generic64"
299 CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
305 # check for ecc/ecpc compiler support
306 ## TODO: cross compiler problem
307 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
308 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
314 # vcvarsamd64.bat should have been used to enable 64-bit builds.
315 # We only do this check to display the correct answer.
316 ## TODO: cross compiler problem
317 if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
321 *-*-aix*|powerpc64-*-linux*)
322 CFLAGS="${CFLAGS} -q64"
323 CXXFLAGS="${CXXFLAGS} -q64"
324 LDFLAGS="${LDFLAGS} -q64"
325 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
326 CAN_BUILD_64=yes, CAN_BUILD_64=no)
327 if test "$CAN_BUILD_64" = yes; then
328 # worked- set other options.
331 # tell AIX what executable mode to use.
332 ARFLAGS="${ARFLAGS} -X64"
337 # First we try the newer +DD64, if that doesn't work,
340 CFLAGS="${CFLAGS} +DD64"
341 CXXFLAGS="${CXXFLAGS} +DD64"
342 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
343 CAN_BUILD_64=yes, CAN_BUILD_64=no)
344 if test "$CAN_BUILD_64" != yes; then
346 CFLAGS="${CFLAGS_OLD}"
347 CXXFLAGS="${CXXFLAGS_OLD}"
349 CFLAGS="${CFLAGS} +DA2.0W"
350 CXXFLAGS="${CXXFLAGS} +DA2.0W"
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)
355 *-*ibm-openedition*|*-*-os390*)
356 CFLAGS="${CFLAGS} -Wc,lp64"
357 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
358 LDFLAGS="${LDFLAGS} -Wl,lp64"
359 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
360 CAN_BUILD_64=yes, CAN_BUILD_64=no)
367 AC_MSG_RESULT($CAN_BUILD_64)
368 if test "$CAN_BUILD_64" = yes; then
369 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
370 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
371 BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
372 AC_MSG_RESULT($BITS_RUN_64);
374 CFLAGS_64="${CFLAGS}"
375 CXXFLAGS_64="${CXXFLAGS}"
376 LDFLAGS_64="${LDFLAGS}"
377 ARFLAGS_64="${ARFLAGS}"
380 CFLAGS="${CFLAGS_OLD}"
381 CXXFLAGS="${CXXFLAGS_OLD}"
382 LDFLAGS="${LDFLAGS_OLD}"
383 ARFLAGS="${ARFLAGS_OLD}"
385 if test "$BITS_CHECK_32" = "yes"; then
386 # see comment under 'if BITS_CHECK_64', above.
387 AC_MSG_CHECKING([how to build 32-bit executables])
388 if test "$GCC" = yes; then
389 CFLAGS="${CFLAGS} -m32"
390 CXXFLAGS="${CXXFLAGS} -m32"
391 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
392 CAN_BUILD_32=yes, CAN_BUILD_32=no)
394 AC_MSG_RESULT($CAN_BUILD_32)
395 if test "$CAN_BUILD_32" = yes; then
396 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
397 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
398 BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
399 AC_MSG_RESULT($BITS_RUN_32);
400 CFLAGS_32="${CFLAGS}"
401 CXXFLAGS_32="${CXXFLAGS}"
402 LDFLAGS_32="${LDFLAGS}"
403 ARFLAGS_32="${ARFLAGS}"
406 CFLAGS="${CFLAGS_OLD}"
407 CXXFLAGS="${CXXFLAGS_OLD}"
408 LDFLAGS="${LDFLAGS_OLD}"
409 ARFLAGS="${ARFLAGS_OLD}"
413 # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
416 # First, implement 64else32
417 if test "$BITS_REQ" = "64else32"; then
418 if test "$BITS_RUN_64" = "yes"; then
427 if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
428 CFLAGS="${CFLAGS_32}"
429 CXXFLAGS="${CXXFLAGS_32}"
430 LDFLAGS="${LDFLAGS_32}"
431 ARFLAGS="${ARFLAGS_32}"
433 elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
434 CFLAGS="${CFLAGS_64}"
435 CXXFLAGS="${CXXFLAGS_64}"
436 LDFLAGS="${LDFLAGS_64}"
437 ARFLAGS="${ARFLAGS_64}"
439 elif test "$BITS_OK" != "yes"; then
440 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.])
445 # Strict compilation options.
446 AC_DEFUN([AC_CHECK_STRICT_COMPILE],
448 AC_MSG_CHECKING([whether strict compiling is on])
449 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=yes]], [
450 if test "$enableval" = no
452 ac_use_strict_options=no
454 ac_use_strict_options=yes
456 ], [ac_use_strict_options=yes])
457 AC_MSG_RESULT($ac_use_strict_options)
459 if test "$ac_use_strict_options" = yes
465 # Do not use -ansi. It limits us to C90, and it breaks some platforms.
466 # We use -std=c99 to disable the gnu99 defaults and its associated warnings
467 CFLAGS="$CFLAGS -std=c99"
471 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
475 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
480 CFLAGS="$CFLAGS -W4" ;;
485 CXXFLAGS="$CXXFLAGS -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
489 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
491 CXXFLAGS="$CXXFLAGS /W4"
494 CFLAGS="$CFLAGS -W4" ;;