first attempts at more autoconf'isation

This commit is contained in:
tg 2006-11-08 23:23:41 +00:00
parent 3b29b8be87
commit 0e0782c856
5 changed files with 116 additions and 45 deletions

107
Build.sh
View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirOS: src/bin/mksh/Build.sh,v 1.58 2006/09/29 19:33:48 tg Exp $
# $MirOS: src/bin/mksh/Build.sh,v 1.59 2006/11/08 23:23:40 tg Exp $
#-
# Environment: CC, CFLAGS, CPPFLAGS, LDFLAGS, LIBS, NROFF
@ -67,8 +67,6 @@ SRCS="$SRCS jobs.c lex.c main.c misc.c shf.c syn.c tree.c var.c"
test $x = 1 || case `uname -s 2>/dev/null || uname` in
CYGWIN*)
LDSTATIC=
SRCS="$SRCS compat.c"
CPPFLAGS="$CPPFLAGS -DNEED_COMPAT"
sigseen=:
;;
Darwin)
@ -76,19 +74,19 @@ Darwin)
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
;;
Interix)
CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE -DNEED_COMPAT"
CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
;;
Linux)
SRCS="$SRCS compat.c strlfun.c"
CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=2 -D_BSD_SOURCE -D_GNU_SOURCE"
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DNEED_COMPAT"
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
LDSTATIC=
sigseen=:
;;
SunOS)
SRCS="$SRCS compat.c"
CPPFLAGS="$CPPFLAGS -D_BSD_SOURCE -D__EXTENSIONS__"
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DNEED_COMPAT"
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
LDSTATIC=
sigseen=:
r=1
@ -120,50 +118,119 @@ if test x"$sigseen" = x:; then
test -f signames.inc || exit 1
fi
$e Scanning for functions...
$e Scanning for functions... please ignore any errors.
test 0 = "$HAVE_ARC4RANDOM" || test 1 = "$HAVE_ARC4RANDOM" ||
f=arc4random
fu=$(echo $f | tr '[a-z]' '[A-Z]')
test 0 = "$HAVE_$fu" || test 1 = "$HAVE_$fu" ||
{
$e ... arc4random
$e ... $f
cat >scn.c <<-'EOF'
#include <stdlib.h>
int main() { arc4random(); return (0); }
EOF
$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS
if test -f a.out || test -f a.exe; then
HAVE_ARC4RANDOM=1
$e "==> arc4random... yes"
eval HAVE_$fu=1
$e "==> $f... yes"
else
HAVE_ARC4RANDOM=0
$e "==> arc4random... no"
eval HAVE_$fu=0
$e "==> $f... no"
fi
rm -f scn.c a.out a.exe
}
test 0 = "$HAVE_ARC4RANDOM_PUSH" || test 1 = "$HAVE_ARC4RANDOM_PUSH" ||
f=arc4random_push
fu=$(echo $f | tr '[a-z]' '[A-Z]')
test 0 = "$HAVE_$fu" || test 1 = "$HAVE_$fu" ||
if test 1 = "$HAVE_ARC4RANDOM"; then
$e ... arc4random_push
$e ... $f
cat >scn.c <<-'EOF'
#include <stdlib.h>
int main() { arc4random_push(1); return (0); }
EOF
$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN scn.c $LIBS
if test -f a.out || test -f a.exe; then
HAVE_ARC4RANDOM_PUSH=1
$e "==> arc4random_push... yes"
eval HAVE_$fu=1
$e "==> $f... yes"
else
HAVE_ARC4RANDOM_PUSH=0
$e "==> arc4random_push... no"
eval HAVE_$fu=0
$e "==> $f... no"
fi
rm -f scn.c a.out a.exe
else
HAVE_ARC4RANDOM_PUSH=0
fi
f=setmode
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>
int main(int ac, char *av[]) { setmode(av[0]); return (0); }
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
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>
int main(int ac, char *av[]) { strlcat(av[0], av[1], 1); return (0); }
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
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>
int main(int ac, char *av[]) { strlcpy(av[0], av[1], 1); return (0); }
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.
addcppf HAVE_ARC4RANDOM HAVE_ARC4RANDOM_PUSH
addcppf HAVE_ARC4RANDOM HAVE_ARC4RANDOM_PUSH HAVE_SETMODE \
HAVE_STRLCAT HAVE_STRLCPY
(v "cd '$srcdir' && exec $CC $CFLAGS -I'$curdir' $CPPFLAGS" \
"-DHAVE_CONFIG_H -DCONFIG_H_FILENAME=\\\"sh.h\\\"" \
"$LDFLAGS $LDSTATIC -o '$curdir/mksh' $SRCS $LIBS") || exit 1
result=mksh
test -f mksh.exe && result=mksh.exe

View File

@ -1,7 +0,0 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/compat.c,v 1.2 2006/09/21 22:03:23 tg Exp $");
#if defined(__gnu_linux__) || defined(__sun__) || defined(__CYGWIN__)
#include "setmode.c"
#endif

