diff --git a/ChangeLog b/ChangeLog index 8a4e563..8069fc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,12 @@ Version 1.4.5 * Fix for a bug in makeAction where va_arg was beeing called one extra time. +2007-04-19 Marcelo Jimenez + * SF Tracker [ 1703533 ] Patch to make it compile under FreeBSD + Submitted By: Timothy Redaelli - drittz + I made some patches to make it compile under FreeBSD using + gethostbyaddr_r when supported. + ************************************************************************* Version 1.4.4 ************************************************************************* diff --git a/bootstrap b/bootstrap index 55d1a1b..8c0a507 100755 --- a/bootstrap +++ b/bootstrap @@ -13,7 +13,3 @@ autoreconf --force --install -Wall -Wno-obsolete $* || exit 1 echo "Now run ./configure and then make." exit 0 - - - - diff --git a/configure.ac b/configure.ac index c4a1945..36b78a8 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,11 @@ AC_CONFIG_SRCDIR(upnp/inc/upnp.h) AM_INIT_AUTOMAKE([1.8 -Wall foreign subdir-objects dist-bzip2]) +# +# Get canonical host names in host and host_os +# +AC_CANONICAL_HOST + # # There are 3 configuration files : # 1) "./autoconfig.h" is auto-generated and used only internally during build @@ -131,11 +136,14 @@ RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code]) # version on that. docdir="${datadir}/doc/${PACKAGE_NAME}-${PACKAGE_VERSION}" AC_MSG_CHECKING([for documentation directory]) -AC_ARG_WITH([documentation], - AS_HELP_STRING([--with-documentation=directory_name], +AC_ARG_WITH( + [documentation], + AS_HELP_STRING( + [--with-documentation=directory_name], [where documentation is installed @<:@[DATADIR/doc/]AC_PACKAGE_NAME[-]AC_PACKAGE_VERSION@:>@]) -AS_HELP_STRING([--without-documentation], +AS_HELP_STRING( + [--without-documentation], [do not install the documentation]), [], [with_documentation=no]) @@ -159,25 +167,40 @@ AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_EGREP - # # Default compilation flags # -if test x"$enable_debug" = xyes; then - # AC_PROG_CC already sets CFLAGS to "-g -O2" by default - : -else - # add optimise for size - AX_CFLAGS_GCC_OPTION([-Os]) -fi +echo "--------------------- Default compilation flags -------------------------------" +echo host is $host +echo host_os is $host_os +case $host_os in +FreeBSD*) + echo "Using FreeBSD specific compiler settings" + # Put FreeBSD specific compiler flags here + ;; +*) + echo "Using non-specific system compiler settings" + if test x"$enable_debug" = xyes; then + # AC_PROG_CC already sets CFLAGS to "-g -O2" by default + : + else + # add optimise for size + AX_CFLAGS_GCC_OPTION([-Os]) + fi + ;; +esac + AX_CFLAGS_WARN_ALL +echo "-------------------------------------------------------------------------------" + # # Lot's of stuff to ensure large file support # +AC_TYPE_SIZE_T AC_TYPE_OFF_T -AC_DEFINE(_LARGE_FILE_SOURCE, [], [Large files support]) -AC_DEFINE(_FILE_OFFSET_BITS, [64], [File Offset size]) +AC_DEFINE([_LARGE_FILE_SOURCE], [], [Large files support]) +AC_DEFINE([_FILE_OFFSET_BITS], [64], [File Offset size]) # @@ -186,7 +209,24 @@ AC_DEFINE(_FILE_OFFSET_BITS, [64], [File Offset size]) AC_HEADER_STDC # libupnp code doesn't use autoconf variables yet, # so just abort if a header file is not found. -AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h],[],[AC_MSG_ERROR([required header file missing])]) +AC_CHECK_HEADERS( + [ \ + arpa/inet.h \ + fcntl.h \ + limits.h \ + netdb.h \ + netinet/in.h \ + stdlib.h \ + string.h \ + sys/ioctl.h \ + sys/socket.h \ + sys/time.h \ + sys/timeb.h \ + syslog.h \ + unistd.h \ + ], + [], + [AC_MSG_ERROR([required header file missing])]) # @@ -202,25 +242,28 @@ TYPE_SOCKLEN_T # AC_FUNC_VPRINTF AC_FUNC_FSEEKO +AC_CHECK_FUNCS(ftime,, [AC_CHECK_LIB(compat, ftime)]) # # Checks for POSIX Threads # -ACX_PTHREAD([],[AC_MSG_ERROR([POSIX threads are required to build this program])]) +ACX_PTHREAD( + [], + [AC_MSG_ERROR([POSIX threads are required to build this program])]) +AC_CONFIG_FILES([ + Makefile + ixml/Makefile + ixml/doc/Makefile + threadutil/Makefile + upnp/Makefile + upnp/doc/Makefile + docs/dist/Makefile + libupnp.pc + ]) -AC_CONFIG_FILES([Makefile - ixml/Makefile - ixml/doc/Makefile - threadutil/Makefile - upnp/Makefile - upnp/doc/Makefile - docs/dist/Makefile - libupnp.pc - ]) - AC_OUTPUT diff --git a/threadutil/inc/ithread.h b/threadutil/inc/ithread.h index 7b6f53a..5024443 100644 --- a/threadutil/inc/ithread.h +++ b/threadutil/inc/ithread.h @@ -47,6 +47,10 @@ extern "C" { #include #endif +#ifdef __FreeBSD__ +#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE +#endif + #ifdef PTHREAD_MUTEX_RECURSIVE /* This system has SuS2-compliant mutex attributes. * E.g. on Cygwin, where we don't have the old nonportable (NP) symbols diff --git a/upnp/src/genlib/net/uri/uri.c b/upnp/src/genlib/net/uri/uri.c index fefc396..a6a1105 100644 --- a/upnp/src/genlib/net/uri/uri.c +++ b/upnp/src/genlib/net/uri/uri.c @@ -34,8 +34,11 @@ ************************************************************************/ #ifdef __FreeBSD__ +#include +#if __FreeBSD_version < 601103 #include #endif +#endif #include "config.h" #include "uri.h" @@ -620,7 +623,7 @@ parse_hostport( const char *in, &h, temp_hostbyname_buff, BUFFER_SIZE, &errcode ); -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) && __FreeBSD_version < 601103 h = lwres_gethostbyname_r( temp_host_name, &h_buf, temp_hostbyname_buff,