From 89c8592f93cfe11f2127af0213d10bbe5b4b7b88 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 13 Dec 2020 22:05:10 +0100 Subject: [PATCH] libnm: allow opt-out of including system headers in In public libnm headers we include some libc/linux headers, although libnm doesn't strictly need them. The headers conflict with some network headers provided by libc and they need to be included in the right order. As drags in some linux headers, this makes it unnecessarily complicated. It also feels ugly to include headers we don't need, only for the sake of convenience. Allow to opt out. Also, for internal build, don't do this. When building NetworkManager we need control about the headers and their order of inclusion. --- libnm-core/nm-setting-vlan.h | 1 - libnm-core/nm-utils.h | 6 ------ libnm/NetworkManager.h | 11 +++++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libnm-core/nm-setting-vlan.h b/libnm-core/nm-setting-vlan.h index 9d2cf3a0b..28cdfd6dc 100644 --- a/libnm-core/nm-setting-vlan.h +++ b/libnm-core/nm-setting-vlan.h @@ -11,7 +11,6 @@ #endif #include "nm-setting.h" -#include G_BEGIN_DECLS diff --git a/libnm-core/nm-utils.h b/libnm-core/nm-utils.h index 052660d70..393f0f3a5 100644 --- a/libnm-core/nm-utils.h +++ b/libnm-core/nm-utils.h @@ -12,12 +12,6 @@ #include -#include - -/* For ETH_ALEN and INFINIBAND_ALEN */ -#include -#include - #include "nm-core-enum-types.h" #include "nm-setting-sriov.h" #include "nm-setting-tc-config.h" diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index ba83647af..c0ffc0441 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -115,6 +115,17 @@ #include "nm-autoptr.h" +#if !defined(NETWORKMANAGER_COMPILATION) \ + && (!defined(NM_NO_INCLUDE_EXTRA_HEADERS) || !NM_NO_INCLUDE_EXTRA_HEADERS) + /* historically, NetworkManager.h drags in the following system headers. + * These are not strictly necessary and the user may wish to opt out from + * including them. */ + #include + #include + #include + #include +#endif + #undef __NETWORKMANAGER_H_INSIDE__ #endif /* __NETWORKMANAGER_H__ */