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