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