xref: /aosp_15_r20/external/icu/icu4c/source/runConfigureICU (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
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    MacOSX              Use the default compilers on MacOS X (Darwin)
56    MacOSX/GCC          Use the GNU gcc/g++ compilers on MacOSX (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 cxx compiler on z/OS (os/390)
65    zOSV1R2             Use the IBM cxx compiler for z/OS 1.2
66EOE
67    fi
68
69    exit $ec
70}
71
72# Parse arguments
73
74platform=
75debug=0
76release=1
77
78while test $# -ne 0
79do
80    case "$1" in
81    -h|--help)
82        usage 0
83        ;;
84    --enable-debug)
85        debug=1
86        OPTS="$OPTS --enable-debug"
87        ;;
88    --disable-release)
89        release=0
90        OPTS="$OPTS --disable-release"
91        ;;
92    *)
93        platform="$1"
94        shift
95        break
96        ;;
97    esac
98    shift
99done
100
101if test x$platform = x
102then
103   usage 1
104fi
105
106# Go.
107
108rm -f config.cache
109rm -f config.log
110rm -f config.status
111
112DEBUG_CFLAGS='-g'
113DEBUG_CXXFLAGS='-g'
114
115if test x$configure = x
116then
117    if test -f ./configure
118    then
119        configuredir=.
120    else
121        configuredir=`echo $0 | sed 's,[^/]*$,,'`
122        if test x$configuredir = x$0
123        then
124            configuredir=.
125        fi
126    fi
127
128    if test x$configuredir = x
129    then
130        configuredir=.
131    fi
132
133    configure=$configuredir/configure
134fi
135
136case $platform in
137    AIX)
138        THE_OS=AIX
139        THE_COMP="xlclang"
140        CC=`which xlclang`; export CC
141        if [ ! -x $CC ]; then
142           echo "ERROR: xlclang was not found, please check the PATH to make sure it is correct."; exit 1
143        fi
144        CXX=`which xlclang++`; export CXX
145        if [ ! -x $CXX ]; then
146           echo "ERROR: xlclang++ was not found, please check the PATH to make sure it is correct."; exit 1
147        fi
148        RELEASE_CFLAGS="-O3 -qstrict=ieeefp"
149        RELEASE_CXXFLAGS="-O3 -qstrict=ieeefp"
150        ;;
151    AIX/GCC)
152        THE_OS=AIX
153        THE_COMP="the GNU C++"
154        CC=gcc; export CC
155        CXX=g++; export CXX
156        DEBUG_CFLAGS='-g -O0'
157        DEBUG_CXXFLAGS='-g -O0'
158        ;;
159    AIX/OpenXL)
160        THE_OS=AIX
161        THE_COMP="ibm-clang_r"
162        CC=`which ibm-clang_r`; export CC
163        if [ ! -x $CC ]; then
164           echo "ERROR: ibm-clang_r was not found, please check the PATH to make sure it is correct."; exit 1
165        fi
166        CXX=`which ibm-clang++_r`; export CXX
167        if [ ! -x $CXX ]; then
168           echo "ERROR: ibm-clang++_r was not found, please check the PATH to make sure it is correct."; exit 1
169        fi
170        RELEASE_CFLAGS="-O3"
171        RELEASE_CXXFLAGS="-O3"
172	;;
173    Solaris)
174        THE_OS=SOLARIS
175        THE_COMP="Sun's CC"
176        CC=`which cc`; export CC
177        CXX=`which CC`; export CXX
178        RELEASE_CFLAGS="-xO1 -xlibmil"
179        RELEASE_CXXFLAGS="-O4 -xlibmil"
180        ;;
181    Solaris/GCC)
182        THE_OS=SOLARIS
183        THE_COMP="the GNU C++"
184        CC=gcc; export CC
185        CXX=g++; export CXX
186        RELEASE_CFLAGS=-O1
187        RELEASE_CXXFLAGS=-O2
188        ;;
189    SolarisX86)
190        THE_OS="SOLARIS X86"
191        THE_COMP="Sun's CC"
192        CC=`which cc`; export CC
193        CXX=`which CC`; export CXX
194        LDFLAGS="${LDFLAGS} -lCrun";export LDFLAGS
195        RELEASE_CFLAGS=-xO3
196        RELEASE_CXXFLAGS=-O3
197        ;;
198    HP-UX/ACC)
199        THE_OS="HP-UX 11"
200        THE_COMP="aCC"
201        CC=cc; export CC
202        CXX=aCC; export CXX
203        RELEASE_CFLAGS='+O2 +Ofltacc'
204        RELEASE_CXXFLAGS='+O2 +Ofltacc'
205        ;;
206    IBMi)
207        THE_OS="IBM i"
208        THE_COMP="the iCC C++"
209        CC=icc; export CC
210        CXX=icc; export CXX
211        CPP="$CC -c -qpponly"; export CPP
212        MAKE=gmake; export MAKE
213        U_MAKE=gmake; export U_MAKE
214        # gmake is a .pgm and may not be on the path.  Don't use a full path, just use gmake.
215        ac_cv_path_U_MAKE=gmake; export ac_cv_path_U_MAKE
216        RELEASE_CFLAGS='-O4'
217        RELEASE_CXXFLAGS='-O4'
218        ;;
219    Linux/ECC)
220        THE_OS="Linux"
221        THE_COMP="Intel ECC 7.1"
222        CC=ecc; export CC
223        CXX=ecpc; export CXX
224        RELEASE_CFLAGS='-O2'
225        RELEASE_CXXFLAGS='-O2'
226        ;;
227    Linux/ICC)
228        THE_OS="Linux"
229        CC=`which icc`; export CC
230        CXX=`which icpc`; export CXX
231	ICC_VER=`${CC} -v 2>&1`
232        RELEASE_CFLAGS='-O'
233        RELEASE_CXXFLAGS='-O'
234        export CFLAGS="-fp-model precise"
235        export CXXFLAGS="-fp-model precise"
236	if [ "${ICC_VER}" = "Version 9.0 " ]; then
237		RELEASE_CFLAGS=''
238		RELEASE_CXXFLAGS=''
239		export CFLAGS="${CFLAGS} -O0"
240		export CXXFLAGS="${CXXFLAGS} -O0"
241		echo "ICC 9.0 does not work with optimization- disabling optimizations"
242	fi
243        THE_COMP="Intel ${ICC_VER}"
244        ;;
245    Linux/VA)
246        THE_OS="Linux"
247        THE_COMP="IBM XL C++ Compiler"
248        CC=`which xlclang`; export CC
249        CXX=`which xlclang++`; export CXX
250        RELEASE_CFLAGS="-O3"
251        RELEASE_CXXFLAGS="-O3"
252        ;;
253    Linux/gcc)
254        THE_OS="Linux"
255        THE_COMP="the GNU C++"
256        CC=gcc; export CC
257        CXX=g++; export CXX
258        RELEASE_CFLAGS='-O3'
259        RELEASE_CXXFLAGS='-O3'
260        DEBUG_CFLAGS='-g'
261        DEBUG_CXXFLAGS='-g'
262        ;;
263    Linux/clang)
264        THE_OS="Linux"
265        THE_COMP="the Clang C++"
266        CC=clang; export CC
267        CXX=clang++; export CXX
268        RELEASE_CFLAGS='-O3'
269        RELEASE_CXXFLAGS='-O3'
270        DEBUG_CFLAGS='-g'
271        DEBUG_CXXFLAGS='-g'
272        ;;
273    Linux*)
274        THE_OS="Linux"
275        THE_COMP="the default C++"
276        RELEASE_CFLAGS='-O3'
277        RELEASE_CXXFLAGS='-O3'
278        DEBUG_CFLAGS='-g'
279        DEBUG_CXXFLAGS='-g'
280        ;;
281    Cygwin)
282        THE_OS="Cygwin"
283        THE_COMP="the GNU C++"
284        RELEASE_CFLAGS='-O3'
285        RELEASE_CXXFLAGS='-O3'
286        ;;
287    Cygwin/MSVC)
288        THE_OS="Windows with Cygwin"
289        THE_COMP="Microsoft Visual C++"
290        CC=cl; export CC
291        CXX=cl; export CXX
292        RELEASE_CFLAGS='-Gy -MD'
293        RELEASE_CXXFLAGS='-Gy -MD'
294        DEBUG_CFLAGS='-FS -Zi -MDd'
295        DEBUG_CXXFLAGS='-FS -Zi -MDd'
296        DEBUG_LDFLAGS='-DEBUG'
297        ;;
298    Cygwin/MSVC2005)
299        THE_OS="Windows with Cygwin"
300        THE_COMP="Microsoft Visual C++ 2005"
301        CC=cl; export CC
302        CXX=cl; export CXX
303        RELEASE_CFLAGS='/Gy /MD'
304        RELEASE_CXXFLAGS='/Gy /MD'
305        DEBUG_CFLAGS='/Zi /MDd'
306        DEBUG_CXXFLAGS='/Zi /MDd'
307        DEBUG_LDFLAGS='/DEBUG'
308        ;;
309    Cygwin/ICL)
310        THE_OS="Windows with Cygwin"
311        THE_COMP="Intel C++"
312        CC=icl; export CC
313        CXX=icl; export CXX
314        # The Intel compiler has optimization bugs. So we disable optimization.
315        RELEASE_CFLAGS='/Od'
316        RELEASE_CXXFLAGS='/Od'
317        DEBUG_CFLAGS='/Zi'
318        DEBUG_CXXFLAGS='/Zi'
319        DEBUG_LDFLAGS='/DEBUG'
320        ;;
321    MacOSX)
322        THE_OS="MacOS X (Darwin)"
323        THE_COMP="the default"
324        RELEASE_CFLAGS='-O2'
325        RELEASE_CXXFLAGS='-O2'
326        DEBUG_CFLAGS='-g -O0'
327        DEBUG_CXXFLAGS='-g -O0'
328        ;;
329    MacOSX/GCC)
330        THE_OS="MacOS X (Darwin)"
331        THE_COMP="the GNU C++"
332        RELEASE_CFLAGS='-O2'
333        RELEASE_CXXFLAGS='-O2'
334        DEBUG_CFLAGS='-g -O0'
335        DEBUG_CXXFLAGS='-g -O0'
336        CC=gcc; export CC
337        CXX=g++; export CXX
338        ;;
339    MinGW)
340        THE_OS="MinGW"
341        THE_COMP="the GNU C++"
342        RELEASE_CFLAGS='-O3'
343        RELEASE_CXXFLAGS='-O3'
344        export CXXFLAGS
345        ;;
346    MSYS/MSVC)
347        THE_OS="MSYS"
348        THE_COMP="Microsoft Visual C++"
349        CC=cl; export CC
350        CXX=cl; export CXX
351        RELEASE_CFLAGS='-Gy -MD'
352        RELEASE_CXXFLAGS='-Gy -MD'
353        DEBUG_CFLAGS='-FS -Zi -MDd'
354        DEBUG_CXXFLAGS='-FS -Zi -MDd'
355        DEBUG_LDFLAGS='-DEBUG'
356        ;;
357    *BSD)
358        THE_OS="BSD"
359        THE_COMP="the GNU C++"
360        DEBUG_CFLAGS='-g -O0'
361        DEBUG_CXXFLAGS='-g -O0'
362        ;;
363    TRU64V5.1/CXX)
364        THE_OS="OSF1"
365        THE_COMP="Compaq cxx"
366        CC=cc; export CC
367        CXX=cxx; export CXX
368        ;;
369    QNX)
370        THE_OS="QNX"
371        THE_COMP="QNX cc"
372        CC=qcc; export CC
373        CXX=QCC; export CXX
374        ;;
375    zOS)
376        THE_OS="z/OS (OS/390)"
377        THE_COMP="z/OS C/C++"
378        CC=xlc; export CC
379        CXX=xlC; export CXX
380        RELEASE_CFLAGS="-O2 -Wc,'inline(AUTO,NOREPORT,1000,8000)'"
381        RELEASE_CXXFLAGS="-O2 -Wc,'inline(AUTO,NOREPORT,1000,8000)'"
382        ;;
383    zOSV1R2)
384        THE_OS="z/OS 1.2"
385        THE_COMP="z/OS 1.2 C/C++"
386        CC=cc; export CC
387        CXX=cxx; export CXX
388        export COMPILE_LINK_ENVVAR='_CXX_CICC_VER}=0x41020000 _C89_CVERSION=0x41020000 _CC_CVERSION=0x41020000 _CXX_PVERSION=0x41020000 _C89_PVERSION=0x41020000 _CC_PVERSION=0x41020000'
389        export _CXX_CVERSION=0x41020000 _C89_CVERSION=0x41020000 _CC_CVERSION=0x41020000 _CXX_PVERSION=0x41020000 _C89_PVERSION=0x41020000 _CC_PVERSION=0x41020000
390        export LDFLAGS="-Wl,'compat=pm3'"
391        export CFLAGS="-Wc,'target(zOSV1R2)'"
392        export CXXFLAGS="-Wc,'target(zOSV1R2)'"
393        RELEASE_CFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
394        RELEASE_CXXFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
395        ;;
396    *)
397        >&2 echo "$me: unrecognized platform \"$platform\" (use --help for help)"
398        exit 1;;
399esac
400
401
402# Tweak flags
403
404if test $release -eq 1
405then
406    if test "$RELEASE_CFLAGS" = ""
407    then
408        case $CC in
409            gcc|*/gcc|*-gcc-*|*/*-gcc-*)
410                RELEASE_CFLAGS=-O3
411                ;;
412        esac
413    fi
414    if test "$RELEASE_CFLAGS" != ""
415    then
416        CFLAGS="$RELEASE_CFLAGS $CFLAGS"
417    fi
418    if test "$RELEASE_CXXFLAGS" = ""
419    then
420        case $CXX in
421            g++|*/g++|*-g++-*|*/*-g++-*)
422                RELEASE_CXXFLAGS=-O3
423                ;;
424        esac
425    fi
426    if test "$RELEASE_CXXFLAGS" != ""
427    then
428        CXXFLAGS="$RELEASE_CXXFLAGS $CXXFLAGS"
429    fi
430    if test "$RELEASE_LDFLAGS" != ""
431    then
432        LDFLAGS="$RELEASE_LDFLAGS $LDFLAGS"
433    fi
434fi
435
436if test $debug -eq 1
437then
438    if test "$DEBUG_CFLAGS" != ""
439    then
440        CFLAGS="$DEBUG_CFLAGS $CFLAGS"
441    fi
442    if test "$DEBUG_CXXFLAGS" != ""
443    then
444        CXXFLAGS="$DEBUG_CXXFLAGS $CXXFLAGS"
445    fi
446    if test "$DEBUG_LDFLAGS" != ""
447    then
448        LDFLAGS="$DEBUG_LDFLAGS $LDFLAGS"
449    fi
450fi
451
452export CFLAGS
453export CXXFLAGS
454export LDFLAGS
455
456# Run configure
457
458echo "export CPP=$CPP CC=$CC CXX=$CXX CPPFLAGS=$CPPFLAGS CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS MAKE=$MAKE"
459echo "Running ./configure $OPTS $@ for $THE_OS using $THE_COMP compiler"
460echo
461if $configure $OPTS $@
462then
463	echo
464	echo If the result of the above commands looks okay to you, go to the directory
465	echo source in the ICU distribution to build ICU. Please remember that ICU needs
466	echo GNU make to build properly...
467else
468	echo $0: ./configure failed
469	exit 1
470fi
471