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