xref: /titanic_41/usr/src/lib/libshell/misc/buildksh93.sh (revision 6a1af1a67532df169a657cce07140be64bdea084)
1#!/bin/ksh -p
2# (note we use "/bin/ksh -p" for Linux/pdksh support in this script)
3
4#
5# CDDL HEADER START
6#
7# The contents of this file are subject to the terms of the
8# Common Development and Distribution License (the "License").
9# You may not use this file except in compliance with the License.
10#
11# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
12# or http://www.opensolaris.org/os/licensing.
13# See the License for the specific language governing permissions
14# and limitations under the License.
15#
16# When distributing Covered Code, include this CDDL HEADER in each
17# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
18# If applicable, add the following below this CDDL HEADER, with the
19# fields enclosed by brackets "[]" replaced with your own identifying
20# information: Portions Copyright [yyyy] [name of copyright owner]
21#
22# CDDL HEADER END
23#
24
25#
26# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
27#
28
29#
30# buildksh93.sh - ast-ksh standalone build script for the
31# OpenSolaris ksh93-integration project
32#
33
34# ksh93t sources can be downloaded like this from the AT&T site:
35# wget --http-user="I accept www.opensource.org/licenses/cpl" --http-passwd="." 'http://www.research.att.com/~gsf/download/tgz/INIT.2010-03-09.tgz'
36# wget --http-user="I accept www.opensource.org/licenses/cpl" --http-passwd="." 'http://www.research.att.com/~gsf/download/tgz/ast-ksh.2010-03-09.tgz'
37
38function fatal_error
39{
40    print -u2 "${progname}: $*"
41    exit 1
42}
43
44set -o errexit
45set -o xtrace
46
47typeset progname="$(basename "${0}")"
48typeset buildmode="$1"
49
50if [[ "${buildmode}" == "" ]] ; then
51    fatal_error "buildmode required."
52fi
53
54# Make sure we use the C locale during building to avoid any unintended
55# side-effects
56export LANG=C
57export LC_ALL=$LANG LC_MONETARY=$LANG LC_NUMERIC=$LANG LC_MESSAGES=$LANG LC_COLLATE=$LANG LC_CTYPE=$LANG
58# Make sure the POSIX/XPG6 tools are in front of /usr/bin (/bin is needed for Linux after /usr/bin)
59export PATH=/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/bin:/opt/SUNWspro/bin
60
61# Make sure the POSIX/XPG6 packages are installed (mandatory for building
62# our version of ksh93 correctly).
63if [[ "$(uname -s)" == "SunOS" ]] ; then
64    if [[ ! -x "/usr/xpg6/bin/tr" ]] ; then
65        fatal_error "XPG6/4 packages (SUNWxcu6,SUNWxcu4) not installed."
66    fi
67fi
68
69function print_solaris_builtin_header
70{
71# Make sure to use \\ instead of \ for continuations
72cat <<ENDOFTEXT
73/*
74 * CDDL HEADER START
75 *
76 * The contents of this file are subject to the terms of the
77 * Common Development and Distribution License (the "License").
78 * You may not use this file except in compliance with the License.
79 *
80 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
81 * or http://www.opensolaris.org/os/licensing.
82 * See the License for the specific language governing permissions
83 * and limitations under the License.
84 *
85 * When distributing Covered Code, include this CDDL HEADER in each
86 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
87 * If applicable, add the following below this CDDL HEADER, with the
88 * fields enclosed by brackets "[]" replaced with your own identifying
89 * information: Portions Copyright [yyyy] [name of copyright owner]
90 *
91 * CDDL HEADER END
92 */
93
94/*
95 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
96 */
97
98#ifndef _SOLARIS_KSH_CMDLIST_H
99#define	_SOLARIS_KSH_CMDLIST_H
100
101#ifdef	__cplusplus
102extern "C" {
103#endif
104
105/*
106 * List builtins for Solaris.
107 * The list here is partially autogenerated and partially hand-picked
108 * based on compatibility with the native Solaris versions of these
109 * tools
110 */
111
112/*
113 * Commands which are 100% compatible with native Solaris versions (/bin is
114 * a softlink to ./usr/bin, ksh93 takes care about the lookup)
115 */
116#define	BINCMDLIST(f)	\\
117	{ "/bin/"	#f, NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
118#define	USRBINCMDLIST(f)	\\
119	{ "/usr/bin/"	#f, NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
120#define	SBINCMDLIST(f)	\\
121	{ "/sbin/"	#f, NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
122#define	SUSRBINCMDLIST(f)	\\
123	{ "/usr/sbin/"	#f, NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
124/* POSIX compatible commands */
125#define	XPG6CMDLIST(f)	\\
126	{ "/usr/xpg6/bin/" #f, NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
127#define	XPG4CMDLIST(f)	\\
128	{ "/usr/xpg4/bin/" #f, NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
129#ifdef SHOPT_USR_GNU_BIN_BUILTINS
130/* GNU coreutils compatible commands */
131#define	GNUCMDLIST(f)	\\
132	{ "/usr/gnu/bin/" #f, NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
133#else
134#define	GNUCMDLIST(f)
135#endif
136/*
137 * Make all ksh93 builtins accessible when /usr/ast/bin was added to
138 * /usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/bin:/opt/SUNWspro/bin
139 */
140#define	ASTCMDLIST(f)	\\
141	{ "/usr/ast/bin/" #f, NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
142
143/* undo ast_map.h #defines to avoid collision */
144#undef basename
145#undef dirname
146#undef mktemp
147
148/* Generated data, do not edit. */
149ASTCMDLIST(basename)
150GNUCMDLIST(basename)
151XPG4CMDLIST(basename)
152ASTCMDLIST(cat)
153BINCMDLIST(cat)
154ASTCMDLIST(chgrp)
155// XPG4CMDLIST(chgrp)
156ASTCMDLIST(chmod)
157ASTCMDLIST(chown)
158// XPG4CMDLIST(chown)
159BINCMDLIST(chown)
160ASTCMDLIST(cksum)
161BINCMDLIST(cksum)
162GNUCMDLIST(cksum)
163ASTCMDLIST(cmp)
164BINCMDLIST(cmp)
165ASTCMDLIST(comm)
166BINCMDLIST(comm)
167GNUCMDLIST(comm)
168ASTCMDLIST(cp)
169// XPG4CMDLIST(cp)
170ASTCMDLIST(cut)
171BINCMDLIST(cut)
172GNUCMDLIST(cut)
173ASTCMDLIST(date)
174// XPG4CMDLIST(date)
175ASTCMDLIST(dirname)
176BINCMDLIST(dirname)
177GNUCMDLIST(dirname)
178// ASTCMDLIST(egrep)
179// XPG4CMDLIST(egrep)
180ASTCMDLIST(expr)
181GNUCMDLIST(expr)
182XPG6CMDLIST(expr)
183ASTCMDLIST(fds)
184// ASTCMDLIST(fgrep)
185// XPG4CMDLIST(fgrep)
186ASTCMDLIST(fmt)
187ASTCMDLIST(fold)
188BINCMDLIST(fold)
189GNUCMDLIST(fold)
190// ASTCMDLIST(grep)
191// XPG4CMDLIST(grep)
192ASTCMDLIST(head)
193BINCMDLIST(head)
194ASTCMDLIST(id)
195XPG4CMDLIST(id)
196ASTCMDLIST(join)
197BINCMDLIST(join)
198GNUCMDLIST(join)
199ASTCMDLIST(ln)
200// XPG4CMDLIST(ln)
201ASTCMDLIST(logname)
202BINCMDLIST(logname)
203GNUCMDLIST(logname)
204ASTCMDLIST(md5sum)
205ASTCMDLIST(mkdir)
206BINCMDLIST(mkdir)
207GNUCMDLIST(mkdir)
208ASTCMDLIST(mkfifo)
209BINCMDLIST(mkfifo)
210GNUCMDLIST(mkfifo)
211ASTCMDLIST(mktemp)
212BINCMDLIST(mktemp)
213GNUCMDLIST(mktemp)
214ASTCMDLIST(mv)
215// XPG4CMDLIST(mv)
216ASTCMDLIST(paste)
217BINCMDLIST(paste)
218GNUCMDLIST(paste)
219ASTCMDLIST(pathchk)
220BINCMDLIST(pathchk)
221GNUCMDLIST(pathchk)
222// ASTCMDLIST(readlink)
223ASTCMDLIST(rev)
224BINCMDLIST(rev)
225ASTCMDLIST(rm)
226XPG4CMDLIST(rm)
227ASTCMDLIST(rmdir)
228BINCMDLIST(rmdir)
229GNUCMDLIST(rmdir)
230GNUCMDLIST(sleep)
231ASTCMDLIST(stty)
232// XPG4CMDLIST(stty)
233ASTCMDLIST(sum)
234BINCMDLIST(sum)
235ASTCMDLIST(sync)
236BINCMDLIST(sync)
237GNUCMDLIST(sync)
238SBINCMDLIST(sync)
239SUSRBINCMDLIST(sync)
240ASTCMDLIST(tail)
241BINCMDLIST(tail)
242XPG4CMDLIST(tail)
243ASTCMDLIST(tee)
244BINCMDLIST(tee)
245GNUCMDLIST(tee)
246ASTCMDLIST(tty)
247BINCMDLIST(tty)
248GNUCMDLIST(tty)
249ASTCMDLIST(uname)
250ASTCMDLIST(uniq)
251BINCMDLIST(uniq)
252GNUCMDLIST(uniq)
253ASTCMDLIST(wc)
254BINCMDLIST(wc)
255GNUCMDLIST(wc)
256// ASTCMDLIST(xgrep)
257// BINCMDLIST(xgrep)
258
259/* Mandatory for ksh93 test suite and AST scripts */
260BINCMDLIST(getconf)
261
262#ifdef	__cplusplus
263}
264#endif
265#endif /* !_SOLARIS_KSH_CMDLIST_H */
266
267ENDOFTEXT
268}
269
270function build_shell
271{
272    set -o errexit
273    set -o xtrace
274
275    # OS.cputype.XXbit.compiler
276    case "${buildmode}" in
277        *.linux.*)
278            # ksh93+AST config flags
279            bast_flags="-DSHOPT_CMDLIB_BLTIN=0 -DSH_CMDLIB_DIR=\\\"/usr/ast/bin\\\" -DSHOPT_SYSRC -D_map_libc=1"
280
281            # gcc flags
282            bgcc99="gcc -std=gnu99 "
283            bgcc_ccflags="${bon_flags} ${bast_flags} -g"
284
285            case "${buildmode}" in
286                # Linux i386
287                *.i386.32bit.gcc*)  HOSTTYPE="linux.i386" CC="${bgcc99} -fPIC" cc_sharedlib="-shared" CCFLAGS="${bgcc_ccflags}"
288                    ;;
289                *)
290                    fatal_error "build_shell: Illegal Linux type/compiler build mode \"${buildmode}\"."
291                    ;;
292            esac
293            ;;
294        *.solaris.*)
295            # Notes:
296            # 1. Do not remove/modify these flags or their order before either
297            # asking the project leads at
298            # http://www.opensolaris.org/os/project/ksh93-integration/
299            # These flags all have a purpose, even if they look
300            # weird/redundant/etc. at the first look.
301            #
302            # 2. We use -KPIC here since -Kpic is too small on 64bit sparc and
303            # on 32bit it's close to the barrier so we use it for both 32bit and
304            # 64bit to avoid later suprises when people update libast in the
305            # future
306            #
307            # 3. "-D_map_libc=1" is needed to force map.c to add a "_ast_" prefix to all
308            # AST symbol names which may otherwise collide with Solaris/Linux libc
309            #
310            # 4. "-DSHOPT_SYSRC" enables /etc/ksh.kshrc support (AST default is currently
311            # to enable it if /etc/ksh.kshrc or /etc/bash.bashrc are available on the
312            # build machine).
313            #
314            # 5. -D_lib_socket=1 -lsocket -lnsl" was added to make sure ksh93 is compiled
315            # with networking support enabled, the current AST build infratructure has
316            # problems with detecting networking support in Solaris.
317            #
318            # 6. "-xc99=%all -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1" is used to force
319            # the compiler into C99 mode. Otherwise ksh93 will be much slower and lacks
320            # lots of arithmethic functions.
321            #
322            # 7. "-D_TS_ERRNO -D_REENTRANT" are flags taken from the default OS/Net
323            # build system.
324            #
325            # 8. "-xpagesize_stack=64K is used on SPARC to enhance the performace
326            #
327            # 9. -DSHOPT_CMDLIB_BLTIN=0 -DSH_CMDLIB_DIR=\\\"/usr/ast/bin\\\" -DSHOPT_CMDLIB_HDR=\\\"/home/test001/ksh93/ast_ksh_20070322/solaris_cmdlist.h\\\"
328            # is used to bind all ksh93 builtins to a "virtual" directory
329            # called "/usr/ast/bin/" and to adjust the list of builtins
330            # enabled by default to those defined by PSARC 2006/550
331
332            solaris_builtin_header="${PWD}/tmp_solaris_builtin_header.h"
333            print_solaris_builtin_header >"${solaris_builtin_header}"
334
335            # OS/Net build flags
336            bon_flags="-D_TS_ERRNO -D_REENTRANT"
337
338            # ksh93+AST config flags
339            bast_flags="-DSHOPT_CMDLIB_BLTIN=0 -DSH_CMDLIB_DIR=\\\"/usr/ast/bin\\\" -DSHOPT_CMDLIB_HDR=\\\"${solaris_builtin_header}\\\" -DSHOPT_SYSRC -D_map_libc=1"
340
341            # Sun Studio flags
342            bsunc99="/opt/SUNWspro/bin/cc -xc99=%all -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1"
343            bsuncc_app_ccflags_sparc="-xpagesize_stack=64K" # use bsuncc_app_ccflags_sparc only for final executables
344            bsuncc_ccflags="${bon_flags} -KPIC -g -xs -xspace -Xa -xstrconst -z combreloc -xildoff -xcsi -errtags=yes ${bast_flags} -D_lib_socket=1 -lsocket -lnsl"
345
346            # gcc flags
347            bgcc99="/usr/sfw/bin/gcc -std=gnu99 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1"
348            bgcc_warnflags="-Wall -Wextra -Wno-unknown-pragmas -Wno-missing-braces -Wno-sign-compare -Wno-parentheses -Wno-uninitialized -Wno-implicit-function-declaration -Wno-unused -Wno-trigraphs -Wno-char-subscripts -Wno-switch"
349            bgcc_ccflags="${bon_flags} ${bgcc_warnflags} ${bast_flags} -D_lib_socket=1 -lsocket -lnsl"
350
351            case "${buildmode}" in
352	        # for -m32/-m64 flags see usr/src/Makefile.master, makefile symbols *_XARCH/co.
353                *.i386.32bit.suncc*)  HOSTTYPE="sol11.i386" CC="${bsunc99} -m32"                  cc_sharedlib="-G" CCFLAGS="${bsuncc_ccflags}"  ;;
354                *.i386.64bit.suncc*)  HOSTTYPE="sol11.i386" CC="${bsunc99} -m64 -KPIC"            cc_sharedlib="-G" CCFLAGS="${bsuncc_ccflags}"  ;;
355                *.sparc.32bit.suncc*) HOSTTYPE="sol11.sun4" CC="${bsunc99} -m32"                  cc_sharedlib="-G" CCFLAGS="${bsuncc_ccflags}" bsuncc_app_ccflags="${bsuncc_app_ccflags_sparc}" ;;
356                *.sparc.64bit.suncc*) HOSTTYPE="sol11.sun4" CC="${bsunc99} -m64 -dalign -KPIC"    cc_sharedlib="-G" CCFLAGS="${bsuncc_ccflags}" bsuncc_app_ccflags="${bsuncc_app_ccflags_sparc}" ;;
357
358                *.i386.32bit.gcc*)  HOSTTYPE="sol11.i386" CC="${bgcc99} -fPIC"                                            cc_sharedlib="-shared" CCFLAGS="${bgcc_ccflags}"  ;;
359                *.i386.64bit.gcc*)  HOSTTYPE="sol11.i386" CC="${bgcc99} -m64 -mtune=opteron -Ui386 -U__i386 -fPIC"        cc_sharedlib="-shared" CCFLAGS="${bgcc_ccflags}"  ;;
360                *.sparc.32bit.gcc*) HOSTTYPE="sol11.sun4" CC="${bgcc99} -m32 -mcpu=v8 -fPIC"                              cc_sharedlib="-shared" CCFLAGS="${bgcc_ccflags}"  ;;
361                *.sparc.64bit.gcc*) HOSTTYPE="sol11.sun4" CC="${bgcc99} -m64 -mcpu=v9 -fPIC"                              cc_sharedlib="-shared" CCFLAGS="${bgcc_ccflags}"  ;;
362                *.s390.32bit.gcc*)  HOSTTYPE="sol11.s390" CC="${bgcc99} -m32          -fPIC"				  cc_sharedlib="-shared" CCFLAGS="${bgcc_ccflags}"  ;;
363                *.s390.64bit.gcc*)  HOSTTYPE="sol11.s390" CC="${bgcc99} -m64          -fPIC"				  cc_sharedlib="-shared" CCFLAGS="${bgcc_ccflags}"  ;;
364
365                *)
366                    fatal_error "build_shell: Illegal Solaris type/compiler build mode \"${buildmode}\"."
367                    ;;
368            esac
369            ;;
370        *)
371            fatal_error "Illegal OS build mode \"${buildmode}\"."
372            ;;
373    esac
374
375    # some prechecks
376    [[ -z "${CCFLAGS}"  ]] && fatal_error "build_shell: CCFLAGS is empty."
377    [[ -z "${CC}"       ]] && fatal_error "build_shell: CC is empty."
378    [[ -z "${HOSTTYPE}" ]] && fatal_error "build_shell: HOSTTYPE is empty."
379    [[ ! -f "bin/package" ]] && fatal_error "build_shell: bin/package missing."
380    [[ ! -x "bin/package" ]] && fatal_error "build_shell: bin/package not executable."
381
382    export CCFLAGS CC HOSTTYPE
383
384    # build ksh93
385    bin/package make CCFLAGS="${CCFLAGS}" CC="${CC}" HOSTTYPE="${HOSTTYPE}"
386
387    root="${PWD}/arch/${HOSTTYPE}"
388    [[ -d "$root" ]] || fatal_error "build_shell: directory ${root} not found."
389    log="${root}/lib/package/gen/make.out"
390
391    [[ -s $log ]] || fatal_error "build_shell: no make.out log found."
392
393    if [[ -f ${root}/lib/libast-g.a   ]] then link_libast="ast-g"     ; else link_libast="ast"     ; fi
394    if [[ -f ${root}/lib/libdll-g.a   ]] then link_libdll="dll-g"     ; else link_libdll="dll"     ; fi
395    if [[ -f ${root}/lib/libsum-g.a   ]] then link_libsum="sum-g"     ; else link_libsum="sum"     ; fi
396    if [[ -f ${root}/lib/libcmd-g.a   ]] then link_libcmd="cmd-g"     ; else link_libcmd="cmd"     ; fi
397    if [[ -f ${root}/lib/libshell-g.a ]] then link_libshell="shell-g" ; else link_libshell="shell" ; fi
398
399    if [[ "${buildmode}" != *.staticshell* ]] ; then
400        # libcmd causes some trouble since there is a squatter in solaris
401        # This has been fixed in Solaris 11/B48 but may require adjustments
402        # for older Solaris releases
403        for lib in libast libdll libsum libcmd libshell ; do
404            case "$lib" in
405            libshell)
406                base="src/cmd/ksh93/"
407                vers=1
408                link="-L${root}/lib/ -l${link_libcmd} -l${link_libsum} -l${link_libdll} -l${link_libast} -lm"
409                ;;
410            libdll)
411                base="src/lib/${lib}"
412                vers=1
413                link="-ldl"
414                ;;
415            libast)
416                base="src/lib/${lib}"
417                vers=1
418                link="-lm"
419                ;;
420            *)
421                base="src/lib/${lib}"
422                vers=1
423                link="-L${root}/lib/ -l${link_libast} -lm"
424                ;;
425            esac
426
427            (
428            cd "${root}/${base}"
429
430	    if [[ -f ${lib}-g.a ]] ; then lib_a="${lib}-g.a" ; else lib_a="${lib}.a" ; fi
431
432            if [[ "${buildmode}" == *solaris* ]] ; then
433                ${CC} ${cc_sharedlib} ${CCFLAGS} -Bdirect -Wl,-zallextract -Wl,-zmuldefs -o "${root}/lib/${lib}.so.${vers}" "${lib_a}"  $link
434            else
435                ${CC} ${cc_sharedlib} ${CCFLAGS} -Wl,--whole-archive -Wl,-zmuldefs "${lib_a}" -Wl,--no-whole-archive -o "${root}/lib/${lib}.so.${vers}" $link
436            fi
437
438            #rm ${lib}.a
439            mv "${lib_a}" "disabled_${lib_a}_"
440
441            cd "${root}/lib"
442            ln -sf "${lib}.so.${vers}" "${lib}.so"
443            )
444        done
445
446        (
447          base=src/cmd/ksh93
448          cd "${root}/${base}"
449          rm -f \
450	      "${root}/lib/libshell.a" "${root}/lib/libshell-g.a" \
451              "${root}/lib/libsum.a" "${root}/lib/libsum-g.a" \
452              "${root}/lib/libdll.a" "${root}/lib/libdll-g.a" \
453              "${root}/lib/libast.a" "${root}/lib/libast-g.a"
454
455          if [[ "${buildmode}" == *solaris* ]] ; then
456              ${CC} ${CCFLAGS} ${bsuncc_app_ccflags} -L${root}/lib/ -Bdirect -o ksh pmain.o -lshell -Bstatic -l${link_libcmd} -Bdynamic -lsum -ldll -last -lm -lmd -lsecdb
457          else
458              ${CC} ${CCFLAGS} ${bsuncc_app_ccflags} -L${root}/lib/ -o ksh pmain.o -lshell -lcmd -lsum -ldll -last -lm
459          fi
460
461	  file ksh
462	  file shcomp
463
464	  export LD_LIBRARY_PATH="${root}/lib:${LD_LIBRARY_PATH}"
465	  export LD_LIBRARY_PATH_32="${root}/lib:${LD_LIBRARY_PATH_32}"
466	  export LD_LIBRARY_PATH_64="${root}/lib:${LD_LIBRARY_PATH_64}"
467	  ldd ksh
468        )
469    fi
470}
471
472function test_builtin_getconf
473{
474(
475    print "# testing getconf builtin..."
476    set +o errexit
477    export PATH=/bin:/usr/bin
478    for lang in ${TEST_LANG} ; do
479        (
480	    printf "## testing LANG=%s\n" "${lang}"
481            export LC_ALL="${lang}" LANG="${lang}"
482            ${SHELL} -c '/usr/bin/getconf -a |
483                         while read i ; do
484                         t="${i%:*}" ; a="$(getconf "$t" 2>/dev/null)" ;
485                         b="$(/usr/bin/getconf "$t" 2>/dev/null)" ; [ "$a" != "$b" ] && print "# |$t|:|$a| != |$b|" ;
486                         done'
487        )
488    done
489    print "# testing getconf done."
490)
491}
492
493function test_shell
494{
495    set -o errexit
496    set -o xtrace
497
498    ulimit -s 65536 # need larger stack on 64bit SPARC to pass all tests
499
500    export SHELL="$(ls -1 $PWD/arch/*/src/cmd/ksh93/ksh)"
501    export LD_LIBRARY_PATH="$(ls -1ad $PWD/arch/*/lib):${LD_LIBRARY_PATH}"
502    export LD_LIBRARY_PATH_32="$(ls -1ad $PWD/arch/*/lib):${LD_LIBRARY_PATH_32}"
503    export LD_LIBRARY_PATH_64="$(ls -1ad $PWD/arch/*/lib):${LD_LIBRARY_PATH_64}"
504    printf "## SHELL is |%s|\n" "${SHELL}"
505    printf "## LD_LIBRARY_PATH is |%s|\n" "${LD_LIBRARY_PATH}"
506
507    [[ ! -f "${SHELL}" ]] && fatal_error "test_shell: |${SHELL}| is not a file."
508    [[ ! -x "${SHELL}" ]] && fatal_error "test_shell: |${SHELL}| is not executable."
509
510    [[ "${TEST_LANG}" == "" ]] && TEST_LANG="C zh_CN.GB18030 en_US.UTF-8"
511
512    case "${buildmode}" in
513            testshell.bcheck*)
514                for lang in ${TEST_LANG} ; do
515                    (
516                        export LC_ALL="${lang}" LANG="${lang}"
517                        for i in ./src/cmd/ksh93/tests/*.sh ; do
518                            bc_logfile="$(basename "$i").$$.bcheck"
519                            rm -f "${bc_logfile}"
520                            /opt/SUNWspro/bin/bcheck -q -access -o "${bc_logfile}" ${SHELL} ./src/cmd/ksh93/tests/shtests \
521                                LD_LIBRARY_PATH_64="$LD_LIBRARY_PATH_64" \
522                                LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
523                                LD_LIBRARY_PATH_32="$LD_LIBRARY_PATH_32"\
524                                LC_ALL="${lang}" LANG="${lang}" \
525                                VMALLOC_OPTIONS=abort \
526                                "$i"
527                            cat "${bc_logfile}"
528                        done
529                    )
530                done
531                ;;
532            testshell.builtin.getconf)
533                test_builtin_getconf
534                ;;
535            testshell)
536                for lang in ${TEST_LANG} ; do
537                    (
538                        export LC_ALL="${lang}" LANG="${lang}"
539                        for i in ./src/cmd/ksh93/tests/*.sh ; do
540                            ${SHELL} ./src/cmd/ksh93/tests/shtests -a \
541                                LD_LIBRARY_PATH_64="$LD_LIBRARY_PATH_64" \
542                                LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
543                                LD_LIBRARY_PATH_32="$LD_LIBRARY_PATH_32" \
544                                LC_ALL="${lang}" LANG="${lang}" \
545                                VMALLOC_OPTIONS=abort \
546				SHCOMP=$PWD/arch/*/bin/shcomp \
547                                "$i"
548                        done
549                    )
550                done
551                test_builtin_getconf
552                ;;
553    esac
554}
555
556# main
557case "${buildmode}" in
558        build.*) build_shell ;;
559        testshell*)  test_shell  ;;
560        *) fatal_error "Illegal build mode \"${buildmode}\"." ;;
561esac
562# EOF.
563