summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-01-17 06:25:52 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2011-01-17 06:26:59 (GMT)
commit5d5d8be9deb29563d666323aaeb9baf03e470a9c (patch)
tree9adae05d3577f4b9a6392821f31da2595f6b93c7
parentbe986af65aad4dc28fd5c1ff33700ee54a09c79c (diff)
downloadipxrelay-autoconf.zip
ipxrelay-autoconf.tar.gz
ipxrelay-autoconf.tar.bz2
ipxrelay-autoconf.tar.xz
More autoconf workautoconf
Unfortunately autoconf handles winsock extremely poorly due to the special calling convention, so the autoconf track might have been a mistake.
-rw-r--r--MCONFIG.in6
-rw-r--r--Makefile2
-rw-r--r--aclocal.m447
-rw-r--r--config.h121
-rw-r--r--configure.in60
-rw-r--r--xconfig.h120
6 files changed, 177 insertions, 179 deletions
diff --git a/MCONFIG.in b/MCONFIG.in
index 1d068b5..5cb239b 100644
--- a/MCONFIG.in
+++ b/MCONFIG.in
@@ -57,8 +57,12 @@ CFLAGS = @CFLAGS@ -I$(SRCROOT)
# Link flags
LDFLAGS = @LDFLAGS@
+# Libraries
+LIBS = @LIBS@
+
# Additional library we need to build
-LIBOBJS = $(addprefix lib/,@LIBOBJS@)
+LIBOBJDIR = lib/
+LIBOBJS = @LIBOBJS@
# ar and ranlib (for making libraries)
AR = ar cq
diff --git a/Makefile b/Makefile
index bfb1ad3..bf9b235 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ SRCROOT = .
all: ipxrelay
ipxrelay$(X): ipxrelay.$(O) $(LIBOBJS)
- $(CC) $(LDFLAGS) -o $@ $^
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -f ipxrelay$(X) *.$(O)
diff --git a/aclocal.m4 b/aclocal.m4
index c07702c..89e8cbb 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -255,26 +255,63 @@ int main()
AC_MSG_RESULT(no)
])])
+# PA_SEARCH_LIBS(FUNCTION, ARGUMENTS, SEARCH-LIBS,
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+# [OTHER-LIBRARIES])
+# --------------------------------------------------------
+# Search for a library defining FUNC, if it's not already available.
+AC_DEFUN([PA_SEARCH_LIBS],
+[AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$1])dnl
+AC_CACHE_CHECK([for library containing $1], [ac_Search],
+[ac_func_search_save_LIBS=$LIBS
+AC_LANG_CONFTEST([AC_LANG_CALL([], [$1])])
+for ac_lib in '' $3; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $6 $ac_func_search_save_LIBS"
+ fi
+ AC_LINK_IFELSE([
+#include "xconfig.h"
+int main (void)
+{
+ $1$2;
+ return 0;
+}], [AS_VAR_SET([ac_Search], [$ac_res])])
+ AS_VAR_SET_IF([ac_Search], [break])
+done
+AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])
+LIBS=$ac_func_search_save_LIBS])
+AS_VAR_COPY([ac_res], [ac_Search])
+AS_IF([test "$ac_res" != no],
+ [test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+ $4],
+ [$5])
+AS_VAR_POPDEF([ac_Search])dnl
+])
+
dnl --------------------------------------------------------------------------
dnl PA_SEARCH_LIBS_AND_ADD
dnl
-dnl PA_SEARCH_LIBS_AND_ADD(function, libraries [,function to add])
+dnl PA_SEARCH_LIBS_AND_ADD(function, arguments, libraries [,function to add])
dnl --------------------------------------------------------------------------
-AC_DEFUN(PA_SEARCH_LIBS_AND_ADD,
+AC_DEFUN([PA_SEARCH_LIBS_AND_ADD],
[
AH_TEMPLATE(AS_TR_CPP(HAVE_$1), [Define if $1 function was found])
- AC_SEARCH_LIBS($1, $2,
+ PA_SEARCH_LIBS($1, $2, $3,
[
AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1))
pa_add_$1=false;
],
[
XTRA=true;
- if test $# -eq 3; then
- AC_LIBOBJ($3)
+ if test $# -eq 4; then
+ AC_LIBOBJ($4)
else
AC_LIBOBJ($1)
fi
pa_add_$1=true;
])])
+
diff --git a/config.h b/config.h
index c0127df..8f01987 100644
--- a/config.h
+++ b/config.h
@@ -20,125 +20,8 @@
/* Must be included before we include any system headers! */
#include "aconfig.h" /* autogenerated configuration header */
-/* Standard includes */
-
-#include <stdio.h>
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#else
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#endif
-
-#ifdef HAVE_MEMORY_H
-#ifndef STDC_HEADERS
-#include <memory.h>
-#endif
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#ifdef HAVE_INTTYPES_H
-#ifdef INTTYPES_H_IS_SANE
-#include <inttypes.h>
-#endif
-#else
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SETJMP_H
-#include <setjmp.h>
-#endif
-
-#ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#include <errno.h>
-#include <signal.h>
-
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#else
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#else
-#ifdef HAVE_WINSOCK_H
-#include <winsock.h>
-#endif
-#endif
-#endif
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-
-#ifdef HAVE_GETOPT_LONG
-#include <getopt.h>
-#else
-#include "lib/getopt.h"
-#endif
-
-#ifdef HAVE_SYS_CAPABILITY_H
-#include <sys/capability.h>
-#endif
-
-/* A lot of this is old BSD code. Some newer systems don't approve. */
-
-/* The type used by htons(), ntohs() */
-#ifndef HAVE_U_SHORT
-#ifdef HAVE_UINT16_T
-typedef uint16_t u_short;
-#else
-typedef unsigned short u_short;
-#endif
-#endif
-
-/* The type used to htonl(), ntohl() */
-#ifndef HAVE_U_LONG
-#ifdef HAVE_UINT32_T
-typedef uint32_t u_long;
-#else
-typedef unsigned long u_long;
-#endif
-#endif
+/* Standard include files */
+#include "xconfig.h"
/* socklen_t */
#ifndef HAVE_SOCKLEN_T
diff --git a/configure.in b/configure.in
index 23045a2..d8b4622 100644
--- a/configure.in
+++ b/configure.in
@@ -69,48 +69,8 @@ dnl <sys/socket.h> isn't among the list of standard headers that
dnl autoconf checks, but POSIX requires <sys/socket.h> for socklen_t
dnl to be defined.
dnl
-AC_CHECK_TYPES(socklen_t,,,
-[
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-])
-
-AC_SEARCH_LIBS(socket, [socket ws2_32 wsock32], ,
+AC_CHECK_TYPES(socklen_t,,,[#include "xconfig.h"])
+PA_SEARCH_LIBS(socket, [(0,0,0)], [socket ws2_32 wsock32], ,
[AC_MSG_ERROR(socket library not found)])
AC_CHECK_FUNCS(fcntl)
@@ -127,19 +87,13 @@ dnl
SRCROOT=`cd $srcdir && pwd`
OBJROOT=`pwd`
-PA_SEARCH_LIBS_AND_ADD(getopt_long, [getopt cygwin iberty], getopt_long)
-PA_SEARCH_LIBS_AND_ADD(getaddrinfo, [nsl resolv])
+PA_SEARCH_LIBS_AND_ADD(getopt_long, [(0, NULL, NULL, NULL, NULL)],
+ [getopt cygwin iberty], getopt_long)
+PA_SEARCH_LIBS_AND_ADD(getaddrinfo, [(NULL, NULL, NULL, NULL)], [nsl resolv])
if $pa_add_getaddrinfo
then
- AC_SEARCH_LIBS(gethostbyname, [nsl resolv],
- [AC_SEARCH_LIBS(herror, [nsl resolv], ,
- [AC_MSG_ERROR(herror not found)])],
- [AC_MSG_ERROR(gethostbyname not found)])
-else
- AC_SEARCH_LIBS(freeaddrinfo, [nsl resolv], ,
- [AC_MSG_ERROR(getaddrinfo but not freeaddrinfo found)])
- AC_SEARCH_LIBS(gai_strerror, [nsl resolv], ,
- [AC_MSG_ERROR(getaddrinfo but not gai_strerror found)])
+ PA_SEARCH_LIBS(gethostbyname, [(NULL)], [nsl resolv], ,
+ [AC_MSG_ERROR(gethostbyname not found)])
fi
AC_CHECK_FUNCS(daemon)
diff --git a/xconfig.h b/xconfig.h
new file mode 100644
index 0000000..3ecfcd7
--- /dev/null
+++ b/xconfig.h
@@ -0,0 +1,120 @@
+/* -*- c -*- ------------------------------------------------------------- *
+ *
+ * Copyright 2001-2006 H. Peter Anvin - All Rights Reserved
+ *
+ * This program is free software available under the same license
+ * as the "OpenBSD" operating system, distributed at
+ * http://www.openbsd.org/.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * xconfig.h
+ *
+ * Standard header files usable from inside "configure"
+ */
+
+#ifndef XCONFIG_H
+#define XCONFIG_H
+
+/* Standard includes */
+
+#include <stdio.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#else
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#endif
+
+#ifdef HAVE_MEMORY_H
+#ifndef STDC_HEADERS
+#include <memory.h>
+#endif
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#ifdef INTTYPES_H_IS_SANE
+#include <inttypes.h>
+#endif
+#else
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SETJMP_H
+#include <setjmp.h>
+#endif
+
+#ifdef TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#include <errno.h>
+#include <signal.h>
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#else
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#ifdef HAVE_GETOPT_LONG
+#include <getopt.h>
+#else
+#include "lib/getopt.h"
+#endif
+
+#ifdef HAVE_SYS_CAPABILITY_H
+#include <sys/capability.h>
+#endif
+
+#endif /* XCONFIG_H */