Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / intl / icu / source / configure.ac
blob2d7eb300173658252aa3d10affb2db42a8d2a6d1
1 # -*-autoconf-*-
2 AC_COPYRIGHT([ Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html ])
3 # AC_COPYRIGHT([ Copyright (c) 1999-2015, International Business Machines Corporation and others. All Rights Reserved. ])
4 # configure.in for ICU
5 # Stephen F. Booth, heavily modified by Yves and others
7 # NOTE: please use 'autoreconf' to rebuild, otherwise 'aclocal && autoconf'.
9 # Check for autoconf version
10 AC_PREREQ(2.69)
12 # Process this file with autoreconf to produce a configure script
13 AC_INIT([ICU],
14         m4_esyscmd_s([sed -n 's/^[      ]*#[    ]*define[       ]*U_ICU_VERSION[        ]*"\([^"]*\)".*/\1/p' "./common/unicode/uvernum.h]"),
15         [http://icu-project.org/bugs],
16         [International Components for Unicode],
17         [http://icu-project.org])
19 # Instruct Python to never write any byte code to the ICU source tree.
20 PYTHONDONTWRITEBYTECODE=1
21 export PYTHONDONTWRITEBYTECODE
23 AC_CONFIG_MACRO_DIR([config/m4])
24 AC_CONFIG_SRCDIR([common/unicode/utypes.h])
26 PACKAGE="icu"
27 AC_SUBST(PACKAGE)
29 # Use custom echo test for newline option
30 # Current autoconf (2.65) gives incorrect echo newline option
31 # for icu-config
32 # This may be removed later - mow (June 17, 2010)
33 ICU_ECHO_C= ICU_ECHO_N= ICU_ECHO_T=
34 case `/bin/sh -c "echo -n x"` in
35 -n*)
36   case `/bin/sh -c "echo 'x\c'"` in
37   *c*) ICU_ECHO_T=' ';;     # ECHO_T is single tab character.
38   *)   ICU_ECHO_C='\c';;
39   esac;;
41   ICU_ECHO_N='-n';;
42 esac
43 AC_SUBST(ICU_ECHO_N)
44 AC_SUBST(ICU_ECHO_C)
45 AC_SUBST(ICU_ECHO_T)
47 AC_MSG_CHECKING(for ICU version numbers)
49 # Get the ICU version from uversion.h or other headers
50 geticuversion() {
51     [sed -n 's/^[       ]*#[    ]*define[       ]*U_ICU_VERSION[        ]*"\([^"]*\)".*/\1/p' "$@"]
53 getuversion() {
54     [sed -n 's/^[       ]*#[    ]*define[       ]*U_UNICODE_VERSION[    ]*"\([^"]*\)".*/\1/p' "$@"]
56 VERSION=`geticuversion $srcdir/common/unicode/uvernum.h`
57 if test x"$VERSION" = x; then
58    as_fn_error $? "Cannot determine ICU version number from uvernum.h header file" "$LINENO" 5
61 #TODO: IcuBug:8502
62 #if test "$VERSION" != "$PACKAGE_VERSION"; then
63 #   AC_MSG_ERROR([configure was generated for $PACKAGE_VERSION but uvernum.h has $VERSION - please rerun autoconf])
64 #fi
66 UNICODE_VERSION=`getuversion $srcdir/common/unicode/uchar.h`
67 if test x"$UNICODE_VERSION" = x; then
68     AC_MSG_ERROR([Cannot determine Unicode version number from uchar.h header file])
70 # Compute a reasonable library version from the release version. This is
71 # very bad, but that's wanted... We want to make sure that the LIB_VERSION
72 # has at least a dot in it, so we'll add a .0 if needed.
73 #[LIB_VERSION=`echo $VERSION | sed -e 's/\.//' -e 's/^\([^.]*\)$/\1.0/'`]
74 LIB_VERSION=$VERSION
75 LIB_VERSION_MAJOR=`echo $LIB_VERSION | sed 's/\..*//'`
76 AC_SUBST(VERSION)
77 AC_SUBST(LIB_VERSION)
78 AC_SUBST(LIB_VERSION_MAJOR)
79 AC_MSG_RESULT([release $VERSION, library $LIB_VERSION, unicode version $UNICODE_VERSION])
81 AC_SUBST(UNICODE_VERSION)
83 # Determine the host system
84 AC_CANONICAL_HOST
86 AC_SUBST(CPPFLAGS)
88 # This variable is needed on z/OS because the C++ compiler only recognizes .C
89 _CXX_CXXSUFFIX=cpp
90 export _CXX_CXXSUFFIX
92 # Accumulate #defines
94 # CONFIG_CPPFLAGS: These are defines that are set for ICU Build time only.
95 # They are only needed for building ICU itself. Example: platform stuff
96 CONFIG_CPPFLAGS=""
97 # UCONFIG_CPPFLAGS: These are defines which are set for ICU build time,
98 # and also a notice is output that they need to be set
99 # for end-users of ICU also. uconfig.h.prepend is generated
100 # with, for example, "#define U_DISABLE_RENAMING 1"
101 # Example: ICU configuration stuff
102 UCONFIG_CPPFLAGS=""
103 # UCONFIG_CFLAGS: contains a copy of anything that needs to be set by end users
104 # such as -std
105 UCONFIG_CFLAGS=""
107 # Check whether to install icu-config
108 AC_ARG_ENABLE([icu-config],
109     AS_HELP_STRING([--enable-icu-config], [install icu-config]),
110         [case "${enableval}" in
111             yes) enable_icu_config=true ;;
112             no) enable_icu_config=false ;;
113             *) AC_MSG_ERROR([bad value '${enableval}' for --enable-icu-config]) ;;
114         esac], [enable_icu_config=true])
115 AC_SUBST(INSTALL_ICU_CONFIG, [$enable_icu_config])
117 # Check whether to build debug libraries
118 AC_MSG_CHECKING([whether to build debug libraries])
119 enabled=no
120 ENABLE_DEBUG=0
121 AC_ARG_ENABLE(debug,
122     [  --enable-debug          build debug libraries and enable the U_DEBUG define [default=no]],
123     [ case "${enableval}" in
124          yes|"") enabled=yes; ENABLE_DEBUG=1; CONFIG_CPPFLAGS="$CONFIG_CPPFLAGS -DU_DEBUG=1" ;;
125          *) ;;
126     esac],
128 AC_MSG_RESULT($enabled)
129 AC_SUBST(ENABLE_DEBUG)
131 # Check whether to build release libraries
132 AC_MSG_CHECKING([whether to build release libraries])
133 enabled=yes
134 ENABLE_RELEASE=1
135 AC_ARG_ENABLE(release,
136     [  --enable-release        build release libraries [default=yes]],
137     [ case "${enableval}" in
138          no) enabled=no; ENABLE_RELEASE=0 ;;
139          *) ;;
140     esac],
142 AC_MSG_RESULT($enabled)
143 AC_SUBST(ENABLE_RELEASE)
145 # Don't use the default C/CXXFLags
146 : ${CFLAGS=""}
147 : ${CXXFLAGS=""}
149 # Checks for compilers
150 AC_PROG_CC([clang gcc cc c99 c89 xlc_r xlc cl.exe icc])
151 # Make sure that we try clang++ first, which provides C++11 support.
152 # The g++ compiler is less likely to support C++11.
153 AC_PROG_CXX([clang++ g++ c++ gpp xlC_r xlC aCC CC cxx cc++ cl.exe icc FCC KCC RCC])
155 # pkg-config is needed for harfbuzz support
156 PKG_PROG_PKG_CONFIG([0.20])
157 PKG_CHECK_MODULES(ICULEHB, icu-le-hb, have_icu_le_hb=true, :)
159 # Ensure that if CXXFLAGS/CFLAGS were not set when calling configure, set it correctly based on (enable/disable) debug or release option
160 # The release mode use is the default one for autoconf
161 if test "$GCC" = yes; then
162     if test "$CFLAGS" = ""; then
163         if test "$ENABLE_DEBUG" = 1; then
164             CFLAGS=-g
165         fi
166         if test "$ENABLE_RELEASE" = 1; then
167             CFLAGS="$CFLAGS -O2"
168         fi
169     fi
170     if test "$CXXFLAGS" = ""; then
171         if test "$ENABLE_DEBUG" = 1; then
172             CXXFLAGS=-g
173         fi
174         if test "$ENABLE_RELEASE" = 1; then
175             CXXFLAGS="$CXXFLAGS -O2"
176         fi
177     fi
180 AC_PROG_CPP
182 AC_PROG_INSTALL
184 AC_SUBST(cross_compiling)
186 dnl use the pld hack to get ac_fn_cxx_try_link defined globally and not local
187 AC_LANG_PUSH([C++])
188 AC_LINK_IFELSE([AC_LANG_PROGRAM()])
189 AC_LANG_POP([C++])
191 # make sure install is relative to srcdir - if a script
192 if test "$srcdir" = "."; then
193   # If srcdir isn't just ., then (srcdir) is already prepended.
194   if test "${ac_install_sh}" = "${INSTALL}"; then
195    INSTALL="\\\$(top_srcdir)/${ac_install_sh}"
196   fi
199 #AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, true)
200 #AC_CHECK_PROG(STRIP, strip, strip, true)
202 m4_ifndef([AX_CHECK_COMPILE_FLAG], [AC_MSG_ERROR(['autoconf-archive' is missing])])
204 # TODO(ICU-20301): Remove fallback to Python 2.
205 AC_CHECK_PROGS(PYTHON, python3 "py -3" python "py")
206 AC_SUBST(PYTHON)
208 # Check for the platform make
209 AC_PATH_PROGS(U_MAKE, gmake gnumake, make)
210 AC_SUBST(U_MAKE)
213 AC_ARG_WITH(cross-build,
214         [  --with-cross-build=dir specify an absolute path to the build directory of an ICU built for the current platform [default=no cross dir]],
215         [cross_buildroot="${withval}"],
216         [cross_buildroot=""])
218 if test "X$cross_buildroot" = "X"; then
219     if test "$cross_compiling" = "yes"; then
220         AC_MSG_ERROR([Error! Cross compiling but no --with-cross-build option specified - please supply the path to an executable ICU's build root])
221         dnl '
222     fi
223 else
224     if test -f "${cross_buildroot}/config/icucross.mk"; then
225         AC_MSG_RESULT([Using cross buildroot: $cross_buildroot])
226     else
227         if test -d "${cross_buildroot}"; then
228             AC_MSG_ERROR([${cross_buildroot}/config/icucross.mk not found. Please build ICU in ${cross_buildroot} first.])
229         else
230             AC_MSG_ERROR([No such directory ${cross_buildroot} supplied as the argument to --with-cross-build. Use an absolute path.])
231         fi
232     fi
234 AC_SUBST(cross_buildroot)
236 # Check for doxygen to generate documentation
237 AC_PATH_PROG(DOXYGEN,doxygen,,$PATH:/usr/local/bin:/usr/bin)
239 # Check that the linker is usable
240 ICU_PROG_LINK
242 # Determine the executable suffix
243 # We don't use AC_EXEEXT because some compilers output separate debugging
244 # files, which confuses the AC_EXEEXT macro.
245 AC_MSG_CHECKING(checking for executable suffix)
246 case "${host}" in
247     *-*-cygwin*|*-*-mingw*)  EXEEXT=.exe ;;
248     *)      EXEEXT="" ;;
249 esac
250 ac_exeext=$EXEEXT
251 AC_MSG_RESULT($EXEEXT)
252 AC_SUBST(EXEEXT)
254 # Determine how strict we want to be when compiling
255 AC_CHECK_STRICT_COMPILE
257 # Check if we can build and use 64-bit libraries
258 AC_CHECK_64BIT_LIBS
259 AC_SUBST(ARFLAGS)
260 AC_SUBST(COMPILE_LINK_ENVVAR)
262 # Determine the Makefile fragment
263 ICU_CHECK_MH_FRAG
265 # Checks for libraries and other host specific stuff
266 # On HP/UX, don't link to -lm from a shared lib because it isn't
267 #  PIC (at least on 10.2)
268 case "${host}" in
269         *-*-hpux*)      AC_CHECK_LIB(m, floor, LIB_M="-lm") ;;
271         *)              AC_CHECK_LIB(m, floor)
272                         LIB_M="" ;;
273 esac
274 AC_SUBST(LIB_M)
276 # Check whether to build shared libraries
277 AC_MSG_CHECKING([whether to build shared libraries])
278 enabled=no
279 AC_ARG_ENABLE(shared,
280     [  --enable-shared         build shared libraries [default=yes]],
281     [ case "${enableval}" in
282              yes|"") enabled=yes; ENABLE_SHARED=YES ;;
283              no);;
284              *) ;;
285     esac],
286     [enabled=yes; ENABLE_SHARED=YES]
288 AC_MSG_RESULT($enabled)
289 AC_SUBST(ENABLE_SHARED)
291 # Check whether to build static libraries
292 AC_MSG_CHECKING([whether to build static libraries])
293 enabled=no
294 AC_ARG_ENABLE(static,
295     [  --enable-static         build static libraries [default=no]],
296     [ case "${enableval}" in
297              yes|"") enabled=yes; ENABLE_STATIC=YES ;;
298              no) ;;
299              *) ;;
300     esac],
302 AC_MSG_RESULT($enabled)
303 AC_SUBST(ENABLE_STATIC)
305 # When building release static library, there might be some optimization flags we can use
306 if test "$ENABLE_STATIC" = "YES"; then
307     if test "$ENABLE_SHARED" != "YES"; then
308         if test "$ENABLE_RELEASE" = 1; then
309             AC_MSG_CHECKING([whether we can use static library optimization option])
310             CHECK_STATIC_OPT_FLAG=no
312             OLD_CPPFLAGS="${CPPFLAGS}"
313             OLD_LDFLAGS="${LDFLAGS}"
315             case "${host}" in
316             *-linux*|i*86-*-*bsd*|i*86-pc-gnu)
317                 if test "$GCC" = yes; then
318                     CPPFLAGS="${CPPFLAGS} -ffunction-sections -fdata-sections"
319                     LDFLAGS="${LDFLAGS} -Wl,--gc-sections"
320                 fi
321                 ;;
322             *)
323                 ;;
324             esac
326             AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [CHECK_STATIC_OPT_FLAG=yes], [CHECK_STATIC_OPT_FLAG=no])
327             AC_MSG_RESULT($CHECK_STATIC_OPT_FLAG)
328             if test "$CHECK_STATIC_OPT_FLAG" = no; then
329                 CPPFLAGS="${OLD_CPPFLAGS}"
330                 LDFLAGS="${OLD_LDFLAGS}"
331             fi
332         fi
333     fi
337 # Check whether to enable auto cleanup of libraries
338 AC_MSG_CHECKING([whether to enable auto cleanup of libraries])
339 enabled=no
340 UCLN_NO_AUTO_CLEANUP=1
341 AC_ARG_ENABLE(auto-cleanup,
342     [  --enable-auto-cleanup   enable auto cleanup of libraries [default=no]],
343     [ case "${enableval}" in
344          yes) enabled=yes;
345          CONFIG_CPPFLAGS="$CONFIG_CPPFLAGS -DUCLN_NO_AUTO_CLEANUP=0";
346          UCLN_NO_AUTO_CLEANUP=0
347           ;;
348          *) ;;
349     esac],
351 AC_MSG_RESULT($enabled)
352 AC_SUBST(UCLN_NO_AUTO_CLEANUP)
354 # MSVC floating-point option
355 MSVC_RELEASE_FLAG=""
356 if test $enabled = yes
357 then
358     if test $icu_cv_host_frag = mh-cygwin-msvc -o $icu_cv_host_frag = mh-msys-msvc
359     then
360         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
361     #if defined _MSC_VER && _MSC_VER >= 1400
362     #else
363     Microsoft Visual C++ < 2005
364     #endif
365         ]], [[]])],[MSVC_RELEASE_FLAG="/fp:precise"],[MSVC_RELEASE_FLAG="/Op"])
367         CFLAGS="${CFLAGS} ${MSVC_RELEASE_FLAG}"
368         CXXFLAGS="${CXXFLAGS} ${MSVC_RELEASE_FLAG}"
369     fi
372 # Check whether to enabled draft APIs
373 AC_MSG_CHECKING([whether to enable draft APIs])
374 enabled=yes
375 U_DEFAULT_SHOW_DRAFT=1
376 AC_ARG_ENABLE(draft,
377     [  --enable-draft          enable draft APIs (and internal APIs) [default=yes]],
378     [ case "${enableval}" in
379          no) enabled=no; U_DEFAULT_SHOW_DRAFT=0;
380          CONFIG_CPPFLAGS="$CONFIG_CPPFLAGS -DU_DEFAULT_SHOW_DRAFT=0"
381           ;;
382          *) ;;
383     esac],
385 AC_MSG_RESULT($enabled)
386 # Make sure that we can use draft API in ICU.
387 if test "$U_DEFAULT_SHOW_DRAFT" = 0; then
388     CONFIG_CPPFLAGS="$CONFIG_CPPFLAGS -DU_SHOW_DRAFT_API -DU_SHOW_INTERNAL_API"
390 AC_SUBST(U_DEFAULT_SHOW_DRAFT)
392 AC_PROG_RANLIB
394 # need sed
395 AC_PROG_SED
397 # look for 'ar' the proper way
398 AC_CHECK_TOOL(AR, ar, false)
400 AC_MSG_CHECKING([whether to enable renaming of symbols])
401 enabled=yes
402 U_DISABLE_RENAMING=0
403 AC_ARG_ENABLE(renaming,
404     [  --enable-renaming       add a version suffix to symbols [default=yes]],
405     [ case "${enableval}" in
406              yes|"") enabled=yes ;;
407              no) enabled=no; U_DISABLE_RENAMING=1;
408              UCONFIG_CPPFLAGS="${UCONFIG_CPPFLAGS} -DU_DISABLE_RENAMING=1"
409               ;;
410              *) ;;
411     esac],
413 AC_MSG_RESULT($enabled)
414 AC_SUBST(U_DISABLE_RENAMING)
416 AC_MSG_CHECKING([whether to enable function and data tracing])
417 enabled=no
418 U_ENABLE_TRACING=0
419 AC_ARG_ENABLE(tracing,
420     [  --enable-tracing        enable function and data tracing [default=no]],
421     [ case "${enableval}" in
422              yes|"") enabled=yes;
423                      CONFIG_CPPFLAGS="$CONFIG_CPPFLAGS -DU_ENABLE_TRACING=1";
424                      U_ENABLE_TRACING=1 ;;
425              no) enabled=no; U_ENABLE_TRACING=0 ;;
426              *) ;;
427     esac],
429 AC_MSG_RESULT($enabled)
430 AC_SUBST(U_ENABLE_TRACING)
432 # check if elf.h is present.
433 AC_CHECK_HEADERS([elf.h])
434 if test "x$ac_cv_header_elf_h" = "xyes"; then
435     CONFIG_CPPFLAGS="$CONFIG_CPPFLAGS -DU_HAVE_ELF_H=1";
438 # Enable/disable plugins
439 AC_ARG_ENABLE(plugins,
440         [  --enable-plugins        enable plugins [default=no]],
441         [case "${enableval}" in
442                 yes) plugins=true ;;
443                 no)  plugins=false ;;
444                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-plugins) ;;
445                 esac],
446         plugins=false)
447 ICU_CONDITIONAL(PLUGINS, test "$plugins" = true)
449 if test "x$plugins" = "xtrue"; then
450    UCONFIG_CPPFLAGS="$UCONFIG_CPPFLAGS -DUCONFIG_ENABLE_PLUGINS=1"
454 U_ENABLE_DYLOAD=1
455 enable=yes
456 AC_MSG_CHECKING([whether to enable dynamic loading of plugins. Ignored if plugins disabled.])
457 AC_ARG_ENABLE(dyload,
458     [  --disable-dyload        disable dynamic loading [default=no]],
459     [ case "${enableval}" in
460              yes|"")
461                      U_ENABLE_DYLOAD=1
462                      enable=yes
463                      ;;
464              no)
465                  U_ENABLE_DYLOAD=0;
466                  enable=no;
467                  CONFIG_CPPFLAGS="$CONFIG_CPPFLAGS -DU_ENABLE_DYLOAD=0";
468                  ;;
469              *) ;;
470     esac],
472 AC_MSG_RESULT($enable)
473 AC_SUBST(U_ENABLE_DYLOAD)
475 if test "$enable" = "yes"; then
476    AC_CHECK_HEADERS([dlfcn.h])
477    #AC_MSG_RESULT($enabled)
478    AC_SEARCH_LIBS([dlopen], [dl])
479    AC_CHECK_FUNCS([dlopen])
481    if test "x$ac_cv_func_dlopen" != xyes; then
482       CONFIG_CPPFLAGS="$CONFIG_CPPFLAGS -DHAVE_DLOPEN=0"
483    fi
486 # Check for miscellaneous functions.
487 # So, use for putil / tools only.
488 # Note that this will generate HAVE_GETTIMEOFDAY, not U_HAVE_GETTIMEOFDAY
489 AC_CHECK_FUNCS([gettimeofday])
492 # Check whether to use the evil rpath or not
493 AC_ARG_ENABLE(rpath,
494     [  --enable-rpath          use rpath when linking [default is only if necessary]],
495     [ case "${enableval}" in
496              yes|"") ENABLE_RPATH=YES ;;
497              no) ;;
498              *) ;;
499     esac],
500     [ENABLE_RPATH=NO]
502 AC_SUBST(ENABLE_RPATH)
506 AC_LANG_PUSH([C++])
507 AC_MSG_CHECKING([[if we have a C++ compiler]])
508 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[cxx_okay=yes],[cxx_okay=no])
509 if test $cxx_okay = yes
510 then
511         AC_MSG_RESULT([[Good]])
512 else
513         AC_MSG_RESULT([[no]])
514         AC_MSG_ERROR([[C++ compiler $CXX does not work or no compiler found]])
517 if [[ "$GXX" = yes ]]; then
518     # if CXXFLAGS does not have a "-std=" setting, set it now to -std=c++11,
519     # and check that the compiler still works.
520     if ! echo "$CXXFLAGS" | grep '\-std=' >/dev/null 2>&1; then
521         OLD_CXXFLAGS="${CXXFLAGS}"
522         CXXFLAGS="$CXXFLAGS -std=c++11"
523         AC_MSG_CHECKING([[if we have a C++11 compiler]])
524         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[cxx11_okay=yes],[cxx11_okay=no])
525         AC_MSG_RESULT($cxx11_okay)
526         if [[ $cxx11_okay = yes ]]; then
527             AC_MSG_NOTICE([Adding CXXFLAGS option -std=c++11])
528             UCONFIG_CXXFLAGS="${UCONFIG_CXXFLAGS} -std=c++11"
529         else
530             CXXFLAGS="$OLD_CXXFLAGS"
531         fi
532     fi
535 AC_LANG_POP([C++])
537 # Always build ICU with multi-threading support.
538 OLD_LIBS=${LIBS}
540 # For Compaq Tru64 (OSF1), we must look for pthread_attr_init
541 # and must do this before searching for pthread_mutex_destroy, or
542 # we will pick up libpthreads.so not libpthread.so
543 # If this fails, then we must test for HPUX specials, before
544 # moving on to a more generic test
546 AC_CHECK_LIB(pthread, pthread_attr_init)
547 if test $ac_cv_lib_pthread_pthread_attr_init = yes; then
548   :
549 else
550   # Locate the right library for POSIX threads. We look for the
551   # symbols in the libraries first, because on Solaris libc provides
552   # pthread_create but libpthread has the real code :(
553   # AIX uses libpthreads instead of libpthread, and HP/UX uses libpthread
554   # FreeBSD users may need libpthread if they do not have libc_r.
556   AC_SEARCH_LIBS_FIRST(pthread_mutex_destroy, pthread pthreads c_r )
558   if test "$ac_cv_search_pthread_mutex_destroy" != no; then
559     :
560   else
561     # For HP 11
562     AC_CHECK_LIB(pthread, pthread_mutex_init)
563     if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then
564       :
565     fi
566   fi
568   AC_CHECK_FUNC(pthread_mutex_lock)
570   if test $ac_cv_func_pthread_mutex_lock = yes; then
571     :
572   fi
574 # Check to see if we are using CygWin with MSVC
575 case "${host}" in
576 *-pc-cygwin*|*-pc-mingw*)
577   # For gcc, the thread options are set by mh-mingw/mh-cygwin
578   # For msvc, the thread options are set by runConfigureICU
579   :
580   ;;
581 *-*-hpux*)
582   # Add -mt because it does several nice things on newer compilers.
583   case "${icu_cv_host_frag}" in
584     mh-hpux-acc)
585       OLD_CXXFLAGS="${CXXFLAGS}"
586       CXXFLAGS="${CXXFLAGS} -mt"
587       if test x"`${CXX} ${CXXFLAGS} 2>&1`" != x""; then
588          CXXFLAGS="${OLD_CXXFLAGS}"
589       else
590          UCONFIG_CXXFLAGS="${UCONFIG_CXXFLAGS} -mt"
591       fi
592     ;;
593   esac
594   ;;
595 *-*-solaris*)
596   case "${icu_cv_host_frag}" in
597     mh-solaris)
598          LIBS="${LIBS} -mt"
599     ;;
600   esac
601   ;;
602 esac
604 AC_ARG_ENABLE(weak-threads,
605         [  --enable-weak-threads   weakly reference the threading library [default=no]],
606         [case "${enableval}" in
607                 yes)
608             LIB_THREAD="${LIBS%${OLD_LIBS}}"
609             LIBS=${OLD_LIBS}
610             ;;
611                 no)  ;;
612                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-weak-threads) ;;
613                 esac])
614 AC_SUBST(LIB_THREAD)
616 # Check for mmap()
618 # The AC_FUNC_MMAP macro doesn't work properly.  It seems to be too specific.
619 # Do this check instead.
620 HAVE_MMAP=0
621 AC_MSG_CHECKING([for mmap])
622 AC_CACHE_VAL(ac_cv_func_mmap_ok,
623     [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>
624 #include <sys/mman.h>
625 #include <sys/stat.h>
626 #include <fcntl.h>], [mmap((void *)0, 0, PROT_READ, 0, 0, 0);])],[ac_cv_func_mmap_ok=yes],[ac_cv_func_mmap_ok=no])] )
627 AC_MSG_RESULT($ac_cv_func_mmap_ok)
628 if test $ac_cv_func_mmap_ok = yes
629 then
630     HAVE_MMAP=1
631 else
632     CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_MMAP=0"
634 AC_SUBST(HAVE_MMAP)
636 AC_MSG_CHECKING([for genccode assembly])
638 # Check to see if genccode can generate simple assembly.
639 GENCCODE_ASSEMBLY=
640 case "${host}" in
641 *-linux*|*-kfreebsd*-gnu*|i*86-*-*bsd*|i*86-pc-gnu)
642     if test "$GCC" = yes; then
643         # We're using gcc, and the simple -a gcc command line works for genccode
644         GENCCODE_ASSEMBLY="-a gcc"
645     fi ;;
646 i*86-*-solaris*)
647     if test "$GCC" = yes; then
648         # When using gcc, look if we're also using GNU as.
649         # When using GNU as, the simple -a gcc command line works for genccode.
650         asv=`"${CC}" -print-prog-name=as 2>/dev/null`
651         asv=`"${asv}" --version 2>/dev/null`
652         case "X${asv}" in
653         X*GNU*) GENCCODE_ASSEMBLY="-a gcc" ;;
654         X*) GENCCODE_ASSEMBLY="-a sun-x86" ;;
655         esac
656         unset asv
657     else
658         GENCCODE_ASSEMBLY="-a sun-x86"
659     fi ;;
660 sparc-*-solaris*)
661     GENCCODE_ASSEMBLY="-a sun"
662     ;;
663 ia64-*-hpux*)
664 # There has been some issues with building ICU data on HPUX ia64 aCC
665 # when using the assemble code setting below.  For now, build without
666 # assemble code for this platform.  This will increase the build time.   
667 #    GENCCODE_ASSEMBLY="-a aCC-ia64"
668     ;;
669 esac
670 AC_SUBST(GENCCODE_ASSEMBLY)
672 AC_MSG_RESULT($GENCCODE_ASSEMBLY)
674 # Checks for header files
675 AC_CHECK_HEADERS(inttypes.h)
676 if test $ac_cv_header_inttypes_h = no; then
677  U_HAVE_INTTYPES_H=0
678  CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_INTTYPES_H=0"
679 else
680  U_HAVE_INTTYPES_H=1
682 if test "$CC" = ccc; then
683  AC_MSG_RESULT("C compiler set to CCC ${CC}" )
684  case "${host}" in
685         alpha*-*-*) U_HAVE_INTTYPES_H=0;
686         CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_INTTYPES_H=0"
687  esac
690 AC_SUBST(U_HAVE_INTTYPES_H)
692 AC_CHECK_HEADERS(dirent.h)
693 if test $ac_cv_header_dirent_h = no; then
694  U_HAVE_DIRENT_H=0
695  CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_DIRENT_H=0"
696 else
697  U_HAVE_DIRENT_H=1
700 AC_SUBST(U_HAVE_DIRENT_H)
702 # Check for endianness
703 AC_C_BIGENDIAN()
704 if test $ac_cv_c_bigendian = no; then
705 U_IS_BIG_ENDIAN=0
706 U_ENDIAN_CHAR="l"
707 else
708 U_IS_BIG_ENDIAN=1
709 U_ENDIAN_CHAR="b"
711 AC_SUBST(U_IS_BIG_ENDIAN)
713 # Do various POSIX related checks
714 U_HAVE_NL_LANGINFO_CODESET=0
715 U_NL_LANGINFO_CODESET=-1
716 AC_CHECK_FUNC(nl_langinfo,[U_HAVE_NL_LANGINFO=1],[U_HAVE_NL_LANGINFO=0])
717 dnl AC_SUBST(U_HAVE_NL_LANGINFO)
718 if test $U_HAVE_NL_LANGINFO -eq 1; then
719   AC_CACHE_CHECK([for nl_langinfo's argument to obtain the codeset],
720   ac_cv_nl_langinfo_codeset,
721   [ac_cv_nl_langinfo_codeset="unknown"
722   for a in CODESET _NL_CTYPE_CODESET_NAME; do
723   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]], [[nl_langinfo($a);]])],[ac_cv_nl_langinfo_codeset="$a"; break],[])]
724   done)
725   if test x$ac_cv_nl_langinfo_codeset != xunknown
726   then
727       U_HAVE_NL_LANGINFO_CODESET=1
728       U_NL_LANGINFO_CODESET=$ac_cv_nl_langinfo_codeset
729       if test "x${ac_cv_nl_langinfo_codeset}" != "xCODESET"
730       then
731         CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DNL_LANGINFO_CODESET=${ac_cv_nl_langinfo_codeset}"
732       fi
733   else
734       CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_NL_LANGINFO_CODESET=0"
735   fi
737 AC_SUBST(U_HAVE_NL_LANGINFO_CODESET)
738 AC_SUBST(U_NL_LANGINFO_CODESET)
740 # Namespace support checks
741 AC_LANG(C++)
742 AC_MSG_CHECKING([for namespace support])
743 AC_CACHE_VAL(ac_cv_namespace_ok,
744     [AC_LINK_IFELSE([AC_LANG_PROGRAM([namespace x_version {void f(){}}
745     namespace x = x_version;
746     using namespace x_version;
747     ], [f();])],[ac_cv_namespace_ok=yes],[ac_cv_namespace_ok=no])] )
748 AC_MSG_RESULT($ac_cv_namespace_ok)
749 if test $ac_cv_namespace_ok = no
750 then
751     AC_MSG_ERROR(Namespace support is required to build ICU.)
754 AC_MSG_CHECKING([for properly overriding new and delete])
755 U_OVERRIDE_CXX_ALLOCATION=0
756 U_HAVE_PLACEMENT_NEW=0
757 AC_CACHE_VAL(ac_cv_override_cxx_allocation_ok,
758     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
759     class UMemory {
760     public:
761     void *operator new(size_t size) {return malloc(size);}
762     void *operator new[](size_t size) {return malloc(size);}
763     void operator delete(void *p) {free(p);}
764     void operator delete[](void *p) {free(p);}
765     };
766     ]], [])],[ac_cv_override_cxx_allocation_ok=yes],[ac_cv_override_cxx_allocation_ok=no])] )
767 AC_MSG_RESULT($ac_cv_override_cxx_allocation_ok)
768 if test $ac_cv_override_cxx_allocation_ok = yes
769 then
770     U_OVERRIDE_CXX_ALLOCATION=1
771     AC_MSG_CHECKING([for placement new and delete])
772     AC_CACHE_VAL(ac_cv_override_placement_new_ok,
773         [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
774         class UMemory {
775         public:
776         void *operator new(size_t size) {return malloc(size);}
777         void *operator new[](size_t size) {return malloc(size);}
778         void operator delete(void *p) {free(p);}
779         void operator delete[](void *p) {free(p);}
780         void * operator new(size_t, void *ptr) { return ptr; }
781         void operator delete(void *, void *) {}
782         };
783         ]], [])],[ac_cv_override_placement_new_ok=yes],[ac_cv_override_placement_new_ok=no])] )
784     AC_MSG_RESULT($ac_cv_override_placement_new_ok)
785     if test $ac_cv_override_placement_new_ok = yes
786     then
787         U_HAVE_PLACEMENT_NEW=1
788     else
789         CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_PLACEMENT_NEW=0"
790     fi
791 else
792     CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_OVERRIDE_CXX_ALLOCATION=0"
794 AC_SUBST(U_OVERRIDE_CXX_ALLOCATION)
795 AC_SUBST(U_HAVE_PLACEMENT_NEW)
797 AC_LANG(C)
798 AC_CHECK_FUNC(popen)
799 if test x$ac_cv_func_popen = xyes
800 then
801      U_HAVE_POPEN=1
802 else
803      CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_POPEN=0"
804      U_HAVE_POPEN=0
806 AC_SUBST(U_HAVE_POPEN)
808 AC_CHECK_FUNC(tzset)
809 U_HAVE_TZSET=0
810 if test x$ac_cv_func_tzset = xyes
811 then
812     U_TZSET=tzset
813     U_HAVE_TZSET=1
814 else
815     AC_CHECK_FUNC(_tzset)
816     if test x$ac_cv_func__tzset = xyes
817     then
818         U_TZSET=_tzset
819         U_HAVE_TZSET=1
820     else
821       CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_TZSET=0"
822     fi
824 AC_SUBST(U_HAVE_TZSET)
825 AC_SUBST(U_TZSET)
827 U_HAVE_TZNAME=0
828 AC_CACHE_CHECK(for tzname,ac_cv_var_tzname,
829 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#ifndef _XOPEN_SOURCE
830 #define _XOPEN_SOURCE
831 #endif
832 #include <stdlib.h>
833 #include <time.h>
834 #ifndef tzname /* For SGI.  */
835 extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
836 #endif]], [atoi(*tzname);])],[ac_cv_var_tzname=yes],[ac_cv_var_tzname=no])])
837 if test $ac_cv_var_tzname = yes; then
838   U_TZNAME=tzname
839   U_HAVE_TZNAME=1
840 else
841   AC_CACHE_CHECK(for _tzname,ac_cv_var__tzname,
842   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
843   #include <time.h>
844   extern char *_tzname[];]], [atoi(*_tzname);])],[ac_cv_var__tzname=yes],[ac_cv_var__tzname=no])])
845     if test $ac_cv_var__tzname = yes; then
846       U_TZNAME=_tzname
847       U_HAVE_TZNAME=1
848     else
849      CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_TZNAME=0"
850     fi
852 AC_SUBST(U_HAVE_TZNAME)
853 AC_SUBST(U_TZNAME)
855 AC_CACHE_CHECK(for timezone,ac_cv_var_timezone,
856 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#ifndef _XOPEN_SOURCE
857 #define _XOPEN_SOURCE
858 #endif
859 #include <time.h>
860 ], [[timezone = 1;]])],[ac_cv_var_timezone=yes],[ac_cv_var_timezone=no])])
861 U_HAVE_TIMEZONE=0
862 if test $ac_cv_var_timezone = yes; then
863   U_TIMEZONE=timezone
864   U_HAVE_TIMEZONE=1
865 else
866   AC_CACHE_CHECK(for __timezone,ac_cv_var___timezone,
867   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[__timezone = 1;]])],[ac_cv_var___timezone=yes],[ac_cv_var___timezone=no])])
868   if test $ac_cv_var___timezone = yes; then
869     U_TIMEZONE=__timezone
870     U_HAVE_TIMEZONE=1
871   else
872     AC_CACHE_CHECK(for _timezone,ac_cv_var__timezone,
873     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[_timezone = 1;]])],[ac_cv_var__timezone=yes],[ac_cv_var__timezone=no])])
874     if test $ac_cv_var__timezone = yes; then
875       U_TIMEZONE=_timezone
876       U_HAVE_TIMEZONE=1
877     else
878      CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_TIMEZONE=0"
879     fi
880   fi
882 AC_SUBST(U_HAVE_TIMEZONE)
883 AC_SUBST(U_TIMEZONE)
885 AC_CHECK_FUNC(strtod_l)
886 if test x$ac_cv_func_strtod_l = xyes
887 then
888     U_HAVE_STRTOD_L=1
889     AC_CHECK_HEADER(xlocale.h)
890     if test "$ac_cv_header_xlocale_h" = yes; then
891       U_HAVE_XLOCALE_H=1
892       CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_STRTOD_L=1 -DU_HAVE_XLOCALE_H=1"
893     else
894       U_HAVE_XLOCALE_H=0
895       CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_STRTOD_L=1 -DU_HAVE_XLOCALE_H=0"
896     fi
897 else
898     CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_STRTOD_L=0"
899     U_HAVE_STRTOD_L=0
901 AC_SUBST(U_HAVE_STRTOD_L)
903 # Check if C++17 std::string_view is available.
904 AC_LANG_PUSH([C++])
905 AC_CHECK_TYPE(std::string_view, [], [], [[#include <string_view>]])
906 if test "x$ac_cv_type_std__string_view" = xyes; then :
907   CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_STRING_VIEW=1"
909 AC_LANG_POP([C++])
911 # Checks for typedefs
912 AC_CHECK_TYPE(int8_t,signed char)
913 AC_CHECK_TYPE(uint8_t,unsigned char)
914 AC_CHECK_TYPE(int16_t,signed short)
915 AC_CHECK_TYPE(uint16_t,unsigned short)
916 AC_CHECK_TYPE(int32_t,signed long)
917 AC_CHECK_TYPE(uint32_t,unsigned long)
918 AC_CHECK_TYPE(int64_t,signed long long)
919 AC_CHECK_TYPE(uint64_t,unsigned long long)
921 if test $ac_cv_type_int8_t = no; then
922 CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_INT8_T=0"
925 if test $ac_cv_type_uint8_t = no; then
926 CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_UINT8_T=0"
929 if test $ac_cv_type_int16_t = no; then
930 CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_INT16_T=0"
933 if test $ac_cv_type_uint16_t = no; then
934 CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_UINT16_T=0"
937 if test $ac_cv_type_int32_t = no; then
938 CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_INT32_T=0"
941 if test $ac_cv_type_uint32_t = no; then
942 CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_UINT32_T=0"
945 if test $ac_cv_type_int64_t = no; then
946 CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_INT64_T=0"
949 if test $ac_cv_type_uint64_t = no; then
950 CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_UINT64_T=0"
953 # Do various wchar_t related checks
954 AC_CHECK_HEADER(wchar.h)
955 if test "$ac_cv_header_wchar_h" = no
956 then
957     U_HAVE_WCHAR_H=0
958     U_HAVE_WCSCPY=0
959     CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_WCHAR_H=0 -DU_HAVE_WCSCPY=0"
960 else
961     AC_DEFINE([HAVE_WCHAR_H], [1], [wchar.h was found.])
962     U_HAVE_WCHAR_H=1
963     # Some broken systems have wchar.h but not some of its functions...
964     AC_SEARCH_LIBS(wcscpy, wcs w)
965     if test "$ac_cv_search_wcscpy" != no; then
966       U_HAVE_WCSCPY=1
967     else
968       U_HAVE_WCSCPY=0
969       CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_WCSCPY=0"
970     fi
972 AC_SUBST(U_HAVE_WCHAR_H)
973 AC_SUBST(U_HAVE_WCSCPY)
975 AC_CHECK_SIZEOF([wchar_t], 0, [
976 #if STDC_HEADERS
977 #include <stddef.h>
978 #endif
979 #include <stdlib.h>
980 #if HAVE_WCHAR_H
981 #include <string.h>
982 #include <wchar.h>
983 #endif])
984 U_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t
985 # We do this check to verify that everything is okay.
986 if test $U_SIZEOF_WCHAR_T = 0; then
987     if test $U_HAVE_WCHAR_H=1; then
988        AC_MSG_ERROR(There is wchar.h but the size of wchar_t is 0)
989     fi
992 AC_MSG_CHECKING([for UTF-16 string literal support])
993 U_CHECK_UTF16_STRING=1
994 CHECK_UTF16_STRING_RESULT="unknown"
996 case "${host}" in
997 *-*-aix*|powerpc64-*-linux*)
998     if test "$GCC" = no; then
999         OLD_CFLAGS="${CFLAGS}"
1000         OLD_CXXFLAGS="${CXXFLAGS}"
1001         CFLAGS="${CFLAGS} -qutf"
1002         CXXFLAGS="${CXXFLAGS} -qutf"
1003         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[const unsigned short hello[] = u"hello";]], [[]])],[U_CHECK_UTF16_STRING=1],[U_CHECK_UTF16_STRING=0])
1004         if test "$U_CHECK_UTF16_STRING" = 0; then
1005             CFLAGS="${OLD_CFLAGS}"
1006             CXXFLAGS="${OLD_CXXFLAGS}"
1007         else
1008             UCONFIG_CXXFLAGS="${UCONFIG_CXXFLAGS} -qutf"
1009             CHECK_UTF16_STRING_RESULT="-qutf"
1010         fi
1011     fi
1012     ;;
1013 *-*-solaris*)
1014     if test "$GCC" = no; then
1015         OLD_CFLAGS="${CFLAGS}"
1016         OLD_CXXFLAGS="${CXXFLAGS}"
1017         CFLAGS="${CFLAGS} -xustr=ascii_utf16_ushort"
1018         CXXFLAGS="${CXXFLAGS} -xustr=ascii_utf16_ushort"
1019         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[const unsigned short hello[] = U"hello";]], [[]])],[U_CHECK_UTF16_STRING=1],[U_CHECK_UTF16_STRING=0])
1020         if test "$U_CHECK_UTF16_STRING" = 0; then
1021             CFLAGS="${OLD_CFLAGS}"
1022             CXXFLAGS="${OLD_CXXFLAGS}"
1023         else
1024             CHECK_UTF16_STRING_RESULT="-xustr=ascii_utf16_ushort"
1025             UCONFIG_CXXFLAGS="${UCONFIG_CXXFLAGS} -xustr=ascii_utf16_ushort"
1026             UCONFIG_CFLAGS="${UCONFIG_CFLAGS} -xustr=ascii_utf16_ushort"
1027             # Since we can't detect the availability of this UTF-16 syntax at compile time,
1028             # we depend on configure telling us that we can use it.
1029             # Since we can't ensure ICU users use -xustr=ascii_utf16_ushort,
1030             # we only use this macro within ICU.
1031             # If an ICU user uses icu-config, this feature will be enabled.
1032             CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_CHECK_UTF16_STRING=1"
1033             U_CHECK_UTF16_STRING=0
1034         fi
1035     fi
1036     ;;
1037 *-*-hpux*)
1038     if test "$GCC" = no; then
1039         # The option will be detected at compile time without additional compiler options.
1040         CHECK_UTF16_STRING_RESULT="available"
1041     fi
1042     ;;
1043 *-*-cygwin)
1044     # wchar_t can be used
1045     CHECK_UTF16_STRING_RESULT="available"
1046     ;;
1048     ;;
1049 esac
1051 # GCC >= 4.4 supports UTF16 string literals. As of ICU 62, both C and C++ files require them.
1052 if test "$CHECK_UTF16_STRING_RESULT" = "unknown"; then
1053     if test "$GCC" = yes; then
1054         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1055 static const unsigned short test[] = u"This is a UTF16 literal string.";
1056         ]], [[]])],[CC_UTF16_STRING=1],[CC_UTF16_STRING=0])
1057         if test "$CC_UTF16_STRING" = 1; then
1058             CHECK_UTF16_STRING_RESULT="C only";
1059         fi
1060     fi
1061     if test "$GXX" = yes; then
1062         # -Wno-return-type-c-linkage is desired so that stable ICU API is not warned about.
1063         AC_LANG_PUSH([C++])
1064         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1065 static const char16_t test[] = u"This is a UTF16 literal string.";
1066         ]], [[]])],[CXX_UTF16_STRING=1],[CXX_UTF16_STRING=0])
1067         AC_LANG_POP([C++])
1068         if test "$CXX_UTF16_STRING" = 1; then
1069             if test "$CC_UTF16_STRING" = 1; then
1070                 CHECK_UTF16_STRING_RESULT="available";
1071             else
1072                 CHECK_UTF16_STRING_RESULT="C++ only";
1073             fi
1074         fi
1075     fi
1077 AC_MSG_RESULT($CHECK_UTF16_STRING_RESULT)
1079 # Enable/disable extras
1080 AC_ARG_ENABLE(extras,
1081         [  --enable-extras         build ICU extras [default=yes]],
1082         [case "${enableval}" in
1083                 yes) extras=true ;;
1084                 no)  extras=false ;;
1085                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-extras) ;;
1086                 esac],
1087         extras=true)
1088 ICU_CONDITIONAL(EXTRAS, test "$extras" = true)
1089 AC_ARG_ENABLE(icuio,
1090         [  --enable-icuio          build ICU's icuio library [default=yes]],
1091         [case "${enableval}" in
1092                 yes) icuio=true ;;
1093                 no)  icuio=false ;;
1094                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-icuio) ;;
1095                 esac],
1096         icuio=true)
1097 ICU_CONDITIONAL(ICUIO, test "$icuio" = true)
1099 # Enable/disable layoutex
1100 AC_ARG_ENABLE(layoutex,
1101         [  --enable-layoutex         build ICU's Paragraph Layout library [default=no].
1102             icu-le-hb must be installed via pkg-config. See http://harfbuzz.org],
1103         [case "${enableval}" in
1104                 yes) layoutex=$have_icu_le_hb ;;
1105                 no)  layoutex=false ;;
1106                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-layoutex) ;;
1107                 esac],
1108         layoutex=false)
1109 ICU_CONDITIONAL(LAYOUTEX, test "$layoutex" = true)
1111 # Enable/disable layout
1112 AC_ARG_ENABLE(layout,
1113         [],
1114         [case "${enableval}" in
1115                 yes) AC_MSG_ERROR(The ICU Layout Engine has been removed.) ;;
1116                 no)   ;;
1117                 *) ;;
1118                 esac],
1119         )
1121 # Enable/disable tools
1122 AC_ARG_ENABLE(tools,
1123         [  --enable-tools         build ICU's tools [default=yes]],
1124         [case "${enableval}" in
1125                 yes) tools=true ;;
1126                 no)  tools=false ;;
1127                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-tools) ;;
1128                 esac],
1129         tools=true)
1130 ICU_CONDITIONAL(TOOLS, test "$tools" = true)
1132 # Enable/disable fuzzer target tests.
1133 AC_ARG_ENABLE(fuzzer,
1134         [  --enable-fuzzer        build ICU's fuzzer test targets [default=no]],
1135         [case "${enableval}" in
1136                 yes) fuzzer=true ;;
1137                 no)  fuzzer=false ;;
1138                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-fuzzer) ;;
1139                 esac],
1140         fuzzer=false)
1141 ICU_CONDITIONAL(FUZZER, test "$fuzzer" = true)
1143 ICU_CONDITIONAL(DATA, test "$tools" = true || test "$cross_compiling" = "yes")
1145 AC_ARG_WITH(data-packaging,
1146         [  --with-data-packaging     specify how to package ICU data. Possible values:
1147         files    raw files (.res, etc)
1148         archive  build a single icudtXX.dat file
1149         library  shared library (.dll/.so/etc.)
1150         static   static library (.a/.lib/etc.)
1151         auto     build shared if possible (default)
1152            See https://unicode-org.github.io/icu/userguide/icu_data for more info.],
1153         [case "${withval}" in
1154                 files|archive|library) datapackaging=$withval ;;
1155                 auto) datapackaging=$withval ;;
1156                 common) datapackaging=archive ;;
1157                 dll) datapackaging=library ;;
1158                 static) datapackaging=static ;;
1159                 *) AC_MSG_ERROR(bad value ${withval} for --with-data-packaging) ;;
1160                 esac],
1161         [datapackaging=])
1163 # Note:  'thesysconfdir' is an evaluated version, for Man pages, so also for thedatadir, thelibdir, etc..
1164 # thesysconfdir=`eval echo $sysconfdir`
1165 dnl# AC_SUBST(thesysconfdir)
1166 dnl# thelibdir=`test "x$exec_prefix" = xNONE && exec_prefix="$prefix"; eval echo $libdir`
1167 dnl# AC_SUBST(thelibdir)
1168 thedatadir=`eval echo $datadir`
1169 dnl# AC_SUBST(thedatadir)
1170 # Always put raw data files in share/icu/{version}, etc.   Never use lib/icu/{version} for data files.. Actual shared libraries will go in {libdir}.
1171 pkgicudatadir=$datadir
1172 thepkgicudatadir=$thedatadir
1173 AC_SUBST(pkgicudatadir)
1174 AC_SUBST(thepkgicudatadir)
1176 dnl# Shouldn't need the AC_SUBST
1178 if test x"$datapackaging" = x -o x"$datapackaging" = xauto; then
1179         # default to library
1180         datapackaging=library
1181         if test "$ENABLE_STATIC" = "YES"; then
1182                 if test "$ENABLE_SHARED" != "YES"; then
1183                         datapackaging=static
1184                 fi
1185         fi
1188 datapackaging_dir=`eval echo $thedatadir`"/icu/${VERSION}"
1190 datapackaging_msg="(No explanation for mode $datapackaging.)"
1192 datapackaging_msg_path="ICU will look in $datapackaging_dir which is the installation location. Call u_setDataDirectory() or use the ICU_DATA environment variable to override."
1193 datapackaging_msg_set="ICU will use the linked data library. If linked with the stub library located in stubdata/, the application can use udata_setCommonData() or set a data path to override."
1194 datapackaging_howfound="(unknown)"
1196 case "$datapackaging" in
1197     files)
1198     DATA_PACKAGING_MODE=files
1199     datapackaging_msg="ICU data will be stored in individual files."
1200     datapackaging_howfound="$datapackaging_msg_path"
1201     ;;
1202     archive)
1203     DATA_PACKAGING_MODE=common
1204     datapackaging_msg="ICU data will be stored in a single .dat file."
1205     datapackaging_howfound="$datapackaging_msg_path"
1206     ;;
1207     library)
1208     DATA_PACKAGING_MODE=dll
1209     datapackaging_msg="ICU data will be linked with ICU."
1210     if test "$ENABLE_STATIC" = "YES"; then
1211         datapackaging_msg="$datapackaging_msg A static data library will be built. "
1212     fi
1213     if test "$ENABLE_SHARED" = "YES"; then
1214         datapackaging_msg="$datapackaging_msg A shared data library will be built. "
1215     fi
1216     datapackaging_howfound="$datapackaging_msg_set"
1217     ;;
1218     static)
1219     DATA_PACKAGING_MODE=static
1220     datapackaging_msg="ICU data will be stored in a static library."
1221     datapackaging_howfound="$datapackaging_msg_set"
1222     ;;
1223 esac
1224 AC_SUBST(DATA_PACKAGING_MODE)
1226 # Sets a library suffix
1227 AC_MSG_CHECKING([for a library suffix to use])
1228 AC_ARG_WITH(library-suffix,
1229         [  --with-library-suffix=suffix    tag a suffix to the library names [default=]],
1230         [ICULIBSUFFIX="${withval}"],
1231         [ICULIBSUFFIX=])
1232 msg=$ICULIBSUFFIX
1233 if test "$msg" = ""; then
1234     msg=none
1236 AC_MSG_RESULT($msg)
1237 AC_SUBST(ICULIBSUFFIX)
1238 if test "$ICULIBSUFFIX" != ""
1239 then
1240     U_HAVE_LIB_SUFFIX=1
1241     ICULIBSUFFIXCNAME=`echo _$ICULIBSUFFIX | sed 's/[^A-Za-z0-9_]/_/g'`
1242     UCONFIG_CPPFLAGS="${UCONFIG_CPPFLAGS} -DU_HAVE_LIB_SUFFIX=1 -DU_LIB_SUFFIX_C_NAME=${ICULIBSUFFIXCNAME} "
1243 else
1244     U_HAVE_LIB_SUFFIX=0
1246 AC_SUBST(U_HAVE_LIB_SUFFIX)
1247 AC_SUBST(ICULIBSUFFIXCNAME)
1249 # Enable/disable tests
1250 AC_ARG_ENABLE(tests,
1251         [  --enable-tests          build ICU tests [default=yes]],
1252         [case "${enableval}" in
1253                 yes) tests=true ;;
1254                 no)  tests=false ;;
1255                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
1256                 esac],
1257         tests=true)
1258 ICU_CONDITIONAL(TESTS, test "$tests" = true)
1260 # Enable/disable samples
1261 AC_ARG_ENABLE(samples,
1262         [  --enable-samples        build ICU samples [default=yes]
1264 Additionally, the variable FORCE_LIBS may be set before calling configure.
1265 If set, it will REPLACE any automatic list of libraries.],
1266         [case "${enableval}" in
1267                 yes) samples=true ;;
1268                 no)  samples=false ;;
1269                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-samples) ;;
1270                 esac],
1271         samples=true)
1272 ICU_CONDITIONAL(SAMPLES, test "$samples" = true)
1274 ICUDATA_CHAR=$U_ENDIAN_CHAR
1276 # Platform-specific Makefile setup
1277 # set ICUDATA_CHAR to 'e' for any EBCDIC (which should be big endian) platform.
1278 case "${host}" in
1279         *-*-solaris*)   platform=U_SOLARIS ;;
1280         *-*-linux*|*-*-gnu|*-*-k*bsd*-gnu|*-*-kopensolaris*-gnu)        platform=U_LINUX ;;
1281         *-*-*bsd*|*-*-dragonfly*)       platform=U_BSD ;;
1282         *-*-aix*)       platform=U_AIX ;;
1283         *-*-hpux*)      platform=U_HPUX ;;
1284         *-apple-darwin*|*-apple-rhapsody*)      platform=U_DARWIN ;;
1285         *-*-cygwin*)    platform=U_CYGWIN ;;
1286         *-*-mingw*)     platform=U_MINGW ;;
1287         *-*ibm-openedition*|*-*-os390*) platform=OS390
1288                         if test "${ICU_ENABLE_ASCII_STRINGS}" != "1"; then
1289                                 ICUDATA_CHAR="e"
1290                         fi ;;
1291         *-*-os400*)     platform=OS400
1292                         if test "${ICU_ENABLE_ASCII_STRINGS}" != "1"; then
1293                                 ICUDATA_CHAR="e"
1294                         fi ;;
1295         *-*-nto*)       platform=U_QNX ;;
1296         *-dec-osf*)     platform=U_OSF ;;
1297         *-*-beos)               platform=U_BEOS ;;
1298         *-*-irix*)              platform=U_IRIX ;;
1299         *-ncr-*)                platform=U_MPRAS ;;
1300         *)              platform=U_UNKNOWN_PLATFORM ;;
1301 esac
1302 AC_SUBST(ICUDATA_CHAR)
1303 AC_SUBST(platform)
1304 platform_make_fragment_name="$icu_cv_host_frag"
1305 platform_make_fragment='$(top_srcdir)/config/'"$platform_make_fragment_name"
1306 AC_SUBST(platform_make_fragment_name)
1307 AC_SUBST(platform_make_fragment)
1309 if test "${FORCE_LIBS}" != ""; then
1310    echo " *** Overriding automatically chosen [LIBS=$LIBS], using instead [FORCE_LIBS=${FORCE_LIBS}]"  1>&6
1311    LIBS=${FORCE_LIBS}
1314 # Now that we're done using CPPFLAGS etc. for tests, we can change it
1315 # for build.
1317 AC_LANG_PUSH([C++])
1318 # Silence a Clang warning about ambiguous operators with C++20 rewritten
1319 # expressions that possibly or maybe even probably is a mistake (ICU-20973).
1320 AX_CHECK_COMPILE_FLAG(
1321   [-Wambiguous-reversed-operator],
1322   [CXXFLAGS+=" -Wno-ambiguous-reversed-operator"],
1323   [],
1324   [-Werror])
1325 AC_LANG_POP([C++])
1327 if test "${CC}" = "clang"; then
1328    CLANGCFLAGS="-Qunused-arguments -Wno-parentheses-equality"
1329 else
1330    CLANGCFLAGS=""
1333 if test "${CXX}" = "clang++"; then
1334    CLANGCXXFLAGS="-Qunused-arguments -Wno-parentheses-equality"
1335    LIBCXXFLAGS="$LIBCXXFLAGS -Wglobal-constructors"
1336 else
1337    CLANGCXXFLAGS=""
1340 CPPFLAGS="$CPPFLAGS \$(THREADSCPPFLAGS)"
1341 CFLAGS="$CFLAGS \$(THREADSCFLAGS) $CLANGCFLAGS"
1342 CXXFLAGS="$CXXFLAGS \$(THREADSCXXFLAGS) $CLANGCXXFLAGS"
1344 AC_SUBST(LIBCFLAGS)
1345 AC_SUBST(LIBCXXFLAGS)
1347 # append all config cppflags
1348 CPPFLAGS="$CPPFLAGS $CONFIG_CPPFLAGS $UCONFIG_CPPFLAGS"
1350 echo "CPPFLAGS=$CPPFLAGS"
1351 echo "CFLAGS=$CFLAGS"
1352 echo "CXXFLAGS=$CXXFLAGS"
1355 # output the Makefiles
1356 AC_CONFIG_FILES([icudefs.mk \
1357                 Makefile \
1358                 data/pkgdataMakefile \
1359                 config/Makefile.inc \
1360                 config/icu.pc \
1361                 config/pkgdataMakefile \
1362                 data/Makefile \
1363                 stubdata/Makefile \
1364                 common/Makefile \
1365                 i18n/Makefile \
1366                 layoutex/Makefile \
1367                 io/Makefile \
1368                 extra/Makefile \
1369                 extra/uconv/Makefile \
1370                 extra/uconv/pkgdataMakefile \
1371                 extra/scrptrun/Makefile \
1372                 tools/Makefile \
1373                 tools/ctestfw/Makefile \
1374                 tools/toolutil/Makefile \
1375                 tools/makeconv/Makefile \
1376                 tools/genrb/Makefile \
1377                 tools/genccode/Makefile \
1378                 tools/gencmn/Makefile \
1379                 tools/gencnval/Makefile \
1380                 tools/gendict/Makefile \
1381                 tools/gentest/Makefile \
1382                 tools/gennorm2/Makefile \
1383                 tools/genbrk/Makefile \
1384                 tools/gensprep/Makefile \
1385                 tools/icuinfo/Makefile \
1386                 tools/icupkg/Makefile \
1387                 tools/icuswap/Makefile \
1388                 tools/pkgdata/Makefile \
1389                 tools/icuexportdata/Makefile \
1390                 tools/tzcode/Makefile \
1391                 tools/gencfu/Makefile \
1392                 tools/escapesrc/Makefile \
1393                 test/Makefile \
1394                 test/compat/Makefile \
1395                 test/testdata/Makefile \
1396                 test/testdata/pkgdataMakefile \
1397                 test/hdrtst/Makefile \
1398                 test/intltest/Makefile \
1399                 test/cintltst/Makefile \
1400                 test/iotest/Makefile \
1401                 test/letest/Makefile \
1402                 test/perf/Makefile \
1403                 test/perf/collationperf/Makefile \
1404                 test/perf/collperf/Makefile \
1405                 test/perf/collperf2/Makefile \
1406                 test/perf/dicttrieperf/Makefile \
1407                 test/perf/ubrkperf/Makefile \
1408                 test/perf/charperf/Makefile \
1409                 test/perf/convperf/Makefile \
1410                 test/perf/localecanperf/Makefile \
1411                 test/perf/normperf/Makefile \
1412                 test/perf/DateFmtPerf/Makefile \
1413                 test/perf/howExpensiveIs/Makefile \
1414                 test/perf/strsrchperf/Makefile \
1415                 test/perf/unisetperf/Makefile \
1416                 test/perf/usetperf/Makefile \
1417                 test/perf/ustrperf/Makefile \
1418                 test/perf/utfperf/Makefile \
1419                 test/perf/utrie2perf/Makefile \
1420                 test/perf/leperf/Makefile \
1421                 test/fuzzer/Makefile \
1422                 samples/Makefile samples/date/Makefile \
1423                 samples/cal/Makefile samples/layout/Makefile])
1424 AC_OUTPUT
1426 if test -z "$PYTHON";
1427 then
1428     echo "" > data/rules.mk
1429     echo "" > test/testdata/rules.mk
1430 else
1431     if test -f "$srcdir/data/locales/root.txt";
1432     then
1433         echo "Spawning Python to generate data/rules.mk..."
1434         PYTHONPATH="$srcdir/python" \
1435             $PYTHON -m icutools.databuilder \
1436             --mode gnumake \
1437             --seqmode parallel \
1438             --src_dir "$srcdir/data" \
1439             --filter_file "$ICU_DATA_FILTER_FILE" \
1440             $ICU_DATA_BUILDTOOL_OPTS \
1441             > data/rules.mk
1442         if test "$?" != "0"; then
1443             AC_MSG_ERROR(Python failed to run; see above error.)
1444         fi
1445     else
1446       echo "Not rebuilding data/rules.mk, assuming prebuilt data in data/in"
1447       touch data/rules.mk
1448     fi
1449     echo "Spawning Python to generate test/testdata/rules.mk..."
1450     PYTHONPATH="$srcdir/python" \
1451         $PYTHON -m icutools.databuilder \
1452         --mode gnumake \
1453         --seqmode parallel \
1454         --src_dir "$srcdir/test/testdata" \
1455         > test/testdata/rules.mk
1456     if test "$?" != "0"; then
1457         AC_MSG_ERROR(Python failed to run; see above error.)
1458     fi
1461 echo
1462 echo "ICU for C/C++ $VERSION is ready to be built."
1463 echo "=== Important Notes: ==="
1465 echo "Data Packaging: $datapackaging"
1466 echo " This means: $datapackaging_msg"
1467 echo " To locate data: $datapackaging_howfound"
1469 if test -n "`$U_MAKE -v 2>&1 | grep '^GNU Make'`"; then
1470 echo "Building ICU: Use a GNU make such as $U_MAKE to build ICU."
1471 else
1472 echo "** WARNING: $U_MAKE may not be GNU make."
1473 echo "This may cause ICU to fail to build. Please make sure that GNU make"
1474 echo "is in your PATH so that the configure script can detect its location."
1476 if test "x$AR" = "xfalse"; then
1477   echo "*** WARNING: Archiver ar not found. Set AR= or fix PATH. Some builds (such as static) may fail."
1480 AC_MSG_CHECKING([the version of "$U_MAKE"])
1481 if "$U_MAKE" -f "$srcdir/config/gmakever.mk" PLATFORM="$platform"; then
1482 AC_MSG_RESULT([ok])
1483 else
1484 AC_MSG_RESULT([too old or test failed - try upgrading GNU Make])
1487 AC_SUBST(UCONFIG_CPPFLAGS)
1488 if test -n "$UCONFIG_CPPFLAGS"; then
1489    HDRFILE="uconfig.h.prepend"
1490    echo "*** WARNING: You must set the following flags before code compiled against this ICU will function properly:"
1491    echo
1492    echo "   ${UCONFIG_CPPFLAGS}"
1493    echo
1494    echo 'The recommended way to do this is to prepend the following lines to source/common/unicode/uconfig.h or #include them near the top of that file.'
1495    echo "Creating the file ${HDRFILE}"
1496    echo
1497    echo '---------------   ' "${HDRFILE}"
1498    echo > "${HDRFILE}"
1499    echo '/* ICU customizations: put these lines at the top of uconfig.h */' >> "${HDRFILE}"
1500    echo >> "${HDRFILE}"
1501    for flag in ${UCONFIG_CPPFLAGS};
1502    do
1503         echo " /* $flag */" >> "${HDRFILE}"
1504         case "${flag}" in
1505         -D*=*)
1506           [ \echo "${flag}" | sed -n 's%-D\([^=]*\)=%#define \1 %p' >> "${HDRFILE}" ]
1507           \echo >> "${HDRFILE}"
1508           ;;
1509         -D*)
1510           [ \echo "${flag}" | sed -n 's%-D\([^=]*\)%#define \1 %p' >> "${HDRFILE}" ]
1511           \echo >> "${HDRFILE}"
1512           ;;
1513         *)
1514           \echo "/*  Not sure how to handle this argument: ${flag} */" >> "${HDRFILE}"
1515           \echo >> "${HDRFILE}"
1516           ;;
1517         esac
1518    done
1519    cat "${HDRFILE}"
1520    \echo  "/* End of ${HDRFILE} ------------ */" >> "${HDRFILE}"
1521    echo >> "${HDRFILE}"
1522    echo '--------------- end ' "${HDRFILE}"
1525 AC_SUBST(UCONFIG_CFLAGS)
1526 if test -n "$UCONFIG_CFLAGS"; then
1527    echo "C   apps may want to build with CFLAGS   = ${UCONFIG_CFLAGS}"
1529 AC_SUBST(UCONFIG_CXXFLAGS)
1530 if test -n "$UCONFIG_CXXFLAGS"; then
1531    echo "C++ apps may want to build with CXXFLAGS = ${UCONFIG_CXXFLAGS}"
1534 if test "$tools" = false;
1535 then
1536         echo "## Note: you have disabled ICU's tools. This ICU cannot build its own data or tests."
1537         echo "## Expect build failures in the 'data', 'test', and other directories."
1540 if test -z "$PYTHON";
1541 then
1542     echo "** Note: Python not found. You will not be able to build data from source or run tests."
1545 $as_unset _CXX_CXXSUFFIX