• scanning for integer types: only scan for these we need,

i.e. uint32_t and uint64_t
• faking <stdint.h>: u_int32_t is not part of ISO C99, so
  do not add it there
• add a test if u_int32_t is declared, for the sake of the
  fucked up OpenBSD standard arc4random(3) declaration, and
  define it to uint32_t if the former type is not available,
  e.g. on Solaris or if we fake <stdint.h>
• fix detection of arc4random_pushb(3) and the prototypes
  if one of the things above applied to our system
• fix detection of arc4random function suite prototypes if
  they are added via an arc4random.c file in the srcdir, and
  copy that file into builddir (if it does not already exist)
  to keep these isolated from each other

based on a real-life bug report by cnuke@ at the Croatian restaurant ☺☻
unbreaks “set ±o arc4random” on Solaris, both SUNpro and GCC
This commit is contained in:
tg 2007-09-11 18:12:16 +00:00
parent 699b908b9d
commit 12e371f1af
1 changed files with 22 additions and 6 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirOS: src/bin/mksh/Build.sh,v 1.263 2007/09/11 17:49:57 tg Exp $
# $MirOS: src/bin/mksh/Build.sh,v 1.264 2007/09/11 18:12:16 tg Exp $
#-
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM
@ -38,6 +38,7 @@ ao=
fx=
me=`basename "$0"`
orig_CFLAGS=$CFLAGS
NEED_ARC4RANDOM=0
if test -t 1; then
bi=''
@ -650,11 +651,11 @@ ac_header values.h
ac_testn can_inttypes '!' stdint_h 1 "if we have standard integer types" <<-'EOF'
#include <sys/types.h>
int main(int ac, char **av) { uint32_t x = (uint32_t)**av;
return (x == (u_int32_t)ac);
return (x == (uint64_t)ac);
}
EOF
if test 0 = $HAVE_CAN_INTTYPES; then
ac_testn can_inttypes2 '' "if we have u_char, u_int, u_long" <<-'EOF'
ac_testn can_uinttypes '' "if we have u_char, u_int, u_long" <<-'EOF'
#include <sys/types.h>
int main(int ac, char **av) { u_int x = (u_int)**av;
return (x == (u_int)(u_long)(u_char)ac);
@ -669,7 +670,6 @@ if test 0 = $HAVE_CAN_INTTYPES; then
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef unsigned int u_int32_t;
EOF
test 1 = $HAVE_CAN_UINTTYPES || cat >>stdint.h <<-'EOF'
typedef unsigned char u_char;
@ -742,6 +742,15 @@ fi
ac_cppflags SIG_T
ac_testn u_int32_t <<-'EOF'
#include <sys/types.h>
#if HAVE_STDINT_H
#include <stdint.h>
#endif
int main(void) { return ((int)(u_int32_t)0); }
EOF
test 1 = $HAVE_U_INT32_T || CPPFLAGS="$CPPFLAGS -Du_int32_t=uint32_t"
#
# Environment: signals
#
@ -782,12 +791,15 @@ ac_testn arc4random <<-'EOF'
int main(void) { return (arc4random()); }
EOF
save_LIBS=$LIBS
if test 0 = $HAVE_ARC4RANDOM && test -f "$srcdir/arc4random.c"; then
ac_header sys/sysctl.h
addsrcs HAVE_ARC4RANDOM arc4random.c
HAVE_ARC4RANDOM=1
HAVE_ARC4RANDOM_DECL=0
HAVE_ARC4RANDOM_PUSH=0
# ensure isolation of source directory from build directory
test -f arc4random.c || cp "$srcdir/arc4random.c" .
NEED_ARC4RANDOM=1
LIBS="$LIBS arc4random.c"
fi
ac_cppflags ARC4RANDOM
@ -799,6 +811,7 @@ ac_test arc4random_pushb arc4random 0 <<-'EOF'
extern uint32_t arc4random_pushb(void *, size_t);
int main(int ac, char *av[]) { return (arc4random_pushb(*av, ac)); }
EOF
LIBS=$save_LIBS
ac_test flock_ex '' 'flock and mmap' <<-'EOF'
#include <sys/types.h>
@ -882,6 +895,8 @@ EOF
#
# check headers for declarations
#
save_LIBS=$LIBS
test 1 = $NEED_ARC4RANDOM && LIBS="$LIBS arc4random.c"
ac_test '!' arc4random_decl arc4random 1 'if arc4random() does not need to be declared' <<-'EOF'
#define MKSH_INCLUDES_ONLY
#include "sh.h"
@ -894,6 +909,7 @@ ac_test '!' arc4random_pushb_decl arc4random_pushb 1 'if arc4random_pushb() does
int arc4random_pushb(char, int); /* this clashes if defined before */
int main(int ac, char *av[]) { return (arc4random_pushb(**av, ac)); }
EOF
LIBS=$save_LIBS
ac_test sys_siglist_decl sys_siglist 1 'if sys_siglist[] does not need to be declared' <<-'EOF'
#define MKSH_INCLUDES_ONLY
#include "sh.h"