Home | History | Annotate | Download | only in icu4c
      1 #!/bin/sh
      2 # Copyright (c) 1999-2010, International Business Machines Corporation and
      3 # others. All Rights Reserved.
      4 
      5 # runConfigureICU: This script will run the "configure" script for the appropriate platform
      6 # Only supported platforms are recognized
      7 
      8 me=`basename $0`
      9 OPTS=
     10 
     11 usage()
     12 {
     13     ec=0$1
     14     if test $ec -eq 0
     15     then
     16         uletter=U
     17     else
     18         uletter=u
     19     fi
     20 
     21     echo "${uletter}sage: $me [ -h, --help ]  [ --enable-debug | --disable-release ] platform [ configurearg ... ]"
     22     if test $ec -eq 0
     23     then
     24         cat <<EOE
     25 
     26 Options: -h, --help         Print this message and exit
     27          --enable-debug     Enable support for debugging
     28          --disable-release  Disable presetting optimization flags
     29 
     30 The following names can be supplied as the argument for platform:
     31 
     32     AIX                 Use the IBM Visual Age xlc_r/xlC_r compilers on AIX
     33     AIX/GCC             Use the GNU gcc/g++ compilers on AIX
     34     Cygwin              Use the GNU gcc/g++ compilers on Cygwin
     35     Cygwin/MSVC         Use the Microsoft Visual C++ compiler on Cygwin
     36     Cygwin/MSVC2005     Use the Microsoft Visual C++ 2005 compiler on Cygwin
     37     Cygwin/ICL          Use the Intel C++ compiler on Cygwin
     38     FreeBSD             Use the GNU gcc/g++ compilers on Free BSD
     39     HP-UX/ACC           Use the HP ANSI C/Advanced C++ compilers on HP-UX 11
     40     IBMi                Use the iCC compilers on IBM i, i5/OS, OS/400
     41     Linux               Use the GNU gcc/g++ compilers on Linux
     42     Linux/ECC           Use the Intel ECC compiler on Linux
     43     Linux/ICC           Use the Intel ICC compiler on Linux
     44     Linux/VA            Use the IBM Visual Age compiler on Power PC Linux
     45     MacOSX              Use the GNU gcc/g++ compilers on MacOS X (Darwin)
     46     QNX                 Use the QNX QCC compiler on QNX/Neutrino
     47     Solaris             Use the Sun cc/CC compilers on Solaris
     48     Solaris/GCC         Use the GNU gcc/g++ compilers on Solaris
     49     SolarisX86          Use the Sun cc/CC compilers on Solaris x86
     50     TRU64V5.1/CXX       Use the Compaq cxx compiler on Tru64 (OSF)
     51     zOS                 Use the IBM cxx compiler on z/OS (os/390)
     52     zOSV1R2             Use the IBM cxx compiler for z/OS 1.2
     53 EOE
     54     fi
     55 
     56     exit $ec
     57 }
     58 
     59 # Parse arguments
     60 
     61 platform=
     62 debug=0
     63 release=1
     64 
     65 while test $# -ne 0
     66 do
     67     case "$1" in
     68     -h|--help)
     69         usage 0
     70         ;;
     71     --enable-debug)
     72         debug=1
     73         OPTS="$OPTS --enable-debug"
     74         ;;
     75     --disable-release)
     76         release=0
     77         OPTS="$OPTS --disable-release"
     78         ;;
     79     *)
     80         platform="$1"
     81         shift
     82         break
     83         ;;
     84     esac
     85     shift
     86 done
     87 
     88 if test x$platform = x
     89 then
     90    usage 1
     91 fi
     92 
     93 # Go.
     94 
     95 rm -f config.cache
     96 rm -f config.log
     97 rm -f config.status
     98 
     99 DEBUG_CFLAGS='-g'
    100 DEBUG_CXXFLAGS='-g'
    101 
    102 if test x$configure = x
    103 then
    104     if test -f ./configure
    105     then
    106         configuredir=.
    107     else
    108         configuredir=`echo $0 | sed 's,[^/]*$,,'`
    109         if test x$configuredir = x$0
    110         then
    111             configuredir=.
    112         fi
    113     fi
    114 
    115     if test x$configuredir = x
    116     then
    117         configuredir=.
    118     fi
    119 
    120     configure=$configuredir/configure
    121 fi
    122 
    123 case $platform in
    124     AIX)
    125         THE_OS=AIX
    126         THE_COMP="xlC_r"
    127         CC=`which xlc_r`; export CC
    128         if [ ! -x $CC ]; then
    129            echo "ERROR: xlc_r was not found, please check the PATH to make sure it is correct."; exit 1
    130         fi
    131         CXX=`which xlC_r`; export CXX
    132         if [ ! -x $CXX ]; then
    133            echo "ERROR: xlC_r was not found, please check the PATH to make sure it is correct."; exit 1
    134         fi
    135         RELEASE_CFLAGS="-O2 -qmaxmem=-1"
    136         RELEASE_CXXFLAGS="-O2 -qmaxmem=-1"
    137         ;;
    138     AIX/GCC)
    139         THE_OS=AIX
    140         THE_COMP="the GNU C++"
    141         CC=gcc; export CC
    142         CXX=g++; export CXX
    143         DEBUG_CFLAGS='-g -O0'
    144         DEBUG_CXFLAGS='-g -O0'
    145         ;;
    146     Solaris)
    147         THE_OS=SOLARIS
    148         THE_COMP="Sun's CC"
    149         CC=`which cc`; export CC
    150         CXX=`which CC`; export CXX
    151         RELEASE_CFLAGS="-xO4 -xlibmil"
    152         RELEASE_CXXFLAGS="-O4 -xlibmil"
    153         ;;
    154     Solaris/GCC)
    155         THE_OS=SOLARIS
    156         THE_COMP="the GNU C++"
    157         CC=gcc; export CC
    158         CXX=g++; export CXX
    159         RELEASE_CFLAGS=-O1
    160         RELEASE_CXXFLAGS=-O3
    161         ;;
    162     SolarisX86)
    163         THE_OS="SOLARIS X86"
    164         THE_COMP="Sun's CC"
    165         CC=`which cc`; export CC
    166         CXX=`which CC`; export CXX
    167         LDFLAGS="-L -lCrun";export LDFLAGS
    168         RELEASE_CFLAGS=-xO3
    169         RELEASE_CXXFLAGS=-O3
    170         ;;
    171     HP-UX/ACC)
    172         THE_OS="HP-UX 11"
    173         THE_COMP="aCC"
    174         CC=cc; export CC
    175         CXX=aCC; export CXX
    176         RELEASE_CFLAGS='+O2 +Ofltacc'
    177         RELEASE_CXXFLAGS='+O2 +Ofltacc'
    178         ;;
    179     IBMi)
    180         THE_OS="IBM i"
    181         THE_COMP="the iCC C++"
    182         CC=/usr/bin/icc; export CC
    183         CXX=/usr/bin/icc; export CXX
    184         CPP="$CC -c -qpponly"; export CPP
    185         MAKE=/usr/bin/gmake; export MAKE
    186         RELEASE_CFLAGS='-O4'
    187         RELEASE_CXXFLAGS='-O4'
    188         ;;
    189     Linux/ECC)
    190         THE_OS="Linux"
    191         THE_COMP="Intel ECC 7.1"
    192         CC=ecc; export CC
    193         CXX=ecpc; export CXX
    194         RELEASE_CFLAGS='-O2'
    195         RELEASE_CXXFLAGS='-O2'
    196         ;;
    197     Linux/ICC)
    198         THE_OS="Linux"
    199         CC=`which icc`; export CC
    200         CXX=`which icpc`; export CXX
    201 	ICC_VER=`${CC} -v 2>&1`
    202         RELEASE_CFLAGS='-O'
    203         RELEASE_CXXFLAGS='-O'
    204         export CFLAGS="-fp-model precise"
    205         export CXXFLAGS="-fp-model precise"
    206 	if [ "${ICC_VER}" = "Version 9.0 " ]; then
    207 		RELEASE_CFLAGS=''
    208 		RELEASE_CXXFLAGS=''
    209 		export CFLAGS="${CFLAGS} -O0"
    210 		export CXXFLAGS="${CXXFLAGS} -O0"
    211 		echo "ICC 9.0 does not work with optimization- disabling optimizations"
    212 	fi
    213         THE_COMP="Intel ${ICC_VER}"
    214         ;;
    215     Linux/VA)
    216         THE_OS="Linux"
    217         THE_COMP="IBM Visual Age C++ Compiler"
    218         CC=`which xlc_r`; export CC
    219         CXX=`which xlC_r`; export CXX
    220         RELEASE_CFLAGS="-O2 -qmaxmem=-1"
    221         RELEASE_CXXFLAGS="-O2 -qmaxmem=-1"
    222         ;;
    223     Linux*)
    224         THE_OS="Linux"
    225         THE_COMP="the GNU C++"
    226         CC=gcc; export CC
    227         CXX=g++; export CXX
    228         DEBUG_CFLAGS='-g -O0'
    229         DEBUG_CXFLAGS='-g -O0'
    230         ;;
    231     Cygwin)
    232         THE_OS="Cygwin"
    233         THE_COMP="the GNU C++"
    234         RELEASE_CFLAGS='-O3'
    235         RELEASE_CXXFLAGS='-O3'
    236         ;;
    237     Cygwin/MSVC)
    238         THE_OS="Windows with Cygwin"
    239         THE_COMP="Microsoft Visual C++"
    240         CC=cl; export CC
    241         CXX=cl; export CXX
    242         RELEASE_CFLAGS='/Gy /MD'
    243         RELEASE_CXXFLAGS='/Gy /MD'
    244         DEBUG_CFLAGS='/Zi /MDd'
    245         DEBUG_CXXFLAGS='/Zi /MDd'
    246         DEBUG_LDFLAGS='/DEBUG'
    247         ;;
    248     Cygwin/MSVC2005)
    249         THE_OS="Windows with Cygwin"
    250         THE_COMP="Microsoft Visual C++ 2005"
    251         CC=cl; export CC
    252         CXX=cl; export CXX
    253         RELEASE_CFLAGS='/Gy /MD'
    254         RELEASE_CXXFLAGS='/Gy /MD'
    255         DEBUG_CFLAGS='/Zi /MDd'
    256         DEBUG_CXXFLAGS='/Zi /MDd'
    257         DEBUG_LDFLAGS='/DEBUG'
    258         ;;
    259     Cygwin/ICL)
    260         THE_OS="Windows with Cygwin"
    261         THE_COMP="Intel C++"
    262         CC=icl; export CC
    263         CXX=icl; export CXX
    264         # The Intel compiler has optimization bugs. So we disable optimization.
    265         RELEASE_CFLAGS='/Od'
    266         RELEASE_CXXFLAGS='/Od'
    267         DEBUG_CFLAGS='/Zi'
    268         DEBUG_CXXFLAGS='/Zi'
    269         DEBUG_LDFLAGS='/DEBUG'
    270         ;;
    271     MacOSX)
    272         THE_OS="MacOS X (Darwin)"
    273         THE_COMP="the GNU C++"
    274         RELEASE_CFLAGS='-O2'
    275         RELEASE_CXXFLAGS='-O2'
    276         DEBUG_CFLAGS='-g -O0'
    277         DEBUG_CXXFLAGS='-g -O0'
    278         ;;
    279     *BSD)
    280         THE_OS="BSD"
    281         THE_COMP="the GNU C++"
    282         CC=gcc; export CC
    283         CXX=g++; export CXX
    284         DEBUG_CFLAGS='-g -O0'
    285         DEBUG_CXFLAGS='-g -O0'
    286         ;;
    287     TRU64V5.1/CXX)
    288         THE_OS="OSF1"
    289         THE_COMP="Compaq cxx"
    290         CC=cc; export CC
    291         CXX=cxx; export CXX
    292         ;;
    293     QNX)
    294         THE_OS="QNX"
    295         THE_COMP="QNX cc"
    296         CC=qcc; export CC
    297         CXX=QCC; export CXX
    298         ;;
    299     zOS)
    300         THE_OS="z/OS (OS/390)"
    301         THE_COMP="z/OS C/C++"
    302         CC=cc; export CC
    303         CXX=cxx; export CXX
    304         RELEASE_CFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
    305         RELEASE_CXXFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
    306         ;;
    307     zOSV1R2)
    308         THE_OS="z/OS 1.2"
    309         THE_COMP="z/OS 1.2 C/C++"
    310         CC=cc; export CC
    311         CXX=cxx; export CXX
    312         export COMPILE_LINK_ENVVAR='_CXX_CICC_VER}=0x41020000 _C89_CVERSION=0x41020000 _CC_CVERSION=0x41020000 _CXX_PVERSION=0x41020000 _C89_PVERSION=0x41020000 _CC_PVERSION=0x41020000'
    313         export _CXX_CVERSION=0x41020000 _C89_CVERSION=0x41020000 _CC_CVERSION=0x41020000 _CXX_PVERSION=0x41020000 _C89_PVERSION=0x41020000 _CC_PVERSION=0x41020000
    314         export LDFLAGS="-Wl,'compat=pm3'"
    315         export CFLAGS="-Wc,'target(zOSV1R2)'"
    316         export CXXFLAGS="-Wc,'target(zOSV1R2)'"
    317         RELEASE_CFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
    318         RELEASE_CXXFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
    319         ;;
    320     *)
    321         >&2 echo "$me: unrecognized platform \"$platform\" (use --help for help)"
    322         exit 1;;
    323 esac
    324 
    325 
    326 # Tweak flags
    327 
    328 if test $release -eq 1
    329 then
    330     if test "$RELEASE_CFLAGS" = ""
    331     then
    332         case $CC in
    333             gcc|*/gcc|*-gcc-*|*/*-gcc-*)
    334                 RELEASE_CFLAGS=-O3
    335                 ;;
    336         esac
    337     fi
    338     if test "$RELEASE_CFLAGS" != ""
    339     then
    340         CFLAGS="$CFLAGS $RELEASE_CFLAGS"
    341     fi
    342     if test "$RELEASE_CXXFLAGS" = ""
    343     then
    344         case $CXX in
    345             g++|*/g++|*-g++-*|*/*-g++-*)
    346                 RELEASE_CXXFLAGS=-O3
    347                 ;;
    348         esac
    349     fi
    350     if test "$RELEASE_CXXFLAGS" != ""
    351     then
    352         CXXFLAGS="$CXXFLAGS $RELEASE_CXXFLAGS"
    353     fi
    354     if test "$RELEASE_LDFLAGS" != ""
    355     then
    356         LDFLAGS="$LDFLAGS $RELEASE_LDFLAGS"
    357     fi
    358 fi
    359 
    360 if test $debug -eq 1
    361 then
    362     if test "$DEBUG_CFLAGS" != ""
    363     then
    364         CFLAGS="$CFLAGS $DEBUG_CFLAGS"
    365     fi
    366     if test "$DEBUG_CXXFLAGS" != ""
    367     then
    368         CXXFLAGS="$CXXFLAGS $DEBUG_CXXFLAGS"
    369     fi
    370     if test "$DEBUG_LDFLAGS" != ""
    371     then
    372         LDFLAGS="$LDFLAGS $DEBUG_LDFLAGS"
    373     fi
    374 fi
    375 
    376 export CFLAGS
    377 export CXXFLAGS
    378 export LDFLAGS
    379 
    380 # Run configure
    381 
    382 echo "export CPP=$CPP CC=$CC CXX=$CXX CPPFLAGS=$CPPFLAGS CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS MAKE=$MAKE"
    383 echo "Running ./configure $OPTS $@ for $THE_OS using $THE_COMP compiler"
    384 echo
    385 if $configure $OPTS $@
    386 then
    387 	echo
    388 	echo If the result of the above commands looks okay to you, go to the directory
    389 	echo source in the ICU distribution to build ICU. Please remember that ICU needs
    390 	echo GNU make to build properly...
    391 else
    392 	echo $0: ./configure failed
    393 	exit 1
    394 fi
    395