threads / patch / 15048

patch, 6 partsOnly define NEEDS_SOCKET if libsocket is usable

Subject: [PATCH 2/6] Only define NEEDS_SOCKET if libsocket is usable

## tl;dr

3 messages between Aug 17, 2008 and Aug 17, 2008. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Andreas Färber· Aug 17, 2008, 08:57 UTC · lore
Signed-off-by: Andreas Faerber <andreas.faerber@web.de>
---
BeOS R5 had socket functions in libnet, Haiku has them in libnetwork,
OpenSolaris has them in libxnet. Hence checking libc is not enough.
  configure.ac |    8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)
Show changes to configure.ac +4 −4
diff --git a/configure.ac b/configure.ac
index 7c2856e..75ec83a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,11 +223,11 @@ AC_LINK_IFELSE(ZLIBTEST_SRC,
  LIBS="$old_LIBS"
  AC_SUBST(NO_DEFLATE_BOUND)
  #
-# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
+# Define NEEDS_SOCKET if linking with libc is required (SunOS,
  # Patrick Mauritz).
-AC_CHECK_LIB([c], [socket],
-[NEEDS_SOCKET=],
-[NEEDS_SOCKET=YesPlease])
+AC_CHECK_LIB([socket], [socket],
+[NEEDS_SOCKET=YesPlease],
+[NEEDS_SOCKET=])
  AC_SUBST(NEEDS_SOCKET)
  test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
-- 
1.6.0.rc3.32.g8aaa
Junio C Hamano· Aug 17, 2008, 09:16 UTC · re: Andreas Färber · lore

Re: [PATCH 2/6] Only define NEEDS_SOCKET if libsocket is usable

Andreas Färber <andreas.faerber@web.de> writes:
Show 19 quoted lines
> diff --git a/configure.ac b/configure.ac
> index 7c2856e..75ec83a 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -223,11 +223,11 @@ AC_LINK_IFELSE(ZLIBTEST_SRC,
>  LIBS="$old_LIBS"
>  AC_SUBST(NO_DEFLATE_BOUND)
>  #
> -# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
> +# Define NEEDS_SOCKET if linking with libc is required (SunOS,
>  # Patrick Mauritz).
> -AC_CHECK_LIB([c], [socket],
> -[NEEDS_SOCKET=],
> -[NEEDS_SOCKET=YesPlease])
> +AC_CHECK_LIB([socket], [socket],
> +[NEEDS_SOCKET=YesPlease],
> +[NEEDS_SOCKET=])
>  AC_SUBST(NEEDS_SOCKET)
>  test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"

Doesn't this force linkage with -lsocket even if -lc is enough to use socket(2) calls?

In other words, "checking libc is not enough" is only half correct. The right thing to do is "check libc and if it is sufficient be happy, but otherwise do not automatically assume -lsocket is Ok." Something like:

AC_CHECK_LIB([c], [socket],
[NEEDS_SOCKET=],
[AC_CHECK_LIB([socket], [socket],
        	[NEEDS_SOCKET=YesPlease],
                [NEEDS_SOCKET=])])

Other patches seemed Ok from my cursory look; I do not know the people whose Ack's were on your patch submission, though...

Thanks.
Andreas Färber· Aug 17, 2008, 11:40 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/6] Only define NEEDS_SOCKET if libsocket is usable

Am 17.08.2008 um 11:16 schrieb Junio C Hamano:
Show 24 quoted lines
> Andreas Färber <andreas.faerber@web.de> writes:
>
>> diff --git a/configure.ac b/configure.ac
>> index 7c2856e..75ec83a 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -223,11 +223,11 @@ AC_LINK_IFELSE(ZLIBTEST_SRC,
>> LIBS="$old_LIBS"
>> AC_SUBST(NO_DEFLATE_BOUND)
>> #
>> -# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
>> +# Define NEEDS_SOCKET if linking with libc is required (SunOS,
>> # Patrick Mauritz).
>> -AC_CHECK_LIB([c], [socket],
>> -[NEEDS_SOCKET=],
>> -[NEEDS_SOCKET=YesPlease])
>> +AC_CHECK_LIB([socket], [socket],
>> +[NEEDS_SOCKET=YesPlease],
>> +[NEEDS_SOCKET=])
>> AC_SUBST(NEEDS_SOCKET)
>> test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
>
> Doesn't this force linkage with -lsocket even if -lc is enough to use
> socket(2) calls?
If both libc and libsocket provide it, yes.
Show 11 quoted lines
> In other words, "checking libc is not enough" is only half correct.   
> The
> right thing to do is "check libc and if it is sufficient be happy, but
> otherwise do not automatically assume -lsocket is Ok."  Something  
> like:
>
> AC_CHECK_LIB([c], [socket],
> [NEEDS_SOCKET=],
> [AC_CHECK_LIB([socket], [socket],
>        	[NEEDS_SOCKET=YesPlease],
>                [NEEDS_SOCKET=])])
Looks okay to me that way.
> Other patches seemed Ok from my cursory look; I do not know the
> people whose Ack's were on your patch submission, though...

Sorry for not explaining: Ingo is one of the core Haiku developers, and Scott is from HaikuPorts. This is the initial submission to this list, trying to adhere to the SubmittingPatches document.

Andreas

← back to recent threads