make this actually call getopt.sh, correctly, and Heirloom sh compatible
This commit is contained in:
parent
47ba4d13b4
commit
73106b6e75
39
Build.sh
39
Build.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.650 2013/11/17 22:22:50 tg Exp $'
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.651 2013/11/20 21:14:49 tg Exp $'
|
||||
#-
|
||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012, 2013
|
||||
|
@ -66,7 +66,7 @@ vq() {
|
|||
rmf() {
|
||||
for _f in "$@"; do
|
||||
case $_f in
|
||||
Build.sh|check.pl|check.t|dot.mkshrc|*.c|*.h|*.ico|*.1) ;;
|
||||
Build.sh|check.pl|check.t|dot.mkshrc|genopt.sh|*.1|*.c|*.h|*.ico|*.opt) ;;
|
||||
*) rm -f "$_f" ;;
|
||||
esac
|
||||
done
|
||||
|
@ -327,8 +327,17 @@ addsrcs() {
|
|||
|
||||
curdir=`pwd` srcdir=`dirname "$0" 2>/dev/null`
|
||||
case x$srcdir in
|
||||
x) srcdir=. ;;
|
||||
*"'"*) echo Source directory must not contain single quotes.; exit 1 ;;
|
||||
x)
|
||||
srcdir=.
|
||||
;;
|
||||
*\ *|*" "*|*"$nl"*)
|
||||
echo >&2 Source directory should not contain space or tab or newline.
|
||||
echo >&2 Errors may occur.
|
||||
;;
|
||||
*"'"*)
|
||||
echo Source directory must not contain single quotes.
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
dstversion=`sed -n '/define MKSH_VERSION/s/^.*"\([^"]*\)".*$/\1/p' "$srcdir/sh.h"`
|
||||
add_cppflags -DMKSH_BUILDSH
|
||||
|
@ -427,7 +436,7 @@ if test -d $tfn || test -d $tfn.exe; then
|
|||
echo "$me: Error: ./$tfn is a directory!" >&2
|
||||
exit 1
|
||||
fi
|
||||
rmf a.exe* a.out* conftest.c *core core.* lft ${tfn}* no *.bc *.ll *.o \
|
||||
rmf a.exe* a.out* conftest.c *core core.* lft ${tfn}* no *.bc *.ll *.o *.gen \
|
||||
Rebuild.sh signames.inc test.sh x vv.out
|
||||
|
||||
SRCS="lalloc.c eval.c exec.c expr.c funcs.c histrap.c jobs.c"
|
||||
|
@ -466,7 +475,7 @@ oswarn=
|
|||
ccpc=-Wc,
|
||||
ccpl=-Wl,
|
||||
tsts=
|
||||
ccpr='|| for _f in ${tcfn}*; do case $_f in Build.sh|check.pl|check.t|dot.mkshrc|*.c|*.h|*.ico|*.1) ;; *) rm -f "$_f" ;; esac; done'
|
||||
ccpr='|| for _f in ${tcfn}*; do case $_f in Build.sh|check.pl|check.t|dot.mkshrc|genopt.sh|*.1|*.c|*.h|*.ico|*.opt) ;; *) rm -f "$_f" ;; esac; done'
|
||||
|
||||
# Evil hack
|
||||
if test x"$TARGET_OS" = x"Android"; then
|
||||
|
@ -1602,7 +1611,7 @@ else
|
|||
#define EXTERN
|
||||
#define MKSH_INCLUDES_ONLY
|
||||
#include "sh.h"
|
||||
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.650 2013/11/17 22:22:50 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.651 2013/11/20 21:14:49 tg Exp $");
|
||||
int main(void) { printf("Hello, World!\n"); return (0); }
|
||||
EOF
|
||||
case $cm in
|
||||
|
@ -2228,6 +2237,10 @@ llvm)
|
|||
;;
|
||||
esac
|
||||
echo ": # work around NeXTstep bug" >Rebuild.sh
|
||||
for file in "$srcdir"/*.opt; do
|
||||
echo "echo + Running \\\$srcdir/genopt.sh on '$file'..."
|
||||
echo "(srcfile='$file'; . '$srcdir/genopt.sh')"
|
||||
done >>Rebuild.sh
|
||||
echo set -x >>Rebuild.sh
|
||||
for file in $SRCS; do
|
||||
op=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1./'`
|
||||
|
@ -2259,6 +2272,13 @@ echo "test -f \$tcfn || exit 1; $SIZE \$tcfn" >>Rebuild.sh
|
|||
if test $cm = makefile; then
|
||||
extras='emacsfn.h genopt.sh rlimits.opt sh.h sh_flags.opt var_spec.h'
|
||||
test 0 = $HAVE_SYS_SIGNAME && extras="$extras signames.inc"
|
||||
gens= genq=
|
||||
for file in "$srcdir"/*.opt; do
|
||||
genf=`basename "$file" | sed 's/.opt$/.gen/'`
|
||||
gens="$gens $genf"
|
||||
genq="$genq$nl$genf: $srcdir/genopt.sh $file
|
||||
srcfile=$file; . $srcdir/genopt.sh"
|
||||
done
|
||||
cat >Makefrag.inc <<EOF
|
||||
# Makefile fragment for building mksh $dstversion
|
||||
|
||||
|
@ -2276,6 +2296,8 @@ CPPFLAGS= $CPPFLAGS
|
|||
LDFLAGS= $LDFLAGS
|
||||
LIBS= $LIBS
|
||||
|
||||
.depend \$(OBJS_BP):$gens$genq
|
||||
|
||||
# not BSD make only:
|
||||
#VPATH= $srcdir
|
||||
#all: \$(PROG)
|
||||
|
@ -2299,6 +2321,9 @@ EOF
|
|||
$e Generated Makefrag.inc successfully.
|
||||
exit 0
|
||||
fi
|
||||
for file in "$srcdir"/*.opt; do
|
||||
v "(srcfile='$file'; . '$srcdir/genopt.sh')" || exit 1
|
||||
done
|
||||
if test $cm = combine; then
|
||||
objs="-o $mkshexe"
|
||||
for file in $SRCS; do
|
||||
|
|
4
Makefile
4
Makefile
|
@ -1,4 +1,4 @@
|
|||
# $MirOS: src/bin/mksh/Makefile,v 1.127 2013/11/17 22:21:17 tg Exp $
|
||||
# $MirOS: src/bin/mksh/Makefile,v 1.128 2013/11/20 21:14:50 tg Exp $
|
||||
#-
|
||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012, 2013
|
||||
|
@ -85,7 +85,7 @@ OPTGENS!= cd ${.CURDIR:Q} && echo *.opt
|
|||
.for _i in ${OPTGENS}
|
||||
GENERATED+= ${_i:R}.gen
|
||||
${_i:R}.gen: ${_i} ${.CURDIR}/genopt.sh
|
||||
${MKSH} ${.CURDIR:Q}/genopt.sh ${.CURDIR:Q}/${_i}
|
||||
(srcfile=${.CURDIR:Q}/${_i}; . ${.CURDIR:Q}/genopt.sh)
|
||||
.endfor
|
||||
CLEANFILES+= ${GENERATED}
|
||||
|
||||
|
|
164
genopt.sh
164
genopt.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
# $MirOS: src/bin/mksh/genopt.sh,v 1.3 2013/11/20 20:55:01 tg Exp $
|
||||
# $MirOS: src/bin/mksh/genopt.sh,v 1.4 2013/11/20 21:14:50 tg Exp $
|
||||
#-
|
||||
# Copyright (c) 2013
|
||||
# Thorsten Glaser <tg@mirbsd.org>
|
||||
|
@ -87,89 +87,85 @@ scond() {
|
|||
esac
|
||||
}
|
||||
|
||||
for srcfile
|
||||
do
|
||||
bn=`basename "$srcfile" | sed 's/.opt$//'`
|
||||
o_gen=
|
||||
o_str=
|
||||
o_sym=
|
||||
ddefs=
|
||||
state=0
|
||||
exec <"$srcfile"
|
||||
while IFS= read -r line; do
|
||||
case $state:$line in
|
||||
2:'|'*)
|
||||
# end of input
|
||||
o_sym=`echo "$line" | sed 's/^.//'`
|
||||
o_gen=$o_gen$nl"#undef F0"
|
||||
o_gen=$o_gen$nl"#undef FN"
|
||||
for sym in $ddefs; do
|
||||
o_gen=$o_gen$nl"#undef $sym"
|
||||
done
|
||||
state=3
|
||||
;;
|
||||
1:@@)
|
||||
# begin of data block
|
||||
o_gen=$o_gen$nl"#endif"
|
||||
o_gen=$o_gen$nl"#ifndef F0"
|
||||
o_gen=$o_gen$nl"#define F0 FN"
|
||||
o_gen=$o_gen$nl"#endif"
|
||||
state=2
|
||||
;;
|
||||
*:@@*)
|
||||
die ;;
|
||||
0:@*|1:@*)
|
||||
# begin of a definition block
|
||||
sym=`echo "$line" | sed 's/^@//'`
|
||||
if test $state = 0; then
|
||||
o_gen=$o_gen$nl"#if defined($sym)"
|
||||
else
|
||||
o_gen=$o_gen$nl"#elif defined($sym)"
|
||||
fi
|
||||
ddefs="$ddefs $sym"
|
||||
state=1
|
||||
;;
|
||||
0:*|3:*)
|
||||
die ;;
|
||||
1:*)
|
||||
# definition line
|
||||
o_gen=$o_gen$nl$line
|
||||
;;
|
||||
2:'<'*'|'*)
|
||||
soptc
|
||||
;;
|
||||
2:'>'*'|'*)
|
||||
soptc
|
||||
cond=`echo "$line" | sed 's/^[^|]*|//'`
|
||||
scond
|
||||
case $optc in
|
||||
'|') optc=0 ;;
|
||||
*) optc=\'$optc\' ;;
|
||||
esac
|
||||
IFS= read -r line || die Unexpected EOF
|
||||
test -n "$cond" && o_gen=$o_gen$nl"$cond"
|
||||
o_gen=$o_gen$nl"$line, $optc)"
|
||||
test -n "$cond" && o_gen=$o_gen$nl"#endif"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case $state:$o_sym in
|
||||
3:) die Expected optc sym at EOF ;;
|
||||
3:*) ;;
|
||||
*) die Missing EOF marker ;;
|
||||
esac
|
||||
echo "$o_str" | sort | while IFS='|' read -r x opts cond; do
|
||||
test -n "$x" || continue
|
||||
test -f "$srcfile" || die Source file \$srcfile not set.
|
||||
bn=`basename "$srcfile" | sed 's/.opt$//'`
|
||||
o_gen=
|
||||
o_str=
|
||||
o_sym=
|
||||
ddefs=
|
||||
state=0
|
||||
exec <"$srcfile"
|
||||
while IFS= read -r line; do
|
||||
case $state:$line in
|
||||
2:'|'*)
|
||||
# end of input
|
||||
o_sym=`echo "$line" | sed 's/^.//'`
|
||||
o_gen=$o_gen$nl"#undef F0"
|
||||
o_gen=$o_gen$nl"#undef FN"
|
||||
o_gen=$o_gen$ddefs
|
||||
state=3
|
||||
;;
|
||||
1:@@)
|
||||
# begin of data block
|
||||
o_gen=$o_gen$nl"#endif"
|
||||
o_gen=$o_gen$nl"#ifndef F0"
|
||||
o_gen=$o_gen$nl"#define F0 FN"
|
||||
o_gen=$o_gen$nl"#endif"
|
||||
state=2
|
||||
;;
|
||||
*:@@*)
|
||||
die ;;
|
||||
0:@*|1:@*)
|
||||
# begin of a definition block
|
||||
sym=`echo "$line" | sed 's/^@//'`
|
||||
if test $state = 0; then
|
||||
o_gen=$o_gen$nl"#if defined($sym)"
|
||||
else
|
||||
o_gen=$o_gen$nl"#elif defined($sym)"
|
||||
fi
|
||||
ddefs="$ddefs$nl#undef $sym"
|
||||
state=1
|
||||
;;
|
||||
0:*|3:*)
|
||||
die ;;
|
||||
1:*)
|
||||
# definition line
|
||||
o_gen=$o_gen$nl$line
|
||||
;;
|
||||
2:'<'*'|'*)
|
||||
soptc
|
||||
;;
|
||||
2:'>'*'|'*)
|
||||
soptc
|
||||
cond=`echo "$line" | sed 's/^[^|]*|//'`
|
||||
scond
|
||||
test -n "$cond" && echo "$cond"
|
||||
echo "\"$opts\""
|
||||
test -n "$cond" && echo "#endif"
|
||||
done | {
|
||||
echo "#ifndef $o_sym$o_gen"
|
||||
echo "#else"
|
||||
cat
|
||||
echo "#undef $o_sym"
|
||||
echo "#endif"
|
||||
} >"$bn.gen"
|
||||
case $optc in
|
||||
'|') optc=0 ;;
|
||||
*) optc=\'$optc\' ;;
|
||||
esac
|
||||
IFS= read -r line || die Unexpected EOF
|
||||
test -n "$cond" && o_gen=$o_gen$nl"$cond"
|
||||
o_gen=$o_gen$nl"$line, $optc)"
|
||||
test -n "$cond" && o_gen=$o_gen$nl"#endif"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case $state:$o_sym in
|
||||
3:) die Expected optc sym at EOF ;;
|
||||
3:*) ;;
|
||||
*) die Missing EOF marker ;;
|
||||
esac
|
||||
echo "$o_str" | sort | while IFS='|' read -r x opts cond; do
|
||||
test -n "$x" || continue
|
||||
scond
|
||||
test -n "$cond" && echo "$cond"
|
||||
echo "\"$opts\""
|
||||
test -n "$cond" && echo "#endif"
|
||||
done | {
|
||||
echo "#ifndef $o_sym$o_gen"
|
||||
echo "#else"
|
||||
cat
|
||||
echo "#undef $o_sym"
|
||||
echo "#endif"
|
||||
} >"$bn.gen"
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue