2002-12-22  Roland McGrath  <roland@redhat.com>

	Update to Autoconf 2.57, and Automakify with version 1.7.
	* Makefile.am: New file.
	* Makefile.in: File removed.
	* configure.in: Moved to ...
	* configure.ac: ... here.  Update for Autoconf 2.5x and Automake.
	* aclocal.m4: Moved to ...
	* acinclude.m4: ... here.  Update for Autoconf 2.5x.
	* AUTHORS: New file, makes automake happy.
	* autogen.sh: File removed.
	* README-CVS: Update to recommend autoreconf instead.
	* file.c: HAVE_ST_* -> HAVE_STRUCT_STAT_ST_*.
	* net.c: HAVE_SIN6_SCOPE_ID -> HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID,
	HAVE_MSG_CONTROL -> HAVE_STRUCT_MSGHDR_MSG_CONTROL.
	* strace.c: *_DECLARED -> HAVE_DECL_*
	* stream.c: HAVE_* -> HAVE_STRUCT_*
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..bbba831
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+See the file CREDITS.  Automake likes us to have this file called AUTHORS.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..8a76800
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,23 @@
+# Automake input for strace.
+
+bin_PROGRAMS = strace
+man_MANS = strace.1
+
+# OS is one of `linux', `sunos4', `svr4', or `freebsd'.
+OS		= @opsys@
+# ARCH is `i386', `m68k', `sparc', etc.
+ARCH		= @arch@
+# OSARCH is OS/ARCH if a makefile exists there, otherwise just OS.
+OSARCH		= @osarch@
+
+INCLUDES = -I$(OS)/$(ARCH) -I$(srcdir)/$(OS)/$(ARCH) -I$(OS) -I$(srcdir)/$(OS)
+
+SUBDIRS = $(OSARCH)
+DIST_SUBDIRS = test freebsd/i386 sunos4 svr4 linux
+
+strace_SOURCES = strace.c version.c syscall.c util.c desc.c file.c ipc.c \
+		 io.c ioctl.c mem.c net.c process.c bjm.c \
+		 resource.c signal.c sock.c system.c term.c time.c \
+		 proc.c stream.c
+
+EXTRA_DIST = $(man_MANS) errnoent.sh signalent.sh syscallent.sh ioctlsort.c
diff --git a/README-CVS b/README-CVS
index cc7c627..fbc4bdf 100644
--- a/README-CVS
+++ b/README-CVS
@@ -1,9 +1,5 @@
 
 If you use the CVS version of strace there will be some files missing
