1
#!/bin/sh
2
# Copyright (c) 1999-2007, 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
    i5OS                Use the i5/OS compilers on i5/OS
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
        CXX=`which xlC_r`; export CXX
129
        RELEASE_CFLAGS="-O2 -qmaxmem=-1"
130
        RELEASE_CXXFLAGS="-O2 -qmaxmem=-1"
131
        ;;
132
    AIX/GCC)
133
        THE_OS=AIX
134
        THE_COMP="the GNU C++"
135
        CC=gcc; export CC
136
        CXX=g++; export CXX
137
        ;;
138
    Solaris)
139
        THE_OS=SOLARIS
140
        THE_COMP="Sun's CC"
141
        CC=`which cc`; export CC
142
        CXX=`which CC`; export CXX
143
        RELEASE_CFLAGS="-xO4 -xlibmil"
144
        RELEASE_CXXFLAGS="-O4 -xlibmil"
145
        ;;
146
    Solaris/GCC)
147
        THE_OS=SOLARIS
148
        THE_COMP="the GNU C++"
149
        CC=gcc; export CC
150
        CXX=g++; export CXX
151
        RELEASE_CFLAGS=-O1
152
        RELEASE_CXXFLAGS=-O3
153
        ;;
154
    SolarisX86)
155
        THE_OS="SOLARIS X86"
156
        THE_COMP="Sun's CC"
157
        CC=`which cc`; export CC
158
        CXX=`which CC`; export CXX
159
        LDFLAGS="-L -lCrun";export LDFLAGS
160
        RELEASE_CFLAGS=-xO3
161
        RELEASE_CXXFLAGS=-O3
162
        ;;
163
    HP-UX/ACC)
164
        THE_OS="HP-UX 11"
165
        THE_COMP="aCC"
166
        CC=cc; export CC
167
        CXX=aCC; export CXX
168
        RELEASE_CFLAGS='+O2 +Ofltacc'
169
        RELEASE_CXXFLAGS='+O2 +Ofltacc'
170
        ;;
171
    i5OS)
172
        THE_OS="i5/OS"
173
        THE_COMP="the i5/OS C++"
174
        CC=/usr/bin/icc; export CC
175
        CXX=/usr/bin/icc; export CXX
176
        MAKE=/usr/bin/gmake; export MAKE
177
        RELEASE_CFLAGS='-O4'
178
        RELEASE_CXXFLAGS='-O4'
179
        ;;
180
    Linux/ECC)
181
        THE_OS="Linux"
182
        THE_COMP="Intel ECC 7.1"
183
        CC=ecc; export CC
184
        CXX=ecpc; export CXX
185
        RELEASE_CFLAGS='-O2'
186
        RELEASE_CXXFLAGS='-O2'
187
        ;;
188
    Linux/ICC)
189
        THE_OS="Linux"
190
        THE_COMP="Intel ICC 9.0"
191
        CC=`which icc`; export CC
192
        CXX=`which icpc`; export CXX
193
        RELEASE_CFLAGS='-O'
194
        RELEASE_CXXFLAGS='-O'
195
        ;;
196
    Linux/VA)
197
        THE_OS="Linux"
198
        THE_COMP="IBM Visual Age C++ Compiler"
199
        CC=`which xlc_r`; export CC
200
        CXX=`which xlC_r`; export CXX
201
        RELEASE_CFLAGS="-O2 -qmaxmem=-1"
202
        RELEASE_CXXFLAGS="-O2 -qmaxmem=-1"
203
        ;;
204
    Linux*)
205
        THE_OS="Linux"
206
        THE_COMP="the GNU C++"
207
        CC=gcc; export CC
208
        CXX=g++; export CXX
209
        ;;
210
    Cygwin)
211
        THE_OS="Cygwin"
212
        THE_COMP="the GNU C++"
213
        RELEASE_CFLAGS='-O3'
214
        RELEASE_CXXFLAGS='-O3'
215
        ;;
216
    Cygwin/MSVC)
217
        THE_OS="Windows with Cygwin"
218
        THE_COMP="Microsoft Visual C++"
219
        CC=cl; export CC
220
        CXX=cl; export CXX
221
        RELEASE_CFLAGS='/O2 /Ob2 /Op'
222
        RELEASE_CXXFLAGS='/O2 /Ob2 /Op'
223
        DEBUG_CFLAGS='/Zi'
224
        DEBUG_CXXFLAGS='/Zi'
225
        DEBUG_LDFLAGS='/DEBUG'
226
        ;;
227
    Cygwin/MSVC2005)
228
        THE_OS="Windows with Cygwin"
229
        THE_COMP="Microsoft Visual C++ 2005"
230
        CC=cl; export CC
231
        CXX=cl; export CXX
232
        RELEASE_CFLAGS='/O2 /Ob2'
233
        RELEASE_CXXFLAGS='/O2 /Ob2'
234
        RELEASE_LDFLAGS='/OPT:NOWIN98'
235
        DEBUG_CFLAGS='/Zi'
236
        DEBUG_CXXFLAGS='/Zi'
237
        DEBUG_LDFLAGS='/DEBUG'
238
        ;;
239
    Cygwin/ICL)
