1
dnl -*-m4-*-
2
dnl configure.in for ICU
3
dnl Copyright (c) 1999-2007, International Business Machines Corporation and
4
dnl others. All Rights Reserved.
5
dnl Stephen F. Booth, heavily modified by Yves and others
6
7
dnl Process this file with autoconf to produce a configure script
8
AC_INIT(common/unicode/utypes.h)
9
10
AC_CONFIG_HEADER(common/icucfg.h)
11
PACKAGE="icu"
12
AC_SUBST(PACKAGE)
13
14
AC_MSG_CHECKING(for ICU version numbers)
15
16
dnl Get the ICU version from uversion.h or other headers
17
geticuversion() {
18
    [sed -n 's/^[ 	]*#[ 	]*define[ 	]*U_ICU_VERSION[ 	]*"\([^"]*\)".*/\1/p' "$@"]
19
}
20
VERSION=`geticuversion $srcdir/common/unicode/uversion.h`
21
if test x"$VERSION" = x; then
22
    VERSION=`geticuversion $srcdir/common/unicode/*.h`
23
    if test x"$VERSION" = x; then
24
        AC_MSG_ERROR([Cannot determine ICU version number from header files])
25
    fi
26
fi
27
dnl Compute a reasonable library version from the release version. This is
28
dnl very bad, but that's wanted... We want to make sure that the LIB_VERSION
29
dnl has at least a dot in it, so we'll add a .0 if needed.
30
[LIB_VERSION=`echo $VERSION | sed -e 's/\.//' -e 's/^\([^.]*\)$/\1.0/'`]
31
LIB_VERSION_MAJOR=`echo $LIB_VERSION | sed 's/\..*//'`
32
AC_SUBST(VERSION)
33
AC_SUBST(LIB_VERSION)
34
AC_SUBST(LIB_VERSION_MAJOR)
35
AC_MSG_RESULT([release $VERSION, library $LIB_VERSION])
36
37
UNICODE_VERSION="5.0"
38
AC_SUBST(UNICODE_VERSION)
39
40
dnl Determine the host system
41
AC_CANONICAL_HOST
42
43
AC_SUBST(CPPFLAGS)
44
45
dnl This variable is needed on z/OS because the C++ compiler only recognizes .C
46
_CXX_CXXSUFFIX=cc
47
export _CXX_CXXSUFFIX
48
dnl Checks for programs
49
AC_PROG_CC
50
AC_PROG_CXX
51
AC_PROG_INSTALL
52
53
# make sure install is relative to srcdir - if a script
54
if test "$srcdir" = "."; then
55
  # If srcdir isn't just ., then (srcdir) is already prepended.
56
  if test "${ac_install_sh}" = "${INSTALL}"; then
57
   INSTALL="\\\$(top_srcdir)/${ac_install_sh}"
58
  fi
59
fi
60
61
#AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, true)
62
#AC_CHECK_PROG(STRIP, strip, strip, true)
63
64
dnl Check for the platform make
65
AC_PATH_PROGS(U_MAKE, gmake gnumake, make)
66
AC_SUBST(U_MAKE)
67
68
dnl Check for doxygen to generate documentation
69
AC_PATH_PROG(DOXYGEN,doxygen,,$PATH:/usr/local/bin:/usr/bin)
70
71
dnl Check that the linker is usable
72
ICU_PROG_LINK
73
74
dnl Determine the executable suffix
75
dnl We don't use AC_EXEEXT because some compilers output separate debugging
76
dnl files, which confuses the AC_EXEEXT macro.
77
AC_MSG_CHECKING(checking for executable suffix)
78
case "${host}" in
79
    *-*-cygwin*|*-*-mingw*)  EXEEXT=.exe ;;
80
    *)      EXEEXT="" ;;
81
esac
82
ac_exeext=$EXEEXT
83
AC_MSG_RESULT($EXEEXT)
84
AC_SUBST(EXEEXT)
85
86
dnl Determine how strict we want to be when compiling
87
AC_CHECK_STRICT_COMPILE
88
89
dnl Check if we can build and use 64-bit libraries
90
AC_CHECK_64BIT_LIBS
91
AC_SUBST(ARFLAGS)
92
AC_SUBST(COMPILE_LINK_ENVVAR)
93
94
dnl Determine the Makefile fragment
95
ICU_CHECK_MH_FRAG
96
97
dnl Checks for libraries and other host specific stuff
98
dnl On HP/UX, don't link to -lm from a shared lib because it isn't
99
dnl  PIC (at least on 10.2)
100
case "${host}" in
101
	*-*-hpux*) 	AC_CHECK_LIB(m, floor, LIB_M="-lm") ;;
102
	
103
	*) 		AC_CHECK_LIB(m, floor) 
104
			LIB_M="" ;;
105
esac
106
AC_SUBST(LIB_M)
107
108
dnl Check whether to build shared libraries
109
AC_MSG_CHECKING([whether to build shared libraries])
110
enabled=no
111
AC_ARG_ENABLE(shared,
112
    [  --enable-shared         build shared libraries [default=yes]],
113
    [ case "${enableval}" in
114
	     yes|"") enabled=yes; ENABLE_SHARED=YES ;;
115
	     no);;
116
	     *) ;;
117
    esac],
118
    [enabled=yes; ENABLE_SHARED=YES]
119
)
120
AC_MSG_RESULT($enabled)
121
AC_SUBST(ENABLE_SHARED)
122
123
dnl Check whether to build static libraries
124
AC_MSG_CHECKING([whether to build static libraries])
125
enabled=no
126
AC_ARG_ENABLE(static,
127
    [  --enable-static         build static libraries [default=no]],
128
    [ case "${enableval}" in
129
	     yes|"") enabled=yes; ENABLE_STATIC=YES ;;
130
	     no) ;;
131
	     *) ;;
132
    esac],
133
)
134
AC_MSG_RESULT($enabled)
135
AC_SUBST(ENABLE_STATIC)
136
137
dnl Check whether to build debug libraries
138
AC_MSG_CHECKING([whether to build debug libraries])
139
enabled=no
140
ENABLE_DEBUG=0
141
AC_ARG_ENABLE(debug,
142
    [  --enable-debug          build debug libraries [default=no]],
143
    [ case "${enableval}" in
144
         yes|"") enabled=yes; ENABLE_DEBUG=1 ;;
145
         *) ;;
