• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Copyright (C) 2016 and later: Unicode, Inc. and others.
3# License & terms of use: http://www.unicode.org/copyright.html
4# Copyright (c) 1999-2015, International Business Machines Corporation and
5# others. All Rights Reserved.
6
7# runConfigureICU: This script will run the "configure" script for the appropriate platform
8# Only supported platforms are recognized
9
10me=`basename $0`
11OPTS=
12
13usage()
14{
15    ec=0$1
16    if test $ec -eq 0
17    then
18        uletter=U
19    else
20        uletter=u
21    fi
22
23    echo "${uletter}sage: $me [ -h, --help ]  [ --enable-debug | --disable-release ] platform [ configurearg ... ]"
24    if test $ec -eq 0
25    then
26        cat <<EOE
27
28Options: -h, --help         Print this message and exit
29         --enable-debug     Enable support for debugging
30         --disable-release  Disable presetting optimization flags
31
32If you want to add custom CFLAGS or CXXFLAGS or similar, provide them _before_
33the runConfigureICU command:
34
35    CXXFLAGS=xyz path/to/runConfigureICU --enable-debug ...
36
37The following names can be supplied as the argument for platform:
38
39    AIX                 Use the IBM XL xlclang/xlclang compilers on AIX
40    AIX/GCC             Use the GNU gcc/g++ compilers on AIX
41    AIX/OpenXL          Use the IBM Open XL ibm-clang_r/ibm-clang++_r compilers on AIX
42    Cygwin              Use the GNU gcc/g++ compilers on Cygwin
43    Cygwin/MSVC         Use the Microsoft Visual C++ compiler on Cygwin
44    Cygwin/MSVC2005     Use the Microsoft Visual C++ 2005 compiler on Cygwin
45    Cygwin/ICL          Use the Intel C++ compiler on Cygwin
46    FreeBSD             Use the clang/clang++ or GNU gcc/g++ compilers on FreeBSD
47    HP-UX/ACC           Use the HP ANSI C/Advanced C++ compilers on HP-UX 11
48    IBMi                Use the iCC compilers on IBM i, i5/OS, OS/400
49    Linux               Use the default cc/c++ compilers on Linux
50    Linux/clang         Use the clang/clang++ compilers on Linux
51    Linux/gcc           Use the GNU gcc/g++ compilers on Linux
52    Linux/ECC           Use the Intel ECC compiler on Linux
53    Linux/ICC           Use the Intel ICC compiler on Linux
54    Linux/VA            Use the IBM XL compiler on Power PC Linux
55    macOS               Use the default compilers on macOS (Darwin)
56    macOS/gcc           Use the GNU gcc/g++ compilers on macOS (Darwin)
57    MinGW               Use the GNU gcc/g++ compilers on MinGW
58    MSYS/MSVC           Use the Microsoft Visual C++ compiler on MSYS
59    QNX                 Use the QNX QCC compiler on QNX/Neutrino
60    Solaris             Use the Sun cc/CC compilers on Solaris
61    Solaris/GCC         Use the GNU gcc/g++ compilers on Solaris
62    SolarisX86          Use the Sun cc/CC compilers on Solaris x86
63    TRU64V5.1/CXX       Use the Compaq cxx compiler on Tru64 (OSF)
64    zOS                 Use the IBM Open XL C/C++ 2.1 for z/OS compiler on z/OS (OS/390)
65EOE
66    fi
67
68    exit $ec
69}
70
71# Parse arguments
72
73platform=
74debug=0
75release=1
76
77while test $# -ne 0
78do
79    case "$1" in
80    -h|--help)
81        usage 0
82        ;;
83    --enable-debug)
84        debug=1
85        OPTS="$OPTS --enable-debug"
86        ;;
87    --disable-release)
88        release=0
89        OPTS="$OPTS --disable-release"
90        ;;
91    *)
92        platform="$1"
93        shift
94        break
95        ;;
96    esac
97    shift
98done
99
100if test x$platform = x
101then
102   usage 1
103fi
104
105# Go.
106
107rm -f config.cache
108rm -f config.log
109rm -f config.status
110
111DEBUG_CFLAGS='-g'
112DEBUG_CXXFLAGS='-g'
113
114if test x$configure = x
115then
116    if test -f ./configure
117    then
118        configuredir=.
119    else
120        configuredir=`echo $0 | sed 's,[^/]*$,,'`
121        if test x$configuredir = x$0
122        then
123            configuredir=.
124        fi
125    fi
126
127    if test x$configuredir = x
128    then
129        configuredir=.
130    fi
131
132    configure=$configuredir/configure
133fi
134
135case $platform in
136    AIX)
137        THE_OS=AIX
138        THE_COMP="xlclang"
139        CC=`which xlclang`; export CC
140        if [ ! -x $CC ]; then
141           echo "ERROR: xlclang was not found, please check the PATH to make sure it is correct."; exit 1
142        fi
143        CXX=`which xlclang++`; export CXX
144        if [ ! -x $CXX ]; then
145           echo "ERROR: xlclang++ was not found, please check the PATH to make sure it is correct."; exit 1
146        fi
147        RELEASE_CFLAGS="-O3 -qstrict=ieeefp"
148        RELEASE_CXXFLAGS="-O3 -qstrict=ieeefp"
149        ;;
150    AIX/GCC)
151        THE_OS=AIX
152        THE_COMP="the GNU C++"
153        CC=gcc; export CC
154        CXX=g++; export CXX
155        DEBUG_CFLAGS='-g -O0'
156        DEBUG_CXXFLAGS='-g -O0'
157        ;;
158    AIX/OpenXL)
159        THE_OS=AIX
160        THE_COMP="ibm-clang_r"
161        CC=`which ibm-clang_r`; export CC
162        if [ ! -x $CC ]; then
163           echo "ERROR: ibm-clang_r was not found, please check the PATH to make sure it is correct."; exit 1
164        fi
165        CXX=`which ibm-clang++_r`; export CXX
166        if [ ! -x $CXX ]; then
167           echo "ERROR: ibm-clang++_r was not found, please check the PATH to make sure it is correct."; exit 1
168        fi
169        RELEASE_CFLAGS="-O3"
170        RELEASE_CXXFLAGS="-O3"
171	;;
172    Solaris)
173        THE_OS=SOLARIS
174        THE_COMP="Sun's CC"
175        CC=`which cc`; export CC
176        CXX=`which CC`; export CXX
177        RELEASE_CFLAGS="-xO1 -xlibmil"
178        RELEASE_CXXFLAGS="-O4 -xlibmil"
179        ;;
180    Solaris/GCC)
181        THE_OS=SOLARIS
182        THE_COMP="the GNU C++"
183        CC=gcc; export CC
184        CXX=g++; export CXX
185        RELEASE_CFLAGS=-O1
186        RELEASE_CXXFLAGS=-O2
187        ;;
188    SolarisX86)
189        THE_OS="SOLARIS X86"
190        THE_COMP="Sun's CC"
191        CC=`which cc`; export CC
192        CXX=`which CC`; export CXX
193        LDFLAGS="${LDFLAGS} -lCrun";export LDFLAGS
194        RELEASE_CFLAGS=-xO3
195        RELEASE_CXXFLAGS=-O3
196        ;;
197    HP-UX/ACC)
198        THE_OS="HP-UX 11"
199        THE_COMP="aCC"
200        CC=cc; export CC
201        CXX=aCC; export CXX
202        RELEASE_CFLAGS='+O2 +Ofltacc'
203        RELEASE_CXXFLAGS='+O2 +Ofltacc'
204        ;;
205    IBMi)
206        THE_OS="IBM i"
207        THE_COMP="the iCC C++"
208        CC=icc; export CC
209        CXX=icc; export CXX
210        CPP="$CC -c -qpponly"; export CPP
211        MAKE=gmake; export MAKE
212        U_MAKE=gmake; export U_MAKE
213        # gmake is a .pgm and may not be on the path.  Don't use a full path, just use gmake.
214        ac_cv_path_U_MAKE=gmake; export ac_cv_path_U_MAKE
215        RELEASE_CFLAGS='-O4'
216        RELEASE_CXXFLAGS='-O4'
217        ;;
218    Linux/ECC)
219        THE_OS="Linux"
220        THE_COMP="Intel ECC 7.1"
221        CC=ecc; export CC
222        CXX=ecpc; export CXX
223        RELEASE_CFLAGS='-O2'
224        RELEASE_CXXFLAGS='-O2'
225        ;;
226    Linux/ICC)
227        THE_OS="Linux"
228        CC=`which icc`; export CC
229        CXX=`which icpc`; export CXX
230	ICC_VER=`${CC} -v 2>&1`
231        RELEASE_CFLAGS='-O'
232        RELEASE_CXXFLAGS='-O'
233        export CFLAGS="-fp-model precise"
234        export CXXFLAGS="-fp-model precise"
235	if [ "${ICC_VER}" = "Version 9.0 " ]; then
236		RELEASE_CFLAGS=''
237		RELEASE_CXXFLAGS=''
238		export CFLAGS="${CFLAGS} -O0"
239		export CXXFLAGS="${CXXFLAGS} -O0"
240		echo "ICC 9.0 does not work with optimization- disabling optimizations"
241	fi
242        THE_COMP="Intel ${ICC_VER}"
243        ;;
244    Linux/VA)
245        THE_OS="Linux"
246        THE_COMP="IBM XL C++ Compiler"
247        CC=`which xlclang`; export CC
248        CXX=`which xlclang++`; export CXX
249        RELEASE_CFLAGS="-O3"
250        RELEASE_CXXFLAGS="-O3"
251        ;;
252    Linux/gcc)
253        THE_OS="Linux"
254        THE_COMP="the GNU C++"
255        CC=gcc; export CC
256        CXX=g++; export CXX
257        RELEASE_CFLAGS='-O3'
258        RELEASE_CXXFLAGS='-O3'
259        DEBUG_CFLAGS='-g'
260        DEBUG_CXXFLAGS='-g'
261        ;;
262    Linux/clang)
263        THE_OS="Linux"
264        THE_COMP="the Clang C++"
265        CC=clang; export CC
266        CXX=clang++; export CXX
267        RELEASE_CFLAGS='-O3'
268        RELEASE_CXXFLAGS='-O3'
269        DEBUG_CFLAGS='-g'
270        DEBUG_CXXFLAGS='-g'
271        ;;
272    Linux*)
273        THE_OS="Linux"
274        THE_COMP="the default C++"
275        RELEASE_CFLAGS='-O3'
276        RELEASE_CXXFLAGS='-O3'
277        DEBUG_CFLAGS='-g'
278        DEBUG_CXXFLAGS='-g'
279        ;;
280    Cygwin)
281        THE_OS="Cygwin"
282        THE_COMP="the GNU C++"
283        RELEASE_CFLAGS='-O3'
284        RELEASE_CXXFLAGS='-O3'
285        ;;
286    Cygwin/MSVC)
287        THE_OS="Windows with Cygwin"
288        THE_COMP="Microsoft Visual C++"
289        CC=cl; export CC
290        CXX=cl; export CXX
291        RELEASE_CFLAGS='-Gy -MD'
292        RELEASE_CXXFLAGS='-Gy -MD'
293        DEBUG_CFLAGS='-FS -Zi -MDd'
294        DEBUG_CXXFLAGS='-FS -Zi -MDd'
295        DEBUG_LDFLAGS='-DEBUG'
296        ;;
297    Cygwin/MSVC2005)
298        THE_OS="Windows with Cygwin"
299        THE_COMP="Microsoft Visual C++ 2005"
300        CC=cl; export CC
301        CXX=cl; export CXX
302        RELEASE_CFLAGS='/Gy /MD'
303        RELEASE_CXXFLAGS='/Gy /MD'
304        DEBUG_CFLAGS='/Zi /MDd'
305        DEBUG_CXXFLAGS='/Zi /MDd'
306        DEBUG_LDFLAGS='/DEBUG'
307        ;;
308    Cygwin/ICL)
309        THE_OS="Windows with Cygwin"
310        THE_COMP="Intel C++"
311        CC=icl; export CC
312        CXX=icl; export CXX
313        # The Intel compiler has optimization bugs. So we disable optimization.
314        RELEASE_CFLAGS='/Od'
315        RELEASE_CXXFLAGS='/Od'
316        DEBUG_CFLAGS='/Zi'
317        DEBUG_CXXFLAGS='/Zi'
318        DEBUG_LDFLAGS='/DEBUG'
319        ;;
320    macOS|MacOSX)
321        THE_OS="MacOS X (Darwin)"
322        THE_COMP="the default"
323        RELEASE_CFLAGS='-O2'
324        RELEASE_CXXFLAGS='-O2'
325        DEBUG_CFLAGS='-g -O0'
326        DEBUG_CXXFLAGS='-g -O0'
327        ;;
328    macOS/gcc|MacOSX/GCC)
329        THE_OS="MacOS X (Darwin)"
330        THE_COMP="the GNU C++"
331        RELEASE_CFLAGS='-O2'
332        RELEASE_CXXFLAGS='-O2'
333        DEBUG_CFLAGS='-g -O0'
334        DEBUG_CXXFLAGS='-g -O0'
335        CC=gcc; export CC
336        CXX=g++; export CXX
337        ;;
338    MinGW)
339        THE_OS="MinGW"
340        THE_COMP="the GNU C++"
341        RELEASE_CFLAGS='-O3'
342        RELEASE_CXXFLAGS='-O3'
343        export CXXFLAGS
344        ;;
345    MSYS/MSVC)
346        THE_OS="MSYS"
347        THE_COMP="Microsoft Visual C++"
348        CC=cl; export CC
349        CXX=cl; export CXX
350        RELEASE_CFLAGS='-Gy -MD'
351        RELEASE_CXXFLAGS='-Gy -MD'
352        DEBUG_CFLAGS='-FS -Zi -MDd'
353        DEBUG_CXXFLAGS='-FS -Zi -MDd'
354        DEBUG_LDFLAGS='-DEBUG'
355        ;;
356    *BSD)
357        THE_OS="BSD"
358        THE_COMP="the GNU C++"
359        DEBUG_CFLAGS='-g -O0'
360        DEBUG_CXXFLAGS='-g -O0'
361        ;;
362    TRU64V5.1/CXX)
363        THE_OS="OSF1"
364        THE_COMP="Compaq cxx"
365        CC=cc; export CC
366        CXX=cxx; export CXX
367        ;;
368    QNX)
369        THE_OS="QNX"
370        THE_COMP="QNX cc"
371        CC=qcc; export CC
372        CXX=QCC; export CXX
373        ;;
374    zOS)
375        THE_OS="z/OS (OS/390)"
376        THE_COMP="IBM OpenXL C/C++"
377        CC=`which ibm-clang`; export CC
378        if [ ! -x $CC ]; then
379           echo "ERROR: ibm-clang was not found, please check the PATH to make sure it is correct."; exit 1
380        fi
381        CXX=`which ibm-clang++`; export CXX
382        if [ ! -x $CXX ]; then
383           echo "ERROR: ibm-clang++ was not found, please check the PATH to make sure it is correct."; exit 1
384        fi
385        RELEASE_CFLAGS='-O2 -m32 -D_UNIX03_SOURCE -D_UNIX03_THREADS -D_POSIX_SOURCE -D_POSIX_THREADS -D_OPEN_SYS_SOCK_IPV6=1 -D_XOPEN_SOURCE_EXTENDED=1 -DOE_SOCKETS -D_OPEN_SYS_IF_EXT=1'
386        RELEASE_CXXFLAGS='-O2 -m32 -D_UNIX03_SOURCE -D_UNIX03_THREADS -D_POSIX_SOURCE -D_POSIX_THREADS -D_OPEN_SYS_SOCK_IPV6=1 -D_XOPEN_SOURCE_EXTENDED=1 -DOE_SOCKETS -D_OPEN_SYS_IF_EXT=1'
387        RELEASE_LDFLAGS='-m32'
388        DEBUG_CFLAGS='-g -O0 -m32 -D_UNIX03_SOURCE -D_UNIX03_THREADS -D_POSIX_SOURCE -D_POSIX_THREADS -D_OPEN_SYS_SOCK_IPV6=1 -D_XOPEN_SOURCE_EXTENDED=1 -DOE_SOCKETS -D_OPEN_SYS_IF_EXT=1'
389        DEBUG_CXXFLAGS='-g -O0 -m32 -D_UNIX03_SOURCE -D_UNIX03_THREADS -D_POSIX_SOURCE -D_POSIX_THREADS -D_OPEN_SYS_SOCK_IPV6=1 -D_XOPEN_SOURCE_EXTENDED=1 -DOE_SOCKETS -D_OPEN_SYS_IF_EXT=1'
390        DEBUG_LDFLAGS='-m32'
391        ;;
392    *)
393        >&2 echo "$me: unrecognized platform \"$platform\" (use --help for help)"
394        exit 1;;
395esac
396
397
398# Tweak flags
399
400if test $release -eq 1
401then
402    if test "$RELEASE_CFLAGS" = ""
403    then
404        case $CC in
405            gcc|*/gcc|*-gcc-*|*/*-gcc-*)
406                RELEASE_CFLAGS=-O3
407                ;;
408        esac
409    fi
410    if test "$RELEASE_CFLAGS" != ""
411    then
412        CFLAGS="$RELEASE_CFLAGS $CFLAGS"
413    fi
414    if test "$RELEASE_CXXFLAGS" = ""
415    then
416        case $CXX in
417            g++|*/g++|*-g++-*|*/*-g++-*)
418                RELEASE_CXXFLAGS=-O3
419                ;;
420        esac
421    fi
422    if test "$RELEASE_CXXFLAGS" != ""
423    then
424        CXXFLAGS="$RELEASE_CXXFLAGS $CXXFLAGS"
425    fi
426    if test "$RELEASE_LDFLAGS" != ""
427    then
428        LDFLAGS="$RELEASE_LDFLAGS $LDFLAGS"
429    fi
430fi
431
432if test $debug -eq 1
433then
434    if test "$DEBUG_CFLAGS" != ""
435    then
436        CFLAGS="$DEBUG_CFLAGS $CFLAGS"
437    fi
438    if test "$DEBUG_CXXFLAGS" != ""
439    then
440        CXXFLAGS="$DEBUG_CXXFLAGS $CXXFLAGS"
441    fi
442    if test "$DEBUG_LDFLAGS" != ""
443    then
444        LDFLAGS="$DEBUG_LDFLAGS $LDFLAGS"
445    fi
446fi
447
448export CFLAGS
449export CXXFLAGS
450export LDFLAGS
451
452# Run configure
453
454echo "export CPP=$CPP CC=$CC CXX=$CXX CPPFLAGS=$CPPFLAGS CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS MAKE=$MAKE"
455echo "Running ./configure $OPTS $@ for $THE_OS using $THE_COMP compiler"
456echo
457if $configure $OPTS $@
458then
459	echo
460	echo If the result of the above commands looks okay to you, go to the directory
461	echo source in the ICU distribution to build ICU. Please remember that ICU needs
462	echo GNU make to build properly...
463else
464	echo $0: ./configure failed
465	exit 1
466fi
467