header overhaul: replace all #ifdef __OS__ with mirtoconf checks

(except the persistent history one)
This commit is contained in:
tg 2007-01-18 15:50:32 +00:00
parent 44af708ac8
commit 7b903e4aa9
5 changed files with 61 additions and 54 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirOS: src/bin/mksh/Build.sh,v 1.142 2007/01/18 03:31:50 tg Exp $
# $MirOS: src/bin/mksh/Build.sh,v 1.143 2007/01/18 15:50:31 tg Exp $
#-
# Env: CC, CFLAGS, CPP, CPPFLAGS, LDFLAGS, LIBS, NOWARN, NROFF, TARGET_OS
# CPPFLAGS recognised: MKSH_SMALL MKSH_NOPWNAM
@ -25,10 +25,13 @@ else
ao=
fi
allu=QWERTYUIOPASDFGHJKLZXCVBNM
alll=qwertyuiopasdfghjklzxcvbnm
alln=0123456789
upper()
{
echo :"$@" | sed 's/^://' | \
tr qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM
echo :"$@" | sed 's/^://' | tr $alll $allu
}
# pipe .c | ac_test[n] label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
@ -103,6 +106,21 @@ ac_flags()
test 11 = $fa$fv || CFLAGS=$save_CFLAGS
}
# ac_header header [prereq ...]
ac_header()
{
hf=$1; shift
hv=`echo "$hf" | tr -d '\r\n' | tr -c $alll$allu$alln- _`
for i
do
echo "#include <$i>" >>x
done
echo "#include <$hf>" >>x
echo 'int main(void) { return (0); }' >>x
ac_test "$hv" "" "<$hf>" <x
rm -f x
}
addsrcs()
{
eval i=\$$1
@ -202,6 +220,7 @@ CPPFLAGS="$CPPFLAGS -I'$curdir'"
#
# Begin of mirtoconf checks
#
rm -f scn.c a.out a.exe x
$e ${ao}Scanning for functions... please ignore any errors.
#
@ -251,8 +270,7 @@ NOWARN=$save_NOWARN
#
# Compiler: extra flags (-O2 -f* -W* etc.)
#
i=`echo :"$CFLAGS" | sed 's/^://' | \
tr -c -d qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789-`
i=`echo :"$CFLAGS" | sed 's/^://' | tr -c -d $alll$allu$alln-`
test x"$i" = x"" && ac_flags 1 otwo "-O2"
ac_flags 1 fnostrictaliasing "-fno-strict-aliasing"
ac_flags 1 fwholepgm "-fwhole-program --combine"
@ -289,25 +307,15 @@ fi
#
# Environment: headers
#
ac_test sys_param_h '' '<sys/param.h>' <<-'EOF'
#include <sys/param.h>
int main(void) { return (0); }
EOF
ac_test sys_sysmacros_h '' '<sys/sysmacros.h>' <<-'EOF'
#include <sys/sysmacros.h>
int main(void) { return (0); }
EOF
ac_test libgen_h '' '<libgen.h>' <<-'EOF'
#include <libgen.h>
int main(void) { return (0); }
EOF
ac_test stdbool_h '' '<stdbool.h>' <<-'EOF'
#include <stdbool.h>
int main(void) { return (0); }
EOF
ac_header sys/param.h
ac_header sys/mkdev.h
ac_header sys/sysmacros.h
ac_header libgen.h
ac_header paths.h
ac_header stdbool.h
ac_header grp.h sys/types.h
ac_header ulimit.h
ac_header values.h
#
# Environment: types
@ -443,7 +451,9 @@ EOF
ac_test setgroups setresugid 0 <<-'EOF'
#include <sys/types.h>
#if HAVE_GRP_H
#include <grp.h>
#endif
#include <unistd.h>
int main(void) { gid_t gid = 0; return (setgroups(0, &gid)); }
EOF
@ -476,7 +486,6 @@ EOF
#
if test 1 = $NEED_MKSH_SIGNAME; then
$e ... checking how to run the C Preprocessor
rm -f x
save_CPP=$CPP
for i in "$save_CPP" "$CC -E -" "cpp" "/usr/libexec/cpp" "/lib/cpp"; do
CPP=$i
@ -500,7 +509,6 @@ $e ... done.
# Some operating systems have ancient versions of ed(1) writing
# the character count to standard output; cope for that
rm -f x
echo wq >x
ed x <x 2>/dev/null | grep 3 >/dev/null 2>&1 && \
check_categories=$check_categories,oldish-ed

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/Makefile,v 1.27 2007/01/18 01:24:46 tg Exp $
# $MirOS: src/bin/mksh/Makefile,v 1.28 2007/01/18 15:50:32 tg Exp $
PROG= mksh
SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \
@ -6,11 +6,12 @@ SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \
.if !make(test-build)
CPPFLAGS+= -DHAVE_ATTRIBUTE=1 -DHAVE_ATTRIBUTE_BOUNDED=1 \
-DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_PARAM_H=1 \
-DHAVE_SYS_SYSMACROS_H=0 -DHAVE_LIBGEN_H=1 \
-DHAVE_STDBOOL_H=1 -DHAVE_RLIM_T=1 -DHAVE_SIG_T=1 \
-DHAVE_MKSH_SIGNAME=0 -DHAVE_SYS_SIGNAME=1 \
-DHAVE__SYS_SIGNAME=0 -DHAVE_SYS_SIGLIST=1 \
-DHAVE_STRSIGNAL=0 -DHAVE_ARC4RANDOM=1 \
-DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_SYSMACROS_H=0 \
-DHAVE_LIBGEN_H=1 -DHAVE_PATHS_H=1 -DHAVE_STDBOOL_H=1 \
-DHAVE_GRP_H=1 -DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 \
-DHAVE_RLIM_T=1 -DHAVE_SIG_T=1 -DHAVE_MKSH_SIGNAME=0 \
-DHAVE_SYS_SIGNAME=1 -DHAVE__SYS_SIGNAME=0 \
-DHAVE_SYS_SIGLIST=1 -DHAVE_STRSIGNAL=0 -DHAVE_ARC4RANDOM=1 \
-DHAVE_ARC4RANDOM_PUSH=1 -DHAVE_SETLOCALE_CTYPE=1 \
-DHAVE_LANGINFO_CODESET=1 -DHAVE_REVOKE=1 -DHAVE_SETMODE=1 \
-DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 \

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.85 2007/01/18 01:10:55 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.86 2007/01/18 15:50:32 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -7,7 +7,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R29 2007/01/17
@(#)MIRBSD KSH R29 2007/01/18
description:
Check version of shell.
category: pdksh

4
misc.c
View File

@ -2,11 +2,11 @@
/* $OpenBSD: path.c,v 1.12 2005/03/30 17:16:37 deraadt Exp $ */
#include "sh.h"
#if HAVE_SETGROUPS
#if HAVE_GRP_H
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.46 2007/01/18 01:01:25 tg Exp $\t"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.47 2007/01/18 15:50:32 tg Exp $\t"
MKSH_SH_H_ID);
#undef USE_CHVT

34
sh.h
View File

@ -8,8 +8,8 @@
/* $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.107 2007/01/18 01:03:10 tg Exp $"
#define MKSH_VERSION "R29 2007/01/17"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.108 2007/01/18 15:50:32 tg Exp $"
#define MKSH_VERSION "R29 2007/01/18"
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
@ -41,6 +41,9 @@
#include <sys/time.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#if HAVE_SYS_MKDEV_H
#include <sys/mkdev.h>
#endif
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/stat.h>
@ -55,7 +58,7 @@
#include <libgen.h>
#endif
#include <limits.h>
#if !defined(__sun__)
#if HAVE_PATHS_H
#include <paths.h>
#endif
#include <pwd.h>
@ -71,17 +74,11 @@
#include <string.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
/* extra headers */
#if defined(__sun__) || defined(__INTERIX)
#include <sys/mkdev.h>
#endif
#if !defined(__OpenBSD__) && !defined(__CYGWIN__)
#if HAVE_ULIMIT_H
#include <ulimit.h>
#endif
#if defined(__sun__) || defined(__gnu_linux__)
#include <unistd.h>
#if HAVE_VALUES_H
#include <values.h>
#endif
@ -91,6 +88,10 @@
typedef long rlim_t;
#endif
#if !HAVE_SIG_T
typedef void (*sig_t)(int);
#endif
#if !HAVE_STDBOOL_H
/* kludge, but enough for mksh */
typedef int bool;
@ -166,7 +167,7 @@ typedef int bool;
/* OS-dependent additions */
#if !HAVE_SETMODE && !defined(MKSH_SMALL)
#if !HAVE_SETMODE
mode_t getmode(const void *, mode_t);
void *setmode(const char *);
#endif
@ -182,7 +183,7 @@ size_t confstr(int, char *, size_t);
#endif
#ifdef __INTERIX
#define makedev(x,y) mkdev((x),(y))
#define makedev mkdev
extern int __cdecl seteuid(uid_t);
extern int __cdecl setegid(gid_t);
#endif
@ -373,10 +374,6 @@ struct temp {
#define shl_out (&shf_iob[2])
EXTERN int shl_stdout_ok;
#if !HAVE_SIG_T
typedef void (*sig_t)(int);
#endif
/*
* trap handlers
*/
@ -742,6 +739,7 @@ extern const struct builtin shbuiltins [], kshbuiltins [];
#define V_OPTIND 4
#define V_RANDOM 8
#define V_HISTSIZE 9
/* this is defined when we support persistent history, undefined otherwise */
#if !defined(__sun__) && !defined(MKSH_SMALL)
#define V_HISTFILE 10
#endif