146
    esac],
147
)
148
AC_MSG_RESULT($enabled)
149
AC_SUBST(ENABLE_DEBUG)
150
151
dnl Check whether to build release libraries
152
AC_MSG_CHECKING([whether to build release libraries])
153
enabled=yes
154
ENABLE_RELEASE=1
155
AC_ARG_ENABLE(release,
156
    [  --enable-release        build release libraries [default=yes]],
157
    [ case "${enableval}" in
158
         no) enabled=no; ENABLE_RELEASE=0 ;;
159
         *) ;;
160
    esac],
161
)
162
AC_MSG_RESULT($enabled)
163
AC_SUBST(ENABLE_RELEASE)
164
165
dnl Check whether to enabled draft APIs
166
AC_MSG_CHECKING([whether to enable draft APIs])
167
enabled=yes
168
U_DEFAULT_SHOW_DRAFT=1
169
AC_ARG_ENABLE(draft,
170
    [  --enable-draft          enable draft APIs [default=yes]],
171
    [ case "${enableval}" in
172
         no) enabled=no; U_DEFAULT_SHOW_DRAFT=0 ;;
173
         *) ;;
174
    esac],
175
)
176
AC_MSG_RESULT($enabled)
177
dnl Make sure that we can use draft API in ICU.
178
if test "$U_DEFAULT_SHOW_DRAFT" = 0; then
179
    CPPFLAGS="$CPPFLAGS -DU_SHOW_DRAFT_API"
180
fi
181
AC_SUBST(U_DEFAULT_SHOW_DRAFT)
182
183
dnl Check if we can hide variables from 
184
AC_MSG_CHECKING([for library API export])
185
SHAREDLIBEXPORT=no
186
U_USE_GCC_VISIBILITY_ATTRIBUTE=0
187
if test "$ac_cv_c_compiler_gnu" = yes; then
188
    OLD_CFLAGS="${CFLAGS}"
189
    OLD_CXXFLAGS="${CXXFLAGS}"
190
    LIBCFLAGS="-fvisibility=hidden"
191
    LIBCXXFLAGS="-fvisibility=hidden"
192
    CFLAGS="${CFLAGS} ${LIBCFLAGS}"
193
    CXXFLAGS="${CXXFLAGS} ${LIBCXXFLAGS}"
194
    AC_TRY_LINK([__attribute__ ((visibility ("default"))) void f(void);
195
#include <stdlib.h>],[exit(0);],
196
        [SHAREDLIBEXPORT=yes],[SHAREDLIBEXPORT=no])
197
    # Restore to their original state because the Intel compiler chokes
198
    # on this option when checking for the wchar_t size, but the
199
    # option otherwise works.
200
    CFLAGS="${OLD_CFLAGS}"
201
    CXXFLAGS="${OLD_CXXFLAGS}"
202
    if test "$SHAREDLIBEXPORT" = no; then
203
        LIBCFLAGS=
204
        LIBCXXFLAGS=
205
    else
206
        U_USE_GCC_VISIBILITY_ATTRIBUTE=1
207
    fi
208
fi
209
AC_MSG_RESULT($SHAREDLIBEXPORT)
210
AC_SUBST(U_USE_GCC_VISIBILITY_ATTRIBUTE)
211
AC_SUBST(LIBCFLAGS)
212
AC_SUBST(LIBCXXFLAGS)
213
214
AC_PROG_RANLIB
215
AC_PATH_PROG(AR,ar,[echo archiver ar not found re-run configure ; false],$PATH:/bin:/usr/bin:/usr/ccs/bin)
216
217
AC_MSG_CHECKING([whether to enable renaming of symbols])
218
enabled=yes
219
U_DISABLE_RENAMING=0
220
AC_ARG_ENABLE(renaming,
221
    [  --enable-renaming       add a version suffix to symbols [default=yes]],
222
    [ case "${enableval}" in
223
	     yes|"") enabled=yes ;;
224
	     no) enabled=no; U_DISABLE_RENAMING=1 ;;
225
	     *) ;;
226
    esac],
227
)
228
AC_MSG_RESULT($enabled)
229
AC_SUBST(U_DISABLE_RENAMING)
230
231
AC_MSG_CHECKING([whether to enable function and data tracing])
232
enabled=yes
233
U_ENABLE_TRACING=0
234
AC_ARG_ENABLE(tracing,
235
    [  --enable-tracing        enable function and data tracing [default=no]],
236
    [ case "${enableval}" in
237
	     yes|"") enabled=yes ;;
238
	     no) enabled=no; U_ENABLE_TRACING=0 ;;
239
	     *) ;;
240
    esac],
241
)
242
AC_MSG_RESULT($enabled)
243
AC_SUBST(U_ENABLE_TRACING)
244
245
dnl Check whether to use the evil rpath or not
246
AC_ARG_ENABLE(rpath,
247
    [  --enable-rpath          use rpath when linking [default is only if necessary]],
248
    [ case "${enableval}" in
249
	     yes|"") ENABLE_RPATH=YES ;;
250
	     no) ;;
251
	     *) ;;
252
    esac],
253
    [ENABLE_RPATH=NO]
254
)
255
AC_SUBST(ENABLE_RPATH)
256
257
258
dnl set up U_INLINE.  
259
dnl Copy the definition of AC_C_INLINE, with slight mods.
260
dnl
261
AC_CACHE_CHECK([for definition of U_INLINE for C], ac_cv_c_inline,
262
[ac_cv_c_inline=no
263
for ac_kw in inline __inline__ __inline; do
264
  AC_TRY_COMPILE(, [return 0;} $ac_kw int foo() {], [ac_cv_c_inline=$ac_kw; break])
265
  done
266
  ])
267
case "$ac_cv_c_inline" in
268
      yes)       U_INLINE= "inline" ;;
269
	  no )       U_INLINE= ;;
270
	    *)       U_INLINE=$ac_cv_c_inline ;;
