modularise, optimise, upgrade coding style(9), display nicer
This commit is contained in:
parent
0cc45784ca
commit
1336e9f1bb
185
Build.sh
185
Build.sh
@ -1,18 +1,16 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $MirOS: src/bin/mksh/Build.sh,v 1.220 2007/06/30 20:04:23 tg Exp $
|
# $MirOS: src/bin/mksh/Build.sh,v 1.221 2007/06/30 20:57:55 tg Exp $
|
||||||
#-
|
#-
|
||||||
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
|
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
|
||||||
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM
|
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM
|
||||||
# MKSH_NOVI
|
# MKSH_NOVI
|
||||||
|
|
||||||
v()
|
v() {
|
||||||
{
|
|
||||||
$e "$*"
|
$e "$*"
|
||||||
eval "$@"
|
eval "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
vq()
|
vq() {
|
||||||
{
|
|
||||||
eval "$@"
|
eval "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,16 +25,6 @@ if test -n "${ZSH_VERSION+x}" && (emulate sh) >/dev/null 2>&1; then
|
|||||||
NULLCMD=:
|
NULLCMD=:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -t 1; then
|
|
||||||
bi='[1m'
|
|
||||||
ui='[4m'
|
|
||||||
ao='[0m'
|
|
||||||
else
|
|
||||||
bi=
|
|
||||||
ui=
|
|
||||||
ao=
|
|
||||||
fi
|
|
||||||
|
|
||||||
allu=QWERTYUIOPASDFGHJKLZXCVBNM
|
allu=QWERTYUIOPASDFGHJKLZXCVBNM
|
||||||
alll=qwertyuiopasdfghjklzxcvbnm
|
alll=qwertyuiopasdfghjklzxcvbnm
|
||||||
alln=0123456789
|
alln=0123456789
|
||||||
@ -44,23 +32,53 @@ alls=______________________________________________________________
|
|||||||
nl='
|
nl='
|
||||||
'
|
'
|
||||||
tcfn=no
|
tcfn=no
|
||||||
|
bi=
|
||||||
|
ui=
|
||||||
|
ao=
|
||||||
|
fx=
|
||||||
|
me=`basename "$0"`
|
||||||
|
|
||||||
upper()
|
if test -t 1; then
|
||||||
{
|
bi='[1m'
|
||||||
|
ui='[4m'
|
||||||
|
ao='[0m'
|
||||||
|
fi
|
||||||
|
|
||||||
|
upper() {
|
||||||
echo :"$@" | sed 's/^://' | tr $alll $allu
|
echo :"$@" | sed 's/^://' | tr $alll $allu
|
||||||
}
|
}
|
||||||
|
|
||||||
# pipe .c | ac_test[n] [!] label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
|
# clean up after ac_testrun()
|
||||||
ac_testn()
|
ac_testdone() {
|
||||||
{
|
eval HAVE_$fu=$fv
|
||||||
if test x"$1" = x"!"; then
|
fr=no
|
||||||
reverse=1
|
test 0 = $fv || fr=yes
|
||||||
shift
|
$e "$bi==> $fd...$ao $ui$fr$ao$fx"
|
||||||
else
|
fx=
|
||||||
reverse=0
|
}
|
||||||
fi
|
|
||||||
|
# ac_cache label: sets f, fu, fv?=0
|
||||||
|
ac_cache() {
|
||||||
f=$1
|
f=$1
|
||||||
fu=`upper $f`
|
fu=`upper $f`
|
||||||
|
eval fv=\$HAVE_$fu
|
||||||
|
case $fv in
|
||||||
|
0|1)
|
||||||
|
fx=' (cached)'
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fv=0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# ac_testinit label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
|
||||||
|
# returns 1 if value was cached/implied, 0 otherwise: call ac_testdone
|
||||||
|
ac_testinit() {
|
||||||
|
if ac_cache $1; then
|
||||||
|
ac_testdone
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
fc=0
|
fc=0
|
||||||
if test x"$2" = x""; then
|
if test x"$2" = x""; then
|
||||||
ft=1
|
ft=1
|
||||||
@ -74,54 +92,46 @@ ac_testn()
|
|||||||
fi
|
fi
|
||||||
fd=$3
|
fd=$3
|
||||||
test x"$fd" = x"" && fd=$f
|
test x"$fd" = x"" && fd=$f
|
||||||
eval fv=\$HAVE_$fu
|
|
||||||
if test 0 = "$fv"; then
|
|
||||||
$e "$bi==> $fd...$ao ${ui}no$ao (cached)"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if test 1 = "$fv"; then
|
|
||||||
$e "$bi==> $fd...$ao ${ui}yes$ao (cached)"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if test $fc = "$ft"; then
|
if test $fc = "$ft"; then
|
||||||
fv=$2
|
fv=$2
|
||||||
eval HAVE_$fu=$fv
|
fx=' (implied)'
|
||||||
test 0 = "$fv" && fv=no
|
ac_testdone
|
||||||
test 1 = "$fv" && fv=yes
|
return 1
|
||||||
$e "$bi==> $fd...$ao $ui$fv$ao (implied)"
|
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
$e ... $fd
|
$e ... $fd
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# pipe .c | ac_test[n] [!] label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
|
||||||
|
ac_testn() {
|
||||||
|
if test x"$1" = x"!"; then
|
||||||
|
reverse=1
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
reverse=0
|
||||||
|
fi
|
||||||
|
ac_testinit "$@" || return
|
||||||
cat >scn.c
|
cat >scn.c
|
||||||
eval 'v "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS" 2>&'$h | \
|
eval 'v "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS" 2>&'$h | \
|
||||||
sed 's/^/] /'
|
sed 's/^/] /'
|
||||||
test x"$tcfn" = x"no" && test -f a.out && tcfn=a.out
|
test x"$tcfn" = x"no" && test -f a.out && tcfn=a.out
|
||||||
test x"$tcfn" = x"no" && test -f a.exe && tcfn=a.exe
|
test x"$tcfn" = x"no" && test -f a.exe && tcfn=a.exe
|
||||||
fr=0
|
|
||||||
if test -f $tcfn; then
|
if test -f $tcfn; then
|
||||||
test $reverse = 1 || fr=1
|
test $reverse = 1 || fv=1
|
||||||
else
|
else
|
||||||
test $reverse = 0 || fr=1
|
test $reverse = 0 || fv=1
|
||||||
fi
|
|
||||||
if test $fr = 1; then
|
|
||||||
eval HAVE_$fu=1
|
|
||||||
$e "$bi==> $fd...$ao ${ui}yes$ao"
|
|
||||||
else
|
|
||||||
eval HAVE_$fu=0
|
|
||||||
$e "$bi==> $fd...$ao ${ui}no$ao"
|
|
||||||
fi
|
fi
|
||||||
rm -f scn.c scn.o $tcfn
|
rm -f scn.c scn.o $tcfn
|
||||||
|
ac_testdone
|
||||||
}
|
}
|
||||||
|
|
||||||
ac_test()
|
ac_test() {
|
||||||
{
|
|
||||||
ac_testn "$@"
|
ac_testn "$@"
|
||||||
eval CPPFLAGS=\"\$CPPFLAGS -DHAVE_$fu=\$HAVE_$fu\"
|
eval CPPFLAGS=\"\$CPPFLAGS -DHAVE_$fu=\$HAVE_$fu\"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ac_flags [-] add varname flags [text]
|
# ac_flags [-] add varname flags [text]
|
||||||
ac_flags()
|
ac_flags() {
|
||||||
{
|
|
||||||
if test x"$1" = x"-"; then
|
if test x"$1" = x"-"; then
|
||||||
shift
|
shift
|
||||||
hf=1
|
hf=1
|
||||||
@ -147,8 +157,7 @@ ac_flags()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ac_header header [prereq ...]
|
# ac_header header [prereq ...]
|
||||||
ac_header()
|
ac_header() {
|
||||||
{
|
|
||||||
hf=$1; shift
|
hf=$1; shift
|
||||||
hv=`echo "$hf" | tr -d '\012\015' | tr -c $alll$allu$alln $alls`
|
hv=`echo "$hf" | tr -d '\012\015' | tr -c $alll$allu$alln $alls`
|
||||||
for i
|
for i
|
||||||
@ -161,8 +170,7 @@ ac_header()
|
|||||||
rm -f x
|
rm -f x
|
||||||
}
|
}
|
||||||
|
|
||||||
addsrcs()
|
addsrcs() {
|
||||||
{
|
|
||||||
eval i=\$$1
|
eval i=\$$1
|
||||||
test 0 = $i && case " $SRCS " in
|
test 0 = $i && case " $SRCS " in
|
||||||
*\ $2\ *) ;;
|
*\ $2\ *) ;;
|
||||||
@ -171,8 +179,8 @@ addsrcs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if test -d mksh; then
|
if test -d mksh || test -d mksh.exe; then
|
||||||
echo "$0: Error: ./mksh is a directory!" >&2
|
echo "$me: Error: ./mksh is a directory!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm -f a.exe a.out *core crypt.exp lft mksh mksh.cat1 mksh.exe no *.o \
|
rm -f a.exe a.out *core crypt.exp lft mksh mksh.cat1 mksh.exe no *.o \
|
||||||
@ -200,7 +208,7 @@ do
|
|||||||
r=1
|
r=1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$0: Unknown option '$i'!" >&2
|
echo "$me: Unknown option '$i'!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -289,7 +297,7 @@ fi
|
|||||||
#
|
#
|
||||||
# Begin of mirtoconf checks
|
# Begin of mirtoconf checks
|
||||||
#
|
#
|
||||||
$e ${ao}Scanning for functions... please ignore any errors.
|
$e $bi$me: Scanning for functions... please ignore any errors.$ao
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compiler: which one?
|
# Compiler: which one?
|
||||||
@ -714,51 +722,22 @@ EOF
|
|||||||
#
|
#
|
||||||
# other checks
|
# other checks
|
||||||
#
|
#
|
||||||
case $HAVE_PERSISTENT_HISTORY:$HAVE_FLOCK_EX$HAVE_MKSH_FULL in
|
fd='if to use persistent history'
|
||||||
0:*)
|
ac_cache PERSISTENT_HISTORY || test 11 != $HAVE_FLOCK_EX$HAVE_MKSH_FULL || fv=1
|
||||||
fv="yes$ao (cached)"
|
CPPFLAGS="$CPPFLAGS -DHAVE_PERSISTENT_HISTORY=$fv"
|
||||||
;;
|
test 1 = $fv || check_categories=$check_categories,no-histfile
|
||||||
1:*)
|
ac_testdone
|
||||||
fv="no$ao (cached)"
|
|
||||||
;;
|
|
||||||
*:11)
|
|
||||||
HAVE_PERSISTENT_HISTORY=1
|
|
||||||
fv=yes$ao
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
HAVE_PERSISTENT_HISTORY=0
|
|
||||||
fv=no$ao
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
$e "$bi==> if to use persistent history...$ao $ui$fv"
|
|
||||||
CPPFLAGS="$CPPFLAGS -DHAVE_PERSISTENT_HISTORY=$HAVE_PERSISTENT_HISTORY"
|
|
||||||
test 1 = $HAVE_PERSISTENT_HISTORY || \
|
|
||||||
check_categories=$check_categories,no-histfile
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compiler: Praeprocessor (only if needed)
|
# Compiler: Praeprocessor (only if needed)
|
||||||
#
|
#
|
||||||
if test 0 = $HAVE_SYS_SIGNAME; then
|
test 0 = $HAVE_SYS_SIGNAME && if ac_testinit cpp_dd '' \
|
||||||
fd='checking if the C Preprocessor supports -dD'
|
'checking if the C Preprocessor supports -dD'; then
|
||||||
if test 0 = "$HAVE_CPP_DD"; then
|
eval '( echo "#define foo bar" | v "$CC -dD -E - >x" ) 2>&'$h | \
|
||||||
$e "$bi==> $fd...$ao ${ui}no$ao (cached)"
|
sed 's/^/] /'
|
||||||
elif test 1 = "$HAVE_CPP_DD"; then
|
grep '#define foo bar' x >/dev/null 2>&1 && fv=1
|
||||||
$e "$bi==> $fd...$ao ${ui}yes$ao (cached)"
|
rm -f x
|
||||||
else
|
ac_testdone
|
||||||
$e ... $fd
|
|
||||||
eval '( echo "#define foo bar" | \
|
|
||||||
v "$CC -dD -E - >x" ) 2>&'$h | \
|
|
||||||
sed 's/^/] /'
|
|
||||||
if grep '#define foo bar' x >/dev/null 2>&1; then
|
|
||||||
HAVE_CPP_DD=1
|
|
||||||
fv=yes
|
|
||||||
else
|
|
||||||
HAVE_CPP_DD=0
|
|
||||||
fv=no
|
|
||||||
fi
|
|
||||||
rm -f x
|
|
||||||
$e "$bi==> $fd...$ao $ui$fv$ao"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user