-that you need to build strace. These files are generated by tools from
-the GNU autoconf package.
-
-In order to generate the missing package you can run the autogen.sh script.
-For some architectures (powerpc, (ultra)sparc) you need a recent version
-of autoconf, otherwise it might fail to recognize your system.
-
+that you need to build strace.  These files are generated by tools from
+the GNU Autoconf and Automake packages.  You need recent versions, which
+provide the `autoreconf -i' command that will do everything you need.
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 0000000..68f36e7
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,281 @@
+dnl
+dnl This file contains macros used in configure.ac.
+dnl automake uses this file to generate aclocal.m4, which is used by autoconf.
+dnl
+
+dnl ### A macro to find the include directory, useful for cross-compiling.
+AC_DEFUN(AC_INCLUDEDIR,
+[AC_REQUIRE([AC_PROG_AWK])dnl
+AC_SUBST(includedir)
+AC_MSG_CHECKING(for primary include directory)
+includedir=/usr/include
+if test -n "$GCC"
+then
+	>conftest.c
+	new_includedir=`
+		$CC -v -E conftest.c 2>&1 | $AWK '
+			/^End of search list/ { print last; exit }
+			{ last = [$]1 }
+		'
+	`
+	rm -f conftest.c
+	if test -n "$new_includedir" && test -d "$new_includedir"
+	then
+		includedir=$new_includedir
+	fi
+fi
+AC_MSG_RESULT($includedir)
+])
+
+dnl ### A macro to set gcc warning flags.
+define(AC_WARNFLAGS,
+[AC_SUBST(WARNFLAGS)
+if test -z "$WARNFLAGS"
+then
+	if test -n "$GCC"
+	then
+		# If we're using gcc we want warning flags.
+		WARNFLAGS=-Wall
+	fi
+fi
+])
+
+dnl ### A macro to determine if we have a "MP" type procfs
+AC_DEFUN(AC_MP_PROCFS,
+[AC_MSG_CHECKING(for MP procfs)
+AC_CACHE_VAL(ac_cv_mp_procfs,
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <signal.h>
+#include <sys/procfs.h>
+
+main()
+{
+	int pid;
+	char proc[32];
+	FILE *ctl;
+	FILE *status;
+	int cmd;
+	struct pstatus pstatus;
+
+	if ((pid = fork()) == 0) {
+		pause();
+		exit(0);
+	}
+	sprintf(proc, "/proc/%d/ctl", pid);
+	if ((ctl = fopen(proc, "w")) == NULL)
+		goto fail;
+	sprintf(proc, "/proc/%d/status", pid);
+	if ((status = fopen (proc, "r")) == NULL)
+		goto fail;
+	cmd = PCSTOP;
+	if (write (fileno (ctl), &cmd, sizeof cmd) < 0)
+		goto fail;
+	if (read (fileno (status), &pstatus, sizeof pstatus) < 0)
+		goto fail;
+	kill(pid, SIGKILL);
+	exit(0);
+fail:
+	kill(pid, SIGKILL);
+	exit(1);
+}
+]])],[ac_cv_mp_procfs=yes],[ac_cv_mp_procfs=no],[
+# Guess or punt.
+case "$host_os" in
+svr4.2*|svr5*)
+	ac_cv_mp_procfs=yes
+	;;
+*)
+	ac_cv_mp_procfs=no
+	;;
+esac
+])])
+AC_MSG_RESULT($ac_cv_mp_procfs)
+if test "$ac_cv_mp_procfs" = yes
+then
+	AC_DEFINE([HAVE_MP_PROCFS], 1,
+[Define if you have a SVR4 MP type procfs.
+I.E. /dev/xxx/ctl, /dev/xxx/status.
+Also implies that you have the pr_lwp member in prstatus.])
+fi
+])
+
+dnl ### A macro to determine if procfs is pollable.
+AC_DEFUN(AC_POLLABLE_PROCFS,
+[AC_MSG_CHECKING(for pollable procfs)
+AC_CACHE_VAL(ac_cv_pollable_procfs,
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <signal.h>
+#include <sys/procfs.h>
+#include <sys/stropts.h>
+#include <poll.h>
+
+#ifdef HAVE_MP_PROCFS
+#define PIOCSTOP	PCSTOP
+#define POLLWANT	POLLWRNORM
+#define PROC		"/proc/%d/ctl"
+#define PROC_MODE	"w"
+int IOCTL (int fd, int cmd, int arg) {
+	return write (fd, &cmd, sizeof cmd);
+}
+#else
+#define POLLWANT	POLLPRI
+#define	PROC		"/proc/%d"
+#define PROC_MODE	"r+"
+#define IOCTL		ioctl
+#endif
+
+main()
+{
+	int pid;
+	char proc[32];
+	FILE *pfp;
+	struct pollfd pfd;
+
+	if ((pid = fork()) == 0) {
+		pause();
+		exit(0);
+	}
+	sprintf(proc, PROC, pid);
+	if ((pfp = fopen(proc, PROC_MODE)) == NULL)
+		goto fail;
+	if (IOCTL(fileno(pfp), PIOCSTOP, NULL) < 0)
+		goto fail;
+	pfd.fd = fileno(pfp);
+	pfd.events = POLLWANT;
+	if (poll(&pfd, 1, 0) < 0)
+		goto fail;
+	if (!(pfd.revents & POLLWANT))
+		goto fail;
+	kill(pid, SIGKILL);
+	exit(0);
+fail:
+	kill(pid, SIGKILL);
+	exit(1);
+}
+]])],[ac_cv_pollable_procfs=yes],[ac_cv_pollable_procfs=no],[
+# Guess or punt.
+case "$host_os" in
+solaris2*|irix5*|svr4.2uw*|svr5*)
+	ac_cv_pollable_procfs=yes
+	;;
+*)
+	ac_cv_pollable_procfs=no
+	;;
+esac
+])])
+AC_MSG_RESULT($ac_cv_pollable_procfs)
+if test "$ac_cv_pollable_procfs" = yes
+then
+	AC_DEFINE([HAVE_POLLABLE_PROCFS], 1,
+[Define if you have SVR4 and the poll system call works on /proc files.])
+fi
+])
+
+dnl ### A macro to determine if the prstatus structure has a pr_syscall member.
+AC_DEFUN(AC_STRUCT_PR_SYSCALL,
+[AC_MSG_CHECKING(for pr_syscall in struct prstatus)
+AC_CACHE_VAL(ac_cv_struct_pr_syscall,
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/procfs.h>]], [[#ifdef HAVE_MP_PROCFS
+pstatus_t s;
+s.pr_lwp.pr_syscall
+#else
+prstatus_t s;
+s.pr_syscall
+#endif]])],[ac_cv_struct_pr_syscall=yes],[ac_cv_struct_pr_syscall=no])])
+AC_MSG_RESULT($ac_cv_struct_pr_syscall)
+if test "$ac_cv_struct_pr_syscall" = yes
+then
+	AC_DEFINE([HAVE_PR_SYSCALL], 1,
+[Define if the prstatus structure in sys/procfs.h has a pr_syscall member.])
+fi
+])
+
+dnl ### A macro to determine whether stat64 is defined.
+AC_DEFUN(AC_STAT64,
+[AC_MSG_CHECKING(for stat64 in (asm|sys)/stat.h)
+AC_CACHE_VAL(ac_cv_type_stat64,
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef LINUX
+#include <linux/types.h>
+#include <asm/stat.h>
+#else
+#include <sys/stat.h>
+#endif]], [[struct stat64 st;]])],[ac_cv_type_stat64=yes],[ac_cv_type_stat64=no])])
+AC_MSG_RESULT($ac_cv_type_stat64)
+if test "$ac_cv_type_stat64" = yes
+then
+	AC_DEFINE([HAVE_STAT64], 1,
+[Define if stat64 is available in asm/stat.h.])
+fi
+])
+
+dnl ### A macro to determine if off_t is a long long
+AC_DEFUN(AC_OFF_T_IS_LONG_LONG,
+[AC_MSG_CHECKING(for long long off_t)
+AC_CACHE_VAL(ac_cv_have_long_long_off_t,
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
+main () {
+	if (sizeof (off_t) == sizeof (long long) &&
+	    sizeof (off_t) > sizeof (long))
+	    return 0;
+	return 1;
+}
+]])],[ac_cv_have_long_long_off_t=yes],[ac_cv_have_long_long_off_t=no],[# Should try to guess here
+ac_cv_have_long_long_off_t=no
+])])
+AC_MSG_RESULT($ac_cv_have_long_long_off_t)
+if test "$ac_cv_have_long_long_off_t" = yes
+then
+	AC_DEFINE([HAVE_LONG_LONG_OFF_T], 1, [Define if off_t is a long long.])
+fi
+])
+
+dnl ### A macro to determine if rlim_t is a long long
+AC_DEFUN(AC_RLIM_T_IS_LONG_LONG,
+[AC_MSG_CHECKING(for long long rlim_t)
+AC_CACHE_VAL(ac_cv_have_long_long_rlim_t,
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+main () {
+	if (sizeof (rlim_t) == sizeof (long long) &&
+	    sizeof (rlim_t) > sizeof (long))
+	    return 0;
+	return 1;
+}
+]])],[ac_cv_have_long_long_rlim_t=yes],[ac_cv_have_long_long_rlim_t=no],[# Should try to guess here
+ac_cv_have_long_long_rlim_t=no
+])])
+AC_MSG_RESULT($ac_cv_have_long_long_rlim_t)
+if test "$ac_cv_have_long_long_rlim_t" = yes
+then
+	AC_DEFINE([HAVE_LONG_LONG_RLIM_T], 1, [Define if rlim_t is a long long.])
+fi
+])
+
+dnl ### A macro to determine endianness of long long
+AC_DEFUN(AC_LITTLE_ENDIAN_LONG_LONG,
+[AC_MSG_CHECKING(for little endian long long)
+AC_CACHE_VAL(ac_cv_have_little_endian_long_long,
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[
+int main () {
+	union {
+		long long ll;
+		long l [2];
+	} u;
+	u.ll = 0x12345678;
+	if (u.l[0] == 0x12345678)
+		return 0;
+	return 1;
+}
+]])],[ac_cv_have_little_endian_long_long=yes],[ac_cv_have_little_endian_long_long=no],[# Should try to guess here
+ac_cv_have_little_endian_long_long=no
+])])
+AC_MSG_RESULT($ac_cv_have_little_endian_long_long)
+if test "$ac_cv_have_little_endian_long_long" = yes
+then
+	AC_DEFINE([HAVE_LITTLE_ENDIAN_LONG_LONG], 1,
+[Define if long long is little-endian.])
+fi
+])
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..a0d12a7
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,198 @@
+dnl Process this file with autoconf to create configure.  Use autoreconf.
+AC_PREREQ(2.57)
+AC_INIT([strace],[4.4.90])
+AC_CONFIG_SRCDIR([strace.c])
+AM_CONFIG_HEADER([config.h])
+AM_INIT_AUTOMAKE([foreign check-news dist-bzip2])
+AM_MAINTAINER_MODE
+AC_CANONICAL_HOST
+
+AC_MSG_CHECKING([for supported operating system])
+case "$host_os" in
+linux*)
+	opsys=linux
+	AC_DEFINE([LINUX], 1, [Define for the Linux operating system.])
+	;;
+sunos4*)
+	opsys=sunos4
+	AC_DEFINE([SUNOS4], 1, [Define for the SunOS 4.x operating system.])
+	;;
+solaris2* | sysv[[45]]* | irix[[56]]*)
+	opsys=svr4
+	AC_DEFINE([SVR4], 1, [Define for the System V release 4 operating
+system or a derivative like Solaris 2.x or Irix 5.x.])
+	case "$host_os" in
+	sysv4.2uw*)
+		AC_DEFINE(UNIXWARE, 2, [Define for UnixWare systems.])
+		;;
+	sysv5*)
+		AC_DEFINE(UNIXWARE, 7, [Define for UnixWare systems.])
+		;;
+	esac
+	;;
+freebsd*)
+	opsys=freebsd
+	AC_DEFINE([FREEBSD], 1, [Define for the FreeBSD operating system.])
+	;;
+*)
+	AC_MSG_RESULT([NO!])
+	AC_MSG_ERROR([operating system $host_os is not supported by strace])
+	;;
+esac
+AC_MSG_RESULT($opsys)
+
+AC_MSG_CHECKING([for supported architecture])
+case "$host_cpu" in
+i[[3456]]86|pentium)
+	arch=i386
+	AC_DEFINE([I386], 1, [Define for the i386 architecture.])
+	;;
+ia64)
+	arch=ia64
+	AC_DEFINE([IA64], 1, [Define for the IA64 architecture.])
+	;;
+m68k)
+	arch=m68k
+	AC_DEFINE([M68K], 1, [Define for the m68k architecture.])
+	;;
+sparc*)
+	arch=sparc
+	AC_DEFINE([SPARC], 1, [Define for the SPARC architecture.])
+	;;
+mips*)
+	arch=mips
+	AC_DEFINE([MIPS], 1, [Define for the MIPS architecture.])
+	;;
+alpha*)
+	arch=alpha
+	AC_DEFINE([ALPHA], 1, [Define for the Alpha architecture.])
+	;;
+ppc|powerpc)
+	arch=powerpc
+	AC_DEFINE([POWERPC], 1, [Define for the PowerPC architecture.])
+	;;
+arm*)
+	arch=arm
+	AC_DEFINE([ARM], 1, [Define for the ARM architecture.])
+	;;
+s390)
+	arch=s390
+	AC_DEFINE([S390], 1, [Define for the S390 architecture.])
+	;;
+s390x)
+	arch=s390x
+	AC_DEFINE([S390X], 1, [Define for the S390x architecture.])
+	;;
+hppa*|parisc*)
+	arch=hppa
+	AC_DEFINE([HPPA], 1, [Define for the HPPA architecture.])
+	;;
+sh)
+	arch=sh
+	AC_DEFINE([SH], 1, [Define for the SH architecture.])
+	;;
+x86?64*)
+	arch=x86_64
+	AC_DEFINE([X86_64], 1, [Define for the AMD x86-64 architecture.])
+	;;
+*)
+	AC_MSG_RESULT([NO!])
+	AC_MSG_ERROR([architecture $host_cpu is not supported by strace])
+	;;
+esac
+AC_MSG_RESULT($arch)
+
+osarch="$opsys"
+if test -r "$srcdir/$opsys/$arch/Makefile.in"; then
+	osarch="$opsys/$arch"
+fi
+
+AC_SUBST(opsys)
+AC_SUBST(arch)
+AC_SUBST(osarch)
+
+CFLAGS="-D_GNU_SOURCE $CFLAGS"
+AC_PROG_CC
+AC_INCLUDEDIR
+
+if test "x$opsys" = "xsunos4" && test "x$arch" = "xsparc"
+then
+	AC_MSG_CHECKING(for valid machine include directory)
+	if test -d "$includedir/sun4"
+	then
+		rm -f machine
+		ln -s $includedir/sun4 machine
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(SUNOS4_KERNEL_ARCH_KLUDGE, 1, [
+Define if you are have a SPARC with SUNOS4 and your want a version
+of strace that will work on sun4, sun4c and sun4m kernel architectures.
+Only useful if you have a symbolic link from machine to /usr/include/sun4
+in the compilation directory.])
+	else
+		AC_MSG_RESULT(no)
+	fi
+fi
+
+AC_WARNFLAGS
+if test "x$opsys" = "xsunos4"
+then
+	if test -n "$GCC"
+	then
+		# SunOS 4.x header files don't declare int functions.
+		WARNFLAGS="$WARNFLAGS -Wno-implicit"
+	fi
+fi
+
+AC_PROG_CPP
+AC_PROG_GCC_TRADITIONAL
+AC_PROG_INSTALL
+AC_C_CONST
+AC_HEADER_STDC
+AC_HEADER_DIRENT
+AC_HEADER_STAT
+AC_CHECK_MEMBERS([struct stat.st_blksize,
+	          struct stat.st_blocks,
+		  struct stat.st_aclcnt,
+		  struct stat.st_flags,
+		  struct stat.st_fstype,
+		  struct stat.st_gen,
+		  struct stat.st_level,
+		  struct stat.st_rdev])
+AC_STAT64
+
+AC_TYPE_SIGNAL
+AC_TYPE_UID_T
+AC_TYPE_MODE_T
+AC_TYPE_GETGROUPS
+AC_HEADER_MAJOR
+AC_CHECK_TYPES(sig_atomic_t siginfo_t,,, [#include <signal.h>])
+AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id],,, [#include <netinet/in.h])
+AC_CHECK_TYPES([long long])
+AC_LITTLE_ENDIAN_LONG_LONG
+AC_OFF_T_IS_LONG_LONG
+AC_RLIM_T_IS_LONG_LONG
+AC_CHECK_TYPES([struct opthdr],,, [#include <sys/socket.h>])
+AC_CHECK_TYPES([struct t_opthdr],,, [#include <sys/tiuser.h>])
+
+if test x$opsys != xlinux; then
+AC_CHECK_LIB(nsl, main)
+fi
+
+AC_CHECK_FUNCS(sigaction strerror strsignal pread sys_siglist _sys_siglist getdents mctl prctl sendmsg inet_ntop if_indextoname)
+AC_CHECK_HEADERS([sys/reg.h sys/filio.h sys/acl.h sys/asynch.h sys/door.h stropts.h sys/conf.h sys/stream.h sys/tihdr.h sys/tiuser.h sys/sysconfig.h asm/sigcontext.h ioctls.h sys/ioctl.h sys/ptrace.h termio.h linux/ptrace.h asm/reg.h sys/uio.h sys/aio.h  poll.h sys/poll.h sys/vfs.h netinet/tcp.h netinet/udp.h asm/sysmips.h linux/utsname.h sys/nscsys.h], [], [])
+AC_CHECK_HEADERS([linux/icmp.h linux/in6.h linux/netlink.h linux/if_packet.h],
+                 [], [], [#include <linux/socket.h>])
+
+AC_MP_PROCFS
+AC_POLLABLE_PROCFS
+
+AC_CHECK_MEMBERS([struct msghdr.msg_control],,, [#include <sys/socket.h>])
+AC_STRUCT_PR_SYSCALL
+
+AC_CHECK_DECLS([sys_errlist])
+AC_CHECK_DECLS([sys_siglist, _sys_siglist],,, [#include <signal.h>])
+
+AC_PATH_PROG([PERL], [perl])
+
+AC_CONFIG_FILES([Makefile $osarch/Makefile])
+AC_OUTPUT
diff --git a/file.c b/file.c
index addea3e..67e3a5d 100644
--- a/file.c
+++ b/file.c
@@ -725,26 +725,26 @@
 		    (unsigned long) statbuf->st_nlink,
 		    (unsigned long) statbuf->st_uid,
 		    (unsigned long) statbuf->st_gid);
-#ifdef HAVE_ST_BLKSIZE
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
 	    tprintf("st_blksize=%lu, ", (unsigned long) statbuf->st_blksize);
-#endif /* HAVE_ST_BLKSIZE */
-#ifdef HAVE_ST_BLOCKS
+#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
+#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
 	    tprintf("st_blocks=%lu, ", (unsigned long) statbuf->st_blocks);
-#endif /* HAVE_ST_BLOCKS */
+#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
     }
     else
 	    tprintf("{st_mode=%s, ", sprintmode(statbuf->st_mode));
     switch (statbuf->st_mode & S_IFMT) {
     case S_IFCHR: case S_IFBLK:
-#ifdef HAVE_ST_RDEV
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
 	    tprintf("st_rdev=makedev(%lu, %lu), ",
 		    (unsigned long) major(statbuf->st_rdev),
 		    (unsigned long) minor(statbuf->st_rdev));
-#else /* !HAVE_ST_RDEV */
+#else /* !HAVE_STRUCT_STAT_ST_RDEV */
 	    tprintf("st_size=makedev(%lu, %lu), ",
 		    (unsigned long) major(statbuf->st_size),
 		    (unsigned long) minor(statbuf->st_size));
-#endif /* !HAVE_ST_RDEV */
+#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
 	    break;
     default:
 	    tprintf("st_size=%lu, ", statbuf->st_size);
@@ -754,24 +754,24 @@
 	    tprintf("st_atime=%s, ", sprinttime(statbuf->st_atime));
 	    tprintf("st_mtime=%s, ", sprinttime(statbuf->st_mtime));
 	    tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime));
-#if HAVE_ST_FLAGS
+#if HAVE_STRUCT_STAT_ST_FLAGS
 		tprintf(", st_flags=");
 		if (statbuf->st_flags) {
 			printflags(fileflags, statbuf->st_flags);
 		} else
 			tprintf("0");
 #endif
-#if HAVE_ST_ACLCNT
+#if HAVE_STRUCT_STAT_ST_ACLCNT
 		tprintf(", st_aclcnt=%d", statbuf->st_aclcnt);
 #endif
-#if HAVE_ST_LEVEL
+#if HAVE_STRUCT_STAT_ST_LEVEL
 		tprintf(", st_level=%ld", statbuf->st_level);
 #endif
-#if HAVE_ST_FSTYPE
+#if HAVE_STRUCT_STAT_ST_FSTYPE
 		tprintf(", st_fstype=%.*s",
 			(int) sizeof statbuf->st_fstype, statbuf->st_fstype);
 #endif
-#if HAVE_ST_GEN
+#if HAVE_STRUCT_STAT_ST_GEN
 		tprintf(", st_gen=%u", statbuf->st_gen);
 #endif
 		tprintf("}");
@@ -858,27 +858,27 @@
 			(unsigned long) statbuf.st_nlink,
 			(unsigned long) statbuf.st_uid,
 			(unsigned long) statbuf.st_gid);
-#ifdef HAVE_ST_BLKSIZE
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
 		tprintf("st_blksize=%lu, ",
 			(unsigned long) statbuf.st_blksize);
-#endif /* HAVE_ST_BLKSIZE */
-#ifdef HAVE_ST_BLOCKS
+#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
+#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
 		tprintf("st_blocks=%lu, ", (unsigned long) statbuf.st_blocks);
-#endif /* HAVE_ST_BLOCKS */
+#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
 	}
 	else
 		tprintf("{st_mode=%s, ", sprintmode(statbuf.st_mode));
 	switch (statbuf.st_mode & S_IFMT) {
 	case S_IFCHR: case S_IFBLK:
-#ifdef HAVE_ST_RDEV
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
 		tprintf("st_rdev=makedev(%lu, %lu), ",
 			(unsigned long) major(statbuf.st_rdev),
 			(unsigned long) minor(statbuf.st_rdev));
-#else /* !HAVE_ST_RDEV */
+#else /* !HAVE_STRUCT_STAT_ST_RDEV */
 		tprintf("st_size=makedev(%lu, %lu), ",
 			(unsigned long) major(statbuf.st_size),
 			(unsigned long) minor(statbuf.st_size));
-#endif /* !HAVE_ST_RDEV */
+#endif /* !HAVE_STRUCT_STAT_ST_RDEV */
 		break;
 	default:
 		tprintf("st_size=%llu, ", statbuf.st_size);
@@ -888,24 +888,24 @@
 		tprintf("st_atime=%s, ", sprinttime(statbuf.st_atime));
 		tprintf("st_mtime=%s, ", sprinttime(statbuf.st_mtime));
 		tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime));
-#if HAVE_ST_FLAGS
+#if HAVE_STRUCT_STAT_ST_FLAGS
 		tprintf(", st_flags=");
 		if (statbuf.st_flags) {
 			printflags(fileflags, statbuf.st_flags);
 		} else
 			tprintf("0");
 #endif
-#if HAVE_ST_ACLCNT
+#if HAVE_STRUCT_STAT_ST_ACLCNT
 		tprintf(", st_aclcnt=%d", statbuf.st_aclcnt);
 #endif
-#if HAVE_ST_LEVEL
+#if HAVE_STRUCT_STAT_ST_LEVEL
 		tprintf(", st_level=%ld", statbuf.st_level);
 #endif
-#if HAVE_ST_FSTYPE
+#if HAVE_STRUCT_STAT_ST_FSTYPE
 		tprintf(", st_fstype=%.*s",
 			(int) sizeof statbuf.st_fstype, statbuf.st_fstype);
 #endif
-#if HAVE_ST_GEN
+#if HAVE_STRUCT_STAT_ST_GEN
 		tprintf(", st_gen=%u", statbuf.st_gen);
 #endif
 		tprintf("}");
diff --git a/net.c b/net.c
index 5ab0d67..ff85332 100644
--- a/net.c
+++ b/net.c
@@ -766,21 +766,21 @@
 		tprintf("sin6_port=htons(%u), inet_pton(AF_INET6, \"%s\", &sin6_addr), sin6_flowinfo=%u",
 				ntohs(addrbuf.sa6.sin6_port), string_addr,
 				addrbuf.sa6.sin6_flowinfo);
-#ifdef HAVE_SIN6_SCOPE_ID
+#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
 		{
 #if defined(HAVE_IF_INDEXTONAME) && defined(IN6_IS_ADDR_LINKLOCAL) && defined(IN6_IS_ADDR_MC_LINKLOCAL)
 		    int numericscope = 0;
 		    if (IN6_IS_ADDR_LINKLOCAL (&addrbuf.sa6.sin6_addr)
 			    || IN6_IS_ADDR_MC_LINKLOCAL (&addrbuf.sa6.sin6_addr)) {
 			char scopebuf[IFNAMSIZ + 1];
-			
+
 			if (if_indextoname (addrbuf.sa6.sin6_scope_id, scopebuf) == NULL)
 			    numericscope++;
 			else
 			    tprintf(", sin6_scope_id=if_nametoindex(\"%s\")", scopebuf);
 		    } else
 			numericscope++;
-		    
+
 		    if (numericscope)
 #endif
 			tprintf(", sin6_scope_id=%u", addrbuf.sa6.sin6_scope_id);
@@ -798,7 +798,7 @@
 			 * strace-ish, but otherwise the IPX
 			 * addresses just look monstrous...
 			 * Anyways, feel free if you don't like
-			 * this way.. :) 
+			 * this way.. :)
 			 */
 			tprintf("%08lx:", (unsigned long)ntohl(addrbuf.sipx.sipx_network));
 			for (i = 0; i<IPX_NODE_LEN; i++)
@@ -818,7 +818,7 @@
 			tprintf(", addr(%d)={%d, ",
 					addrbuf.ll.sll_halen,
 					addrbuf.ll.sll_hatype);
-			for (i=0; i<addrbuf.ll.sll_halen; i++) 
+			for (i=0; i<addrbuf.ll.sll_halen; i++)
 				tprintf("%02x", addrbuf.ll.sll_addr[i]);
 		}
 		break;
@@ -860,17 +860,17 @@
 	tprintf(", msg_iov(%lu)=", (unsigned long)msg.msg_iovlen);
 	tprint_iov(tcp, msg.msg_iovlen, (long) msg.msg_iov);
 
-#ifdef HAVE_MSG_CONTROL
+#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
 	tprintf(", msg_controllen=%lu", (unsigned long)msg.msg_controllen);
-	if (msg.msg_controllen) 
+	if (msg.msg_controllen)
 		tprintf(", msg_control=%#lx, ", (unsigned long) msg.msg_control);
 	tprintf(", msg_flags=");
 	if (printflags(msg_flags, msg.msg_flags)==0)
 		tprintf("0");
-#else /* !HAVE_MSG_CONTROL */
+#else /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
 	tprintf("msg_accrights=%#lx, msg_accrightslen=%u",
 		(unsigned long) msg.msg_accrights, msg.msg_accrightslen);
-#endif /* !HAVE_MSG_CONTROL */
+#endif /* !HAVE_STRUCT_MSGHDR_MSG_CONTROL */
 	tprintf("}");
 }
 
@@ -1208,7 +1208,7 @@
 			tprintf("]");
 			break;
 #endif /* PF_IPX */
-		default:	
+		default:
 			tprintf("%lu", tcp->u_arg[2]);
 			break;
 		}
@@ -1265,7 +1265,7 @@
 
 		/* SOL_AX25 SOL_ROSE SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
 		 * etc. still need work */
-		default: 
+		default:
 			tprintf("%lu", tcp->u_arg[2]);
 			break;
 		}
@@ -1404,7 +1404,7 @@
 		break;
 #endif
 
-		/* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25 
+		/* SOL_AX25 SOL_ATALK SOL_NETROM SOL_UDP SOL_DECNET SOL_X25
 		 * etc. still need work  */
 
 	    default:
@@ -1414,7 +1414,7 @@
 	/* default arg printing */
 
 	tprintf (", ");
-		
+
 	if (len == sizeof (int)) {
 		printnum(tcp, addr, "%ld");
 	}
@@ -1502,7 +1502,7 @@
 		for (i = 0; i < tcp->u_nargs; i++)
 			tcp->u_arg[i] = tcp->u_arg[i + 1];
 		return func (tcp);
-		
+
 	}
 
 	return func (tcp);
@@ -1581,7 +1581,7 @@
 			tprintf ("%ld, ", tcp->u_arg [1]);
 		}
 		tprintf ("%ld, ", tcp->u_arg [2]);
-	} 
+	}
 	else {
 		if (tcp->u_arg[3] == 0 || syserror(tcp)) {
 			tprintf("%#lx", tcp->u_arg[3]);
diff --git a/strace.c b/strace.c
index 9a4773f..48b4feb 100644
--- a/strace.c
+++ b/strace.c
@@ -1209,10 +1209,10 @@
 
 #ifndef HAVE_STRERROR
 
-#ifndef SYS_ERRLIST_DECLARED
+#if !HAVE_DECL_SYS_ERRLIST
 extern int sys_nerr;
 extern char *sys_errlist[];
-#endif /* SYS_ERRLIST_DECLARED */
+#endif /* HAVE_DECL_SYS_ERRLIST */
 
 const char *
 strerror(errno)
@@ -1231,11 +1231,11 @@
 
 #ifndef HAVE_STRSIGNAL
 
-#ifndef SYS_SIGLIST_DECLARED
 #ifdef HAVE__SYS_SIGLIST
+#if !HAVE_DECL_SYS_SIGLIST
+extern char *sys_siglist[];
 	extern char *_sys_siglist[];
 #else
-	extern char *sys_siglist[];
 #endif
 #endif /* SYS_SIGLIST_DECLARED */
 
diff --git a/stream.c b/stream.c
index e48e0fc..a7629fb 100644
--- a/stream.c
+++ b/stream.c
@@ -481,7 +481,7 @@
 };
 
 
-#ifdef HAVE_T_OPTHDR
+#ifdef HAVE_STRUCT_T_OPTHDR
 
 static struct xlat xti_level [] = {
 	{ XTI_GENERIC,	"XTI_GENERIC"	},
@@ -562,9 +562,9 @@
 {
 	/* We don't know how to tell if TLI (socket) or XTI
 	   optmgmt is being used yet, assume TLI. */
-#if defined (HAVE_OPTHDR)
+#if defined (HAVE_STRUCT_OPTHDR)
 	print_sock_optmgmt (tcp, addr, len);
-#elif defined (HAVE_T_OPTHDR)
+#elif defined (HAVE_STRUCT_T_OPTHDR)
 	print_xti_optmgmt (tcp, addr, len);
 #else
 	printstr (tcp, addr, len);