diff mbox

[RFC] um: define and use HAVE_LIBPCAP/HAVE_LIBVDEPLUG

Message ID 1451701909-24430-1-git-send-email-vegard.nossum@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vegard Nossum Jan. 2, 2016, 2:31 a.m. UTC
If you don't have libpcap or libvdeplug installed, you will get build
failures when compiling certain files:

arch/um/drivers/vde_user.c:8:24: fatal error: libvdeplug.h: No such file or directory
 #include <libvdeplug.h>

arch/um/drivers/pcap_user.c:7:18: fatal error: pcap.h: No such file or directory
 #include <pcap.h>

This patch adds a basic pre-build check and defines the kconfig variables
HAVE_LIBPCAP and HAVE_LIBVDEPLUG depending on the result.

There is a basic disadvantage to this scheme, namely that the user may
never see the options that rely on these libraries if they are not
installed. As a trade-off, we add a brand new option, MISSING_LIBRARIES
(defaulting to 'y'), which allows those options to be visible (and
selectable) anyway.

[Note: I find this useful personally as I ran into the above build
 failures when playing around with UML -- so take this more as a
 suggestion on how things MAY be done better than a real patch.]

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
---
 arch/um/Kconfig.common | 18 ++++++++++++++++++
 arch/um/Kconfig.net    |  2 ++
 arch/um/Kconfig.um     | 13 +++++++++++++
 arch/um/Makefile       |  5 +++++
 4 files changed, 38 insertions(+)

Comments

Thomas Meyer Jan. 2, 2016, 10:33 a.m. UTC | #1
Hi Vegard,

I like this idea. 

With kind regards
Thomas

