use shell macros instead of dupe code
This commit is contained in:
parent
adbd7f4b74
commit
d5c0de53e3
142
Build.sh
142
Build.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $MirOS: src/bin/mksh/Build.sh,v 1.59 2006/11/08 23:23:40 tg Exp $
|
# $MirOS: src/bin/mksh/Build.sh,v 1.60 2006/11/08 23:38:28 tg Exp $
|
||||||
#-
|
#-
|
||||||
# Environment: CC, CFLAGS, CPPFLAGS, LDFLAGS, LIBS, NROFF
|
# Environment: CC, CFLAGS, CPPFLAGS, LDFLAGS, LIBS, NROFF
|
||||||
|
|
||||||
@ -9,6 +9,34 @@ v()
|
|||||||
eval "$@"
|
eval "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ac_test()
|
||||||
|
{
|
||||||
|
f=$1
|
||||||
|
fu=$(echo $f | tr '[a-z]' '[A-Z]')
|
||||||
|
test 0 = "$HAVE_$fu" && return
|
||||||
|
test 1 = "$HAVE_$fu" && return
|
||||||
|
if test x"$2" = x""; then
|
||||||
|
ft=1
|
||||||
|
else
|
||||||
|
eval ft=\$$2
|
||||||
|
fi
|
||||||
|
if test 0 = "$ft"; then
|
||||||
|
eval HAVE_$fu=0
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
$e ... $f
|
||||||
|
cat >scn.c
|
||||||
|
$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS
|
||||||
|
if test -f a.out || test -f a.exe; then
|
||||||
|
eval HAVE_$fu=1
|
||||||
|
$e "==> $f... yes"
|
||||||
|
else
|
||||||
|
eval HAVE_$fu=0
|
||||||
|
$e "==> $f... no"
|
||||||
|
fi
|
||||||
|
rm -f scn.c a.out a.exe
|
||||||
|
}
|
||||||
|
|
||||||
addcppf()
|
addcppf()
|
||||||
{
|
{
|
||||||
for i
|
for i
|
||||||
@ -17,6 +45,15 @@ addcppf()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addsrcs()
|
||||||
|
{
|
||||||
|
eval i=\$$1
|
||||||
|
test 0 = $i && case " $SRCS " in
|
||||||
|
*\ $2\ *) ;;
|
||||||
|
*) SRCS="$SRCS $2" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
if test -d mksh; then
|
if test -d mksh; then
|
||||||
echo "$0: Error: ./mksh is a directory!" >&2
|
echo "$0: Error: ./mksh is a directory!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -120,114 +157,37 @@ fi
|
|||||||
|
|
||||||
$e Scanning for functions... please ignore any errors.
|
$e Scanning for functions... please ignore any errors.
|
||||||
|
|
||||||
f=arc4random
|
ac_test arc4random <<-'EOF'
|
||||||
fu=$(echo $f | tr '[a-z]' '[A-Z]')
|
|
||||||
test 0 = "$HAVE_$fu" || test 1 = "$HAVE_$fu" ||
|
|
||||||
{
|
|
||||||
$e ... $f
|
|
||||||
cat >scn.c <<-'EOF'
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
int main() { arc4random(); return (0); }
|
int main() { arc4random(); return (0); }
|
||||||
EOF
|
EOF
|
||||||
$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS
|
|
||||||
if test -f a.out || test -f a.exe; then
|
|
||||||
eval HAVE_$fu=1
|
|
||||||
$e "==> $f... yes"
|
|
||||||
else
|
|
||||||
eval HAVE_$fu=0
|
|
||||||
$e "==> $f... no"
|
|
||||||
fi
|
|
||||||
rm -f scn.c a.out a.exe
|
|
||||||
}
|
|
||||||
|
|
||||||
f=arc4random_push
|
ac_test arc4random_push HAVE_ARC4RANDOM <<-'EOF'
|
||||||
fu=$(echo $f | tr '[a-z]' '[A-Z]')
|
|
||||||
test 0 = "$HAVE_$fu" || test 1 = "$HAVE_$fu" ||
|
|
||||||
if test 1 = "$HAVE_ARC4RANDOM"; then
|
|
||||||
$e ... $f
|
|
||||||
cat >scn.c <<-'EOF'
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
int main() { arc4random_push(1); return (0); }
|
int main() { arc4random_push(1); return (0); }
|
||||||
EOF
|
EOF
|
||||||
$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS
|
|
||||||
if test -f a.out || test -f a.exe; then
|
|
||||||
eval HAVE_$fu=1
|
|
||||||
$e "==> $f... yes"
|
|
||||||
else
|
|
||||||
eval HAVE_$fu=0
|
|
||||||
$e "==> $f... no"
|
|
||||||
fi
|
|
||||||
rm -f scn.c a.out a.exe
|
|
||||||
else
|
|
||||||
HAVE_ARC4RANDOM_PUSH=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
f=setmode
|
ac_test setmode <<-'EOF'
|
||||||
fu=$(echo $f | tr '[a-z]' '[A-Z]')
|
|
||||||
test 0 = "$HAVE_$fu" || test 1 = "$HAVE_$fu" ||
|
|
||||||
{
|
|
||||||
$e ... $f
|
|
||||||
cat >scn.c <<-'EOF'
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
int main(int ac, char *av[]) { setmode(av[0]); return (0); }
|
int main(int ac, char *av[]) { setmode(av[0]); return (0); }
|
||||||
EOF
|
EOF
|
||||||
$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS
|
|
||||||
if test -f a.out || test -f a.exe; then
|
|
||||||
eval HAVE_$fu=1
|
|
||||||
$e "==> $f... yes"
|
|
||||||
else
|
|
||||||
eval HAVE_$fu=0
|
|
||||||
SRCS="$SRCS setmode.c"
|
|
||||||
$e "==> $f... no"
|
|
||||||
fi
|
|
||||||
rm -f scn.c a.out a.exe
|
|
||||||
}
|
|
||||||
|
|
||||||
f=strlcat
|
ac_test strlcat <<-'EOF'
|
||||||
fu=$(echo $f | tr '[a-z]' '[A-Z]')
|
|
||||||
test 0 = "$HAVE_$fu" || test 1 = "$HAVE_$fu" ||
|
|
||||||
{
|
|
||||||
$e ... $f
|
|
||||||
cat >scn.c <<-'EOF'
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
int main(int ac, char *av[]) { strlcat(av[0], av[1], 1); return (0); }
|
int main(int ac, char *av[]) { strlcat(av[0], av[1], 1); return (0); }
|
||||||
EOF
|
EOF
|
||||||
$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS
|
|
||||||
if test -f a.out || test -f a.exe; then
|
|
||||||
eval HAVE_$fu=1
|
|
||||||
$e "==> $f... yes"
|
|
||||||
else
|
|
||||||
eval HAVE_$fu=0
|
|
||||||
SRCS="$SRCS strlfun.c"
|
|
||||||
$e "==> $f... no"
|
|
||||||
fi
|
|
||||||
rm -f scn.c a.out a.exe
|
|
||||||
}
|
|
||||||
|
|
||||||
f=strlcpy
|
ac_test strlcpy <<-'EOF'
|
||||||
fu=$(echo $f | tr '[a-z]' '[A-Z]')
|
|
||||||
test 0 = "$HAVE_$fu" || test 1 = "$HAVE_$fu" ||
|
|
||||||
{
|
|
||||||
$e ... $f
|
|
||||||
cat >scn.c <<-'EOF'
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
int main(int ac, char *av[]) { strlcpy(av[0], av[1], 1); return (0); }
|
int main(int ac, char *av[]) { strlcpy(av[0], av[1], 1); return (0); }
|
||||||
EOF
|
EOF
|
||||||
$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS
|
|
||||||
if test -f a.out || test -f a.exe; then
|
|
||||||
eval HAVE_$fu=1
|
|
||||||
$e "==> $f... yes"
|
|
||||||
else
|
|
||||||
eval HAVE_$fu=0
|
|
||||||
SRCS="$SRCS strlfun.c"
|
|
||||||
$e "==> $f... no"
|
|
||||||
fi
|
|
||||||
rm -f scn.c a.out a.exe
|
|
||||||
}
|
|
||||||
|
|
||||||
$e ... done.
|
$e ... done.
|
||||||
addcppf HAVE_ARC4RANDOM HAVE_ARC4RANDOM_PUSH HAVE_SETMODE \
|
addcppf HAVE_ARC4RANDOM HAVE_ARC4RANDOM_PUSH HAVE_SETMODE \
|
||||||
HAVE_STRLCAT HAVE_STRLCPY
|
HAVE_STRLCAT HAVE_STRLCPY
|
||||||
|
addsrcs HAVE_SETMODE setmode.c
|
||||||
|
addsrcs HAVE_STRLCAT strlfun.c
|
||||||
|
addsrcs HAVE_STRLCPY strlfun.c
|
||||||
|
|
||||||
(v "cd '$srcdir' && exec $CC $CFLAGS -I'$curdir' $CPPFLAGS" \
|
(v "cd '$srcdir' && exec $CC $CFLAGS -I'$curdir' $CPPFLAGS" \
|
||||||
"-DHAVE_CONFIG_H -DCONFIG_H_FILENAME=\\\"sh.h\\\"" \
|
"-DHAVE_CONFIG_H -DCONFIG_H_FILENAME=\\\"sh.h\\\"" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user