l3.xsock/xsock.m4
2006-01-10 12:03:37 +00:00

111 lines
3.7 KiB
Plaintext

# Configure paths for libxsock
# Glenn Rolland <glenux@gmail.com> 2006-01-10
# Shamelessly inspired from libvorbis-1.1.2
dnl GYR_PATH_XSOCK([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for libxsock, and define XSOCK_CFLAGS and XSOCK_LIBS
dnl
AC_DEFUN([GYR_PATH_XSOCK],
[dnl
dnl Get the cflags and libraries
dnl
AC_ARG_WITH(xsock,[ --with-xsock=PFX Prefix where libxsock is installed (optional)], xsock_prefix="$withval", xsock_prefix="")
AC_ARG_WITH(xsock-libraries,[ --with-xsock-libraries=DIR Directory where libxsock is installed (optional)], vorbis_libraries="$withval", vorbis_libraries="")
AC_ARG_WITH(xsock-includes,[ --with-xsock-includes=DIR Directory where libxsock header files are installed (optional)], xsock_includes="$withval", xsock_includes="")
AC_ARG_ENABLE(xsocktest, [ --disable-xsocktest Do not try to compile and run a test XSock program],, enable_xsocktest=yes)
if test "x$xsock_libraries" != "x" ; then
XSOCK_LIBS="-L$xsock_libraries"
elif test "x$sock_prefix" != "x" ; then
XSOCK_LIBS="-L$xsock_prefix/lib"
elif test "x$prefix" != "xNONE" ; then
XSOCK_LIBS="-L$prefix/lib"
fi
XSOCK_LIBS="$XSOCK_LIBS -lxsock"
if test "x$xsock_includes" != "x" ; then
XSOCK_CFLAGS="-I$xsock_includes"
elif test "x$xsock_prefix" != "x" ; then
XSOCK_CFLAGS="-I$xsock_prefix/include"
elif test "x$prefix" != "xNONE"; then
XSOCK_CFLAGS="-I$prefix/include"
fi
AC_MSG_CHECKING(for XSock)
no_xsock=""
if test "x$enable_xsock" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $XSOCK_CFLAGS"
LIBS="$LIBS $XSOCK_LIBS"
dnl
dnl New check if the installed XSock is sufficiently new
dnl
rm -f conf.xsocktest
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <xsock/xsock.h>
int main()
{
XSock sock_serv_tcp(XSock::CLIENT, XSock::TCP);
sock_serv_tcp.port(20500);
sock_serv_tcp.ip(INADDR_LOOPBACK);
sock_serv_tcp.launch();
// XSock sock_serv_udp_std(XSock::CLIENT, XSock::UDP);
//XSock sock_serv_udp_reliable(XSock::CLIENT, XSock::UDP);
system("touch conf.xsocktest");
return 0;
}
],, no_xsock=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
if test "x$no_xsock" = "x" ; then
AC_MSG_RESULT(yes)
ifelse([$1], , :, [$1])
else
AC_MSG_RESULT(no)
if test -f conf.xsocktest ; then
:
else
echo "*** Could not run XSock test program, checking why..."
CFLAGS="$CFLAGS $XSOCK_CFLAGS"
LIBS="$LIBS $XSOCK_LIBS"
AC_TRY_LINK([
#include <stdio.h>
#include <xsock/xsock.h>
], [ return 0; ],
[ echo "*** The test program compiled, but dit not run. This usually means"
echo "*** that the run-time linker is not finding XSock or finding the wrong"
echo "*** version of XSock. If it is not finding XSock, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location. Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means XSock was incorrectly installed"
echo "*** or that you have moved XSock since it was installed." ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
XSOCK_CFLAGS=""
XSOCK_LIBS=""
ifelse([$2], , :, [$2])
fi
AC_SUBST(XSOCK_CFLAGS)
AC_SUBST(XSOCK_LIBS)
rm -f conf.xsocktest
])