> Am 02.01.2016 um 03:31 schrieb Vegard Nossum <vegard.nossum@oracle.com>:
> 
> If you don't have libpcap or libvdeplug installed, you will get build
> failures when compiling certain files:
> 
> arch/um/drivers/vde_user.c:8:24: fatal error: libvdeplug.h: No such file or directory
> #include <libvdeplug.h>
> 
> arch/um/drivers/pcap_user.c:7:18: fatal error: pcap.h: No such file or directory
> #include <pcap.h>
> 
> This patch adds a basic pre-build check and defines the kconfig variables
> HAVE_LIBPCAP and HAVE_LIBVDEPLUG depending on the result.
> 
> There is a basic disadvantage to this scheme, namely that the user may
> never see the options that rely on these libraries if they are not
> installed. As a trade-off, we add a brand new option, MISSING_LIBRARIES
> (defaulting to 'y'), which allows those options to be visible (and
> selectable) anyway.
> 
> [Note: I find this useful personally as I ran into the above build
> failures when playing around with UML -- so take this more as a
> suggestion on how things MAY be done better than a real patch.]
> 
> Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
> ---
> arch/um/Kconfig.common | 18 ++++++++++++++++++
> arch/um/Kconfig.net    |  2 ++
> arch/um/Kconfig.um     | 13 +++++++++++++
> arch/um/Makefile       |  5 +++++
> 4 files changed, 38 insertions(+)
> 
> diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
> index d195a87..35ce3a1 100644
> --- a/arch/um/Kconfig.common
> +++ b/arch/um/Kconfig.common
> @@ -59,3 +59,21 @@ config HZ
> config SUBARCH
>    string
>    option env="SUBARCH"
> +
> +# Host libraries; these are defined by arch/um/Makefile
> +
> +config ENV_HAVE_LIBPCAP
> +    string
> +    option env="ENV_HAVE_LIBPCAP"
> +
> +config HAVE_LIBPCAP
> +    bool
> +    default y if ENV_HAVE_LIBPCAP="1"
> +
> +config ENV_HAVE_LIBVDEPLUG
> +    string
> +    option env="ENV_HAVE_LIBVDEPLUG"
> +
> +config HAVE_LIBVDEPLUG
> +    bool
> +    default y if ENV_HAVE_LIBVDEPLUG="1"
> diff --git a/arch/um/Kconfig.net b/arch/um/Kconfig.net
> index 820a56f..dfa7849 100644
> --- a/arch/um/Kconfig.net
> +++ b/arch/um/Kconfig.net
> @@ -111,6 +111,7 @@ config UML_NET_DAEMON
> config UML_NET_VDE
>    bool "VDE transport"
>    depends on UML_NET
> +    depends on HAVE_LIBVDEPLUG || MISSING_LIBRARIES
>    help
>    This User-Mode Linux network transport allows one or more running
>    UMLs on a single host to communicate with each other and also
> @@ -158,6 +159,7 @@ config UML_NET_MCAST
> config UML_NET_PCAP
>    bool "pcap transport"
>    depends on UML_NET
> +    depends on HAVE_LIBPCAP || MISSING_LIBRARIES
>    help
>    The pcap transport makes a pcap packet stream on the host look
>    like an ethernet device inside UML.  This is useful for making
> diff --git a/arch/um/Kconfig.um b/arch/um/Kconfig.um
> index 28a9885..15944d9 100644
> --- a/arch/um/Kconfig.um
> +++ b/arch/um/Kconfig.um
> @@ -9,6 +9,19 @@ config STATIC_LINK
>      Additionally, this option enables using higher memory spaces (up to
>      2.75G) for UML.
> 
> +config MISSING_LIBRARIES
> +    bool "Prompt for options which require missing host libraries"
> +    default y
> +    help
> +      Certain options rely on host libraries to compile.
> +
> +      If you say N here, then these options will only be available if
> +      the libraries they require have been detected to be present.
> +
> +      If you say Y, then the options will be available anyway, but
> +      beware that attempting to build the kernel will most likely
> +      result in an error.
> +
> source "mm/Kconfig"
> 
> config LD_SCRIPT_STATIC
> diff --git a/arch/um/Makefile b/arch/um/Makefile
> index e3abe6f..a8320e6 100644
> --- a/arch/um/Makefile
> +++ b/arch/um/Makefile
> @@ -166,3 +166,8 @@ include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s
>    $(call filechk,gen-asm-offsets)
> 
> export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH
> +
> +# Host libraries
> +has_header = $(shell echo | $(CC) -include $(1) -xc -c - >/dev/null 2>&1 && echo 1)
> +export ENV_HAVE_LIBPCAP := $(call has_header,pcap.h)
> +export ENV_HAVE_LIBVDEPLUG := $(call has_header,libvdeplug.h)
> -- 
> 1.9.1
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> User-mode-linux-devel mailing list
> User-mode-linux-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Weinberger Jan. 2, 2016, 11:43 a.m. UTC | #2
Am 02.01.2016 um 03:31 schrieb Vegard Nossum:
> If you don't have libpcap or libvdeplug installed, you will get build
> failures when compiling certain files:
> 
> arch/um/drivers/vde_user.c:8:24: fatal error: libvdeplug.h: No such file or directory
>  #include <libvdeplug.h>
> 
> arch/um/drivers/pcap_user.c:7:18: fatal error: pcap.h: No such file or directory
>  #include <pcap.h>
> 
> This patch adds a basic pre-build check and defines the kconfig variables
> HAVE_LIBPCAP and HAVE_LIBVDEPLUG depending on the result.
> 
> There is a basic disadvantage to this scheme, namely that the user may
> never see the options that rely on these libraries if they are not
> installed. As a trade-off, we add a brand new option, MISSING_LIBRARIES
> (defaulting to 'y'), which allows those options to be visible (and
> selectable) anyway.
> 
> [Note: I find this useful personally as I ran into the above build
>  failures when playing around with UML -- so take this more as a
>  suggestion on how things MAY be done better than a real patch.]

Why can't you build with UML_NET_VDE=n and UML_NET_PCAP=n
or install the missing libs?
To me the patch reads like a lazy approach to make allyesconfig somehow build. :-)

