summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-01-02 13:37:06 +0100
committerThomas Haller <thaller@redhat.com>2018-01-08 12:38:53 +0100
commit22ef6a507a308f2fe495b60bef78ac2ca00fb6d2 (patch)
tree3bd2f287df3db9c5254f9b27607b4f0735b938d7
parent31b6abd4b533c56c91c616498ee2080d56d0fd48 (diff)
downloadNetworkManager-22ef6a507a308f2fe495b60bef78ac2ca00fb6d2.tar.gz
build: refine the NETWORKMANAGER_COMPILATION define
Note that: - we compile some source files multiple times. Most notably those under "shared/". - we include a default header "shared/nm-default.h" in every source file. This header is supposed to setup a common environment by defining and including parts that are commonly used. As we always include the same header, the header must behave differently depending one whether the compilation is for libnm-core, NetworkManager or libnm-glib. E.g. it must include <glib/gi18n.h> or <glib/gi18n-lib.h> depending on whether we compile a library or an application. For that, the source files need the NETWORKMANAGER_COMPILATION #define to behave accordingly. Extend the define to be composed of flags. These flags are all named NM_NETWORKMANAGER_COMPILATION_WITH_*, they indicate which part of the build are available. E.g. when building libnm-core.la itself, then WITH_LIBNM_CORE, WITH_LIBNM_CORE_INTERNAL, and WITH_LIBNM_CORE_PRIVATE are available. When building NetworkManager, WITH_LIBNM_CORE_PRIVATE is not available but the internal parts are still accessible. When building nmcli, only WITH_LIBNM_CORE (the public part) is available. This granularily controls the build.
-rw-r--r--Makefile.am110
-rw-r--r--clients/cli/meson.build4
-rw-r--r--clients/common/meson.build7
-rw-r--r--clients/common/tests/meson.build4
-rw-r--r--clients/meson.build8
-rw-r--r--clients/tui/meson.build10
-rw-r--r--dispatcher/meson.build4
-rw-r--r--dispatcher/tests/meson.build7
-rw-r--r--dispatcher/tests/test-dispatcher-envp.c1
-rw-r--r--libnm-core/crypto.h4
-rw-r--r--libnm-core/meson.build2
-rw-r--r--libnm-core/nm-connection-private.h4
-rw-r--r--libnm-core/nm-core-internal.h3
-rw-r--r--libnm-core/nm-core-types-internal.h4
-rw-r--r--libnm-core/nm-keyfile-internal.h4
-rw-r--r--libnm-core/nm-keyfile-utils.h4
-rw-r--r--libnm-core/nm-property-compare.h4
-rw-r--r--libnm-core/nm-setting-private.h4
-rw-r--r--libnm-core/nm-utils-private.h4
-rw-r--r--libnm-core/tests/meson.build6
-rw-r--r--libnm-glib/meson.build29
-rw-r--r--libnm-glib/tests/meson.build10
-rw-r--r--libnm-util/meson.build9
-rw-r--r--libnm-util/tests/meson.build5
-rw-r--r--libnm/meson.build2
-rw-r--r--libnm/nm-dbus-helpers.h4
-rw-r--r--libnm/nm-dhcp4-config.h11
-rw-r--r--libnm/nm-dhcp6-config.h11
-rw-r--r--libnm/nm-dns-manager.h11
-rw-r--r--libnm/nm-ip4-config.h11
-rw-r--r--libnm/nm-ip6-config.h11
-rw-r--r--libnm/nm-libnm-utils.h4
-rw-r--r--libnm/nm-manager.h14
-rw-r--r--libnm/nm-object-private.h4
-rw-r--r--libnm/nm-remote-connection-private.h4
-rw-r--r--libnm/nm-remote-settings.h12
-rw-r--r--libnm/tests/meson.build6
-rw-r--r--shared/nm-default.h133
-rw-r--r--shared/nm-test-libnm-utils.h28
-rw-r--r--shared/nm-test-utils-impl.c28
-rw-r--r--shared/nm-utils/nm-test-utils.h4
-rw-r--r--src/dhcp/meson.build3
-rw-r--r--src/dnsmasq/tests/meson.build6
-rw-r--r--src/meson.build23
-rw-r--r--src/nm-types.h4
-rw-r--r--src/ppp/meson.build15
-rw-r--r--src/ppp/nm-pppd-plugin.c2
-rw-r--r--src/systemd/sd-adapt/nm-sd-adapt.h4
-rw-r--r--src/tests/meson.build5
49 files changed, 380 insertions, 231 deletions
diff --git a/Makefile.am b/Makefile.am
index 8584866405..913c22c4e3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -579,12 +579,13 @@ $(src_devices_wwan_libnm_device_plugin_wwan_la_OBJECTS): $(li
libnm_core_libnm_core_la_CPPFLAGS = \
$(dflt_cppflags_libnm_core) \
-DG_LOG_DOMAIN=\""libnm"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE \
-DLOCALEDIR=\"$(datadir)/locale\" \
-DNMCONFDIR=\"$(nmconfdir)\" \
-DNMLIBDIR=\"$(nmlibdir)\" \
-DNMPLUGINDIR=\"$(pkglibdir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB
+ $(NULL)
if WITH_JSON_VALIDATION
libnm_core_libnm_core_la_CPPFLAGS += $(JANSSON_CFLAGS)
@@ -662,6 +663,8 @@ libnm_core_tests_cppflags = \
$(dflt_cppflags_libnm_core) \
-I$(srcdir)/libnm-core/tests \
-I$(builddir)/libnm-core/tests \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE \
-DTEST_CERT_DIR=\"$(abs_srcdir)/libnm-core/tests/certs\"
libnm_core_tests_test_compare_CPPFLAGS = $(libnm_core_tests_cppflags)
@@ -842,7 +845,7 @@ libnm_lib_cppflags = \
-I$(srcdir)/libnm \
-I$(builddir)/libnm \
-DG_LOG_DOMAIN=\""libnm"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM \
-DNMRUNDIR=\"$(nmrundir)\"
libnminclude_HEADERS += \
@@ -1047,7 +1050,8 @@ libnm_tests_cppflags = \
$(dflt_cppflags_libnm_core) \
-I$(srcdir)/libnm \
-I$(builddir)/libnm \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM \
-DTEST_NM_SERVICE=\"$(abs_srcdir)/tools/test-networkmanager-service.py\"
libnm_tests_ldadd = \
@@ -1107,7 +1111,9 @@ libnm_tests_libnm_vpn_plugin_utils_test_la_CFLAGS = \
-I$(builddir)/libnm-core \
-I$(srcdir)/libnm \
-I$(builddir)/libnm \
- $(GLIB_CFLAGS)
+ $(GLIB_CFLAGS) \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT
libnm_tests_libnm_vpn_plugin_utils_test_la_LIBADD = \
$(GLIB_LIBS)
@@ -1122,8 +1128,7 @@ src_cppflags = \
-I$(builddir)/src \
\
-DPREFIX=\"$(prefix)\" \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
\
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\" \
@@ -1610,7 +1615,8 @@ $(src_libNetworkManager_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
check_ltlibraries += src/libNetworkManagerTest.la
src_tests_cppflags = \
- $(src_cppflags)
+ $(src_cppflags) \
+ -DNETWORKMANAGER_COMPILATION_TEST
if REQUIRE_ROOT_TESTS
src_tests_cppflags += -DREQUIRE_ROOT_TESTS=1
@@ -1699,9 +1705,8 @@ src_dhcp_nm_dhcp_helper_CPPFLAGS = \
$(GLIB_CFLAGS) \
-I$(srcdir)/shared \
-I$(builddir)/shared \
- -I$(srcdir)/libnm-core \
- -I$(builddir)/libnm-core \
-DG_LOG_DOMAIN=\""nm-dhcp-helper"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_GLIB \
-DNMRUNDIR=\"$(nmrundir)\"
src_dhcp_nm_dhcp_helper_SOURCES = \
@@ -1760,10 +1765,8 @@ src_ppp_nm_pppd_plugin_la_CPPFLAGS = \
-I$(srcdir)/shared \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
- -I$(srcdir)/src \
- -I$(builddir)/libnm-core \
-DG_LOG_DOMAIN=\""nm-pppd-plugin"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_GLIB \
$(GLIB_CFLAGS)
src_ppp_nm_pppd_plugin_la_SOURCES = \
@@ -1798,8 +1801,7 @@ src_ppp_libnm_ppp_plugin_la_CPPFLAGS = \
-I$(builddir)/libnm-core \
-I$(srcdir)/libnm-core \
-DPPPD_PLUGIN_DIR=\"$(PPPD_PLUGIN_DIR)\" \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(GLIB_CFLAGS)
src_ppp_libnm_ppp_plugin_la_LDFLAGS = \
@@ -1890,9 +1892,8 @@ src_settings_plugins_ibft_cppflags = \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
$(GLIB_CFLAGS) \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DSBINDIR=\"$(sbindir)\"
@@ -1931,8 +1932,8 @@ src_settings_plugins_ibft_tests_test_ibft_CPPFLAGS = \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
-I$(srcdir)/src \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
-DTEST_IBFT_DIR=\"$(abs_srcdir)/src/settings/plugins/ibft/tests\" \
-DTEST_SCRATCH_DIR=\"$(abs_builddir)/src/settings/plugins/ibft/tests\"
@@ -1983,10 +1984,9 @@ src_settings_plugins_ifcfg_rh_cppflags = \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
$(GLIB_CFLAGS) \
$(NSS_CFLAGS) \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DSBINDIR=\"$(sbindir)\"
@@ -2320,8 +2320,7 @@ src_settings_plugins_ifupdown_cppflags = \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(GLIB_CFLAGS) \
$(LIBUDEV_CFLAGS) \
-DSYSCONFDIR=\"$(sysconfdir)\"
@@ -2371,8 +2370,8 @@ src_settings_plugins_ifupdown_tests_test_ifupdown_CPPFLAGS = \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
-I$(srcdir)/src \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(GLIB_CFLAGS) \
-DTEST_ENI_DIR=\"$(abs_srcdir)/src/settings/plugins/ifupdown/tests\"
@@ -2431,8 +2430,7 @@ src_devices_adsl_libnm_device_plugin_adsl_la_CPPFLAGS = \
-I$(builddir)/shared \
-I$(builddir)/libnm-core \
-I$(srcdir)/libnm-core \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(GLIB_CFLAGS) \
$(LIBUDEV_CFLAGS)
@@ -2463,8 +2461,7 @@ src_devices_wwan_cppflags = \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(GLIB_CFLAGS) \
$(LIBSYSTEMD_CFLAGS) \
$(MM_GLIB_CFLAGS)
@@ -2564,8 +2561,7 @@ src_devices_bluetooth_libnm_device_plugin_bluetooth_la_CPPFLAGS = \
-I$(builddir)/shared \
-I$(builddir)/libnm-core \
-I$(srcdir)/libnm-core \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(GLIB_CFLAGS)
src_devices_bluetooth_libnm_device_plugin_bluetooth_la_LDFLAGS = \
@@ -2629,8 +2625,7 @@ src_devices_wifi_libnm_device_plugin_wifi_la_CPPFLAGS = \
-I$(builddir)/shared \
-I$(builddir)/libnm-core \
-I$(srcdir)/libnm-core \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(GLIB_CFLAGS)
src_devices_wifi_libnm_device_plugin_wifi_la_LDFLAGS = \
@@ -2663,8 +2658,8 @@ src_devices_wifi_tests_test_general_CPPFLAGS = \
-I$(builddir)/libnm-core \
-I$(srcdir)/src \
-I$(builddir)/src \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(GLIB_CFLAGS)
src_devices_wifi_tests_test_general_LDADD = src/libNetworkManagerTest.la
@@ -2693,8 +2688,7 @@ src_devices_team_libnm_device_plugin_team_la_CPPFLAGS = \
-I$(builddir)/shared \
-I$(builddir)/libnm-core \
-I$(srcdir)/libnm-core \
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
$(LIBTEAMDCTL_CFLAGS) \
$(JANSSON_CFLAGS) \
$(GLIB_CFLAGS)
@@ -2752,8 +2746,7 @@ src_devices_ovs_libnm_device_plugin_ovs_la_CPPFLAGS = \
-I$(builddir)/libnm-core \
-I$(srcdir)/libnm-core \
\
- -DG_LOG_DOMAIN=\""NetworkManager"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \
-DRUNSTATEDIR=\"$(runstatedir)\" \
\
$(JANSSON_CFLAGS) \
@@ -3045,7 +3038,9 @@ $(src_tests_test_general_with_expect_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
$(src_tests_test_wired_defname_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
$(src_tests_test_utils_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
-src_tests_test_systemd_CPPFLAGS = $(src_libsystemd_nm_la_cppflags)
+src_tests_test_systemd_CPPFLAGS = \
+ $(src_libsystemd_nm_la_cppflags) \
+ -DNETWORKMANAGER_COMPILATION_TEST
src_tests_test_systemd_SOURCES = \
shared/nm-utils/siphash24.c \
src/tests/test-systemd.c
@@ -3072,9 +3067,13 @@ dispatcher_cppflags = \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
+ -I$(srcdir)/libnm \
+ -I$(builddir)/libnm \
-I$(srcdir)/dispatcher \
-I$(builddir)/dispatcher \
$(GLIB_CFLAGS) \
+ -DG_LOG_DOMAIN=\""nm-dispatcher"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \
-DNMCONFDIR=\"$(nmconfdir)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLIBEXECDIR=\"$(libexecdir)\"
@@ -3166,9 +3165,13 @@ dispatcher_tests_test_dispatcher_envp_CPPFLAGS = \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
+ -I$(srcdir)/libnm \
+ -I$(builddir)/libnm \
-I$(srcdir)/dispatcher \
-I$(builddir)/dispatcher \
-DSRCDIR=\"$(abs_srcdir)/dispatcher/tests\" \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \
$(GLIB_CFLAGS)
dispatcher_tests_test_dispatcher_envp_LDADD = \
@@ -3202,6 +3205,7 @@ clients_nm_online_CPPFLAGS = \
-I$(builddir)/libnm \
$(GLIB_CFLAGS) \
-DG_LOG_DOMAIN=\""nm-online"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \
-DNMLOCALEDIR=\"$(datadir)/locale\"
clients_nm_online_LDFLAGS = \
@@ -3227,7 +3231,8 @@ clients_cppflags = \
-I$(srcdir)/clients/common \
-I$(builddir)/clients/common \
$(GLIB_CFLAGS) \
- -DNMLOCALEDIR=\"$(datadir)/locale\"
+ -DNMLOCALEDIR=\"$(datadir)/locale\" \
+ $(NULL)
check_ltlibraries += clients/common/libnmc-base.la
@@ -3251,7 +3256,8 @@ clients_common_libnmc_base_la_SOURCES = \
clients_common_libnmc_base_la_CPPFLAGS = \
$(clients_cppflags) \
- -DG_LOG_DOMAIN=\""libnmc"\"
+ -DG_LOG_DOMAIN=\""libnmc"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT
clients_common_libnmc_base_la_LIBADD = \
libnm/libnm.la \
@@ -3301,7 +3307,8 @@ clients_common_libnmc_la_SOURCES = \
clients_common_libnmc_la_CPPFLAGS = \
$(clients_cppflags) \
- -DG_LOG_DOMAIN=\""libnmc"\"
+ -DG_LOG_DOMAIN=\""libnmc"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT
clients_common_libnmc_la_LIBADD = \
libnm/libnm.la \
@@ -3323,7 +3330,8 @@ endif
clients_common_tests_test_general_CPPFLAGS = \
-I$(srcdir)/clients/common/tests \
$(clients_cppflags) \
- -DG_LOG_DOMAIN=\""libnmc"\"
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT
clients_common_tests_test_general_LDADD = \
libnm/libnm.la \
@@ -3366,6 +3374,7 @@ clients_cli_nmcli_CPPFLAGS = \
-I$(srcdir)/clients/cli \
$(clients_cppflags) \
-DG_LOG_DOMAIN=\""nmcli"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \
-DNMCLI_LOCALEDIR=\"$(datadir)/locale\"
clients_cli_nmcli_LDADD = \
@@ -3463,7 +3472,10 @@ clients_tui_newt_libnmt_newt_a_CPPFLAGS = \
-I$(builddir)/shared \
-I$(srcdir)/libnm-core \
-I$(builddir)/libnm-core \
+ -I$(srcdir)/libnm \
+ -I$(builddir)/libnm \
-DG_LOG_DOMAIN=\""nmtui"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \
$(GLIB_CFLAGS) \
$(NEWT_CFLAGS) \
$(NULL)
@@ -3560,6 +3572,7 @@ clients_tui_nmtui_CPPFLAGS = \
$(clients_cppflags) \
$(NEWT_CFLAGS) \
-DG_LOG_DOMAIN=\""nmtui"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \
-DLOCALEDIR=\""$(localedir)"\"
clients_tui_nmtui_LDFLAGS = \
@@ -3686,8 +3699,8 @@ libnm_util_cppflags = \
-I$(srcdir)/shared \
-I$(builddir)/shared \
-DG_LOG_DOMAIN=\""libnm-util"\" \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL \
-DLOCALEDIR=\"$(datadir)/locale\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
$(UUID_CFLAGS)
@@ -3897,7 +3910,9 @@ libnm_util_tests_cppflags = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
-DBUILD_DIR=\"$(abs_builddir)/libnm-util/tests\" \
- -DTEST_CERT_DIR=\"$(abs_srcdir)/libnm-core/tests/certs\"
+ -DTEST_CERT_DIR=\"$(abs_srcdir)/libnm-core/tests/certs\" \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL
libnm_util_tests_ldadd = \
libnm-util/libnm-util.la \
@@ -3961,7 +3976,7 @@ libnm_glib_cppflags = \
-I$(srcdir)/libnm-glib \
-I$(builddir)/libnm-glib \
-DG_LOG_DOMAIN=\""libnm-glib"\" \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB \
$(DBUS_CFLAGS) \
$(GLIB_CFLAGS)
@@ -4232,7 +4247,8 @@ libnm_glib_tests_cppflags = \
-I$(srcdir)/libnm-util \
-I$(builddir)/libnm-util \
-I$(srcdir)/libnm-glib \
- -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \
+ -DNETWORKMANAGER_COMPILATION_TEST \
+ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB \
-DTEST_NM_SERVICE=\"$(abs_srcdir)/tools/test-networkmanager-service.py\" \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS)
diff --git a/clients/cli/meson.build b/clients/cli/meson.build
index bfe7de56c7..3eaf04b8b0 100644
--- a/clients/cli/meson.build
+++ b/clients/cli/meson.build
@@ -30,9 +30,9 @@ deps = [
readline_dep
]
-cflags = [
+cflags = clients_cflags + [
'-DG_LOG_DOMAIN="nmcli"',
- '-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir)
+ '-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir),
]
ldflags = []
diff --git a/clients/common/meson.build b/clients/common/meson.build
index 861a4442f8..44ddfaf9c9 100644
--- a/clients/common/meson.build
+++ b/clients/common/meson.build
@@ -13,9 +13,8 @@ deps = [
libnm_dep
]
-cflags = [
+cflags = clients_cflags + [
'-DG_LOG_DOMAIN="libnmc"',
- '-DNMLOCALEDIR="@0@"'.format(nm_localedir)
]
sources = shared_utils + files(
@@ -29,7 +28,7 @@ libnmc_base = static_library(
sources: sources + [libnm_core_enum[1]],
include_directories: incs,
dependencies: deps,
- c_args: common_cflags
+ c_args: cflags,
)
libnmc_base_dep = declare_dependency(
@@ -75,7 +74,7 @@ libnmc = static_library(
sources: sources + [libnm_core_enum[1]],
include_directories: incs,
dependencies: deps,
- c_args: common_cflags,
+ c_args: cflags,
link_with: libnmc_base,
link_depends: settings_docs_source
)
diff --git a/clients/common/tests/meson.build b/clients/common/tests/meson.build
index 84777011b1..27bf8d6def 100644
--- a/clients/common/tests/meson.build
+++ b/clients/common/tests/meson.build
@@ -10,7 +10,9 @@ exe = executable(
test_unit + '.c',
include_directories: incs,
dependencies: deps,
- c_args: cflags
+ c_args: clients_cflags + [
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ ],
)
test(test_unit, exe)
diff --git a/clients/meson.build b/clients/meson.build
index 1e197d3762..c5c8fd99f7 100644
--- a/clients/meson.build
+++ b/clients/meson.build
@@ -11,9 +11,13 @@ deps = [
libnm_dep
]
-cflags = [
+clients_cflags = [
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT',
+ '-DNMLOCALEDIR="@0@"'.format(nm_localedir),
+]
+
+cflags = clients_cflags + [
'-DG_LOG_DOMAIN="@0@"'.format(name),
- '-DNMLOCALEDIR="@0@"'.format(nm_localedir)
]
ldflags = []
diff --git a/clients/tui/meson.build b/clients/tui/meson.build
index 2bff05359a..1b0702ad81 100644
--- a/clients/tui/meson.build
+++ b/clients/tui/meson.build
@@ -1,7 +1,8 @@
incs = [
top_inc,
shared_inc,
- libnm_core_inc
+ libnm_core_inc,
+ libnm_inc,
]
deps = [
@@ -9,7 +10,10 @@ deps = [
newt_dep
]
-cflags = ['-DG_LOG_DOMAIN="nmtui"']
+cflags = clients_cflags + [
+ '-DG_LOG_DOMAIN="nmtui"',
+ '-DLOCALEDIR="@0@"'.format(nm_localedir),
+]
subdir('newt')
@@ -62,8 +66,6 @@ deps += [
libnmt_newt_dep
]
-cflags += '-DLOCALEDIR="@0@"'.format(nm_localedir)
-
ldflags = []
if have_version_script
ldflags += '-Wl,--version-script,@0@'.format(linker_script_binary)
diff --git a/dispatcher/meson.build b/dispatcher/meson.build
index 20e64e628f..03e8d4e92f 100644
--- a/dispatcher/meson.build
+++ b/dispatcher/meson.build
@@ -39,7 +39,9 @@ deps = [
cflags = [
'-DLIBEXECDIR="@0@"'.format(nm_libexecdir),
'-DSYSCONFDIR="@0@"'.format(nm_sysconfdir),
- '-DNMCONFDIR="@0@"'.format(nm_pkgconfdir)
+ '-DNMCONFDIR="@0@"'.format(nm_pkgconfdir),
+ '-DG_LOG_DOMAIN="@0@"'.format(name),
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT',
]
libnm_dispatcher_core = static_library(
diff --git a/dispatcher/tests/meson.build b/dispatcher/tests/meson.build
index 20caf61d95..2224ade58b 100644
--- a/dispatcher/tests/meson.build
+++ b/dispatcher/tests/meson.build
@@ -4,10 +4,15 @@ incs = [
top_inc,
shared_inc,
libnm_core_inc,
+ libnm_inc,
dispatcher_inc
]
-cflags = '-DSRCDIR="@0@"'.format(meson.current_source_dir())
+cflags = [
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT',
+ '-DSRCDIR="@0@"'.format(meson.current_source_dir()),
+]
exe = executable(
test_unit,
diff --git a/dispatcher/tests/test-dispatcher-envp.c b/dispatcher/tests/test-dispatcher-envp.c
index 6dd4db07b2..25cd5e60ce 100644
--- a/dispatcher/tests/test-dispatcher-envp.c
+++ b/dispatcher/tests/test-dispatcher-envp.c
@@ -24,7 +24,6 @@
#include <stdlib.h>
#include <string.h>
-#include "nm-core-internal.h"
#include "nm-dispatcher-utils.h"
#include "nm-dispatcher-api.h"
diff --git a/libnm-core/crypto.h b/libnm-core/crypto.h
index 8c4cfefe22..e89f091936 100644
--- a/libnm-core/crypto.h
+++ b/libnm-core/crypto.h
@@ -24,6 +24,10 @@
#ifndef __CRYPTO_H__
#define __CRYPTO_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE)
+#error Cannot use this header.
+#endif
+
#define MD5_HASH_LEN 20
#define CIPHER_DES_EDE3_CBC "DES-EDE3-CBC"
#define CIPHER_DES_CBC "DES-CBC"
diff --git a/libnm-core/meson.build b/libnm-core/meson.build
index 7aa85b1728..4772df5576 100644
--- a/libnm-core/meson.build
+++ b/libnm-core/meson.build
@@ -142,7 +142,7 @@ deps = [
cflags = [
'-DG_LOG_DOMAIN="libnm"',
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE',
'-DLIBEXECDIR="@0@"'.format(nm_libexecdir),
'-DLOCALEDIR="@0@"'.format(nm_localedir),
'-DNMCONFDIR="@0@"'.format(nm_pkgconfdir),
diff --git a/libnm-core/nm-connection-private.h b/libnm-core/nm-connection-private.h
index ee2d7264b9..3ff7c57d21 100644
--- a/libnm-core/nm-connection-private.h
+++ b/libnm-core/nm-connection-private.h
@@ -21,6 +21,10 @@
#ifndef __NM_CONNECTION_PRIVATE_H__
#define __NM_CONNECTION_PRIVATE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-setting.h"
#include "nm-connection.h"
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index ba3abf36c1..77c7fe2900 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -31,6 +31,9 @@
* statically against libnm-core. This basically means libnm-core, libnm, NetworkManager
* and some test programs.
**/
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL)
+#error Cannot use this header.
+#endif
#include "nm-connection.h"
diff --git a/libnm-core/nm-core-types-internal.h b/libnm-core/nm-core-types-internal.h
index 843cf9fdf8..4d43aaf45d 100644
--- a/libnm-core/nm-core-types-internal.h
+++ b/libnm-core/nm-core-types-internal.h
@@ -22,6 +22,10 @@
#ifndef NM_CORE_TYPES_INTERNAL_H
#define NM_CORE_TYPES_INTERNAL_H
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL)
+#error Cannot use this header.
+#endif
+
typedef struct {
guint32 from;
guint32 to;
diff --git a/libnm-core/nm-keyfile-internal.h b/libnm-core/nm-keyfile-internal.h
index 5b709c025f..157b9fe8c9 100644
--- a/libnm-core/nm-keyfile-internal.h
+++ b/libnm-core/nm-keyfile-internal.h
@@ -22,6 +22,10 @@
#ifndef __NM_KEYFILE_INTERNAL_H__
#define __NM_KEYFILE_INTERNAL_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL)
+#error Cannot use this header.
+#endif
+
#include <sys/types.h>
#include "nm-connection.h"
diff --git a/libnm-core/nm-keyfile-utils.h b/libnm-core/nm-keyfile-utils.h
index 1f63af8c2c..832ad0b4aa 100644
--- a/libnm-core/nm-keyfile-utils.h
+++ b/libnm-core/nm-keyfile-utils.h
@@ -21,7 +21,9 @@
#ifndef __NM_KEYFILE_UTILS_H__
#define __NM_KEYFILE_UTILS_H__
-#include <glib.h>
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE)
+#error Cannot use this header.
+#endif
#define NM_KEYFILE_GROUP_VPN_SECRETS "vpn-secrets"
diff --git a/libnm-core/nm-property-compare.h b/libnm-core/nm-property-compare.h
index b859989f80..da2aaf2c30 100644
--- a/libnm-core/nm-property-compare.h
+++ b/libnm-core/nm-property-compare.h
@@ -23,6 +23,10 @@
#ifndef __NM_PROPERTY_COMPARE_H__
#define __NM_PROPERTY_COMPARE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE)
+#error Cannot use this header.
+#endif
+
int nm_property_compare (GVariant *value1, GVariant *value2);
#endif /* __NM_PROPERTY_COMPARE_H__ */
diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h
index 30e2a160e4..1e926a66e1 100644
--- a/libnm-core/nm-setting-private.h
+++ b/libnm-core/nm-setting-private.h
@@ -21,6 +21,10 @@
#ifndef __NM_SETTING_PRIVATE_H__
#define __NM_SETTING_PRIVATE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-setting.h"
#include "nm-connection.h"
#include "nm-core-enum-types.h"
diff --git a/libnm-core/nm-utils-private.h b/libnm-core/nm-utils-private.h
index c76b320088..5d0f83868e 100644
--- a/libnm-core/nm-utils-private.h
+++ b/libnm-core/nm-utils-private.h
@@ -21,8 +21,8 @@
#ifndef __NM_UTILS_PRIVATE_H__
#define __NM_UTILS_PRIVATE_H__
-#ifdef __NETWORKMANAGER_TYPES_H__
-#error "nm-utils-private.h" must not be used outside of libnm-core/. Do you want "nm-core-internal.h"?
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE)
+#error Cannot use this header.
#endif
#include "nm-setting-private.h"
diff --git a/libnm-core/tests/meson.build b/libnm-core/tests/meson.build
index d3fab70b14..602a789774 100644
--- a/libnm-core/tests/meson.build
+++ b/libnm-core/tests/meson.build
@@ -35,7 +35,11 @@ incs = [
test_cert_dir = join_paths(meson.current_source_dir(), 'certs')
-cflags = '-DTEST_CERT_DIR="@0@"'.format(test_cert_dir)
+cflags = [
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE',
+ '-DTEST_CERT_DIR="@0@"'.format(test_cert_dir),
+]
foreach test_unit: test_units
exe = executable(
diff --git a/libnm-glib/meson.build b/libnm-glib/meson.build
index 43497e60e4..727c8b39c1 100644
--- a/libnm-glib/meson.build
+++ b/libnm-glib/meson.build
@@ -12,8 +12,11 @@ common_deps = [
]
common_cflags = [
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB',
+]
+
+cflags = common_cflags + [
'-DG_LOG_DOMAIN="libnm-glib"',
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY'
]
libnm_glib_inc = include_directories('.')
@@ -64,17 +67,15 @@ install_headers(
incs = common_incs + [libnm_util_inc]
-cflags = common_cflags + [
- '-Wno-deprecated-declarations',
- '-Wno-deprecated'
-]
-
libdeprecated_nm_glib = static_library(
'deprecated-nm-glib',
sources: 'libnm_glib.c',
include_directories: incs,
dependencies: common_deps,
- c_args: cflags
+ c_args: cflags + [
+ '-Wno-deprecated-declarations',
+ '-Wno-deprecated',
+ ],
)
sources = files(
@@ -119,7 +120,7 @@ libnm_glib_vpn = shared_library(
version: libnm_glib_vpn_version,
include_directories: common_incs,
dependencies: deps,
- c_args: common_cflags,
+ c_args: cflags,
link_args: ldflags,
link_depends: symbol_map,
install: true
@@ -200,8 +201,6 @@ deps = common_deps + [
libnm_util_dep
]
-cflags = common_cflags + ['-DNMRUNDIR="@0@"'.format(nm_pkgrundir)]
-
symbol_map = join_paths(meson.current_source_dir(), 'libnm-glib.ver')
ldflags = []
@@ -215,7 +214,9 @@ libnm_glib = shared_library(
version: libnm_glib_version,
include_directories: common_incs,
dependencies: deps,
- c_args: cflags,
+ c_args: cflags + [
+ '-DNMRUNDIR="@0@"'.format(nm_pkgrundir),
+ ],
link_with: libdeprecated_nm_glib,
link_args: ldflags,
link_depends: symbol_map,
@@ -262,7 +263,9 @@ if enable_introspection
symbol_prefix: nm_id_prefix.to_lower(),
export_packages: ['libnm-glib', 'libnm-glib-vpn'],
includes: gir_includes,
- extra_args: common_cflags + ['--include-uninstalled=' + libnm_util_gir[0].full_path()],
+ extra_args: cflags + [
+ '--include-uninstalled=' + libnm_util_gir[0].full_path(),
+ ],
install: true
)
endif
@@ -276,7 +279,7 @@ executable(
[name + '.c', libnm_utils_enum[1]],
include_directories: common_incs,
dependencies: deps,
- c_args: common_cflags,
+ c_args: cflags,
link_with: libnm_glib
)
diff --git a/libnm-glib/tests/meson.build b/libnm-glib/tests/meson.build
index c655f5fd96..eb12dfe36a 100644
--- a/libnm-glib/tests/meson.build
+++ b/libnm-glib/tests/meson.build
@@ -11,11 +11,6 @@ deps = [
libnm_util_dep
]
-cflags = [
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY',
- '-DTEST_NM_SERVICE="@0@"'.format(join_paths(meson.source_root(), 'tools', 'test-networkmanager-service.py'))
-]
-
test_units = [
'test-nm-client',
'test-remote-settings-client'
@@ -27,7 +22,10 @@ foreach test_unit: test_units
[test_unit + '.c', libnm_utils_enum[1]] + shared_test_utils,
include_directories: incs,
dependencies: deps,
- c_args: cflags
+ c_args: common_cflags + [
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DTEST_NM_SERVICE="@0@"'.format(join_paths(meson.source_root(), 'tools', 'test-networkmanager-service.py')),
+ ],
)
test(test_unit, exe)
diff --git a/libnm-util/meson.build b/libnm-util/meson.build
index 2d49def2b5..944137ea4c 100644
--- a/libnm-util/meson.build
+++ b/libnm-util/meson.build
@@ -104,10 +104,13 @@ deps = [
uuid_dep
]
-cflags = [
+common_cflags = [
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL',
+ '-DLOCALEDIR="@0@"'.format(nm_localedir),
+]
+
+cflags = common_cflags + [
'-DG_LOG_DOMAIN="libnm-util"',
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY',
- '-DLOCALEDIR="@0@"'.format(nm_localedir)
]
symbol_map = join_paths(meson.current_source_dir(), 'libnm-util.ver')
diff --git a/libnm-util/tests/meson.build b/libnm-util/tests/meson.build
index cb1656a901..0c8cd8628b 100644
--- a/libnm-util/tests/meson.build
+++ b/libnm-util/tests/meson.build
@@ -10,9 +10,10 @@ deps = [
libnm_util_dep
]
-cflags = [
+cflags = common_cflags + [
'-DBUILD_DIR="@0@"'.format(meson.current_build_dir()),
- '-DTEST_CERT_DIR="@0@"'.format(test_cert_dir)
+ '-DTEST_CERT_DIR="@0@"'.format(test_cert_dir),
+ '-DNETWORKMANAGER_COMPILATION_TEST',
]
test = 'test-libnm-linking'
diff --git a/libnm/meson.build b/libnm/meson.build
index 80158c2fa2..062e8a8fb8 100644
--- a/libnm/meson.build
+++ b/libnm/meson.build
@@ -21,7 +21,7 @@ deps = [
cflags = [
'-DG_LOG_DOMAIN="libnm"',
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM',
'-DNMRUNDIR="@0@"'.format(nm_pkgrundir)
]
diff --git a/libnm/nm-dbus-helpers.h b/libnm/nm-dbus-helpers.h
index 1847da1d21..0f2cabe8cf 100644
--- a/libnm/nm-dbus-helpers.h
+++ b/libnm/nm-dbus-helpers.h
@@ -21,6 +21,10 @@
#ifndef __NM_DBUS_HELPERS_PRIVATE_H__
#define __NM_DBUS_HELPERS_PRIVATE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-dbus-compat.h"
GBusType _nm_dbus_bus_type (void);
diff --git a/libnm/nm-dhcp4-config.h b/libnm/nm-dhcp4-config.h
index 2cbbdc9ebd..6669aa0ec1 100644
--- a/libnm/nm-dhcp4-config.h
+++ b/libnm/nm-dhcp4-config.h
@@ -21,9 +21,11 @@
#ifndef __NM_DHCP4_CONFIG_H__
#define __NM_DHCP4_CONFIG_H__
-#include "nm-dhcp-config.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-dhcp-config.h"
#define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ())
#define NM_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4Config))
@@ -40,13 +42,8 @@ typedef struct {
typedef struct {
NMDhcpConfigClass parent;
-
- /*< private >*/
- gpointer padding[4];
} NMDhcp4ConfigClass;
GType nm_dhcp4_config_get_type (void);
-G_END_DECLS
-
#endif /* __NM_DHCP4_CONFIG_H__ */
diff --git a/libnm/nm-dhcp6-config.h b/libnm/nm-dhcp6-config.h
index 2d6568e12d..3c18f5ec48 100644
--- a/libnm/nm-dhcp6-config.h
+++ b/libnm/nm-dhcp6-config.h
@@ -21,9 +21,11 @@
#ifndef __NM_DHCP6_CONFIG_H__
#define __NM_DHCP6_CONFIG_H__
-#include "nm-dhcp-config.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-dhcp-config.h"
#define NM_TYPE_DHCP6_CONFIG (nm_dhcp6_config_get_type ())
#define NM_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6Config))
@@ -40,13 +42,8 @@ typedef struct {
typedef struct {
NMDhcpConfigClass parent;
-
- /*< private >*/
- gpointer padding[4];
} NMDhcp6ConfigClass;
GType nm_dhcp6_config_get_type (void);
-G_END_DECLS
-
#endif /* __NM_DHCP6_CONFIG_H__ */
diff --git a/libnm/nm-dns-manager.h b/libnm/nm-dns-manager.h
index 63989451e4..b72aea7da2 100644
--- a/libnm/nm-dns-manager.h
+++ b/libnm/nm-dns-manager.h
@@ -21,11 +21,13 @@
#ifndef __NM_DNS_MANAGER_H__
#define __NM_DNS_MANAGER_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-object.h"
#include "nm-client.h"
-G_BEGIN_DECLS
-
#define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ())
#define NM_DNS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_MANAGER, NMDnsManager))
#define NM_DNS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_MANAGER, NMDnsManagerClass))
@@ -49,13 +51,8 @@ struct _NMDnsManager {
struct _NMDnsManagerClass {
NMObjectClass parent;
-
- /*< private >*/
- gpointer padding[8];
};
-G_END_DECLS
-
GType nm_dns_manager_get_type (void);
const char *nm_dns_manager_get_mode (NMDnsManager *manager);
diff --git a/libnm/nm-ip4-config.h b/libnm/nm-ip4-config.h
index d99b21138d..266e0bc52a 100644
--- a/libnm/nm-ip4-config.h
+++ b/libnm/nm-ip4-config.h
@@ -22,9 +22,11 @@
#ifndef __NM_IP4_CONFIG_H__
#define __NM_IP4_CONFIG_H__
-#include "nm-ip-config.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-ip-config.h"
#define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ())
#define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config))
@@ -42,13 +44,8 @@ typedef struct {
typedef struct {
NMIPConfigClass parent;
-
- /*< private >*/
- gpointer padding[4];
} NMIP4ConfigClass;
GType nm_ip4_config_get_type (void);
-G_END_DECLS
-
#endif /* __NM_IP4_CONFIG_H__ */
diff --git a/libnm/nm-ip6-config.h b/libnm/nm-ip6-config.h
index 12e723b2fc..1d21adb4fe 100644
--- a/libnm/nm-ip6-config.h
+++ b/libnm/nm-ip6-config.h
@@ -22,9 +22,11 @@
#ifndef __NM_IP6_CONFIG_H__
#define __NM_IP6_CONFIG_H__
-#include "nm-ip-config.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-ip-config.h"
#define NM_TYPE_IP6_CONFIG (nm_ip6_config_get_type ())
#define NM_IP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP6_CONFIG, NMIP6Config))
@@ -42,13 +44,8 @@ typedef struct {
typedef struct {
NMIPConfigClass parent;
-
- /*< private >*/
- gpointer padding[4];
} NMIP6ConfigClass;
GType nm_ip6_config_get_type (void);
-G_END_DECLS
-
#endif /* __NM_IP6_CONFIG_H__ */
diff --git a/libnm/nm-libnm-utils.h b/libnm/nm-libnm-utils.h
index 4a5a361c51..7af5ba43ef 100644
--- a/libnm/nm-libnm-utils.h
+++ b/libnm/nm-libnm-utils.h
@@ -21,6 +21,10 @@
#ifndef __NM_LIBNM_UTILS_H__
#define __NM_LIBNM_UTILS_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
char *nm_utils_fixup_desc_string (const char *desc);
#endif /* __NM_LIBNM_UTILS_H__ */
diff --git a/libnm/nm-manager.h b/libnm/nm-manager.h
index 852a088972..ac0630ccf4 100644
--- a/libnm/nm-manager.h
+++ b/libnm/nm-manager.h
@@ -22,11 +22,13 @@
#ifndef __NM_MANAGER_H__
#define __NM_MANAGER_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-object.h"
#include "nm-client.h"
-G_BEGIN_DECLS
-
#define NM_TYPE_MANAGER (nm_manager_get_type ())
#define NM_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MANAGER, NMManager))
#define NM_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_MANAGER, NMManagerClass))
@@ -75,8 +77,6 @@ typedef struct {
void (*permission_changed) (NMManager *manager,
NMClientPermission permission,
NMClientPermissionResult result);
-
- /* nm-manager.h is internal API. We can add more slots without breaking ABI. */
} NMManagerClass;
GType nm_manager_get_type (void);
@@ -102,13 +102,10 @@ gboolean nm_manager_wimax_get_enabled (NMManager *manager);
void nm_manager_wimax_set_enabled (NMManager *manager, gboolean enabled);
gboolean nm_manager_wimax_hardware_get_enabled (NMManager *manager);
-NM_AVAILABLE_IN_1_10
gboolean nm_manager_connectivity_check_get_available (NMManager *manager);
-NM_AVAILABLE_IN_1_10
gboolean nm_manager_connectivity_check_get_enabled (NMManager *manager);
-NM_AVAILABLE_IN_1_10
void nm_manager_connectivity_check_set_enabled (NMManager *manager,
gboolean enabled);
@@ -140,7 +137,6 @@ NMConnectivityState nm_manager_check_connectivity_finish (NMManager *manager,
/* Devices */
const GPtrArray *nm_manager_get_devices (NMManager *manager);
-NM_AVAILABLE_IN_1_2
const GPtrArray *nm_manager_get_all_devices(NMManager *manager);
NMDevice *nm_manager_get_device_by_path (NMManager *manager, const char *object_path);
NMDevice *nm_manager_get_device_by_iface (NMManager *manager, const char *iface);
@@ -215,6 +211,4 @@ GHashTable *nm_manager_checkpoint_rollback_finish (NMManager *manager,
GAsyncResult *result,
GError **error);
-G_END_DECLS
-
#endif /* __NM_MANAGER_H__ */
diff --git a/libnm/nm-object-private.h b/libnm/nm-object-private.h
index 8c2f3a9cf4..1f6d54d324 100644
--- a/libnm/nm-object-private.h
+++ b/libnm/nm-object-private.h
@@ -21,6 +21,10 @@
#ifndef __NM_OBJECT_PRIVATE_H__
#define __NM_OBJECT_PRIVATE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#include "nm-object.h"
typedef gboolean (*PropertyMarshalFunc) (NMObject *, GParamSpec *, GVariant *, gpointer);
diff --git a/libnm/nm-remote-connection-private.h b/libnm/nm-remote-connection-private.h
index e3f35428cd..5ff282f4ba 100644
--- a/libnm/nm-remote-connection-private.h
+++ b/libnm/nm-remote-connection-private.h
@@ -21,6 +21,10 @@
#ifndef __NM_REMOTE_CONNECTION_PRIVATE_H__
#define __NM_REMOTE_CONNECTION_PRIVATE_H__
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
+
#define NM_REMOTE_CONNECTION_INIT_RESULT "init-result"
typedef enum {
diff --git a/libnm/nm-remote-settings.h b/libnm/nm-remote-settings.h
index 06d3ac0a39..ee0e0f225a 100644
--- a/libnm/nm-remote-settings.h
+++ b/libnm/nm-remote-settings.h
@@ -22,9 +22,11 @@
#ifndef __NM_REMOTE_SETTINGS_H__
#define __NM_REMOTE_SETTINGS_H__
-#include "nm-object.h"
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE)
+#error Cannot use this header.
+#endif
-G_BEGIN_DECLS
+#include "nm-object.h"
#define NM_TYPE_REMOTE_SETTINGS (nm_remote_settings_get_type ())
#define NM_REMOTE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_REMOTE_SETTINGS, NMRemoteSettings))
@@ -53,14 +55,10 @@ struct _NMRemoteSettings {
struct _NMRemoteSettingsClass {
NMObjectClass parent;
- /* Signals */
void (*connection_added) (NMRemoteSettings *settings,
NMRemoteConnection *connection);
void (*connection_removed) (NMRemoteSettings *settings,
NMRemoteConnection *connection);
-
- /*< private >*/
- gpointer padding[8];
};
GType nm_remote_settings_get_type (void);
@@ -125,6 +123,4 @@ gboolean nm_remote_settings_save_hostname_finish (NMRemoteSettings *settings,
GAsyncResult *result,
GError **error);
-G_END_DECLS
-
#endif /* __NM_REMOTE_SETTINGS_H__ */
diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build
index fa7470f980..1955707ae1 100644
--- a/libnm/tests/meson.build
+++ b/libnm/tests/meson.build
@@ -18,7 +18,8 @@ deps = [
]
cflags = [
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB',
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM',
'-DTEST_NM_SERVICE="@0@"'.format(join_paths(meson.source_root(), 'tools', 'test-networkmanager-service.py'))
]
@@ -47,5 +48,6 @@ libnm_vpn_plugin_utils_test = static_library(
'nm-vpn-plugin-utils-test',
sources: shared_vpn_plugin_utils + [libnm_enum[1]],
include_directories: incs,
- dependencies: glib_dep
+ dependencies: glib_dep,
+ c_args: cflags,
)
diff --git a/shared/nm-default.h b/shared/nm-default.h
index eb4fbc9e17..2e205a957e 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -22,19 +22,85 @@
#ifndef __NM_DEFAULT_H__
#define __NM_DEFAULT_H__
-/* makefiles define NETWORKMANAGER_COMPILATION for compiling NetworkManager.
- * Depending on which parts are compiled, different values are set. */
-#define NM_NETWORKMANAGER_COMPILATION_DEFAULT 0x0001
-#define NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON 0x0002
-#define NM_NETWORKMANAGER_COMPILATION_LIB 0x0004
-#define NM_NETWORKMANAGER_COMPILATION_SYSTEMD 0x0008
-#define NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY 0x0010
+#define NM_NETWORKMANAGER_COMPILATION_WITH_GLIB (1 << 0)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB (1 << 1)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG (1 << 2)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM (1 << 3)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE (1 << 4)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE (1 << 5)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL (1 << 6)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE (1 << 7)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL (1 << 8)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB (1 << 9)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON (1 << 10)
+#define NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD (1 << 11)
+
+#define NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE ( 0 \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL \
+ )
+
+#define NM_NETWORKMANAGER_COMPILATION_LIBNM ( 0 \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL \
+ )
+
+#define NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL ( 0 \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL \
+ )
+
+#define NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB ( 0 \
+ | NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB \
+ )
+
+#define NM_NETWORKMANAGER_COMPILATION_CLIENT ( 0 \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE \
+ )
+
+#define NM_NETWORKMANAGER_COMPILATION_DAEMON ( 0 \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON \
+ )
+
+#define NM_NETWORKMANAGER_COMPILATION_SYSTEMD ( 0 \
+ | NM_NETWORKMANAGER_COMPILATION_DAEMON \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD \
+ )
+
+#define NM_NETWORKMANAGER_COMPILATION_GLIB ( 0 \
+ | NM_NETWORKMANAGER_COMPILATION_WITH_GLIB \
+ )
#ifndef NETWORKMANAGER_COMPILATION
-/* For convenience, we don't require our Makefile.am to define
- * -DNETWORKMANAGER_COMPILATION. As we now include this internal header,
- * we know we do a NETWORKMANAGER_COMPILATION. */
-#define NETWORKMANAGER_COMPILATION NM_NETWORKMANAGER_COMPILATION_DEFAULT
+#error Define NETWORKMANAGER_COMPILATION accordingly
+#endif
+
+#ifndef G_LOG_DOMAIN
+#if defined(NETWORKMANAGER_COMPILATION_TEST)
+#define G_LOG_DOMAIN "test"
+#elif NETWORKMANAGER_COMPILATION & NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON
+#define G_LOG_DOMAIN "NetworkManager"
+#else
+#error Need to define G_LOG_DOMAIN
+#endif
+#elif defined (NETWORKMANAGER_COMPILATION_TEST) || (NETWORKMANAGER_COMPILATION & NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON)
+#error Do not define G_LOG_DOMAIN with NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON
#endif
/*****************************************************************************/
@@ -110,8 +176,22 @@
#endif
#include <stdlib.h>
+
+/*****************************************************************************/
+
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_GLIB
+
#include <glib.h>
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB
+#error Cannot define NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_PROG and NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB
+#endif
+#include <glib/gi18n.h>
+#elif (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_GLIB_I18N_LIB
+#include <glib/gi18n-lib.h>
+#endif
+
/*****************************************************************************/
#if NM_MORE_ASSERTS == 0
@@ -178,35 +258,30 @@ _nm_g_return_if_fail_warning (const char *log_domain,
#include "nm-utils/nm-macros-internal.h"
#include "nm-utils/nm-shared-utils.h"
-#if ((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY) == 0
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL
+/* no hash-utils in legacy code. */
+#else
#include "nm-utils/nm-hash-utils.h"
#endif
-#include "nm-version.h"
-
/*****************************************************************************/
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB) || ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
-
-#include <glib/gi18n-lib.h>
-
-#else
-
-#include <glib/gi18n.h>
-
-#endif /* NM_NETWORKMANAGER_COMPILATION_LIB || NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */
+#if (NETWORKMANAGER_COMPILATION) & (NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL)
+#include "nm-version.h"
+#endif
/*****************************************************************************/
-#if (NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON || (NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_SYSTEMD
-
-/* the header is used inside src/, where additional
- * headers are available. */
-
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON
#include "nm-types.h"
#include "nm-logging.h"
+#endif
+
+#if ((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM) && !((NETWORKMANAGER_COMPILATION) & (NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE | NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL))
+#include "NetworkManager.h"
+#endif
-#endif /* NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON */
+#endif /* NM_NETWORKMANAGER_COMPILATION_WITH_GLIB */
/*****************************************************************************/
diff --git a/shared/nm-test-libnm-utils.h b/shared/nm-test-libnm-utils.h
index 192c089e10..c4731a520d 100644
--- a/shared/nm-test-libnm-utils.h
+++ b/shared/nm-test-libnm-utils.h
@@ -22,6 +22,10 @@
#include "nm-utils/nm-test-utils.h"
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
+#include "nm-dbus-glib-types.h"
+#endif
+
/*****************************************************************************/
typedef struct {
@@ -29,7 +33,7 @@ typedef struct {
GDBusProxy *proxy;
GPid pid;
int keepalive_fd;
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
struct {
DBusGConnection *bus;
} libdbus;
@@ -54,7 +58,15 @@ static inline void _nmtstc_auto_service_cleanup (NMTstcServiceInfo **info)
/*****************************************************************************/
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB)
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
+
+#include "nm-client.h"
+#include "nm-remote-settings.h"
+
+NMClient *nmtstc_nm_client_new (void);
+NMRemoteSettings *nmtstc_nm_remote_settings_new (void);
+
+#else
NMDevice *nmtstc_service_add_device (NMTstcServiceInfo *info,
NMClient *client,
@@ -67,17 +79,9 @@ NMDevice * nmtstc_service_add_wired_device (NMTstcServiceInfo *sinfo,
const char *hwaddr,
const char **subchannels);
-#endif /* NM_NETWORKMANAGER_COMPILATION_LIB */
-
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
-
-#include "nm-client.h"
-#include "nm-remote-settings.h"
-
-NMClient *nmtstc_nm_client_new (void);
-NMRemoteSettings *nmtstc_nm_remote_settings_new (void);
+#endif
-#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */
+/*****************************************************************************/
void nmtstc_service_add_connection (NMTstcServiceInfo *sinfo,
NMConnection *connection,
diff --git a/shared/nm-test-utils-impl.c b/shared/nm-test-utils-impl.c
index 3eb726d91f..998d792a2a 100644
--- a/shared/nm-test-utils-impl.c
+++ b/shared/nm-test-utils-impl.c
@@ -25,10 +25,6 @@
#include "NetworkManager.h"
#include "nm-dbus-compat.h"
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
-#include "nm-dbus-glib-types.h"
-#endif
-
#include "nm-test-libnm-utils.h"
/*****************************************************************************/
@@ -58,8 +54,7 @@ name_exists (GDBusConnection *c, const char *name)
return exists;
}
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
-
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
static DBusGProxy *
_libdbus_create_proxy_test (DBusGConnection *bus)
{
@@ -75,7 +70,6 @@ _libdbus_create_proxy_test (DBusGConnection *bus)
return proxy;
}
-
#endif
NMTstcServiceInfo *
@@ -121,7 +115,7 @@ nmtstc_service_init (void)
NULL, &error);
g_assert_no_error (error);
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
info->libdbus.bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
g_assert_no_error (error);
g_assert (info->libdbus.bus);
@@ -148,7 +142,7 @@ nmtstc_service_cleanup (NMTstcServiceInfo *info)
g_object_unref (info->bus);
nm_close (info->keepalive_fd);
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
g_clear_pointer (&info->libdbus.bus, dbus_g_connection_unref);
#endif
@@ -156,8 +150,7 @@ nmtstc_service_cleanup (NMTstcServiceInfo *info)
g_free (info);
}
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB)
-
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB)
typedef struct {
GMainLoop *loop;
const char *ifname;
@@ -270,8 +263,7 @@ nmtstc_service_add_wired_device (NMTstcServiceInfo *sinfo, NMClient *client,
{
return add_device_common (sinfo, client, "AddWiredDevice", ifname, hwaddr, subchannels);
}
-
-#endif /* NM_NETWORKMANAGER_COMPILATION_LIB */
+#endif
void
nmtstc_service_add_connection (NMTstcServiceInfo *sinfo,
@@ -279,7 +271,7 @@ nmtstc_service_add_connection (NMTstcServiceInfo *sinfo,
gboolean verify_connection,
char **out_path)
{
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
gs_unref_hashtable GHashTable *new_settings = NULL;
gboolean success;
gs_free_error GError *error = NULL;
@@ -353,7 +345,7 @@ nmtstc_service_update_connection (NMTstcServiceInfo *sinfo,
path = nm_connection_get_path (connection);
g_assert (path);
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
{
gs_unref_hashtable GHashTable *new_settings = NULL;
gboolean success;
@@ -414,8 +406,7 @@ nmtstc_service_update_connection_variant (NMTstcServiceInfo *sinfo,
/*****************************************************************************/
-#if ((NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY)
-
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_GLIB
NMClient *
nmtstc_nm_client_new (void)
{
@@ -461,7 +452,6 @@ nmtstc_nm_remote_settings_new (void)
return settings;
}
-
-#endif /* NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY */
+#endif
/*****************************************************************************/
diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h
index 0646df84ad..6fa4e85f0a 100644
--- a/shared/nm-utils/nm-test-utils.h
+++ b/shared/nm-utils/nm-test-utils.h
@@ -21,6 +21,10 @@
#ifndef __NM_TEST_UTILS_H__
#define __NM_TEST_UTILS_H__
+#if defined(NETWORKMANAGER_COMPILATION) && !defined(NETWORKMANAGER_COMPILATION_TEST)
+#error Need to mark the compilation with NETWORKMANAGER_COMPILATION_TEST.
+#endif
+
/*******************************************************************************
* HOWTO run tests.
*
diff --git a/src/dhcp/meson.build b/src/dhcp/meson.build
index d4ef4d7a8a..a26e6748e3 100644
--- a/src/dhcp/meson.build
+++ b/src/dhcp/meson.build
@@ -2,7 +2,8 @@ name = 'nm-dhcp-helper'
cflags = [
'-DG_LOG_DOMAIN="@0@"'.format(name),
- '-DNMRUNDIR="@0@"'.format(nm_pkgrundir)
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_GLIB',
+ '-DNMRUNDIR="@0@"'.format(nm_pkgrundir),
]
ldflags = []
diff --git a/src/dnsmasq/tests/meson.build b/src/dnsmasq/tests/meson.build
index 4c4173faa0..749e6f64fa 100644
--- a/src/dnsmasq/tests/meson.build
+++ b/src/dnsmasq/tests/meson.build
@@ -1,6 +1,10 @@
test_unit = 'test-dnsmasq-utils'
-cflags = '-DTESTDIR="@0@"'.format(meson.source_root())
+cflags = [
+ '-DTESTDIR="@0@"'.format(meson.source_root()),
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON',
+]
exe = executable(
test_unit,
diff --git a/src/meson.build b/src/meson.build
index 5335fdea06..26c53edcd1 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -7,11 +7,6 @@ install_data(
subdir('systemd')
-core_cflags = [
- '-DG_LOG_DOMAIN="@0@"'.format(nm_name),
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON'
-]
-
core_incs = [
top_inc,
shared_inc,
@@ -23,7 +18,9 @@ core_dep = declare_dependency(
sources: libnm_core_enum[1],
include_directories: core_incs,
dependencies: glib_dep,
- compile_args: core_cflags
+ compile_args: [
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON',
+ ],
)
core_plugins = []
@@ -43,7 +40,8 @@ common_cflags = [
'-DNMPLUGINDIR="@0@"'.format(nm_pkglibdir),
'-DNMRUNDIR="@0@"'.format(nm_pkgrundir),
'-DNMSTATEDIR="@0@"'.format(nm_pkgstatedir),
- '-DNMLIBDIR="@0@"'.format(nm_pkglibdir)
+ '-DNMLIBDIR="@0@"'.format(nm_pkglibdir),
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON',
]
if enable_dhcpcanon
@@ -297,13 +295,20 @@ if enable_tests
libudev_dep
]
- test_cflags = []
+ test_cflags = [
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON',
+ ]
if require_root_tests
test_cflags += ['-DREQUIRE_ROOT_TESTS=1']
endif
platform = (host_machine.system().contains('linux') ? 'linux' : 'fake')
- test_cflags_platform = '-DSETUP=nm_' + platform + '_platform_setup'
+ test_cflags_platform = [
+ '-DSETUP=nm_' + platform + '_platform_setup',
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON',
+ ]
libnetwork_manager_test = static_library(
'NetworkManagerTest',
diff --git a/src/nm-types.h b/src/nm-types.h
index 02163f87e6..39510c3185 100644
--- a/src/nm-types.h
+++ b/src/nm-types.h
@@ -21,8 +21,8 @@
#ifndef __NETWORKMANAGER_TYPES_H__
#define __NETWORKMANAGER_TYPES_H__
-#ifdef __NM_UTILS_PRIVATE_H__
-#error "nm-utils-private.h" must not be used outside of libnm-core/. Do you want "nm-core-internal.h"?
+#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON)
+#error Cannot use this header.
#endif
#define _NM_SD_MAX_CLIENT_ID_LEN (sizeof (guint32) + 128)
diff --git a/src/ppp/meson.build b/src/ppp/meson.build
index 36f9d5eb90..90988050ea 100644
--- a/src/ppp/meson.build
+++ b/src/ppp/meson.build
@@ -5,18 +5,16 @@ deps = [
glib_dep
]
-cflags = [
- '-DG_LOG_DOMAIN="@0@"'.format(name),
- '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_INSIDE_DAEMON'
-]
-
nm_pppd_plugin = shared_module(
name,
name_prefix: '',
sources: [name + '.c', libnm_core_enum[1]],
include_directories: core_incs,
dependencies: deps,
- c_args: cflags,
+ c_args: [
+ '-DG_LOG_DOMAIN="nm-pppd-plugin"',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_GLIB',
+ ],
install: true,
install_dir: pppd_plugin_dir
)
@@ -28,7 +26,10 @@ deps = [
libnmdbus_dep
]
-cflags = '-DPPPD_PLUGIN_DIR="@0@"'.format(pppd_plugin_dir)
+cflags = [
+ '-DPPPD_PLUGIN_DIR="@0@"'.format(pppd_plugin_dir),
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON',
+]
symbol_map = join_paths(meson.current_source_dir(), name + '.ver')
diff --git a/src/ppp/nm-pppd-plugin.c b/src/ppp/nm-pppd-plugin.c
index 9c47c339a3..9f8451d87a 100644
--- a/src/ppp/nm-pppd-plugin.c
+++ b/src/ppp/nm-pppd-plugin.c
@@ -36,7 +36,9 @@
#include <pppd/ipv6cp.h>
#include "nm-default.h"
+
#include "nm-dbus-interface.h"
+
#include "nm-pppd-plugin.h"
#include "nm-ppp-status.h"
diff --git a/src/systemd/sd-adapt/nm-sd-adapt.h b/src/systemd/sd-adapt/nm-sd-adapt.h
index 0d291e26e5..90deb501fd 100644
--- a/src/systemd/sd-adapt/nm-sd-adapt.h
+++ b/src/systemd/sd-adapt/nm-sd-adapt.h
@@ -105,7 +105,7 @@ G_STMT_START { \
* itself.
*****************************************************************************/
-#if (NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_SYSTEMD
+#if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD
#include <netinet/in.h>
#include <string.h>
@@ -186,7 +186,7 @@ static inline pid_t gettid(void) {
return (pid_t) syscall(SYS_gettid);
}
-#endif /* (NETWORKMANAGER_COMPILATION) == NM_NETWORKMANAGER_COMPILATION_SYSTEMD */
+#endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */
#endif /* NM_SD_ADAPT_H */
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 6a8be55854..f8383d89b4 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -23,7 +23,10 @@ endforeach
test_unit = 'test-systemd'
-cflags = '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD'
+cflags = [
+ '-DNETWORKMANAGER_COMPILATION_TEST',
+ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD',
+]
exe = executable(
test_unit,