271
esac
272
AC_SUBST(U_INLINE)
273
274
threads=true
275
276
dnl Enable/disable threads
277
AC_ARG_ENABLE(threads,
278
	[  --enable-threads        build ICU with thread safety [default=yes]],
279
	[case "${enableval}" in
280
		yes) threads=true ;;
281
		no)  threads=false ;;
282
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-threads) ;;
283
		esac], 
284
	threads=true)
285
ICU_CONDITIONAL(THREADS, test "$threads" = true)
286
287
ICU_USE_THREADS=0
288
OLD_LIBS=${LIBS}
289
290
if test $threads = true; then
291
  dnl For Compaq Tru64 (OSF1), we must look for pthread_attr_init
292
  dnl and must do this before seaching for pthread_mutex_destroy, or
293
  dnl we will pick up libpthreads.so not libpthread.so
294
  dnl If this fails, then we must test for HPUX specials, before
295
  dnl moving on to a more generic test
296
 
297
  AC_CHECK_LIB(pthread, pthread_attr_init)
298
  if test $ac_cv_lib_pthread_pthread_attr_init = yes; then
299
    ICU_USE_THREADS=1
300
  else
301
    dnl Locate the right library for POSIX threads. We look for the
302
    dnl symbols in the libraries first, because on Solaris libc provides
303
    dnl pthread_create but libpthread has the real code :(
304
    dnl AIX uses libpthreads instead of libpthread, and HP/UX uses libpthread
305
    dnl FreeBSD users may need libpthread if they do not have libc_r.
306
307
    AC_SEARCH_LIBS_FIRST(pthread_mutex_destroy, pthread pthreads c_r )
308
309
    if test "$ac_cv_search_pthread_mutex_destroy" != no; then
310
      ICU_USE_THREADS=1
311
    else
312
      dnl For HP 11
313
      AC_CHECK_LIB(pthread, pthread_mutex_init)
314
      if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then
315
        ICU_USE_THREADS=1
316
      fi
317
    fi
318
319
    AC_CHECK_FUNC(pthread_mutex_lock)
320
321
    if test $ac_cv_func_pthread_mutex_lock = yes; then
322
      ICU_USE_THREADS=1
323
    fi
324
  fi
325
  dnl Check to see if we are using CygWin with MSVC
326
  case "${host}" in
327
  *-pc-cygwin*|*-pc-mingw*)
328
    dnl For gcc, the thread options are set by mh-mingw/mh-cygwin
329
    ICU_USE_THREADS=1
330
    if test "$ac_cv_prog_gcc" = no; then
331
      dnl We're using normal windows compilers. Threading is available.
332
      ICU_USE_THREADS=1
333
      if test $ENABLE_DEBUG = 1; then
334
        dnl /MDd means 'compiles and links a debugable multithreaded program with DLL'
335
        CFLAGS="${CFLAGS} /MDd"
336
        CXXFLAGS="${CXXFLAGS} /MDd"
337
      else
338
        dnl /MD means 'compiles and links a multithreaded program with DLL'
339
        CFLAGS="${CFLAGS} /MD"
340
        CXXFLAGS="${CXXFLAGS} /MD"
341
      fi
342
    fi ;;
343
  *-*-hpux*)
344
    dnl Add -mt because it does several nice things on newer compilers.
345
    case "${icu_cv_host_frag}" in
346
      mh-hpux-acc)
347
        OLD_CXXFLAGS="${CXXFLAGS}"
348
        CXXFLAGS="${CXXFLAGS} -mt"
349
        if test x"`${CXX} ${CXXFLAGS} 2>&1`" != x""; then
350
           CXXFLAGS="${OLD_CXXFLAGS}"
351
       fi
352
      ;;
353
    esac
354
    ;;
355
  esac
356
fi
357
358
AC_SUBST(ICU_USE_THREADS)
359
360
AC_ARG_ENABLE(weak-threads,
361
	[  --enable-weak-threads   weakly reference the threading library [default=no]],
362
	[case "${enableval}" in
363
		yes)
364
            LIB_THREAD="${LIBS%${OLD_LIBS}}"
365
            LIBS=${OLD_LIBS}
366
            ;;
367
		no)  ;;
368
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-weak-threads) ;;
369
		esac])
370
AC_SUBST(LIB_THREAD)
371
372
dnl Check for mmap()
373
374
# The AC_FUNC_MMAP macro doesn't work properly.  It seems to be too specific.
375
# Do this check instead.
376
HAVE_MMAP=0
377
AC_MSG_CHECKING([for mmap])
378
AC_CACHE_VAL(ac_cv_func_mmap_ok,
379
    [AC_TRY_LINK(
380
    changequote(<<, >>)dnl
381
    <<
382
#include <unistd.h>
383
#include <sys/mman.h>
384
#include <sys/stat.h>
385
#include <fcntl.h>
386
    >>,
387
    changequote([, ])dnl
388
    [mmap((void *)0, 0, PROT_READ, 0, 0, 0);],
389
    ac_cv_func_mmap_ok=yes,
390
    ac_cv_func_mmap_ok=no)] )
391
AC_MSG_RESULT($ac_cv_func_mmap_ok)
392
if test $ac_cv_func_mmap_ok = yes
393
then
394
    HAVE_MMAP=1
395
fi
396
AC_SUBST(HAVE_MMAP)
397
398
dnl Check to see if genccode can generate simple assembly.
399
GENCCODE_ASSEMBLY=
400
case "${host}" in
401
i*86-*-linux*|x86_64-*-linux*|powerpc*-*-linux*|i*86-*-*bsd*|i*86-pc-gnu)
402
    if test "$GCC" = yes; then
403
        dnl We're using gcc, and the simple -a gcc command line works for genccode
404
        GENCCODE_ASSEMBLY="-a gcc"
405
    fi ;;
406
i*86-*-solaris*)
407
    if test "$GCC" = yes; then
408
        dnl We're using gcc, and the simple -a gcc command line works for genccode
409
        GENCCODE_ASSEMBLY="-a gcc"
410
    else
411
        GENCCODE_ASSEMBLY="-a sun-x86"
412
    fi ;;
413
sparc-*-solaris*)
414
    GENCCODE_ASSEMBLY="-a sun"