View File

@ -1,4 +1,5 @@
/** _MirOS: src/lib/libc/gen/setmode.c,v 1.5 2006/07/03 12:13:52 tg Exp $ */
/** $MirOS: src/bin/mksh/setmode.c,v 1.4 2006/11/08 23:23:41 tg Exp $ */
/** _MirOS: src/lib/libc/gen/setmode.c,v 1.6 2006/11/08 23:18:04 tg Exp $ */
/* $OpenBSD: setmode.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */
/* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */
@ -34,6 +35,15 @@
* SUCH DAMAGE.
*/
#if defined(HAVE_CONFIG_H) && (HAVE_CONFIG_H != 0)
/* usually when packaged with third-party software */
#ifdef CONFIG_H_FILENAME
#include CONFIG_H_FILENAME
#else
#include "config.h"
#endif
#endif
#include <sys/types.h>
#include <sys/stat.h>
@ -48,7 +58,7 @@
#endif
__SCCSID("@(#)setmode.c 8.2 (Berkeley) 3/25/94");
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.3 2006/08/01 13:43:28 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.4 2006/11/08 23:23:41 tg Exp $");
#define SET_LEN 6 /* initial # of bitcmd struct to malloc */
#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */

21
sh.h
View File

@ -8,7 +8,7 @@
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.50 2006/11/05 17:01:47 tg Exp $"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.51 2006/11/08 23:23:41 tg Exp $"
#define MKSH_VERSION "R29 2006/11/05"
#include <sys/cdefs.h>
@ -60,7 +60,6 @@
#include <time.h>
#include <unistd.h>
#ifdef NEED_COMPAT
/* extra headers */
#if defined(__sun__) || defined(__INTERIX)
@ -101,11 +100,20 @@
#ifndef S_ISTXT
#define S_ISTXT 0001000
#endif
#ifndef DEFFILEMODE
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
#endif
/* OS-dependent additions */
#if defined(__gnu_linux__)
#if !defined(HAVE_SETMODE) || (HAVE_SETMODE == 0)
mode_t getmode(const void *, mode_t);
void *setmode(const char *);
#endif
#if !defined(HAVE_STRLCAT) || (HAVE_STRLCAT == 0)
size_t strlcat(char *, const char *, size_t);
#endif
#if !defined(HAVE_STRLCPY) || (HAVE_STRLCPY == 0)
size_t strlcpy(char *, const char *, size_t);
#endif
@ -113,18 +121,11 @@ size_t strlcpy(char *, const char *, size_t);
size_t confstr(int, char *, size_t);
#endif
#if defined(__gnu_linux__) || defined(__sun__) || defined(__CYGWIN__)
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
mode_t getmode(const void *, mode_t);
void *setmode(const char *);
#endif
#ifdef __INTERIX
#define makedev(x,y) mkdev((x),(y))
extern int __cdecl seteuid(uid_t);
extern int __cdecl setegid(gid_t);
#endif
#endif
/* some useful #defines */
#ifdef EXTERN

View File

@ -1,5 +1,5 @@
/* $MirOS: src/bin/mksh/strlfun.c,v 1.5 2006/11/08 23:02:30 tg Exp $ */
/* _MirOS: src/lib/libc/string/strlfun.c,v 1.9 2006/11/08 23:01:50 tg Exp $ */
/* $MirOS: src/bin/mksh/strlfun.c,v 1.6 2006/11/08 23:23:41 tg Exp $ */
/* _MirOS: src/lib/libc/string/strlfun.c,v 1.10 2006/11/08 23:18:04 tg Exp $ */
/*-
* Copyright (c) 2006
@ -33,7 +33,7 @@
#undef HAVE_STRLCPY
#undef HAVE_STRLCAT
#else
#if (HAVE_CONFIG_H - 0)
#if defined(HAVE_CONFIG_H) && (HAVE_CONFIG_H != 0)
/* usually when packaged with third-party software */
#ifdef CONFIG_H_FILENAME
#include CONFIG_H_FILENAME
@ -71,12 +71,12 @@ extern size_t strlen(const char *);
#define __predict_false(exp) ((exp) != 0)
#endif
__RCSID("$MirOS: src/bin/mksh/strlfun.c,v 1.5 2006/11/08 23:02:30 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/strlfun.c,v 1.6 2006/11/08 23:23:41 tg Exp $");
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
#if !(HAVE_STRLCAT - 0)
#if !defined(HAVE_STRLCAT) || (HAVE_STRLCAT == 0)
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
@ -113,7 +113,7 @@ strlcat(char *dst, const char *src, size_t dlen)
* copyright notice and this permission notice appear in all copies.
*/
#if !(HAVE_STRLCPY - 0)
#if !defined(HAVE_STRLCPY) || (HAVE_STRLCPY == 0)
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).