]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/engine/build.sh
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / engine / build.sh
1 #!/bin/sh
2
3 #~ Copyright 2002-2005 Rene Rivera.
4 #~ Distributed under the Boost Software License, Version 1.0.
5 #~ (See accompanying file LICENSE_1_0.txt or copy at
6 #~ http://www.boost.org/LICENSE_1_0.txt)
7
8 # Reset the toolset.
9 BOOST_JAM_TOOLSET=
10 BOOST_JAM_OS=
11
12 # Run a command, and echo before doing so. Also checks the exit status and quits
13 # if there was an error.
14 echo_run ()
15 {
16 echo "$@"
17 $@
18 r=$?
19 if test $r -ne 0 ; then
20 exit $r
21 fi
22 }
23
24 # Print an error message, and exit with a status of 1.
25 error_exit ()
26 {
27 echo "###"
28 echo "###" "$@"
29 echo "###"
30 echo "### You can specify the toolset as the argument, i.e.:"
31 echo "### ./build.sh gcc"
32 echo "###"
33 echo "### Toolsets supported by this script are:"
34 echo "### acc, como, darwin, gcc, intel-darwin, intel-linux, kcc, kylix,"
35 echo "### mipspro, pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp"
36 echo "###"
37 echo "### A special toolset; cc, is available which is used as a fallback"
38 echo "### when a more specific toolset is not found and the cc command is"
39 echo "### detected. The 'cc' toolset will use the CC, CFLAGS, and LIBS"
40 echo "### environment variables, if present."
41 echo "###"
42 exit 1
43 }
44
45 # Check that a command is in the PATH.
46 test_path ()
47 {
48 if `command -v command 1>/dev/null 2>/dev/null`; then
49 command -v $1 1>/dev/null 2>/dev/null
50 else
51 hash $1 1>/dev/null 2>/dev/null
52 fi
53 }
54
55 # Check that the OS name, as returned by "uname", is as given.
56 test_uname ()
57 {
58 if test_path uname; then
59 test `uname` = $*
60 fi
61 }
62
63 # Try and guess the toolset to bootstrap the build with...
64 Guess_Toolset ()
65 {
66 if test_uname Darwin ; then BOOST_JAM_TOOLSET=darwin
67 elif test_uname IRIX ; then BOOST_JAM_TOOLSET=mipspro
68 elif test_uname IRIX64 ; then BOOST_JAM_TOOLSET=mipspro
69 elif test_uname OSF1 ; then BOOST_JAM_TOOLSET=tru64cxx
70 elif test_uname QNX && test_path qcc ; then BOOST_JAM_TOOLSET=qcc
71 elif test_uname Linux && test_path xlc; then
72 if /usr/bin/lscpu | grep Byte | grep Little > /dev/null 2>&1 ; then
73 # Little endian linux
74 BOOST_JAM_TOOLSET=xlcpp
75 else
76 #Big endian linux
77 BOOST_JAM_TOOLSET=vacpp
78 fi
79 elif test_uname AIX && test_path xlc; then BOOST_JAM_TOOLSET=vacpp
80 elif test_uname FreeBSD && test_path freebsd-version && test_path clang; then BOOST_JAM_TOOLSET=clang
81 elif test_path gcc ; then BOOST_JAM_TOOLSET=gcc
82 elif test_path icc ; then BOOST_JAM_TOOLSET=intel-linux
83 elif test -r /opt/intel/cc/9.0/bin/iccvars.sh ; then
84 BOOST_JAM_TOOLSET=intel-linux
85 BOOST_JAM_TOOLSET_ROOT=/opt/intel/cc/9.0
86 elif test -r /opt/intel_cc_80/bin/iccvars.sh ; then
87 BOOST_JAM_TOOLSET=intel-linux
88 BOOST_JAM_TOOLSET_ROOT=/opt/intel_cc_80
89 elif test -r /opt/intel/compiler70/ia32/bin/iccvars.sh ; then
90 BOOST_JAM_TOOLSET=intel-linux
91 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler70/ia32/
92 elif test -r /opt/intel/compiler60/ia32/bin/iccvars.sh ; then
93 BOOST_JAM_TOOLSET=intel-linux
94 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler60/ia32/
95 elif test -r /opt/intel/compiler50/ia32/bin/iccvars.sh ; then
96 BOOST_JAM_TOOLSET=intel-linux
97 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler50/ia32/
98 elif test_path pgcc ; then BOOST_JAM_TOOLSET=pgi
99 elif test_path pathcc ; then BOOST_JAM_TOOLSET=pathscale
100 elif test_path como ; then BOOST_JAM_TOOLSET=como
101 elif test_path KCC ; then BOOST_JAM_TOOLSET=kcc
102 elif test_path bc++ ; then BOOST_JAM_TOOLSET=kylix
103 elif test_path aCC ; then BOOST_JAM_TOOLSET=acc
104 elif test_uname HP-UX ; then BOOST_JAM_TOOLSET=acc
105 elif test -r /opt/SUNWspro/bin/cc ; then
106 BOOST_JAM_TOOLSET=sunpro
107 BOOST_JAM_TOOLSET_ROOT=/opt/SUNWspro/
108 # Test for "cc" as the default fallback.
109 elif test_path $CC ; then BOOST_JAM_TOOLSET=cc
110 elif test_path cc ; then
111 BOOST_JAM_TOOLSET=cc
112 CC=cc
113 fi
114 if test "$BOOST_JAM_TOOLSET" = "" ; then
115 error_exit "Could not find a suitable toolset."
116 fi
117 }
118
119 # The one option we support in the invocation
120 # is the name of the toolset to force building
121 # with.
122 case "$1" in
123 --guess-toolset) Guess_Toolset ; echo "$BOOST_JAM_TOOLSET" ; exit 1 ;;
124 -*) Guess_Toolset ;;
125 ?*) BOOST_JAM_TOOLSET=$1 ; shift ;;
126 *) Guess_Toolset ;;
127 esac
128 BOOST_JAM_OPT_JAM="-o bootstrap/jam0"
129 BOOST_JAM_OPT_MKJAMBASE="-o bootstrap/mkjambase0"
130 BOOST_JAM_OPT_YYACC="-o bootstrap/yyacc0"
131 case $BOOST_JAM_TOOLSET in
132
133 gcc)
134 # Check whether it's MinGW GCC, which has Windows headers and none of POSIX ones.
135 machine=$(gcc -dumpmachine 2>/dev/null)
136 if [ $? -ne 0 ]; then
137 echo "BOOST_JAM_TOOLSET is gcc, but the 'gcc' command cannot be executed."
138 echo "Make sure 'gcc' is in PATH, or use a different toolset."
139 exit 1
140 fi
141 case $machine in
142 *mingw*)
143 # MinGW insists that its bin directory be in PATH.
144 if test -r ${BOOST_JAM_TOOLSET_ROOT}bin/gcc ; then
145 export PATH=${BOOST_JAM_TOOLSET_ROOT}bin:$PATH
146 fi
147 BOOST_JAM_CC="gcc -DNT"
148 BOOST_JAM_OS="NT"
149 ;;
150
151 *)
152 BOOST_JAM_CC=gcc
153 esac
154 ;;
155
156 darwin)
157 BOOST_JAM_CC=cc
158 ;;
159
160 intel-darwin)
161 BOOST_JAM_CC=icc
162 ;;
163
164 intel-linux)
165 test_path icc >/dev/null 2>&1
166 if test $? ; then
167 BOOST_JAM_CC=`test_path icc`
168 echo "Found $BOOST_JAM_CC in environment"
169 BOOST_JAM_TOOLSET_ROOT=`echo $BOOST_JAM_CC | sed -e 's/bin.*\/icc//'`
170 # probably the most widespread
171 ARCH=intel64
172 else
173 echo "No intel compiler in current path"
174 echo "Look in a few old place for legacy reason"
175 if test -r /opt/intel/cc/9.0/bin/iccvars.sh ; then
176 BOOST_JAM_TOOLSET_ROOT=/opt/intel/cc/9.0/
177 elif test -r /opt/intel_cc_80/bin/iccvars.sh ; then
178 BOOST_JAM_TOOLSET_ROOT=/opt/intel_cc_80/
179 elif test -r /opt/intel/compiler70/ia32/bin/iccvars.sh ; then
180 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler70/ia32/
181 elif test -r /opt/intel/compiler60/ia32/bin/iccvars.sh ; then
182 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler60/ia32/
183 elif test -r /opt/intel/compiler50/ia32/bin/iccvars.sh ; then
184 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler50/ia32/
185 fi
186 fi
187 if test -r ${BOOST_JAM_TOOLSET_ROOT}bin/iccvars.sh ; then
188 # iccvars does not change LD_RUN_PATH. We adjust LD_RUN_PATH here in
189 # order not to have to rely on ld.so.conf knowing the icc library
190 # directory. We do this before running iccvars.sh in order to allow a
191 # user to add modifications to LD_RUN_PATH in iccvars.sh.
192 if test -z "${LD_RUN_PATH}"; then
193 LD_RUN_PATH="${BOOST_JAM_TOOLSET_ROOT}lib"
194 else
195 LD_RUN_PATH="${BOOST_JAM_TOOLSET_ROOT}lib:${LD_RUN_PATH}"
196 fi
197 export LD_RUN_PATH
198 . ${BOOST_JAM_TOOLSET_ROOT}bin/iccvars.sh $ARCH
199 fi
200 if test -z "$BOOST_JAM_CC" ; then
201 BOOST_JAM_CC=icc
202 fi
203 ;;
204
205 vacpp)
206 BOOST_JAM_CC=xlc
207 ;;
208
209 xlcpp)
210 BOOST_JAM_CC=xlc
211 ;;
212
213 como)
214 BOOST_JAM_CC="como --c"
215 ;;
216
217 kcc)
218 BOOST_JAM_CC=KCC
219 ;;
220
221 kylix)
222 BOOST_JAM_CC=bc++
223 ;;
224
225 mipspro)
226 BOOST_JAM_CC=cc
227 ;;
228
229 pathscale)
230 BOOST_JAM_CC=pathcc
231 ;;
232
233 pgi)
234 BOOST_JAM_CC=pgcc
235 ;;
236
237 sun*)
238 if test -z "${BOOST_JAM_TOOLSET_ROOT}" -a -r /opt/SUNWspro/bin/cc ; then
239 BOOST_JAM_TOOLSET_ROOT=/opt/SUNWspro/
240 fi
241 if test -r "${BOOST_JAM_TOOLSET_ROOT}bin/cc" ; then
242 PATH=${BOOST_JAM_TOOLSET_ROOT}bin:${PATH}
243 export PATH
244 fi
245 BOOST_JAM_CC=cc
246 ;;
247
248 clang*)
249 BOOST_JAM_CC="clang -Wno-unused -Wno-format"
250 BOOST_JAM_TOOLSET=clang
251 ;;
252
253 tru64cxx)
254 BOOST_JAM_CC=cc
255 ;;
256
257 acc)
258 BOOST_JAM_CC="cc -Ae"
259 ;;
260
261 cc)
262 if test -z "$CC" ; then CC=cc ; fi
263 BOOST_JAM_CC=$CC
264 BOOST_JAM_OPT_JAM="$BOOST_JAM_OPT_JAM $CFLAGS $LIBS"
265 BOOST_JAM_OPT_MKJAMBASE="$BOOST_JAM_OPT_MKJAMBASE $CFLAGS $LIBS"
266 BOOST_JAM_OPT_YYACC="$BOOST_JAM_OPT_YYACC $CFLAGS $LIBS"
267 ;;
268
269 qcc)
270 BOOST_JAM_CC=qcc
271 ;;
272
273 *)
274 error_exit "Unknown toolset: $BOOST_JAM_TOOLSET"
275 ;;
276 esac
277
278 echo "###"
279 echo "### Using '$BOOST_JAM_TOOLSET' toolset."
280 echo "###"
281
282 YYACC_SOURCES="yyacc.c"
283 MKJAMBASE_SOURCES="mkjambase.c"
284 BJAM_SOURCES="\
285 command.c compile.c constants.c debug.c execcmd.c frames.c function.c glob.c\
286 hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c\
287 object.c option.c output.c parse.c pathsys.c regexp.c rules.c\
288 scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c\
289 builtins.c class.c cwd.c native.c md5.c w32_getreg.c modules/set.c\
290 modules/path.c modules/regex.c modules/property-set.c modules/sequence.c\
291 modules/order.c"
292 case $BOOST_JAM_OS in
293 NT)
294 BJAM_SOURCES="${BJAM_SOURCES} execnt.c filent.c pathnt.c"
295 ;;
296
297 *)
298 BJAM_SOURCES="${BJAM_SOURCES} execunix.c fileunix.c pathunix.c"
299 ;;
300 esac
301
302 BJAM_UPDATE=
303 if test "$1" = "--update" -o "$2" = "--update" -o "$3" = "--update" -o "$4" = "--update" ; then
304 BJAM_UPDATE="update"
305 fi
306 if test "${BJAM_UPDATE}" = "update" -a ! -x "./bootstrap/jam0" ; then
307 BJAM_UPDATE=
308 fi
309
310 if test "${BJAM_UPDATE}" != "update" ; then
311 echo_run rm -rf bootstrap
312 echo_run mkdir bootstrap
313 if test ! -r jamgram.y -o ! -r jamgramtab.h ; then
314 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_YYACC} ${YYACC_SOURCES}
315 if test -x "./bootstrap/yyacc0" ; then
316 echo_run ./bootstrap/yyacc0 jamgram.y jamgramtab.h jamgram.yy
317 fi
318 fi
319 if test ! -r jamgram.c -o ! -r jamgram.h ; then
320 if test_path yacc ; then YACC="yacc -d"
321 elif test_path bison ; then YACC="bison -y -d --yacc"
322 fi
323 echo_run $YACC jamgram.y
324 mv -f y.tab.c jamgram.c
325 mv -f y.tab.h jamgram.h
326 fi
327 if test ! -r jambase.c ; then
328 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_MKJAMBASE} ${MKJAMBASE_SOURCES}
329 if test -x "./bootstrap/mkjambase0" ; then
330 echo_run ./bootstrap/mkjambase0 jambase.c Jambase
331 fi
332 fi
333 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_JAM} ${BJAM_SOURCES}
334 fi
335 if test -x "./bootstrap/jam0" ; then
336 if test "${BJAM_UPDATE}" != "update" ; then
337 echo_run ./bootstrap/jam0 -f build.jam --toolset=$BOOST_JAM_TOOLSET "--toolset-root=$BOOST_JAM_TOOLSET_ROOT" "$@" clean
338 fi
339 echo_run ./bootstrap/jam0 -f build.jam --toolset=$BOOST_JAM_TOOLSET "--toolset-root=$BOOST_JAM_TOOLSET_ROOT" "$@"
340 fi