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 *-apple-darwin*) icu_cv_host_frag=mh-darwin ;;
81 *-*-beos) icu_cv_host_frag=mh-beos ;;
82 *-*-haiku) icu_cv_host_frag=mh-haiku ;;
83 *-*-irix*) icu_cv_host_frag=mh-irix ;;
84 *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
85 *-*-nto*) icu_cv_host_frag=mh-qnx ;;
86 *-ncr-*) icu_cv_host_frag=mh-mpras ;;
87 *) icu_cv_host_frag=mh-unknown ;;
93 # ICU_PROG_LINK - Make sure that the linker is usable
94 AC_DEFUN([ICU_PROG_LINK],
97 *-*-cygwin*|*-*-mingw*)
98 if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
99 AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
100 Please follow the directions in ICU's readme.])
105 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
106 # [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
107 # Search for a library defining FUNC, then see if it's not already available.
109 AC_DEFUN([AC_SEARCH_LIBS_FIRST],
111 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
112 [ac_func_search_save_LIBS="$LIBS"
115 LIBS="-l$i $5 $ac_func_search_save_LIBS"
116 AC_TRY_LINK_FUNC([$1],
117 [ac_cv_search_$1="-l$i"
120 if test "$ac_cv_search_$1" = "no"; then
121 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
123 LIBS="$ac_func_search_save_LIBS"])
124 if test "$ac_cv_search_$1" != "no"; then
125 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
133 # Check if we can build and use 64-bit libraries
134 AC_DEFUN([AC_CHECK_64BIT_LIBS],
137 ENABLE_64BIT_LIBS=unknown
138 ## revisit this for cross-compile.
140 AC_ARG_ENABLE(64bit-libs,
141 [ --enable-64bit-libs (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
142 [echo "note, use --with-library-bits instead of --*-64bit-libs"
143 case "${enableval}" in
144 no|false|32) with_library_bits=32; ;;
145 yes|true|64) with_library_bits=64else32 ;;
146 nochange) with_library_bits=nochange; ;;
147 *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
151 AC_ARG_WITH(library-bits,
152 [ --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
153 [case "${withval}" in
154 ""|nochange) BITS_REQ=$withval ;;
155 32|64|64else32) BITS_REQ=$withval ;;
156 *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
159 # don't use these for cross compiling
160 if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
161 AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
163 AC_CHECK_SIZEOF([void *])
164 AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
165 case $ac_cv_sizeof_void_p in
166 8) DEFAULT_64BIT=yes ;;
167 4) DEFAULT_64BIT=no ;;
168 *) DEFAULT_64BIT=unknown
172 # 'OK' here means, we can exit any further checking, everything's copa
175 # do we need to check for buildable/runnable 32 or 64 bit?
179 # later, can we run the 32/64 bit binaries so made?
183 if test "$DEFAULT_64BIT" = "yes"; then
184 # we get 64 bits by default.
188 # need to look for 32 bit support.
192 # everyone else is happy.
196 elif test "$DEFAULT_64BIT" = "no"; then
197 # not 64 bit by default.
207 elif test "$DEFAULT_64BIT" = "unknown"; then
211 64|64else32) BITS_OK=no
220 AC_MSG_RESULT($DEFAULT_64BIT);
222 if test "$BITS_OK" != "yes"; then
223 # not copa. back these up.
224 CFLAGS_OLD="${CFLAGS}"
225 CXXFLAGS_OLD="${CXXFLAGS}"
226 LDFLAGS_OLD="${LDFLAGS}"
227 ARFLAGS_OLD="${ARFLAGS}"
229 CFLAGS_32="${CFLAGS}"
230 CXXFLAGS_32="${CXXFLAGS}"
231 LDFLAGS_32="${LDFLAGS}"
232 ARFLAGS_32="${ARFLAGS}"
234 CFLAGS_64="${CFLAGS}"
235 CXXFLAGS_64="${CXXFLAGS}"
236 LDFLAGS_64="${LDFLAGS}"
237 ARFLAGS_64="${ARFLAGS}"
241 # These results can't be cached because is sets compiler flags.
242 if test "$BITS_CHECK_64" = "yes"; then
243 AC_MSG_CHECKING([how to build 64-bit executables])
246 # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
247 # Note, we don't have to actually check if the options work- we'll try them before using them.
248 # So, only try actually testing the options, if you are trying to decide between multiple options.
249 # On exit from the following clauses:
250 # if CAN_BUILD_64=yes:
251 # *FLAGS are assumed to contain the right settings for 64bit
252 # else if CAN_BUILD_64=no: (default)
253 # *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
255 if test "$GCC" = yes; then
256 CFLAGS="${CFLAGS} -m64"
257 CXXFLAGS="${CXXFLAGS} -m64"
258 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
259 CAN_BUILD_64=yes, CAN_BUILD_64=no)
264 CFLAGS="${CFLAGS} -m64"
265 CXXFLAGS="${CXXFLAGS} -m64"
266 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
267 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
268 if test "$CAN_BUILD_64" != yes; then
269 # Nope. back out changes.
270 CFLAGS="${CFLAGS_OLD}"
271 CXXFLAGS="${CXXFLAGS_OLD}"
272 # 2. try xarch=v9 [deprecated]
273 ## TODO: cross compile: the following won't work.
274 SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
275 SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
276 # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
277 if test -z "$SOL64" && test -n "$SPARCV9"; then
278 CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
279 CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
280 LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
287 CFLAGS="${CFLAGS} -m64"
288 CXXFLAGS="${CXXFLAGS} -m64"
289 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
290 CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
291 if test "$CAN_BUILD_64" != yes; then
292 # Nope. back out changes.
293 CFLAGS="${CFLAGS_OLD}"
294 CXXFLAGS="${CXXFLAGS_OLD}"
295 # 2. try the older compiler option
296 ## TODO: cross compile problem
297 AMD64=`isainfo -n 2>&1 | grep amd64`
298 SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
299 if test -z "$SOL64" && test -n "$AMD64"; then
300 CFLAGS="${CFLAGS} -xtarget=generic64"
301 CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
307 # check for ecc/ecpc compiler support
308 ## TODO: cross compiler problem
309 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
310 if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
316 # vcvarsamd64.bat should have been used to enable 64-bit builds.
317 # We only do this check to display the correct answer.
318 ## TODO: cross compiler problem
319 if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
323 *-*-aix*|powerpc64-*-linux*)
324 CFLAGS="${CFLAGS} -q64"
325 CXXFLAGS="${CXXFLAGS} -q64"
326 LDFLAGS="${LDFLAGS} -q64"
327 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
328 CAN_BUILD_64=yes, CAN_BUILD_64=no)
329 if test "$CAN_BUILD_64" = yes; then
330 # worked- set other options.
333 # tell AIX what executable mode to use.
334 ARFLAGS="${ARFLAGS} -X64"
339 # First we try the newer +DD64, if that doesn't work,
342 CFLAGS="${CFLAGS} +DD64"
343 CXXFLAGS="${CXXFLAGS} +DD64"
344 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
345 CAN_BUILD_64=yes, CAN_BUILD_64=no)
346 if test "$CAN_BUILD_64" != yes; then
348 CFLAGS="${CFLAGS_OLD}"
349 CXXFLAGS="${CXXFLAGS_OLD}"
351 CFLAGS="${CFLAGS} +DA2.0W"
352 CXXFLAGS="${CXXFLAGS} +DA2.0W"
353 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
354 CAN_BUILD_64=yes, CAN_BUILD_64=no)
357 *-*ibm-openedition*|*-*-os390*)
358 CFLAGS="${CFLAGS} -Wc,lp64"
359 CXXFLAGS="${CXXFLAGS} -Wc,lp64"
360 LDFLAGS="${LDFLAGS} -Wl,lp64"
361 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
362 CAN_BUILD_64=yes, CAN_BUILD_64=no)
369 AC_MSG_RESULT($CAN_BUILD_64)
370 if test "$CAN_BUILD_64" = yes; then
371 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
372 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
373 BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
374 AC_MSG_RESULT($BITS_RUN_64);
376 CFLAGS_64="${CFLAGS}"
377 CXXFLAGS_64="${CXXFLAGS}"
378 LDFLAGS_64="${LDFLAGS}"
379 ARFLAGS_64="${ARFLAGS}"
382 CFLAGS="${CFLAGS_OLD}"
383 CXXFLAGS="${CXXFLAGS_OLD}"
384 LDFLAGS="${LDFLAGS_OLD}"
385 ARFLAGS="${ARFLAGS_OLD}"
387 if test "$BITS_CHECK_32" = "yes"; then
388 # see comment under 'if BITS_CHECK_64', above.
389 AC_MSG_CHECKING([how to build 32-bit executables])
390 if test "$GCC" = yes; then
391 CFLAGS="${CFLAGS} -m32"
392 CXXFLAGS="${CXXFLAGS} -m32"
393 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
394 CAN_BUILD_32=yes, CAN_BUILD_32=no)
396 AC_MSG_RESULT($CAN_BUILD_32)
397 if test "$CAN_BUILD_32" = yes; then
398 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
399 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
400 BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
401 AC_MSG_RESULT($BITS_RUN_32);
402 CFLAGS_32="${CFLAGS}"
403 CXXFLAGS_32="${CXXFLAGS}"
404 LDFLAGS_32="${LDFLAGS}"
405 ARFLAGS_32="${ARFLAGS}"
408 CFLAGS="${CFLAGS_OLD}"
409 CXXFLAGS="${CXXFLAGS_OLD}"
410 LDFLAGS="${LDFLAGS_OLD}"
411 ARFLAGS="${ARFLAGS_OLD}"
415 # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
418 # First, implement 64else32
419 if test "$BITS_REQ" = "64else32"; then
420 if test "$BITS_RUN_64" = "yes"; then
429 if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
430 CFLAGS="${CFLAGS_32}"
431 CXXFLAGS="${CXXFLAGS_32}"
432 LDFLAGS="${LDFLAGS_32}"
433 ARFLAGS="${ARFLAGS_32}"
435 elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
436 CFLAGS="${CFLAGS_64}"
437 CXXFLAGS="${CXXFLAGS_64}"
438 LDFLAGS="${LDFLAGS_64}"
439 ARFLAGS="${ARFLAGS_64}"
441 elif test "$BITS_OK" != "yes"; then
442 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.])
447 # Strict compilation options.
448 AC_DEFUN([AC_CHECK_STRICT_COMPILE],
450 AC_MSG_CHECKING([whether strict compiling is on])
451 AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=yes]], [
452 if test "$enableval" = no
454 ac_use_strict_options=no
456 ac_use_strict_options=yes
458 ], [ac_use_strict_options=yes])
459 AC_MSG_RESULT($ac_use_strict_options)
461 if test "$ac_use_strict_options" = yes
467 # Don't use -std=c11 on Solaris because of timezone check fails
470 # Do not use -ansi. It limits us to C90, and it breaks some platforms.
471 # We use -std=c11 to disable the gnu99 defaults and its associated warnings
472 CFLAGS="$CFLAGS -std=c11"
476 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
480 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
485 CFLAGS="$CFLAGS -W4" ;;
490 CXXFLAGS="$CXXFLAGS -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
494 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
496 CXXFLAGS="$CXXFLAGS /W4"
499 CFLAGS="$CFLAGS -W4" ;;