415
    ;;
416
ia64-*-hpux*)
417
    GENCCODE_ASSEMBLY="-a aCC-ia64"
418
    ;;
419
esac
420
AC_SUBST(GENCCODE_ASSEMBLY)
421
422
423
dnl Checks for header files
424
AC_CHECK_HEADERS(inttypes.h)
425
if test $ac_cv_header_inttypes_h = no; then
426
 U_HAVE_INTTYPES_H=0
427
else
428
 U_HAVE_INTTYPES_H=1
429
fi
430
if test "$CC" = ccc; then
431
 AC_MSG_RESULT("C compiler set to CCC ${CC}" )
432
 case "${host}" in
433
        alpha*-*-*) U_HAVE_INTTYPES_H=0;
434
 esac
435
fi
436
437
AC_SUBST(U_HAVE_INTTYPES_H)
438
439
AC_ARG_WITH(iostream,
440
	[  --with-iostream=version specify the version of iostream to use (none, old, std, auto) [default=auto]],
441
	[case "${withval}" in
442
		none) streams=none ;;
443
		old) streams=198506 ;;
444
		std) streams=199711 ;;
445
		auto) streams= ;;
446
		*) AC_MSG_ERROR(bad value ${withval} for --with-iostream) ;;
447
		esac], 
448
        [streams=])
449
450
U_IOSTREAM_SOURCE=0
451
if test x$streams != xnone
452
then
453
    AC_LANG_SAVE
454
    AC_LANG_CPLUSPLUS
455
    OLD_CXXFLAGS="${CXXFLAGS}"
456
    case "${icu_cv_host_frag}" in
457
        mh-hpux-acc)
458
            CXXFLAGS="${CXXFLAGS} -AA"
459
        ;;
460
    esac
461
    AC_MSG_CHECKING([for iostream usability])
