Initialize Tizen 2.3
[external/icu.git] / aclocal.m4
1 # aclocal.m4 for ICU
2 # Copyright (c) 1999-2012, International Business Machines Corporation and
3 # others. All Rights Reserved.
4 # Stephen F. Booth
5
6 # @TOP@
7
8 # ICU_CHECK_MH_FRAG
9 AC_DEFUN(ICU_CHECK_MH_FRAG, [
10         AC_CACHE_CHECK(
11                 [which Makefile fragment to use for ${host}],
12                 [icu_cv_host_frag],
13                 [
14 case "${host}" in
15 *-*-solaris*)
16         if test "$GCC" = yes; then      
17                 icu_cv_host_frag=mh-solaris-gcc
18         else
19                 icu_cv_host_frag=mh-solaris
20         fi ;;
21 alpha*-*-linux-gnu)
22         if test "$GCC" = yes; then
23                 icu_cv_host_frag=mh-alpha-linux-gcc
24         else
25                 icu_cv_host_frag=mh-alpha-linux-cc
26         fi ;;
27 powerpc*-*-linux*)
28         if test "$GCC" = yes; then
29                 icu_cv_host_frag=mh-linux
30         else
31                 icu_cv_host_frag=mh-linux-va
32         fi ;;
33 *-*-linux*|*-*-gnu|*-*-k*bsd*-gnu|*-*-kopensolaris*-gnu) icu_cv_host_frag=mh-linux ;;
34 *-*-cygwin|*-*-mingw32|*-*-mingw64)
35         if test "$GCC" = yes; then
36                 AC_TRY_COMPILE([
37 #ifndef __MINGW32__
38 #error This is not MinGW
39 #endif], [], AC_TRY_COMPILE([
40 #ifndef __MINGW64__
41 #error This is not MinGW64
42 #endif], [], icu_cv_host_frag=mh-mingw64, icu_cv_host_frag=mh-mingw), icu_cv_host_frag=mh-cygwin)
43         else
44                 icu_cv_host_frag=mh-cygwin-msvc
45         fi ;;
46 *-*-*bsd*|*-*-dragonfly*)       icu_cv_host_frag=mh-bsd-gcc ;;
47 *-*-aix*)
48         if test "$GCC" = yes; then
49                 icu_cv_host_frag=mh-aix-gcc
50         else
51                 icu_cv_host_frag=mh-aix-va
52         fi ;;
53 *-*-hpux*)
54         if test "$GCC" = yes; then
55                 icu_cv_host_frag=mh-hpux-gcc
56         else
57                 case "$CXX" in
58                 *aCC)    icu_cv_host_frag=mh-hpux-acc ;;
59                 esac
60         fi ;;
61 *-*ibm-openedition*|*-*-os390*) icu_cv_host_frag=mh-os390 ;;
62 *-*-os400*)     icu_cv_host_frag=mh-os400 ;;
63 *-apple-rhapsody*)      icu_cv_host_frag=mh-darwin ;;
64 *-apple-darwin*)        icu_cv_host_frag=mh-darwin ;;
65 *-*-beos)       icu_cv_host_frag=mh-beos ;; 
66 *-*-haiku)      icu_cv_host_frag=mh-haiku ;; 
67 *-*-irix*)      icu_cv_host_frag=mh-irix ;;
68 *-dec-osf*) icu_cv_host_frag=mh-alpha-osf ;;
69 *-*-nto*)       icu_cv_host_frag=mh-qnx ;;
70 *-ncr-*)        icu_cv_host_frag=mh-mpras ;;
71 *)              icu_cv_host_frag=mh-unknown ;;
72 esac
73                 ]
74         )
75 ])
76
77 # ICU_CONDITIONAL - similar example taken from Automake 1.4
78 AC_DEFUN(ICU_CONDITIONAL,
79 [AC_SUBST($1_TRUE)
80 if $2; then
81   $1_TRUE=
82 else
83   $1_TRUE='#'
84 fi])
85
86 # ICU_PROG_LINK - Make sure that the linker is usable
87 AC_DEFUN(ICU_PROG_LINK,
88 [
89 case "${host}" in
90     *-*-cygwin*|*-*-mingw*)
91         if test "$GCC" != yes && test -n "`link --version 2>&1 | grep 'GNU coreutils'`"; then
92             AC_MSG_ERROR([link.exe is not a valid linker. Your PATH is incorrect.
93                   Please follow the directions in ICU's readme.])
94         fi;;
95     *);;
96 esac])
97
98 # AC_SEARCH_LIBS_FIRST(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
99 #            [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
100 # Search for a library defining FUNC, then see if it's not already available.
101
102 AC_DEFUN(AC_SEARCH_LIBS_FIRST,
103 [AC_PREREQ([2.13])
104 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
105 [ac_func_search_save_LIBS="$LIBS"
106 ac_cv_search_$1="no"
107 for i in $2; do
108 LIBS="-l$i $5 $ac_func_search_save_LIBS"
109 AC_TRY_LINK_FUNC([$1],
110 [ac_cv_search_$1="-l$i"
111 break])
112 done
113 if test "$ac_cv_search_$1" = "no"; then
114 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
115 fi
116 LIBS="$ac_func_search_save_LIBS"])
117 if test "$ac_cv_search_$1" != "no"; then
118   test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
119   $3
120 else :
121   $4
122 fi])
123
124
125
126 # Check if we can build and use 64-bit libraries
127 AC_DEFUN(AC_CHECK_64BIT_LIBS,
128 [
129     BITS_REQ=nochange
130     ENABLE_64BIT_LIBS=unknown
131     ## revisit this for cross-compile.
132     
133     AC_ARG_ENABLE(64bit-libs,
134         [  --enable-64bit-libs     (deprecated, use --with-library-bits) build 64-bit libraries [default= platform default]],
135         [echo "note, use --with-library-bits instead of --*-64bit-libs"
136          case "${enableval}" in
137             no|false|32) with_library_bits=32;  ;;
138             yes|true|64) with_library_bits=64else32 ;;
139             nochange) with_library_bits=nochange; ;;
140             *) AC_MSG_ERROR(bad value ${enableval} for '--*-64bit-libs') ;;
141             esac]    )
142     
143
144     AC_ARG_WITH(library-bits,
145         [  --with-library-bits=bits specify how many bits to use for the library (32, 64, 64else32, nochange) [default=nochange]],
146         [case "${withval}" in
147             ""|nochange) BITS_REQ=$withval ;;
148             32|64|64else32) BITS_REQ=$withval ;;
149             *) AC_MSG_ERROR(bad value ${withval} for --with-library-bits) ;;
150             esac])
151         
152     # don't use these for cross compiling
153     if test "$cross_compiling" = "yes" -a "${BITS_REQ}" != "nochange"; then
154         AC_MSG_ERROR([Don't specify bitness when cross compiling. See readme.html for help with cross compilation., and set compiler options manually.])
155     fi
156     AC_CHECK_SIZEOF([void *])
157     AC_MSG_CHECKING([whether runnable 64 bit binaries are built by default])
158     case $ac_cv_sizeof_void_p in
159         8) DEFAULT_64BIT=yes ;;
160         4) DEFAULT_64BIT=no ;;
161         *) DEFAULT_64BIT=unknown
162     esac
163     BITS_GOT=unknown
164     
165     # 'OK' here means, we can exit any further checking, everything's copa
166     BITS_OK=yes
167
168     # do we need to check for buildable/runnable 32 or 64 bit?
169     BITS_CHECK_32=no
170     BITS_CHECK_64=no
171     
172     # later, can we run the 32/64 bit binaries so made?
173     BITS_RUN_32=no
174     BITS_RUN_64=no
175     
176     if test "$DEFAULT_64BIT" = "yes"; then
177         # we get 64 bits by default.
178         BITS_GOT=64
179         case "$BITS_REQ" in
180             32) 
181                 # need to look for 32 bit support. 
182                 BITS_CHECK_32=yes
183                 # not copa.
184                 BITS_OK=no;;
185             # everyone else is happy.
186             nochange) ;;
187             *) ;;
188         esac
189     elif test "$DEFAULT_64BIT" = "no"; then
190         # not 64 bit by default.
191         BITS_GOT=32
192         case "$BITS_REQ" in
193             64|64else32)
194                 BITS_CHECK_64=yes
195                 #BITS_CHECK_32=yes
196                 BITS_OK=no;;
197             nochange) ;;
198             *) ;;
199         esac
200     elif test "$DEFAULT_64BIT" = "unknown"; then
201         # cross compiling.
202         BITS_GOT=unknown
203         case "$BITS_REQ" in
204             64|64else32) BITS_OK=no
205             BITS_CHECK_32=yes
206             BITS_CHECK_64=yes ;;
207             32) BITS_OK=no;;
208             nochange) ;;
209             *) ;;
210         esac
211     fi
212             
213     AC_MSG_RESULT($DEFAULT_64BIT);
214
215     if test "$BITS_OK" != "yes"; then
216         # not copa. back these up.
217         CFLAGS_OLD="${CFLAGS}"
218         CXXFLAGS_OLD="${CXXFLAGS}"
219         LDFLAGS_OLD="${LDFLAGS}"
220         ARFLAGS_OLD="${ARFLAGS}"        
221         
222         CFLAGS_32="${CFLAGS}"
223         CXXFLAGS_32="${CXXFLAGS}"
224         LDFLAGS_32="${LDFLAGS}"
225         ARFLAGS_32="${ARFLAGS}"        
226         
227         CFLAGS_64="${CFLAGS}"
228         CXXFLAGS_64="${CXXFLAGS}"
229         LDFLAGS_64="${LDFLAGS}"
230         ARFLAGS_64="${ARFLAGS}"        
231         
232         CAN_BUILD_64=unknown
233         CAN_BUILD_32=unknown
234         # These results can't be cached because is sets compiler flags.
235         if test "$BITS_CHECK_64" = "yes"; then
236             AC_MSG_CHECKING([how to build 64-bit executables])
237             CAN_BUILD_64=no
238             ####
239             # Find out if we think we can *build* for 64 bit. Doesn't check whether we can run it.
240             #  Note, we don't have to actually check if the options work- we'll try them before using them.
241             #  So, only try actually testing the options, if you are trying to decide between multiple options.
242             # On exit from the following clauses:
243             # if CAN_BUILD_64=yes:
244             #    *FLAGS are assumed to contain the right settings for 64bit
245             # else if CAN_BUILD_64=no: (default)
246             #    *FLAGS are assumed to be trashed, and will be reset from *FLAGS_OLD
247             
248             if test "$GCC" = yes; then
249                 CFLAGS="${CFLAGS} -m64"
250                 CXXFLAGS="${CXXFLAGS} -m64"
251                 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
252                    CAN_BUILD_64=yes, CAN_BUILD_64=no)
253             else
254                 case "${host}" in
255                 sparc*-*-solaris*)
256                     # 1. try -m64
257                     CFLAGS="${CFLAGS} -m64"
258                     CXXFLAGS="${CXXFLAGS} -m64"
259                     AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
260                        CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
261                     if test "$CAN_BUILD_64" != yes; then
262                         # Nope. back out changes.
263                         CFLAGS="${CFLAGS_OLD}"
264                         CXXFLAGS="${CFLAGS_OLD}"
265                         # 2. try xarch=v9 [deprecated]
266                         ## TODO: cross compile: the following won't work.
267                         SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
268                         SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
269                         # "Warning: -xarch=v9 is deprecated, use -m64 to create 64-bit programs"
270                         if test -z "$SOL64" && test -n "$SPARCV9"; then
271                             CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
272                             CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
273                             LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
274                             CAN_BUILD_64=yes
275                         fi
276                     fi
277                     ;;
278                 i386-*-solaris*)
279                     # 1. try -m64
280                     CFLAGS="${CFLAGS} -m64"
281                     CXXFLAGS="${CXXFLAGS} -m64"
282                     AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
283                        CAN_BUILD_64=yes, CAN_BUILD_64=no, CAN_BUILD_64=unknown)
284                     if test "$CAN_BUILD_64" != yes; then
285                         # Nope. back out changes.
286                         CFLAGS="${CFLAGS_OLD}"
287                         CXXFLAGS="${CXXFLAGS_OLD}"
288                         # 2. try the older compiler option
289                         ## TODO: cross compile problem
290                         AMD64=`isainfo -n 2>&1 | grep amd64`
291                         SOL64=`$CXX -xtarget=generic64 2>&1 && $CC -xtarget=generic64 2>&1 | grep -v usage:`
292                         if test -z "$SOL64" && test -n "$AMD64"; then
293                             CFLAGS="${CFLAGS} -xtarget=generic64"
294                             CXXFLAGS="${CXXFLAGS} -xtarget=generic64"
295                             CAN_BUILD_64=yes
296                         fi
297                     fi
298                     ;;
299                 ia64-*-linux*)
300                     # check for ecc/ecpc compiler support
301                     ## TODO: cross compiler problem
302                     if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
303                         if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
304                             CAN_BUILD_64=yes
305                         fi
306                     fi
307                     ;;
308                 *-*-cygwin)
309                     # vcvarsamd64.bat should have been used to enable 64-bit builds.
310                     # We only do this check to display the correct answer.
311                     ## TODO: cross compiler problem
312                     if test -n "`$CXX -help 2>&1 | grep 'for x64'`"; then
313                         CAN_BUILD_64=yes
314                     fi
315                     ;;
316                 *-*-aix*|powerpc64-*-linux*)
317                     CFLAGS="${CFLAGS} -q64"
318                     CXXFLAGS="${CXXFLAGS} -q64"
319                     LDFLAGS="${LDFLAGS} -q64"
320                     AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
321                        CAN_BUILD_64=yes, CAN_BUILD_64=no)
322                     if test "$CAN_BUILD_64" = yes; then
323                         # worked- set other options.
324                         case "${host}" in
325                         *-*-aix*)
326                             # tell AIX what executable mode to use.
327                             ARFLAGS="${ARFLAGS} -X64"
328                         esac
329                     fi
330                     ;;
331                 *-*-hpux*)
332                     # First we try the newer +DD64, if that doesn't work,
333                     # try other options.
334
335                     CFLAGS="${CFLAGS} +DD64"
336                     CXXFLAGS="${CXXFLAGS} +DD64"
337                     AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
338                         CAN_BUILD_64=yes, CAN_BUILD_64=no)
339                     if test "$CAN_BUILD_64" != yes; then
340                         # reset
341                         CFLAGS="${CFLAGS_OLD}"
342                         CXXFLAGS="${CXXFLAGS_OLD}"
343                         # append
344                         CFLAGS="${CFLAGS} +DA2.0W"
345                         CXXFLAGS="${CXXFLAGS} +DA2.0W"
346                         AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
347                             CAN_BUILD_64=yes, CAN_BUILD_64=no)
348                     fi
349                     ;;
350                 *-*ibm-openedition*|*-*-os390*)
351                     CFLAGS="${CFLAGS} -Wc,lp64"
352                     CXXFLAGS="${CXXFLAGS} -Wc,lp64"
353                     LDFLAGS="${LDFLAGS} -Wl,lp64"
354                     AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
355                        CAN_BUILD_64=yes, CAN_BUILD_64=no)
356                     ;;
357                 *)
358                     # unknown platform.
359                     ;;
360                 esac
361             fi
362             AC_MSG_RESULT($CAN_BUILD_64)
363             if test "$CAN_BUILD_64" = yes; then
364                 AC_MSG_CHECKING([whether runnable 64-bit binaries are being built ])
365                 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==64)?0:1;}])],
366                    BITS_RUN_64=yes, BITS_RUN_64=no, BITS_RUN_64=unknown)
367                 AC_MSG_RESULT($BITS_RUN_64);
368
369                 CFLAGS_64="${CFLAGS}"
370                 CXXFLAGS_64="${CXXFLAGS}"
371                 LDFLAGS_64="${LDFLAGS}"
372                 ARFLAGS_64="${ARFLAGS}"        
373             fi
374             # put it back.
375             CFLAGS="${CFLAGS_OLD}"
376             CXXFLAGS="${CXXFLAGS_OLD}"
377             LDFLAGS="${LDFLAGS_OLD}"
378             ARFLAGS="${ARFLAGS_OLD}"     
379         fi
380         if test "$BITS_CHECK_32" = "yes"; then
381             # see comment under 'if BITS_CHECK_64', above.
382             AC_MSG_CHECKING([how to build 32-bit executables])
383             if test "$GCC" = yes; then
384                 CFLAGS="${CFLAGS} -m32"
385                 CXXFLAGS="${CXXFLAGS} -m32"
386                 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
387                    CAN_BUILD_32=yes, CAN_BUILD_32=no)
388             fi
389             AC_MSG_RESULT($CAN_BUILD_32)
390             if test "$CAN_BUILD_32" = yes; then
391                 AC_MSG_CHECKING([whether runnable 32-bit binaries are being built ])
392                 AC_RUN_IFELSE([AC_LANG_SOURCE([int main(void) {return (sizeof(void*)*8==32)?0:1;}])],
393                    BITS_RUN_32=yes, BITS_RUN_32=no, BITS_RUN_32=unknown)
394                 AC_MSG_RESULT($BITS_RUN_32);
395                 CFLAGS_32="${CFLAGS}"
396                 CXXFLAGS_32="${CXXFLAGS}"
397                 LDFLAGS_32="${LDFLAGS}"
398                 ARFLAGS_32="${ARFLAGS}"        
399             fi
400             # put it back.
401             CFLAGS="${CFLAGS_OLD}"
402             CXXFLAGS="${CXXFLAGS_OLD}"
403             LDFLAGS="${LDFLAGS_OLD}"
404             ARFLAGS="${ARFLAGS_OLD}"     
405         fi
406         
407         ##
408         # OK. Now, we've tested for 32 and 64 bitness. Let's see what we'll do.
409         #
410         
411         # First, implement 64else32
412         if test "$BITS_REQ" = "64else32"; then
413             if test "$BITS_RUN_64" = "yes"; then
414                 BITS_REQ=64
415             else
416                 # no changes.
417                 BITS_OK=yes 
418             fi
419         fi
420         
421         # implement.
422         if test "$BITS_REQ" = "32" -a "$BITS_RUN_32" = "yes"; then
423             CFLAGS="${CFLAGS_32}"
424             CXXFLAGS="${CXXFLAGS_32}"
425             LDFLAGS="${LDFLAGS_32}"
426             ARFLAGS="${ARFLAGS_32}"     
427             BITS_OK=yes
428         elif test "$BITS_REQ" = "64" -a "$BITS_RUN_64" = "yes"; then
429             CFLAGS="${CFLAGS_64}"
430             CXXFLAGS="${CXXFLAGS_64}"
431             LDFLAGS="${LDFLAGS_64}"
432             ARFLAGS="${ARFLAGS_64}"     
433             BITS_OK=yes
434         elif test "$BITS_OK" != "yes"; then
435             AC_MSG_ERROR([Requested $BITS_REQ bit binaries but could not compile and execute them. See readme.html for help with cross compilation., and set compiler options manually.])
436         fi
437      fi
438 ])
439
440 # Strict compilation options.
441 AC_DEFUN(AC_CHECK_STRICT_COMPILE,
442 [
443     AC_MSG_CHECKING([whether strict compiling is on])
444     AC_ARG_ENABLE(strict,[  --enable-strict         compile with strict compiler options [default=yes]], [
445         if test "$enableval" = no
446         then
447             ac_use_strict_options=no
448         else
449             ac_use_strict_options=yes
450         fi
451       ], [ac_use_strict_options=yes])
452     AC_MSG_RESULT($ac_use_strict_options)
453
454     if test "$ac_use_strict_options" = yes
455     then
456         if test "$GCC" = yes
457         then
458             # Do not use -ansi. It limits us to C90, and it breaks some platforms.
459             # We use -std=c99 to disable the gnu99 defaults and its associated warnings
460             CFLAGS="$CFLAGS -Wall -std=c99 -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings"
461         else
462             case "${host}" in
463             *-*-cygwin)
464                 if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
465                 then
466                     CFLAGS="$CFLAGS /W4"
467                 fi
468             esac
469         fi
470         if test "$GXX" = yes
471         then
472             CXXFLAGS="$CXXFLAGS -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
473         else
474             case "${host}" in
475             *-*-cygwin)
476                 if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
477                 then
478                     CXXFLAGS="$CXXFLAGS /W4"
479                 fi
480             esac
481         fi
482     fi
483 ])
484
485