erlang: fix musl compatibility
authorNicolas Thill <nico@openwrt.org>
Mon, 22 Jun 2015 23:06:36 +0000 (01:06 +0200)
committerNicolas Thill <nico@openwrt.org>
Mon, 22 Jun 2015 23:06:36 +0000 (01:06 +0200)
gethostbyname_r is available when _GNU_SOURCE is defined, add a patch to check for it instead of __GLIBC__, build with -D_GNU_SOURCE, bump release number

Signed-off-by: Nicolas Thill <nico@openwrt.org>
lang/erlang/Makefile
lang/erlang/patches/102-musl_compat.patch [new file with mode: 0644]

index 2423f374dd4bc1439c0b0e05e9f630ec5bf5077a..47c8b1198bab75fff74bd791bda7802a9b8c6873 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=erlang
 PKG_VERSION:=17.5
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=otp_src_$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:= http://www.erlang.org/download/ \
@@ -232,6 +232,8 @@ HOST_CONFIGURE_ARGS += \
        --disable-smp-support \
        --without-javac
 
+HOST_CFLAGS += -D_GNU_SOURCE
+
 define Host/Compile
        $(MAKE) -C $(HOST_BUILD_DIR) all
 endef
@@ -257,6 +259,7 @@ CONFIGURE_VARS += \
        erl_xcomp_getaddrinfo=no \
        erl_xcomp_sysroot="$(STAGING_DIR)"
 
+EXTRA_CFLAGS+=-D_GNU_SOURCE
 EXTRA_LDFLAGS+=-lz
 
 define Build/Compile
diff --git a/lang/erlang/patches/102-musl_compat.patch b/lang/erlang/patches/102-musl_compat.patch
new file mode 100644 (file)
index 0000000..d23900e
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/lib/erl_interface/src/connect/ei_resolve.c
++++ b/lib/erl_interface/src/connect/ei_resolve.c
+@@ -642,7 +642,7 @@ struct hostent *ei_gethostbyname_r(const
+ #ifndef HAVE_GETHOSTBYNAME_R
+   return my_gethostbyname_r(name,hostp,buffer,buflen,h_errnop);
+ #else
+-#if (defined(__GLIBC__) || (__FreeBSD_version >= 602000) || defined(__DragonFly__) || defined(__ANDROID__))
++#if (defined(_GNU_SOURCE) || (__FreeBSD_version >= 602000) || defined(__DragonFly__) || defined(__ANDROID__))
+   struct hostent *result;
+   gethostbyname_r(name, hostp, buffer, buflen, &result, h_errnop);