462
    AC_TRY_COMPILE([#include <iostream>],[],
463
        [ac_cv_header_iostream=yes],[ac_cv_header_iostream=no])
464
    if test $icu_cv_host_frag = mh-cygwin-msvc
465
    then
466
        dnl <iostream> is always there on Windows.
467
        dnl We do this to prevent the C++ preprocessor from being used because
468
        dnl autoconf can't deal with the Windows C++ preprocessor 
469
        ac_cv_header_iostream=yes
470
    fi
471
    AC_MSG_RESULT($ac_cv_header_iostream)
472
    if test $ac_cv_header_iostream = yes
473
    then
474
        U_IOSTREAM_SOURCE=199711
475
    else
476
        CXXFLAGS="${OLD_CXXFLAGS}"
477
        AC_MSG_CHECKING([whether ostream in iostream.h is really defined])
478
        AC_CACHE_VAL(ac_cv_iostream_ok,
479
            AC_TRY_LINK([#include <iostream.h>],[ostream &testout = cout; testout << "test" << endl;],ac_cv_iostream_ok=yes,ac_cv_iostream_ok=no))
480
        AC_MSG_RESULT($ac_cv_iostream_ok)
481
        if test $ac_cv_iostream_ok = yes
482
        then
483
            U_IOSTREAM_SOURCE=198506
484
        fi
485
    fi
486
    if test x$streams != x
487
    then
488
        if test $U_IOSTREAM_SOURCE -ge $streams
489
        then
490
            U_IOSTREAM_SOURCE=$streams
491
            case "${icu_cv_host_frag}" in
492
                mh-hpux-acc)
493
                    if test $U_IOSTREAM_SOURCE -lt 199711; then
494
                        CXXFLAGS=${OLD_CXXFLAGS}
495
                    fi
496
                ;;
497
            esac
498
        else
499
            AC_MSG_ERROR(${withval} iostream is not available)
500
        fi
501
    fi
502
fi
503
AC_SUBST(U_IOSTREAM_SOURCE)
504
AC_LANG_RESTORE
505
506
dnl Check for endianness
507
AC_C_BIGENDIAN()
508
if test $ac_cv_c_bigendian = no; then
509
U_IS_BIG_ENDIAN=0
510
U_ENDIAN_CHAR="l"
511
else
512
U_IS_BIG_ENDIAN=1
513
U_ENDIAN_CHAR="b"
514
fi
515
AC_SUBST(U_IS_BIG_ENDIAN)
516
517
dnl Do various POSIX related checks
518
U_HAVE_NL_LANGINFO_CODESET=0
519
U_NL_LANGINFO_CODESET=-1
520
AC_CHECK_FUNC(nl_langinfo,[U_HAVE_NL_LANGINFO=1],[U_HAVE_NL_LANGINFO=0])
521
dnl AC_SUBST(U_HAVE_NL_LANGINFO)
522
if test $U_HAVE_NL_LANGINFO -eq 1; then
523
  AC_CACHE_CHECK([for nl_langinfo's argument to obtain the codeset],
524
  ac_cv_nl_langinfo_codeset,
525
  [ac_cv_nl_langinfo_codeset="unknown"
526
  for a in CODESET _NL_CTYPE_CODESET_NAME; do
527
  AC_TRY_LINK([#include <langinfo.h>],[nl_langinfo($a);],[ac_cv_nl_langinfo_codeset="$a"; break])]
528
  done)
529
  if test x$ac_cv_nl_langinfo_codeset != xunknown
530
  then
531
      U_HAVE_NL_LANGINFO_CODESET=1
532
      U_NL_LANGINFO_CODESET=$ac_cv_nl_langinfo_codeset
533
  fi
534
fi
535
AC_SUBST(U_HAVE_NL_LANGINFO_CODESET)
536
AC_SUBST(U_NL_LANGINFO_CODESET)
537
538
dnl Namespace support checks
539
AC_LANG_CPLUSPLUS
540
AC_MSG_CHECKING([for namespace support])
541
AC_CACHE_VAL(ac_cv_namespace_ok,
542
    [AC_TRY_LINK(
543
    changequote(<<, >>)dnl
544
    <<namespace x_version {void f(){}}
545
    namespace x = x_version;
546
    using namespace x_version;
547
    >>,
548
    changequote([, ])dnl
549
    [f();], ac_cv_namespace_ok=yes, ac_cv_namespace_ok=no)] )
550
AC_MSG_RESULT($ac_cv_namespace_ok)
551
U_HAVE_NAMESPACE=1
552
if test $ac_cv_namespace_ok = no
553
then
554
    U_HAVE_NAMESPACE=0
555
fi
556
AC_SUBST(U_HAVE_NAMESPACE)
557
558
AC_MSG_CHECKING([for properly overriding new and delete])
559
U_OVERRIDE_CXX_ALLOCATION=0
560
U_HAVE_PLACEMENT_NEW=0
561
AC_CACHE_VAL(ac_cv_override_cxx_allocation_ok,
562
    [AC_TRY_LINK(
563
    changequote(<<, >>)dnl
564
    <<#include <stdlib.h>
565
    class UMemory {
566
    public:
567
    void *operator new(size_t size) {return malloc(size);}
568
    void *operator new[](size_t size) {return malloc(size);}
569
    void operator delete(void *p) {free(p);}
570
    void operator delete[](void *p) {free(p);}
571
    };
572
    >>,
573
    changequote([, ])dnl
574
    [], ac_cv_override_cxx_allocation_ok=yes, ac_cv_override_cxx_allocation_ok=no)] )
575
AC_MSG_RESULT($ac_cv_override_cxx_allocation_ok)
576
if test $ac_cv_override_cxx_allocation_ok = yes
577
then
578
    U_OVERRIDE_CXX_ALLOCATION=1
579
    AC_MSG_CHECKING([for placement new and delete])
580
    AC_CACHE_VAL(ac_cv_override_placement_new_ok,
581
        [AC_TRY_LINK(
582
        changequote(<<, >>)dnl
583
        <<#include <stdlib.h>
584
        class UMemory {
585
        public:
586
        void *operator new(size_t size) {return malloc(size);}
587
        void *operator new[](size_t size) {return malloc(size);}
588
        void operator delete(void *p) {free(p);}
589
        void operator delete[](void *p) {free(p);}
590
        void * operator new(size_t, void *ptr) { return ptr; }
591
        void operator delete(void *, void *) {}
592
        };
593
        >>,
594
        changequote([, ])dnl
595
        [], ac_cv_override_placement_new_ok=yes, ac_cv_override_placement_new_ok=no)] )
596
    AC_MSG_RESULT($ac_cv_override_placement_new_ok)
597
    if test $ac_cv_override_placement_new_ok = yes
598
    then
599
        U_HAVE_PLACEMENT_NEW=1
600
    fi
601
fi
602
AC_SUBST(U_OVERRIDE_CXX_ALLOCATION)
603
AC_SUBST(U_HAVE_PLACEMENT_NEW)
604
605
AC_LANG_C
606
AC_CHECK_FUNC(popen)
607
if test x$ac_cv_func_popen = xyes
608
then
609
     U_HAVE_POPEN=1
610
else
611
     U_HAVE_POPEN=0
612
fi
613
AC_SUBST(U_HAVE_POPEN)
614
615
AC_CHECK_FUNC(tzset)
616
U_HAVE_TZSET=0
617
if test x$ac_cv_func_tzset = xyes
618
then
619
    U_TZSET=tzset
620
    U_HAVE_TZSET=1
621
else
622
    AC_CHECK_FUNC(_tzset)
623
    if test x$ac_cv_func__tzset = xyes
624
    then
625
        U_TZSET=_tzset
626
        U_HAVE_TZSET=1
627
    fi
628
fi
629
AC_SUBST(U_HAVE_TZSET)
630
AC_SUBST(U_TZSET)
631
632
U_HAVE_TZNAME=0
633
AC_CACHE_CHECK(for tzname,ac_cv_var_tzname,
634
[AC_TRY_LINK(
635
changequote(<<, >>)dnl
636
<<#ifndef __USE_POSIX
637
#define __USE_POSIX
638
#endif
639
#include <stdlib.h>
640
#include <time.h>
641
#ifndef tzname /* For SGI.  */
642
extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
643
#endif>>,
644
changequote([, ])dnl
645
[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
646
if test $ac_cv_var_tzname = yes; then
647
  U_TZNAME=tzname
648
  U_HAVE_TZNAME=1
649
else
650
  AC_CACHE_CHECK(for _tzname,ac_cv_var__tzname,
651
  [AC_TRY_LINK(
652
  changequote(<<, >>)dnl
653
  <<#include <stdlib.h>
654
  #include <time.h>
655
  extern char *_tzname[];
656
  >>,
657
  changequote([, ])dnl
658
  [atoi(*_tzname);], ac_cv_var__tzname=yes, ac_cv_var__tzname=no)])
659
    if test $ac_cv_var__tzname = yes; then
660
      U_TZNAME=_tzname
661
      U_HAVE_TZNAME=1
662
    fi
663
fi
664
AC_SUBST(U_HAVE_TZNAME)
665
AC_SUBST(U_TZNAME)
666
667
AC_CACHE_CHECK(for timezone,ac_cv_var_timezone,
668
[AC_TRY_LINK(
669
changequote(<<, >>)dnl
670
<<#ifndef __USE_POSIX
671
#define __USE_POSIX
672
#endif
673
#ifndef __USE_XOPEN
674
#define __USE_XOPEN
675
#endif
676
#include <time.h>
677
>>,
678
changequote([, ])dnl
679
[timezone = 1;], ac_cv_var_timezone=yes, ac_cv_var_timezone=no)])
680
U_HAVE_TIMEZONE=0
681
if test $ac_cv_var_timezone = yes; then
682
  U_TIMEZONE=timezone
683
  U_HAVE_TIMEZONE=1
684
else
685
  AC_CACHE_CHECK(for __timezone,ac_cv_var___timezone,
686
  [AC_TRY_LINK([#include <time.h>], 
687
  [__timezone = 1;], ac_cv_var___timezone=yes, ac_cv_var___timezone=no)])
688
  if test $ac_cv_var___timezone = yes; then
689
    U_TIMEZONE=__timezone
690
    U_HAVE_TIMEZONE=1
691
  else
692
    AC_CACHE_CHECK(for _timezone,ac_cv_var__timezone,
693
    [AC_TRY_LINK([#include <time.h>],
694
    [_timezone = 1;], ac_cv_var__timezone=yes, ac_cv_var__timezone=no)])
695
    if test $ac_cv_var__timezone = yes; then
696
      U_TIMEZONE=_timezone
697
      U_HAVE_TIMEZONE=1
698
    fi
699
  fi
700
fi
701
AC_SUBST(U_HAVE_TIMEZONE)
702
AC_SUBST(U_TIMEZONE)
703
704
dnl Checks for typedefs
705
AC_CHECK_TYPE(int8_t,signed char)
706
AC_CHECK_TYPE(uint8_t,unsigned char)
707
AC_CHECK_TYPE(int16_t,signed short)
708
AC_CHECK_TYPE(uint16_t,unsigned short)
709
AC_CHECK_TYPE(int32_t,signed long)
710
AC_CHECK_TYPE(uint32_t,unsigned long)
711
AC_CHECK_TYPE(int64_t,signed long long)
712
AC_CHECK_TYPE(uint64_t,unsigned long long)
713
714
if test $ac_cv_type_int8_t = no; then
715
HAVE_INT8_T=0
716
else
717
HAVE_INT8_T=1
718
fi
719
AC_SUBST(HAVE_INT8_T)
720
721
if test $ac_cv_type_uint8_t = no; then
722
HAVE_UINT8_T=0
723
else
724
HAVE_UINT8_T=1
725
fi
726
AC_SUBST(HAVE_UINT8_T)
727
728
if test $ac_cv_type_int16_t = no; then
729
HAVE_INT16_T=0
730
else
731
HAVE_INT16_T=1
732
fi
733
AC_SUBST(HAVE_INT16_T)
734
735
if test $ac_cv_type_uint16_t = no; then
736
HAVE_UINT16_T=0
737
else
738
HAVE_UINT16_T=1
739
fi
740
AC_SUBST(HAVE_UINT16_T)
741
742
if test $ac_cv_type_int32_t = no; then
743
HAVE_INT32_T=0
744
else
745
HAVE_INT32_T=1
746
fi
747
AC_SUBST(HAVE_INT32_T)
748
749
if test $ac_cv_type_uint32_t = no; then
750
HAVE_UINT32_T=0
751
else
752
HAVE_UINT32_T=1
753
fi
754
AC_SUBST(HAVE_UINT32_T)
755
756
if test $ac_cv_type_int64_t = no; then
757
HAVE_INT64_T=0
758
else
759
HAVE_INT64_T=1
760
fi
761
AC_SUBST(HAVE_INT64_T)
762
763
if test $ac_cv_type_uint64_t = no; then
764
HAVE_UINT64_T=0
765
else
766
HAVE_UINT64_T=1
767
fi
768
AC_SUBST(HAVE_UINT64_T)
769
770
dnl Do various wchar_t related checks
771
AC_CHECK_HEADER(wchar.h)
772
if test "$ac_cv_header_wchar_h" = no
773
then
774
    U_HAVE_WCHAR_H=0
775
    U_HAVE_WCSCPY=0
776
else
777
    AC_DEFINE(HAVE_WCHAR_H)
778
    U_HAVE_WCHAR_H=1
779
    dnl Some broken systems have wchar.h but not some of its functions...
780
    AC_SEARCH_LIBS(wcscpy, wcs w)
781
    if test "$ac_cv_search_wcscpy" != no; then
782
      U_HAVE_WCSCPY=1
783
    else
784
      U_HAVE_WCSCPY=0
785
    fi
786
fi
787
AC_SUBST(U_HAVE_WCHAR_H)
788
AC_SUBST(U_HAVE_WCSCPY)
789
790
AC_CHECK_SIZEOF([wchar_t], 0, [
791
#if STDC_HEADERS
792
#include <stddef.h>
793
#endif
794
#include <stdlib.h>
795
#if HAVE_WCHAR_H
796
#include <string.h>
797
#include <wchar.h>
798
#endif])
799
U_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t
800
# We do this check to verify that everything is okay.
801
if test $U_SIZEOF_WCHAR_T = 0; then
802
    if test $U_HAVE_WCHAR_H=1; then
803
       AC_MSG_ERROR(There is wchar.h but the size of wchar_t is 0)
804
    fi
805
fi
806
AC_SUBST(U_SIZEOF_WCHAR_T)
807
808
AC_MSG_CHECKING([for UTF-16 string literal support])
809
U_CHECK_UTF16_STRING=1
810
CHECK_UTF16_STRING_RESULT="unknown"
811
case "${host}" in
812
*-*-aix*|powerpc64-*-linux*)
813
    if test "$ac_cv_prog_gcc" = no; then
814
        OLD_CFLAGS="${CFLAGS}"
815
        OLD_CXXFLAGS="${CXXFLAGS}"
816
        CFLAGS="${CFLAGS} -qutf"
817
        CXXFLAGS="${CXXFLAGS} -qutf"
818
        AC_TRY_COMPILE([const unsigned short hello[] = u"hello";],[],
819
            [U_CHECK_UTF16_STRING=1],[U_CHECK_UTF16_STRING=0])
820
        if test "$U_CHECK_UTF16_STRING" = 0; then
821
            CFLAGS="${OLD_CFLAGS}"
822
            CXXFLAGS="${OLD_CXXFLAGS}"
823
        else
824
            CHECK_UTF16_STRING_RESULT="-qutf"
825
        fi
826
    fi
827
    ;;
828
*-*-solaris*)
829
    if test "$ac_cv_prog_gcc" = no; then
830
        OLD_CFLAGS="${CFLAGS}"
831
        OLD_CXXFLAGS="${CXXFLAGS}"
832
        CFLAGS="${CFLAGS} -xustr=ascii_utf16_ushort"
833
        CXXFLAGS="${CXXFLAGS} -xustr=ascii_utf16_ushort"
834
        AC_TRY_COMPILE([const unsigned short hello[] = U"hello";],[],
835
            [U_CHECK_UTF16_STRING=1],[U_CHECK_UTF16_STRING=0])
836
        if test "$U_CHECK_UTF16_STRING" = 0; then
837
            CFLAGS="${OLD_CFLAGS}"
838
            CXXFLAGS="${OLD_CXXFLAGS}"
839
        else
840
            CHECK_UTF16_STRING_RESULT="-xustr=ascii_utf16_ushort"
841
842
            # Since we can't detect the availability of this UTF-16 syntax at compile time,
843
            # we depend on configure telling us that we can use it.
844
            # Since we can't ensure ICU users use -xustr=ascii_utf16_ushort,
845
            # we only use this macro within ICU.
846
            # If an ICU user uses icu-config, this feature will be enabled.
847
            CPPFLAGS="${CPPFLAGS} -DU_CHECK_UTF16_STRING=1"
848
            U_CHECK_UTF16_STRING=0
849
        fi
850
    fi
851
    ;;
852
*-*-hpux*)
853
    if test "$ac_cv_prog_gcc" = no; then
854
        dnl The option will be detected at compile time without additional compiler options.
855
        CHECK_UTF16_STRING_RESULT="available"
856
    fi
857
    ;;
858
*-*-cygwin)
859
    dnl wchar_t can be used
860
    CHECK_UTF16_STRING_RESULT="available"
861
    ;;
862
*)
863
    ;;
864
esac
865
AC_MSG_RESULT($CHECK_UTF16_STRING_RESULT)
866
AC_SUBST(U_CHECK_UTF16_STRING)
867
868
dnl Enable/disable extras
869
AC_ARG_ENABLE(extras,
870
	[  --enable-extras         build ICU extras [default=yes]],
871
	[case "${enableval}" in
872
		yes) extras=true ;;
873
		no)  extras=false ;;
874
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-extras) ;;
875
		esac], 
876
	extras=true)
877
ICU_CONDITIONAL(EXTRAS, test "$extras" = true)
878
AC_ARG_ENABLE(icuio,
879
	[  --enable-icuio          build ICU's icuio library [default=yes]],
880
	[case "${enableval}" in
881
		yes) icuio=true ;;
882
		no)  icuio=false ;;
883
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-icuio) ;;
884
		esac], 
885
	icuio=true)
886
ICU_CONDITIONAL(ICUIO, test "$icuio" = true)
887
888
dnl Enable/disable layout
889
AC_ARG_ENABLE(layout,
890
	[  --enable-layout         build ICU's layout library [default=yes]],
891
	[case "${enableval}" in
892
		yes) layout=true ;;
893
		no)  layout=false ;;
894
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-layout) ;;
895
		esac], 
896
	layout=true)
897
ICU_CONDITIONAL(LAYOUT, test "$layout" = true)
898
899
AC_ARG_WITH(data-packaging,
900
	[  --with-data-packaging=type specify how to package ICU data (files, archive, library, auto) [default=auto]],
901
	[case "${withval}" in
902
                files|archive|library) datapackaging=$withval ;;
903
		auto) datapackaging=$withval ;;
904
		common) datapackaging=archive ;;
905
		dll) datapackaging=library ;;
906
		static) datapackaging=static ;;
