socat should now build under MacOS X 10.4

This commit is contained in:
Gerhard Rieger 2008-09-21 18:08:26 +02:00
parent 9d7c7f8244
commit 9a097fc49d
3 changed files with 76 additions and 91 deletions

View file

@ -38,6 +38,10 @@ corrections:
Makefile now supports datarootdir (thanks to Camillo Lugaresi for Makefile now supports datarootdir (thanks to Camillo Lugaresi for
providing the patch) providing the patch)
porting:
socat should now build under MacOS X 10.4 (thanks to Camillo Lugaresi for
providing the patch)
####################### V 1.6.0.1: ####################### V 1.6.0.1:
new features: new features:

View file

@ -55,13 +55,24 @@ AC_CHECK_HEADERS(pwd.h grp.h stdint.h sys/types.h sys/poll.h sys/socket.h sys/ui
AC_CHECK_HEADERS(pty.h) AC_CHECK_HEADERS(pty.h)
AC_CHECK_HEADERS(netinet/in.h netinet/in_systm.h netinet/ip.h netinet/tcp.h) AC_CHECK_HEADERS(netinet/in.h netinet/in_systm.h netinet/ip.h netinet/tcp.h)
AC_CHECK_HEADERS(netinet6/in6.h) # found on OpenBSD, used for IPV6_* AC_CHECK_HEADERS(netinet6/in6.h) # found on OpenBSD, used for IPV6_*
AC_CHECK_HEADERS(arpa/nameser.h resolv.h) AC_CHECK_HEADERS(net/if.h, [], [], [AC_INCLUDES_DEFAULT
AC_CHECK_HEADERS(termios.h net/if.h linux/if_tun.h) #if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif]) # Mac OS X requires including sys/socket.h
AC_CHECK_HEADERS(arpa/nameser.h)
AC_HEADER_RESOLV()
AC_CHECK_HEADERS(termios.h linux/if_tun.h)
AC_CHECK_HEADERS(sys/utsname.h sys/select.h sys/file.h) AC_CHECK_HEADERS(sys/utsname.h sys/select.h sys/file.h)
AC_CHECK_HEADERS(util.h libutil.h sys/stropts.h regex.h) AC_CHECK_HEADERS(util.h libutil.h sys/stropts.h regex.h)
AC_CHECK_HEADERS(linux/fs.h linux/ext2_fs.h) AC_CHECK_HEADERS(linux/fs.h linux/ext2_fs.h)
dnl Link libresolv if necessary (for Mac OS X)
AC_SEARCH_LIBS([res_9_init], [resolv])
dnl Check for extra socket library (for Solaris) dnl Check for extra socket library (for Solaris)
AC_CHECK_FUNC(hstrerror, , AC_CHECK_LIB(resolv, hstrerror, [LIBS="$LIBS -lresolv"; AC_DEFINE(HAVE_HSTRERROR)])) AC_CHECK_FUNC(hstrerror, , AC_CHECK_LIB(resolv, hstrerror, [LIBS="$LIBS -lresolv"; AC_DEFINE(HAVE_HSTRERROR)]))
AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent)) AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
@ -185,7 +196,11 @@ AC_ARG_ENABLE(ip6, [ --disable-ip6 disable IPv6 support],
if test "$WITH_IP6"; then if test "$WITH_IP6"; then
AC_CHECK_HEADERS([netinet/ip6.h], AC_CHECK_HEADERS([netinet/ip6.h],
[AC_DEFINE(HAVE_NETINET_IP6_H) AC_DEFINE(WITH_IP6)], [AC_DEFINE(HAVE_NETINET_IP6_H) AC_DEFINE(WITH_IP6)],
[AC_MSG_WARN([include file netinet/ip6.h not found, disabling IP6])]) [AC_MSG_WARN([include file netinet/ip6.h not found, disabling IP6])],
[AC_INCLUDES_DEFAULT
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif])
fi fi
AC_MSG_CHECKING(whether to include raw IP support) AC_MSG_CHECKING(whether to include raw IP support)
@ -284,93 +299,56 @@ AC_ARG_ENABLE(readline, [ --disable-readline disable readline support],
esac], esac],
[AC_MSG_RESULT(yes); WITH_READLINE=1 ]) [AC_MSG_RESULT(yes); WITH_READLINE=1 ])
# check if we find the components of GNU readline
if test -n "$WITH_READLINE"; then if test -n "$WITH_READLINE"; then
# first, we need to find the include file <readline.h> CPPFLAGS_ORIG=$CPPFLAGS
AC_MSG_NOTICE(checking for components of readline) CFLAGS_ORIG=$CFLAGS
#AC_CHECK_HEADERS(readline/readline.h readline/history.h) LIBS_ORIG=$LIBS
AC_CACHE_VAL(sc_cv_have_readline_h, sc_usable_readline_found=
[AC_TRY_COMPILE([#include <stdio.h> /* FreeBSD needs "FILE *" */
#include <readline/readline.h> for D in "" "/usr/local" "/opt/local" "/sw" "/opt/freeware" "/usr/sfw"; do
#include <readline/history.h>],[;], if test -n "$D" ; then
[sc_cv_have_readline_h=yes; READLINE_ROOT=""; ], CPPFLAGS="$CPPFLAGS -I$D/include"
[sc_cv_have_readline_h=no CFLAGS="$CFLAGS -L$D/lib"
for D in "/sw" "/usr/local" "/opt/freeware" "/usr/sfw"; do DLOC="in location $D"
I="$D/include" else
i="$I/readline/readline.h" DLOC="in default location"
if test -r "$i"; then fi
#V_INCL="$V_INCL -I$I/" AC_MSG_CHECKING(for usable readline $DLOC)
CPPFLAGS="$CPPFLAGS -I$I"
AC_MSG_NOTICE(found $i) # Some systems require -lcurses, some require -lncurses.
sc_cv_have_readline_h=yes; READLINE_ROOT="$D" # Mac OS X 10.4 (and others) ships with libedit masquerading as readline,
break; # but it doesn't work well with socat. It can be recognized by the absence
fi # of append_history.
done])
]) for L in "" "-lcurses" "-lncurses"; do
if test "$sc_cv_have_readline_h" = "yes"; then LIBS="$LIBS_ORIG -lreadline $L"
AC_DEFINE(HAVE_READLINE_READLINE_H) AC_TRY_LINK(
AC_DEFINE(HAVE_READLINE_HISTORY_H) [ #include <stdio.h>
fi #include <readline/readline.h>
AC_MSG_NOTICE(checked for readline.h... $sc_cv_have_readline_h) #include <readline/history.h>],
fi # end checking for readline.h [ readline(NULL);
# append_history(0, NULL); ],
if test -n "$WITH_READLINE" -a "$sc_cv_have_readline_h" = yes; then [ sc_usable_readline_found=1
# next, we search for the readline library (libreadline.*) break ])
AC_MSG_CHECKING(for libreadline) done
AC_CACHE_VAL(sc_cv_have_libreadline,
[ LIBS0="$LIBS" if test -n "$sc_usable_readline_found"; then
if test -n "$READLINE_ROOT"; then AC_MSG_RESULT(yes)
L="$READLINE_ROOT/lib"; LIBS="$LIBS0 -L$L -lreadline" AC_DEFINE(HAVE_READLINE_READLINE_H,1)
else AC_DEFINE(HAVE_READLINE_HISTORY_H,1)
LIBS="$LIBS0 -lreadline" AC_DEFINE(HAVE_LIBREADLINE,1)
fi AC_DEFINE(WITH_READLINE,1)
AC_TRY_LINK([#include <stdio.h> /* FreeBSD needs FILE * */ break
#include <readline/readline.h> else
#include <readline/history.h>], AC_MSG_RESULT(no)
[readline(NULL)], CPPFLAGS=$CPPFLAGS_ORIG
[sc_cv_have_libreadline='yes'], CFLAGS=$CFLAGS_ORIG
[sc_cv_have_libreadline='no' LIBS=$LIBS_ORIG
LIBS1="$LIBS" fi
LIBS="$LIBS -lcurses" done
AC_TRY_LINK([#include <stdio.h> /* FreeBSD needs FILE * */
#include <readline/readline.h> if test -z "$sc_usable_readline_found"; then
#include <readline/history.h>], AC_MSG_WARN([no suitable version of readline found; perhaps you need to install a newer version])
[readline(NULL)],
[sc_cv_have_libreadline='yes'],
[sc_cv_have_libreadline='no'
LIBS="$LIBS1 -lncurses" # eg for SuSE52
AC_TRY_LINK([#include <stdio.h> /* FreeBSD needs FILE * */
#include <readline/readline.h>
#include <readline/history.h>],
[readline(NULL)],
[sc_cv_have_libreadline='yes'],
[sc_cv_have_libreadline='no'])
])]
)
if test "$sc_cv_have_libreadline" != 'yes'; then
LIBS="$LIBS0"
fi
]
#! missing libcurses dependency; missing freeware places
# # we test if libcurses is available and if it can be used without further libs
# AC_CHECK_LIB(ncurses, main, , AC_CHECK_LIB(curses, main)) # some Linux work with this
# # we test if readline can be used without further libs
# AC_CHECK_LIB(readline, readline)
# # we see if using_history() is already in $LIBS; if not, we try it with curses
# AC_CHECK_FUNC(using_history, , AC_CHECK_LIB(history, using_history,,, -lcurses))
#fi
)
if test "$sc_cv_have_libreadline" = 'yes'; then
AC_DEFINE(HAVE_LIBREADLINE)
fi
AC_MSG_RESULT($sc_cv_have_libreadline)
fi
#
if test -n "$WITH_READLINE"; then
if test "$sc_cv_have_readline_h" = "yes" -a "$sc_cv_have_libreadline" = "yes"; then
AC_DEFINE(WITH_READLINE)
else
AC_MSG_WARN([not all components of readline found, disabling it]);
fi fi
fi fi

View file

@ -115,6 +115,7 @@ NetBSD)IFCONFIG=/sbin/ifconfig ;;
OpenBSD)IFCONFIG=/sbin/ifconfig ;; OpenBSD)IFCONFIG=/sbin/ifconfig ;;
OSF1) IFCONFIG=/sbin/ifconfig ;; OSF1) IFCONFIG=/sbin/ifconfig ;;
SunOS) IFCONFIG=/sbin/ifconfig ;; SunOS) IFCONFIG=/sbin/ifconfig ;;
Darwin)IFCONFIG=/sbin/ifconfig ;;
#*) IFCONFIG=/sbin/ifconfig ;; #*) IFCONFIG=/sbin/ifconfig ;;
esac esac
@ -177,7 +178,7 @@ ECHO="echo $E"
PRINTF="printf" PRINTF="printf"
case "$TERM" in case "$TERM" in
vt100|vt320|linux|xterm|cons25|dtterm|aixterm|sun-color) vt100|vt320|linux|xterm|cons25|dtterm|aixterm|sun-color|xterm-color)
# there are different behaviours of printf (and echo) # there are different behaviours of printf (and echo)
# on some systems, echo behaves different than printf... # on some systems, echo behaves different than printf...
if [ $($PRINTF "\0101") = "A" ]; then if [ $($PRINTF "\0101") = "A" ]; then
@ -1637,6 +1638,7 @@ runsip4 () {
OpenBSD)l=$($IFCONFIG -a |fgrep 'inet 127.0.0.1 ');; OpenBSD)l=$($IFCONFIG -a |fgrep 'inet 127.0.0.1 ');;
OSF1) l=$($IFCONFIG -a |grep ' inet ') ;; OSF1) l=$($IFCONFIG -a |grep ' inet ') ;;
SunOS) l=$($IFCONFIG -a |grep 'inet ') ;; SunOS) l=$($IFCONFIG -a |grep 'inet ') ;;
Darwin)l=$($IFCONFIG lo0 |fgrep 'inet 127.0.0.1 ') ;;
# *) l=$($IFCONFIG -a |grep ' ::1[^:0-9A-Fa-f]') ;; # *) l=$($IFCONFIG -a |grep ' ::1[^:0-9A-Fa-f]') ;;
esac esac
[ -z "$l" ] && return 1 [ -z "$l" ] && return 1
@ -1662,12 +1664,13 @@ runsip6 () {
NetBSD)l=$(/sbin/ifconfig -a |grep 'inet6 ::1 ');; NetBSD)l=$(/sbin/ifconfig -a |grep 'inet6 ::1 ');;
OSF1) l=$(/sbin/ifconfig -a |grep ' inet6 ') ;; OSF1) l=$(/sbin/ifconfig -a |grep ' inet6 ') ;;
SunOS) l=$(/sbin/ifconfig -a |grep 'inet6 ') ;; SunOS) l=$(/sbin/ifconfig -a |grep 'inet6 ') ;;
Darwin)l=$(/sbin/ifconfig lo0 |grep 'inet6 ::1 ') ;;
*) l=$(/sbin/ifconfig -a |grep ' ::1[^:0-9A-Fa-f]') ;; *) l=$(/sbin/ifconfig -a |grep ' ::1[^:0-9A-Fa-f]') ;;
esac esac
[ -z "$l" ] && return 1 [ -z "$l" ] && return 1
# existence of interface might not suffice, check for routeability: # existence of interface might not suffice, check for routeability:
case "$UNAME" in case "$UNAME" in
Darwin) ping -c 1 ::1; l="$?" ;; Darwin) ping6 -c 1 ::1; l="$?" ;;
Linux) ping6 -c 1 ::1; l="$?" ;; Linux) ping6 -c 1 ::1; l="$?" ;;
*) if [ -n "$l" ]; then l=0; else l=1; fi ;; *) if [ -n "$l" ]; then l=0; else l=1; fi ;;
esac esac