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