907
		*) AC_MSG_ERROR(bad value ${withval} for --with-data-packaging) ;;
908
		esac], 
909
        [datapackaging=])
910
911
dnl Note:  'thesysconfdir' is an evaluated version, for Man pages, so also for thedatadir, thelibdir, etc.. 
912
dnl thesysconfdir=`eval echo $sysconfdir`
913
dnl AC_SUBST(thesysconfdir)
914
dnl thelibdir=`test "x$exec_prefix" = xNONE && exec_prefix="$prefix"; eval echo $libdir`
915
dnl AC_SUBST(thelibdir)
916
thedatadir=`eval echo $datadir`
917
dnl AC_SUBST(thedatadir)
918
dnl 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}. 
919
pkgicudatadir=$datadir
920
thepkgicudatadir=$thedatadir
921
AC_SUBST(pkgicudatadir)
922
AC_SUBST(thepkgicudatadir)
923
924
dnl Shouldn't need the AC_SUBST
925
926
if test x"$datapackaging" = x -o x"$datapackaging" = xauto; then
927
	datapackaging=library
928
fi
929
930
case "$datapackaging" in
931
    files)
932
	DATA_PACKAGING_MODE=files
933
	;;
934
    archive)
935
	DATA_PACKAGING_MODE=common
936
	;;
