From 0bae3bc1813cc9acbde560729897948cd00883b0 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Tue, 25 Mar 2014 01:30:11 +0400 Subject: [PATCH] make: config -- Add testing if we have libbsd installed Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- Makefile.config | 9 +++++++-- include/string.h | 4 ++++ scripts/feature-tests.mak | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Makefile.config b/Makefile.config index 9d150a90f..ca46ca14f 100644 --- a/Makefile.config +++ b/Makefile.config @@ -3,6 +3,11 @@ include scripts/feature-tests.mak CONFIG := include/config.h +ifeq ($(call try-cc,$(LIBBSD_DEV_TEST),-lbsd),y) + LIBS += -lbsd + DEFINES += -DCONFIG_HAS_LIBBSD +endif + $(CONFIG): scripts/utilities.mak scripts/feature-tests.mak include/config-base.h $(E) " GEN " $@ $(Q) @echo '#ifndef __CR_CONFIG_H__' > $@ @@ -16,10 +21,10 @@ endif ifeq ($(call try-cc,$(PRLIMIT_TEST),),y) $(Q) @echo '#define CONFIG_HAS_PRLIMIT' >> $@ endif -ifeq ($(call try-cc,$(STRLCPY_TEST),),y) +ifeq ($(call try-cc,$(STRLCPY_TEST),$(LIBS)),y) $(Q) @echo '#define CONFIG_HAS_STRLCPY' >> $@ endif -ifeq ($(call try-cc,$(STRLCAT_TEST),),y) +ifeq ($(call try-cc,$(STRLCAT_TEST),$(LIBS)),y) $(Q) @echo '#define CONFIG_HAS_STRLCAT' >> $@ endif ifeq ($(call try-cc,$(PTRACE_PEEKSIGINFO_TEST),),y) diff --git a/include/string.h b/include/string.h index 8454b4dd6..b469bfe55 100644 --- a/include/string.h +++ b/include/string.h @@ -4,6 +4,10 @@ #include #include +#ifdef CONFIG_HAS_LIBBSD +# include +#endif + #include "config.h" #ifndef CONFIG_HAS_STRLCPY diff --git a/scripts/feature-tests.mak b/scripts/feature-tests.mak index 42db0cacf..097785704 100644 --- a/scripts/feature-tests.mak +++ b/scripts/feature-tests.mak @@ -30,10 +30,23 @@ int main(void) } endef +define LIBBSD_DEV_TEST +#include + +int main(void) +{ + return 0; +} +endef + define STRLCPY_TEST #include +#ifdef CONFIG_HAS_LIBBSD +# include +#endif + int main(void) { return strlcpy(NULL, NULL, 0); @@ -44,6 +57,10 @@ define STRLCAT_TEST #include +#ifdef CONFIG_HAS_LIBBSD +# include +#endif + int main(void) { return strlcat(NULL, NULL, 0);