1 # Copyright (C) 2016 and later: Unicode, Inc. and others.
2 # License & terms of use: http://www.unicode.org/copyright.html
3 # Copyright (c) 1999-2016, International Business Machines Corporation and
4 # others. All Rights Reserved.
6 # Don't edit aclocal.m4, do edit acinclude.m4
12 AC_DEFUN([ICU_CHECK_MH_FRAG], [
14 [which Makefile fragment to use for ${host}],
19 if test "$GCC" = yes; then
20 icu_cv_host_frag=mh-solaris-gcc
22 icu_cv_host_frag=mh-solaris
25 if test "$GCC" = yes; then
26 icu_cv_host_frag=mh-alpha-linux-gcc
28 icu_cv_host_frag=mh-alpha-linux-cc
31 if test "$GCC" = yes; then
32 icu_cv_host_frag=mh-linux
34 icu_cv_host_frag=mh-linux-va
36 *-*-linux*|*-*-gnu|*-*-k*bsd*-gnu|*-*-kopensolaris*-gnu) icu_cv_host_frag=mh-linux ;;
37 i[[34567]]86-*-cygwin)
38 if test "$GCC" = yes; then
39 icu_cv_host_frag=mh-cygwin
41 icu_cv_host_frag=mh-cygwin-msvc
44 if test "$GCC" = yes; then
45 icu_cv_host_frag=mh-cygwin64
47 icu_cv_host_frag=mh-cygwin-msvc
50 if test "$GCC" = yes; then
51 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
53 #error This is not MinGW64
54 #endif]])], [icu_cv_host_frag=mh-mingw64],
55 [icu_cv_host_frag=mh-mingw])
58 *-*-mingw*) icu_cv_host_frag=mh-msys-msvc ;;
59 *-*-cygwin) icu_cv_host_frag=mh-cygwin-msvc ;;
62 *-*-*bsd*|*-*-dragonfly*) icu_cv_host_frag=mh-bsd-gcc ;;
64 if test "$GCC" = yes; then
65 icu_cv_host_frag=mh-aix-gcc
67 icu_cv_host_frag=mh-aix-va
70 if test "$GCC" = yes; then
71 icu_cv_host_frag=mh-hpux-gcc
74 *aCC) icu_cv_host_frag=mh-hpux-acc ;;
77 *-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
78 *-*-os400*) icu_cv_host_frag=mh-os400 ;;
79 *-apple-rhapsody*) icu_cv_host_frag=mh-darwin ;;
80 powerpc*-apple-darwin*) icu_cv_host_frag=mh-darwin-ppc ;;
81 *-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
82 *-*-beos) icu_cv_host_frag=mh-beos ;;
83 *-*-haiku) icu_cv_host_frag=mh-haiku ;;
84 *-*-irix*) icu_cv_host_frag=mh-irix ;;
85 *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
86 *-*-nto*) icu_cv_host_frag=mh-qnx ;;
87 *-ncr-*) icu_cv_host_frag=mh-mpras ;;
88 *) icu_cv_host_frag=mh-unknown ;;
94 # ICU_PROG_LINK - Make sure that the linker is usable
95 AC_DEFUN([ICU_PROG_LINK],
98 *-*-cygwin*|*-*-mingw*)
99 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
100 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
101 Please follow the directions in ICU's readme.])
106 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
107 # [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
108 # Search for a library defining FUNC, then see if it's not already available.
110 AC_DEFUN([AC_SEARCH_LIBS_FIRST],
112 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
113 [ac_func_search_save_LIBS="$LIBS"
116 LIBS="-l$i $5 $ac_func_search_save_LIBS"
117 AC_TRY_LINK_FUNC([$1],
118 [ac_cv_search_$1="-l$i"
121 if test "$ac_cv_search_$1" = "no"; then
122 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
124 LIBS="$ac_func_search_save_LIBS"])
125 if test "$ac_cv_search_$1" != "no"; then
126 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
134 # Check if we can build and use 64-bit libraries
135 AC_DEFUN([AC_CHECK_64BIT_LIBS],
138 ENABLE_64BIT_LIBS=unknown
139 ## revisit this for cross-compile.
141 AC_ARG_ENABLE(64bit-libs,
142 [ --enable-64bit-libs (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
143 [echo "note, use --with-library-bits instead of --*-64bit-libs"
144 case "${enableval}" in
145 no|false|32) with_library_bits=32; ;;
146 yes|true|64) with_library_bits=64else32 ;;
147 nochange) with_library_bits=nochange; ;;
148 *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
152 AC_ARG_WITH(library-bits,
153 [ --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
154 [case "${withval}" in
155 ""|nochange) BITS_REQ=$withval ;;
156 32|64|64else32) BITS_REQ=$withval ;;
157 *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
160 # don't use these for cross compiling
161 if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
162 AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
164 AC_CHECK_SIZEOF([void *])
165 AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
166 case $ac_cv_sizeof_void_p in
167 8) DEFAULT_64BIT=yes ;;
168 4) DEFAULT_64BIT=no ;;
169 *) DEFAULT_64BIT=unknown
173 # 'OK' here means, we can exit any further checking, everything's copa
176 # do we need to check for buildable/runnable 32 or 64 bit?
180 # later, can we run the 32/64 bit binaries so made?
184 if test "$DEFAULT_64BIT" = "yes"; then
185 # we get 64 bits by default.
189 # need to look for 32 bit support.
193 # everyone else is happy.
197 elif test "$DEFAULT_64BIT" = "no"; then
198 # not 64 bit by default.
208 elif test "$DEFAULT_64BIT" = "unknown"; then
212 64|64else32) BITS_OK=no
221 AC_MSG_RESULT($DEFAULT_64BIT);
223 if test "$BITS_OK" != "yes"; then
224 # not copa. back these up.
225 CFLAGS_OLD="${CFLAGS}"
226 CXXFLAGS_OLD="${CXXFLAGS}"
227 LDFLAGS_OLD="${LDFLAGS}"
228 ARFLAGS_OLD="${ARFLAGS}"
230 CFLAGS_32="${CFLAGS}"
231 CXXFLAGS_32="${CXXFLAGS}"
232 LDFLAGS_32="${LDFLAGS}"
233 ARFLAGS_32="${ARFLAGS}"
235 CFLAGS_64="${CFLAGS}"
236 CXXFLAGS_64="${CXXFLAGS}"
237 LDFLAGS_64="${LDFLAGS}"
238 ARFLAGS_64="${ARFLAGS}"
242 # These results can't be cached because is sets compiler flags.
243 if test "$BITS_CHECK_64" = "yes"; then
244 AC_MSG_CHECKING([how to build 64-bit executables])
247 # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
248 # Note, we don't have to actually check if the options work- we'll try them before using them.
249 # So, only try actually testing the options, if you are trying to decide between multiple options.
250 # On exit from the following clauses:
251 # if CAN_BUILD_64=yes:
252 # *FLAGS are assumed to contain the right settings for 64bit
253 # else if CAN_BUILD_64=no: (default)
254 # *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
256 if test "$GCC" = yes; then
257 CFLAGS="${CFLAGS} -m64"
258 CXXFLAGS="${CXXFLAGS} -m64"
259 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
260 CAN_BUILD_64=yes, CAN_BUILD_64=no)
265 CFLAGS="${CFLAGS} -m64"
266 CXXFLAGS="${CXXFLAGS} -m64"
267 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
268 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
269 if test "$CAN_BUILD_64" != yes; then
270 # Nope. back out changes.
271 CFLAGS="${CFLAGS_OLD}"
272 CXXFLAGS="${CXXFLAGS_OLD}"
273 # 2. try xarch=v9 [deprecated]
274 ## TODO: cross compile: the following won't work.
275 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
276 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
277 # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
278 if test -z "$SOL64" && test -n "$SPARCV9"; then
279 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
280 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
281 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
288 CFLAGS="${CFLAGS} -m64"
289 CXXFLAGS="${CXXFLAGS} -m64"
290 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
291 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
292 if test "$CAN_BUILD_64" != yes; then
293 # Nope. back out changes.
294 CFLAGS="${CFLAGS_OLD}"
295 CXXFLAGS="${CXXFLAGS_OLD}"
296 # 2. try the older compiler option
297 ## TODO: cross compile problem
298 AMD64=`isainfo -n 2>&1 | grep amd64`
299 SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
300 if test -z "$SOL64" && test -n "$AMD64"; then
301 CFLAGS="${CFLAGS} -xtarget=generic64"
302 CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
308 # check for ecc/ecpc compiler support
309 ## TODO: cross compiler problem
310 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
311 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
317 # vcvarsamd64.bat should have been used to enable 64-bit builds.
318 # We only do this check to display the correct answer.
319 ## TODO: cross compiler problem
320 if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
324 *-*-aix*|powerpc64-*-linux*)
325 CFLAGS="${CFLAGS} -q64"
326 CXXFLAGS="${CXXFLAGS} -q64"
327 LDFLAGS="${LDFLAGS} -q64"
328 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
329 CAN_BUILD_64=yes, CAN_BUILD_64=no)
330 if test "$CAN_BUILD_64" = yes; then
331 # worked- set other options.
334 # tell AIX what executable mode to use.
335 ARFLAGS="${ARFLAGS} -X64"
340 # First we try the newer +DD64, if that doesn't work,
343 CFLAGS="${CFLAGS} +DD64"
344 CXXFLAGS="${CXXFLAGS} +DD64"
345 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
346 CAN_BUILD_64=yes, CAN_BUILD_64=no)
347 if test "$CAN_BUILD_64" != yes; then
349 CFLAGS="${CFLAGS_OLD}"
350 CXXFLAGS="${CXXFLAGS_OLD}"
352 CFLAGS="${CFLAGS} +DA2.0W"
353 CXXFLAGS="${CXXFLAGS} +DA2.0W"
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)
358 *-*ibm-openedition*|*-*-os390*)
359 CFLAGS="${CFLAGS} -Wc,lp64"
360 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
361 LDFLAGS="${LDFLAGS} -Wl,lp64"
362 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
363 CAN_BUILD_64=yes, CAN_BUILD_64=no)
370 AC_MSG_RESULT($CAN_BUILD_64)
371 if test "$CAN_BUILD_64" = yes; then
372 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
373 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
374 BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
375 AC_MSG_RESULT($BITS_RUN_64);
377 CFLAGS_64="${CFLAGS}"
378 CXXFLAGS_64="${CXXFLAGS}"
379 LDFLAGS_64="${LDFLAGS}"
380 ARFLAGS_64="${ARFLAGS}"
383 CFLAGS="${CFLAGS_OLD}"
384 CXXFLAGS="${CXXFLAGS_OLD}"
385 LDFLAGS="${LDFLAGS_OLD}"
386 ARFLAGS="${ARFLAGS_OLD}"
388 if test "$BITS_CHECK_32" = "yes"; then
389 # see comment under 'if BITS_CHECK_64', above.
390 AC_MSG_CHECKING([how to build 32-bit executables])
391 if test "$GCC" = yes; then
392 CFLAGS="${CFLAGS} -m32"
393 CXXFLAGS="${CXXFLAGS} -m32"
394 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
395 CAN_BUILD_32=yes, CAN_BUILD_32=no)
397 AC_MSG_RESULT($CAN_BUILD_32)
398 if test "$CAN_BUILD_32" = yes; then
399 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
400 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
401 BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
402 AC_MSG_RESULT($BITS_RUN_32);
403 CFLAGS_32="${CFLAGS}"
404 CXXFLAGS_32="${CXXFLAGS}"
405 LDFLAGS_32="${LDFLAGS}"
406 ARFLAGS_32="${ARFLAGS}"
409 CFLAGS="${CFLAGS_OLD}"
410 CXXFLAGS="${CXXFLAGS_OLD}"
411 LDFLAGS="${LDFLAGS_OLD}"
412 ARFLAGS="${ARFLAGS_OLD}"
416 # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
419 # First, implement 64else32
420 if test "$BITS_REQ" = "64else32"; then
421 if test "$BITS_RUN_64" = "yes"; then
430 if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
431 CFLAGS="${CFLAGS_32}"
432 CXXFLAGS="${CXXFLAGS_32}"
433 LDFLAGS="${LDFLAGS_32}"
434 ARFLAGS="${ARFLAGS_32}"
436 elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
437 CFLAGS="${CFLAGS_64}"
438 CXXFLAGS="${CXXFLAGS_64}"
439 LDFLAGS="${LDFLAGS_64}"
440 ARFLAGS="${ARFLAGS_64}"
442 elif test "$BITS_OK" != "yes"; then
443 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.])
448 # Strict compilation options.
449 AC_DEFUN([AC_CHECK_STRICT_COMPILE],
451 AC_MSG_CHECKING([whether strict compiling is on])
452 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=yes]], [
453 if test "$enableval" = no
455 ac_use_strict_options=no
457 ac_use_strict_options=yes
459 ], [ac_use_strict_options=yes])
460 AC_MSG_RESULT($ac_use_strict_options)
462 if test "$ac_use_strict_options" = yes
468 # Don't use -std=c11 on Solaris because of timezone check fails
471 # Do not use -ansi. It limits us to C90, and it breaks some platforms.
472 # We use -std=c11 to disable the gnu99 defaults and its associated warnings
473 CFLAGS="$CFLAGS -std=c11"
477 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
479 # Suppress clang C warnings:
480 CFLAGS="$CFLAGS -Wno-sign-compare -Wno-unused"
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"
496 # Suppress clang C++ warnings:
497 CXXFLAGS="$CXXFLAGS -Wno-unused -Wno-unused-parameter"
501 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
503 CXXFLAGS="$CXXFLAGS /W4"
506 CFLAGS="$CFLAGS -W4" ;;