937
    library)
938
	DATA_PACKAGING_MODE=dll
939
	;;
940
esac
941
AC_SUBST(DATA_PACKAGING_MODE)
942
943
dnl Sets a library suffix
944
AC_MSG_CHECKING([for a library suffix to use])
945
AC_ARG_WITH(library-suffix,
946
	[  --with-library-suffix=suffix    tag a suffix to the library names [default=]],
947
	[ICULIBSUFFIX="${withval}"],
948
	[ICULIBSUFFIX=])
949
msg=$ICULIBSUFFIX
950
if test "$msg" = ""; then
951
    msg=none
952
fi
953
AC_MSG_RESULT($msg)
954
AC_SUBST(ICULIBSUFFIX)
955
changequote(<<, >>)dnl
956
if test "$ICULIBSUFFIX" != ""
957
then
958
    U_HAVE_LIB_SUFFIX=1
959
    ICULIBSUFFIXCNAME=`echo _$ICULIBSUFFIX | sed 's/[^A-Za-z0-9_]/_/g'`
960
else
961
    U_HAVE_LIB_SUFFIX=0
962
fi
963
changequote([, ])dnl
964
AC_SUBST(U_HAVE_LIB_SUFFIX)
965
AC_SUBST(ICULIBSUFFIXCNAME)
966
967
dnl Enable/disable tests
968
AC_ARG_ENABLE(tests,
969
	[  --enable-tests          build ICU tests [default=yes]],
970
	[case "${enableval}" in
971
		yes) tests=true ;;
972
		no)  tests=false ;;
973
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;;
974
		esac], 
975
	tests=true)
976
ICU_CONDITIONAL(TESTS, test "$tests" = true)
977
978
dnl Enable/disable samples
979
AC_ARG_ENABLE(samples,
980
	[  --enable-samples        build ICU samples [default=yes]  
981
982
Additionally, the variable FORCE_LIBS may be set before calling configure.
983
If set, it will REPLACE any automatic list of libraries.],
984
	[case "${enableval}" in
985
		yes) samples=true ;;
986
		no)  samples=false ;;