If one selects VDE or PCAP (either manually or via allyesconfig) and the libs are
missing the build has to fail. Everything else will introduce nasty side effects
like having different builds with the same config and packagers will cry.

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vegard Nossum Jan. 2, 2016, 11:59 a.m. UTC | #3
On 01/02/2016 12:43 PM, Richard Weinberger wrote:
> Am 02.01.2016 um 03:31 schrieb Vegard Nossum:
>> If you don't have libpcap or libvdeplug installed, you will get build
>> failures when compiling certain files:
>>
>> arch/um/drivers/vde_user.c:8:24: fatal error: libvdeplug.h: No such file or directory
>>   #include <libvdeplug.h>
>>
>> arch/um/drivers/pcap_user.c:7:18: fatal error: pcap.h: No such file or directory
>>   #include <pcap.h>
>>
>> This patch adds a basic pre-build check and defines the kconfig variables
>> HAVE_LIBPCAP and HAVE_LIBVDEPLUG depending on the result.
>>
>> There is a basic disadvantage to this scheme, namely that the user may
>> never see the options that rely on these libraries if they are not
>> installed. As a trade-off, we add a brand new option, MISSING_LIBRARIES
>> (defaulting to 'y'), which allows those options to be visible (and
>> selectable) anyway.
>>
>> [Note: I find this useful personally as I ran into the above build
>>   failures when playing around with UML -- so take this more as a
>>   suggestion on how things MAY be done better than a real patch.]
>
> Why can't you build with UML_NET_VDE=n and UML_NET_PCAP=n
> or install the missing libs?
> To me the patch reads like a lazy approach to make allyesconfig somehow build. :-)
>
> If one selects VDE or PCAP (either manually or via allyesconfig) and the libs are
> missing the build has to fail. Everything else will introduce nasty side effects
> like having different builds with the same config and packagers will cry.

Yeah, fair enough.


Vegard
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index d195a87..35ce3a1 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -59,3 +59,21 @@  config HZ
 config SUBARCH
 	string
 	option env="SUBARCH"
+
+# Host libraries; these are defined by arch/um/Makefile
+
+config ENV_HAVE_LIBPCAP
+	string
+	option env="ENV_HAVE_LIBPCAP"
+
+config HAVE_LIBPCAP
+	bool
+	default y if ENV_HAVE_LIBPCAP="1"
+
+config ENV_HAVE_LIBVDEPLUG
+	string
+	option env="ENV_HAVE_LIBVDEPLUG"
+
+config HAVE_LIBVDEPLUG
+	bool
+	default y if ENV_HAVE_LIBVDEPLUG="1"
diff --git a/arch/um/Kconfig.net b/arch/um/Kconfig.net
index 820a56f..dfa7849 100644
--- a/arch/um/Kconfig.net
+++ b/arch/um/Kconfig.net
@@ -111,6 +111,7 @@  config UML_NET_DAEMON
 config UML_NET_VDE
 	bool "VDE transport"
 	depends on UML_NET
+	depends on HAVE_LIBVDEPLUG || MISSING_LIBRARIES
 	help
 	This User-Mode Linux network transport allows one or more running
 	UMLs on a single host to communicate with each other and also
@@ -158,6 +159,7 @@  config UML_NET_MCAST
 config UML_NET_PCAP
 	bool "pcap transport"
 	depends on UML_NET
+	depends on HAVE_LIBPCAP || MISSING_LIBRARIES
 	help
 	The pcap transport makes a pcap packet stream on the host look
 	like an ethernet device inside UML.  This is useful for making
diff --git a/arch/um/Kconfig.um b/arch/um/Kconfig.um
index 28a9885..15944d9 100644
--- a/arch/um/Kconfig.um
+++ b/arch/um/Kconfig.um
@@ -9,6 +9,19 @@  config STATIC_LINK
 	  Additionally, this option enables using higher memory spaces (up to
 	  2.75G) for UML.
 
+config MISSING_LIBRARIES
+	bool "Prompt for options which require missing host libraries"
+	default y
+	help
+	  Certain options rely on host libraries to compile.
+
+	  If you say N here, then these options will only be available if
+	  the libraries they require have been detected to be present.
+
+	  If you say Y, then the options will be available anyway, but
+	  beware that attempting to build the kernel will most likely
+	  result in an error.
+
 source "mm/Kconfig"
 
 config LD_SCRIPT_STATIC
diff --git a/arch/um/Makefile b/arch/um/Makefile
index e3abe6f..a8320e6 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -166,3 +166,8 @@  include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s
 	$(call filechk,gen-asm-offsets)
 
 export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH
+
+# Host libraries
+has_header = $(shell echo | $(CC) -include $(1) -xc -c - >/dev/null 2>&1 && echo 1)
+export ENV_HAVE_LIBPCAP := $(call has_header,pcap.h)
+export ENV_HAVE_LIBVDEPLUG := $(call has_header,libvdeplug.h)