[PATCH] Check for getaddrinfo via configure test
Felix Janda <[email protected]> Wed, 23 Dec 2015 14:36:19 +0100
| Newsgroups | gmane.comp.gnome.apps.gkrellm |
|---|---|
| Message-ID | <20151223133619.GB565@nyan> |
Fixes the compilation error "redefinition of addrinfo" on linux systems
using the musl c library.
---
server/Makefile | 4 ++--
server/configure | 37 +++++++++++++++++++++++++++++++++++++
server/gkrellmd-private.h | 37 -------------------------------------
src/Makefile | 12 ++++--------
src/client.c | 33 ---------------------------------
src/configure | 34 ++++++++++++++++++++++++++++++++++
6 files changed, 77 insertions(+), 80 deletions(-)
diff --git a/server/Makefile b/server/Makefile
index 7050d00..2a943ff 100644
--- a/server/Makefile
+++ b/server/Makefile
@@ -89,7 +89,7 @@ freebsd3 freebsd:
# Darwin target for systems that still have libkvm
darwin:
- $(MAKE) STRIP= HAVE_GETADDRINFO=1 \
+ $(MAKE) STRIP= \
EXTRAOBJS= \
SYS_LIBS="-framework CoreFoundation -framework IOKit -lkvm" \
LINK_FLAGS="-Wl,-bind_at_load" \
@@ -97,7 +97,7 @@ darwin:
# Darwin 9.x and newer (OS X > 10.4) do not have libkvm, build without it
darwin9:
- $(MAKE) STRIP= HAVE_GETADDRINFO=1 \
+ $(MAKE) STRIP= \
EXTRAOBJS= \
SYS_LIBS="-framework CoreFoundation -framework IOKit" \
LINK_FLAGS="-Wl,-bind_at_load" \
diff --git a/server/configure b/server/configure
index eb94e27..f10ba7b 100755
--- a/server/configure
+++ b/server/configure
@@ -25,6 +25,7 @@ echo "CFLAGS: ${CFLAGS}" 1>& 5
if [ "$without_libsensors" != "yes" ]
then
+echo -n "Checking for libsensors... "
echo "Checking for libsensors... " 1>& 5
cat << EOF > test.c
@@ -58,15 +59,51 @@ $CC test.o -o test -lsensors 2>& 5
if [ -x ./test ]
then
+ echo "Found"
echo 'Defining HAVE_LIBSENSORS' 1>& 5
echo '#define HAVE_LIBSENSORS 1' >> configure.h
else
+ echo "Not found"
echo "Not found, sensors will not have libsensors support..." 1>& 5
fi
fi
# end of libsensors check
+echo -n "Checking for getaddrinfo... "
+echo "Checking for getaddrinfo... " 1>& 5
+
+cat << EOF > test.c
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+int main()
+ {
+ struct addrinfo hints, *r;
+
+ getaddrinfo("", "", &hints, &r);
+
+ return 0;
+ }
+EOF
+
+$CC ${CFLAGS} -c test.c -o test.o 2>& 5
+$CC test.o -o test 2>& 5
+
+if [ -x ./test ]
+then
+ echo "Found"
+ echo 'Defining HAVE_GETADDRINFO' 1>& 5
+ echo '#define HAVE_GETADDRINFO 1' >> configure.h
+else
+ echo "Not found"
+ echo "Not found, some functionality will be disabled..." 1>& 5
+fi
+
+# end of getaddrinfo check
+
+
rm -f test test.o test.c
exit 0
diff --git a/server/gkrellmd-private.h b/server/gkrellmd-private.h
index efebadb..299b295 100644
--- a/server/gkrellmd-private.h
+++ b/server/gkrellmd-private.h
@@ -35,54 +35,17 @@
#include "../src/gkrellm-sysdeps.h"
-#if defined(WIN32)
-// Enable getaddrinfo on win32 if we target win xp or newer
-#if _WIN32_WINNT > 0x0500
-#define HAVE_GETADDRINFO 1
-#endif
-#endif
-
-#if defined(__linux__)
-#if defined(__GLIBC__) && ((__GLIBC__>2)||(__GLIBC__==2 && __GLIBC_MINOR__>=1))
-#define HAVE_GETADDRINFO 1
-#endif
-#endif
-
-#if defined(__DragonFly__)
-#define HAVE_GETADDRINFO 1
-#endif
-
-#if defined(__FreeBSD__)
-#include <sys/param.h>
-#if __FreeBSD_version >= 400000
-#define HAVE_GETADDRINFO 1
-#endif
-#endif
-
-#if defined(__OpenBSD__)
-#define HAVE_GETADDRINFO 1
-#endif
-
#if defined(__NetBSD__)
-#define HAVE_GETADDRINFO 1
#include <sys/param.h>
# if __NetBSD_Version__ <= 105010000
# define sa_family_t unsigned char
# endif
#endif
-#if defined(__solaris__)
-# include <netconfig.h>
-# if defined(NC_INET6)
-# define HAVE_GETADDRINFO 1
-# endif
-#endif
-
#if defined(__APPLE__)
# ifndef socklen_t
# define socklen_t int
# endif
-#define HAVE_GETADDRINFO 1
#endif
#ifndef NI_WITHSCOPEID
diff --git a/src/Makefile b/src/Makefile
index 3e67bbd..b1642d6 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -78,10 +78,6 @@ ifneq ($(PACKAGE),gkrellm)
FLAGS += -DPACKAGE=\"$(PACKAGE)\"
endif
-ifeq ($(HAVE_GETADDRINFO),1)
- FLAGS += -DHAVE_GETADDRINFO
-endif
-
OBJS = main.o alerts.o battery.o base64.o clock.o cpu.o disk.o fs.o \
hostname.o inet.o mail.o mem.o net.o proc.o sensors.o uptime.o \
@@ -117,13 +113,13 @@ endif
# Darwin target for systems that still have libkvm
darwin:
ifeq ($(HAVE_SSL),1)
- $(MAKE) STRIP= HAVE_GETADDRINFO=1 \
+ $(MAKE) STRIP= \
EXTRAOBJS= \
SYS_LIBS="-framework CoreFoundation -framework IOKit -lkvm" \
LINK_FLAGS="-Wl,-bind_at_load" \
gkrellm
else
- $(MAKE) STRIP= HAVE_GETADDRINFO=1 \
+ $(MAKE) STRIP= \
EXTRAOBJS= \
SYS_LIBS="-framework CoreFoundation -framework IOKit -lkvm -lmd5" \
LINK_FLAGS="-Wl,-bind_at_load" \
@@ -132,7 +128,7 @@ endif
# Mac OS X target with X11-based Gtk+
darwin9:
- $(MAKE) STRIP= HAVE_GETADDRINFO=1 \
+ $(MAKE) STRIP= \
EXTRAOBJS= \
SYS_LIBS="-framework CoreFoundation -framework IOKit" \
LINK_FLAGS="-Wl,-bind_at_load" \
@@ -140,7 +136,7 @@ darwin9:
# Mac OS X target with Quartz-based Gtk+ (experimental)
macosx:
- $(MAKE) STRIP= HAVE_GETADDRINFO=1 \
+ $(MAKE) STRIP= \
EXTRAOBJS="winops-gtk-mac.o" \
SYS_LIBS="-framework CoreFoundation -framework IOKit" \
LINK_FLAGS="-Wl,-bind_at_load" \
diff --git a/src/client.c b/src/client.c
index 0eb2924..be3eb64 100644
--- a/src/client.c
+++ b/src/client.c
@@ -54,39 +54,6 @@
-#if defined(__linux__)
-#if defined(__GLIBC__) && ((__GLIBC__>2)||(__GLIBC__==2 && __GLIBC_MINOR__>=1))
-#define HAVE_GETADDRINFO 1
-#endif
-#endif
-
-#if defined(__DragonFly__)
-#define HAVE_GETADDRINFO 1
-#endif
-
-#if defined(__FreeBSD__)
-#if __FreeBSD_version >= 400000
-#define HAVE_GETADDRINFO 1
-#endif
-#endif
-
-#if defined(__OpenBSD__)
-#define HAVE_GETADDRINFO 1
-#endif
-
-#if defined(__NetBSD__)
-#define HAVE_GETADDRINFO 1
-#endif
-
-#if defined(__solaris__)
-/* getaddrinfo is related to IPv6 stuff */
-# include <netconfig.h>
-# if defined(NC_INET6)
-# define HAVE_GETADDRINFO 1
-# endif
-#endif
-
-
typedef struct
{
gchar *key;
diff --git a/src/configure b/src/configure
index 9ff0ed2..4069ab5 100755
--- a/src/configure
+++ b/src/configure
@@ -234,6 +234,40 @@ fi
# end of libsensors check
+echo -n "Checking for getaddrinfo... "
+echo "Checking for getaddrinfo... " 1>& 5
+
+cat << EOF > test.c
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+int main()
+ {
+ struct addrinfo hints, *r;
+
+ getaddrinfo("", "", &hints, &r);
+
+ return 0;
+ }
+EOF
+
+$CC ${CFLAGS} -c test.c -o test.o 2>& 5
+$CC test.o -o test 2>& 5
+
+if [ -x ./test ]
+then
+ echo "Found"
+ echo 'Defining HAVE_GETADDRINFO' 1>& 5
+ echo '#define HAVE_GETADDRINFO 1' >> configure.h
+else
+ echo "Not found"
+ echo "Not found, some functionality will be disabled..." 1>& 5
+fi
+
+# end of getaddrinfo check
+
+
rm -f test test.exe test.o test.c
exit 0
--
2.4.10