987
		*) AC_MSG_ERROR(bad value ${enableval} for --enable-samples) ;;
988
		esac], 
989
	samples=true)
990
ICU_CONDITIONAL(SAMPLES, test "$samples" = true)
991
992
ICUDATA_CHAR=$U_ENDIAN_CHAR
993
994
dnl Platform-specific Makefile setup
995
dnl set ICUDATA_CHAR to 'e' for any EBCDIC (which should be big endian) platform.
996
case "${host}" in
997
	*-*-solaris*) 	platform=U_SOLARIS ;;
998
	*-*-linux*) 	platform=U_LINUX ;;
999
	*-pc-gnu) 	platform=U_HURD ;;
1000
	*-*-*bsd*|*-*-dragonfly*) 	platform=U_BSD ;;
1001
	*-*-aix*) 	platform=U_AIX ;;
1002
	*-*-hpux*) 	platform=U_HPUX ;;
1003
	*-apple-darwin*|*-apple-rhapsody*)	platform=U_DARWIN ;;
1004
	*-*-cygwin*|*-*-mingw*)	platform=U_CYGWIN ;;
1005
	*-*ibm-openedition*|*-*-os390*)	platform=OS390
1006
			if test "${ICU_ENABLE_ASCII_STRINGS}" != "1"; then
1007
				ICUDATA_CHAR="e"
1008
			fi ;;
1009
	*-*-os400*)	platform=OS400
1010
			if test "${ICU_ENABLE_ASCII_STRINGS}" != "1"; then
1011
				ICUDATA_CHAR="e"
1012
			fi ;;
1013
	*-*-nto*)	platform=U_QNX ;;
1014
	*-dec-osf*) 	platform=U_OSF ;;
1015
	*-*-beos)		platform=U_BEOS ;;
1016
	*-*-irix*)		platform=U_IRIX ;;
1017
	*-ncr-*)		platform=U_MPRAS ;;
1018
	*) 		platform=U_UNKNOWN_PLATFORM ;;
1019
esac
1020
AC_SUBST(ICUDATA_CHAR)
1021
AC_SUBST(platform)
1022
platform_make_fragment_name="$icu_cv_host_frag"
1023
platform_make_fragment='$(top_srcdir)/config/'"$platform_make_fragment_name"
1024
AC_SUBST(platform_make_fragment_name)
1025
AC_SUBST(platform_make_fragment)
1026
1027
if test "${FORCE_LIBS}" != ""; then
1028
   echo " *** Overriding automatically chosen [LIBS=$LIBS], using instead [FORCE_LIBS=${FORCE_LIBS}]"  1>&6
1029
   LIBS=${FORCE_LIBS}
1030
fi
1031
1032
1033
dnl Now that we're done using CPPFLAGS etc. for tests, we can change it
1034
dnl for build.
1035
1036
if test $ICU_USE_THREADS -ne 0
1037
then
1038
    CPPFLAGS="$CPPFLAGS \$(THREADSCPPFLAGS)"
1039
    CFLAGS="$CFLAGS \$(THREADSCFLAGS)"
1040
    CXXFLAGS="$CXXFLAGS \$(THREADSCXXFLAGS)"
1041
fi
1042
1043
dnl output the Makefiles
1044
AC_OUTPUT([icudefs.mk \
1045
		Makefile \
1046
		data/icupkg.inc \
1047
		config/Makefile.inc \
1048
		data/Makefile \
1049
		stubdata/Makefile \
1050
		common/Makefile \
1051
		i18n/Makefile \
1052
		layout/Makefile \
1053
		layoutex/Makefile \
1054
		io/Makefile \
1055
		extra/Makefile \
1056
		extra/uconv/Makefile \
1057
		extra/scrptrun/Makefile \
1058
		tools/Makefile \
1059
		tools/ctestfw/Makefile \
1060
		tools/toolutil/Makefile \
1061
		tools/makeconv/Makefile \
1062
		tools/genrb/Makefile \
1063
		tools/genuca/Makefile \
1064
		tools/genccode/Makefile \
1065
		tools/gencmn/Makefile \
1066
		tools/gencnval/Makefile \
1067
		tools/genctd/Makefile \
1068
		tools/gennames/Makefile \
1069
		tools/gentest/Makefile \
1070
		tools/gennorm/Makefile \
1071
		tools/genprops/Makefile \
1072
		tools/gencase/Makefile \
1073
		tools/genbidi/Makefile \
1074
		tools/genpname/Makefile \
1075
		tools/genbrk/Makefile \
1076
		tools/gensprep/Makefile \
1077
		tools/icupkg/Makefile \
1078
		tools/icuswap/Makefile \
1079
		tools/pkgdata/Makefile \
1080
		tools/tzcode/Makefile \
1081
		test/Makefile \
1082
		test/compat/Makefile \
1083
		test/testdata/Makefile \
1084
		test/testdata/pkgdata.inc \
1085
		test/hdrtst/Makefile \
1086
		test/intltest/Makefile \
1087
		test/cintltst/Makefile \
1088
		test/iotest/Makefile \
1089
		test/letest/Makefile \
1090
		samples/Makefile samples/date/Makefile \
1091
		samples/cal/Makefile samples/layout/Makefile \
1092
		common/unicode/platform.h])
1093
1094
if test $ICU_USE_THREADS = 0; then
1095
  echo  " *** Note: configuring the ICU without pthread support or testing. If this isn't what you want, then run configure with --enable-threads=yes or check the messages [above] to see why we couldn't find pthread_create()" 1>&6
1096
fi
1097
1098
if test -n "`$U_MAKE -v 2>&1 | grep '^GNU Make'`"; then
1099
echo "You must use $U_MAKE to build ICU."
1100
else
1101
echo "WARNING: $U_MAKE may not be GNU make."
1102
echo "This may cause ICU to fail to build. Please make sure that GNU make"
1103
echo "is in your PATH so that this configure script can detect its location."
1104
fi
1105
1106
$as_unset _CXX_CXXSUFFIX