240
        THE_OS="Windows with Cygwin"
241
        THE_COMP="Intel C++"
242
        CC=icl; export CC
243
        CXX=icl; export CXX
244
        # The Intel compiler has optimization bugs. So we disable optimization.
245
        RELEASE_CFLAGS='/Od'
246
        RELEASE_CXXFLAGS='/Od'
247
        DEBUG_CFLAGS='/Zi'
248
        DEBUG_CXXFLAGS='/Zi'
249
        DEBUG_LDFLAGS='/DEBUG'
250
        ;;
251
    MacOSX)
252
        THE_OS="MacOS X (Darwin)"
253
        THE_COMP="the GNU C++"
254
        RELEASE_CFLAGS='-O2'
255
        RELEASE_CXXFLAGS='-O2'
256
        ;;
257
    *BSD)
258
        THE_OS="BSD"
259
        THE_COMP="the GNU C++"
260
        CC=gcc; export CC
261
        CXX=g++; export CXX
262
        ;;
263
    TRU64V5.1/CXX)
264
        THE_OS="OSF1"
265
        THE_COMP="Compaq cxx"
266
        CC=cc; export CC
267
        CXX=cxx; export CXX
268
        ;;
269
    QNX)
270
        THE_OS="QNX"
271
        THE_COMP="QNX cc"
272
        CC=qcc; export CC
273
        CXX=QCC; export CXX
274
        ;;
275
    zOS)
276
        THE_OS="z/OS (OS/390)"
277
        THE_COMP="z/OS C/C++"
278
        CC=cc; export CC
279
        CXX=cxx; export CXX
280
        RELEASE_CFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
281
        RELEASE_CXXFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
282
        ;;
283
    zOSV1R2)
284
        THE_OS="z/OS 1.2"
285
        THE_COMP="z/OS 1.2 C/C++"
286
        CC=cc; export CC
287
        CXX=cxx; export CXX
288
        export COMPILE_LINK_ENVVAR='_CXX_CVERSION=0x41020000 _C89_CVERSION=0x41020000 _CC_CVERSION=0x41020000 _CXX_PVERSION=0x41020000 _C89_PVERSION=0x41020000 _CC_PVERSION=0x41020000'
289
        export _CXX_CVERSION=0x41020000 _C89_CVERSION=0x41020000 _CC_CVERSION=0x41020000 _CXX_PVERSION=0x41020000 _C89_PVERSION=0x41020000 _CC_PVERSION=0x41020000
290
        export LDFLAGS="-Wl,'compat=pm3'"
291
        export CFLAGS="-Wc,'target(zOSV1R2)'"
292
        export CXXFLAGS="-Wc,'target(zOSV1R2)'"
293
        export RELEASE_CFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
294
        export RELEASE_CXXFLAGS="-2 -Wc,'inline(auto,noreport,500,4000)'"
295
        ;;
296
    *)
297
        >&2 echo "$me: unrecognized platform \"$platform\" (use --help for help)"
298
        exit 1;;
299
esac
300
301
302
# Tweak flags
303
304
if test $release -eq 1
305
then
306
    if test "$RELEASE_CFLAGS" = ""
307
    then
308
        case $CC in
309
            gcc|*/gcc|*-gcc-*|*/*-gcc-*)
310
                RELEASE_CFLAGS=-O3
311
                ;;
312
        esac
313
    fi
314
    if test "$RELEASE_CFLAGS" != ""
315
    then
316
        CFLAGS="$CFLAGS $RELEASE_CFLAGS"
317
    fi
318
    if test "$RELEASE_CXXFLAGS" = ""
319
    then
320
        case $CXX in
321
            g++|*/g++|*-g++-*|*/*-g++-*)
322
                RELEASE_CXXFLAGS=-O
323
                ;;
324
        esac
325
    fi
326
    if test "$RELEASE_CXXFLAGS" != ""
327
    then
328
        CXXFLAGS="$CXXFLAGS $RELEASE_CXXFLAGS"
329
    fi
330
    if test "$RELEASE_LDFLAGS" != ""
331
    then
332
        LDFLAGS="$LDFLAGS $RELEASE_LDFLAGS"
333
    fi
334
fi
335
336
if test $debug -eq 1
337
then
338
    if test "$DEBUG_CFLAGS" != ""
339
    then
340
        CFLAGS="$CFLAGS $DEBUG_CFLAGS"
341
    fi
342
    if test "$DEBUG_CXXFLAGS" != ""
343
    then
344
        CXXFLAGS="$CXXFLAGS $DEBUG_CXXFLAGS"
345
    fi
346
    if test "$DEBUG_LDFLAGS" != ""
347
    then
348
        LDFLAGS="$LDFLAGS $DEBUG_LDFLAGS"
349
    fi
350
fi
351
352
export CFLAGS
353
export CXXFLAGS
354
export LDFLAGS
355
356
# Run configure
357
358
echo "Running ./configure $OPTS $@ for $THE_OS using $THE_COMP compiler"
359
echo
360
$configure $OPTS $@
361
echo
362
echo If the result of the above commands looks okay to you, go to the directory
363
echo source in the ICU distribution to build ICU. Please remember that ICU needs
364
echo GNU make to build properly...