aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kaiser <martin@kaiser.cx>2021-01-22 22:24:05 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2021-02-07 09:35:04 +0100
commitd40358a1c52079e238c48bf40bff504e55a9f758 (patch)
tree6fffd7dd3671fc564ebabbcef55a1e112ebe3889
parentcad3fc743aa7c7744e4fcf044371f0fda50fa51f (diff)
downloadbusybox-d40358a1c52079e238c48bf40bff504e55a9f758.tar.gz
Makefile.flags: fix the OS detection for libresolv
054493350 ("Do not add -lresolv on non-Linux systems") adds a condition to link with libresolv only on linux systems. The check requires that CONFIG_UNAME_OSNAME equals Linux. This works only if the uname applet is enabled. Otherwise, CONFIG_UNAME_OSNAME is empty, regardless of the platform. By default, CONFIG_UNAME_OSNAME is the output of uname -o. For most linux systems, uname -o returns "GNU/Linux" and the check fails. In this case, linking a static busybox fails because of missing symbols from libresolv. networking/lib.a(nslookup.o): In function `add_query': nslookup.c:789: undefined reference to `__res_mkquery' networking/lib.a(nslookup.o): In function `parse_reply': nslookup.c:355: undefined reference to `ns_initparse' nslookup.c:361: undefined reference to `ns_parserr' nslookup.c:404: undefined reference to `ns_name_uncompress' nslookup.c:418: undefined reference to `ns_get16' nslookup.c:419: undefined reference to `ns_name_uncompress' .. nslookup.c:456: undefined reference to `ns_get16' ... nslookup.c:469: undefined reference to `ns_name_uncompress' ... nslookup.c:489: undefined reference to `ns_get32' ... collect2: error: ld returned 1 exit status This patch uses the output of $CC -dumpmachine to detect the target platform for which we compile. Both gcc and clang support -dumpmachine. Like the original patch, we link against libresolv only if our target platform is linux-based. Fixes: 054493350 ("Do not add -lresolv on non-Linux systems") Signed-off-by: Martin Kaiser <martin@kaiser.cx> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r--Makefile.flags2
1 files changed, 1 insertions, 1 deletions
diff --git a/Makefile.flags b/Makefile.flags
index 5673bc48a..7a445c3b5 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -181,7 +181,7 @@ LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%
endif
ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y)
-ifeq ($(CONFIG_UNAME_OSNAME),Linux)
+ifneq (,$(findstring linux,$(shell $(CC) $(CFLAGS) -dumpmachine)))
LDLIBS += resolv
endif
endif