]> err.no Git - util-linux/commitdiff
build-sys: link with socketlibs when necessary
authorFabian Groffen <grobian@gentoo.org>
Mon, 17 Jan 2011 20:14:54 +0000 (21:14 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 20 Jan 2011 22:03:01 +0000 (23:03 +0100)
To link an object which references socket functions, you need to link
with -lsocket -lnsl on Solaris.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
configure.ac
shlibs/uuid/src/Makefile.am

index 5b491f8ef7dc4168c747db27df4e37de32e5a837..c38cca43f9e0a286e49a3581e417e168c9104ebf 100644 (file)
@@ -211,6 +211,17 @@ AC_CHECK_MEMBER(struct sockaddr.sa_len,
        [#include <sys/types.h>
         #include <sys/socket.h>])
 
+SOCKET_LIBS=
+AC_SEARCH_LIBS([gethostbyname], [nsl],
+       [if test x"$ac_cv_search_gethostbyname" != x"none required"; then
+               SOCKET_LIBS="$SOCKET_LIBS -lnsl";
+        fi])
+AC_SEARCH_LIBS([socket], [socket],
+       [if test x"$ac_cv_search_socket" != x"none required"; then
+               SOCKET_LIBS="$SOCKET_LIBS -lsocket";
+       fi])
+AC_SUBST([SOCKET_LIBS])
+
 dnl Static compilation
 m4_define([UTIL_STATIC_PROGRAMS], [losetup, mount, umount, fdisk, sfdisk, blkid])
 
index 9af1979eabcea145ebe65b5c380f7a06326f96b2..31cb9a2e1dcfe9617e345c54906f6a057c1a6d7e 100644 (file)
@@ -3,7 +3,7 @@ include $(top_srcdir)/config/include-Makefile.am
 AM_CPPFLAGS += -I$(ul_libuuid_srcdir)
 
 noinst_PROGRAMS = tst_uuid
-tst_uuid_LDADD = libuuid.la #$(ul_libuuid_la)
+tst_uuid_LDADD = libuuid.la $(SOCKET_LIBS) #$(ul_libuuid_la)
 
 # includes
 uuidincdir = $(includedir)/uuid
@@ -16,6 +16,8 @@ libuuid_la_SOURCES = clear.c compare.c copy.c gen_uuid.c \
 
 libuuid_la_DEPENDENCIES = uuid.sym
 
+libuuid_la_LIBADD = $(SOCKET_LIBS)
+
 libuuid_la_LDFLAGS = -Wl,--version-script=$(ul_libuuid_srcdir)/uuid.sym \
                      -version-info $(LIBUUID_VERSION_INFO)