diff options
author | Thomas Haller <thaller@redhat.com> | 2018-07-12 10:58:23 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-07-17 17:46:39 +0200 |
commit | a75ab799e4f6b9c5d6f298ad7c1899ae21726a48 (patch) | |
tree | aba81840b03b69817d9ef7a72327700a483f9993 | |
parent | 1c2033301c6a3364239a487e0276313a1570819c (diff) | |
download | NetworkManager-a75ab799e4f6b9c5d6f298ad7c1899ae21726a48.tar.gz |
build: create "config-extra.h" header instead of passing directory variables via CFLAGS
1) the command line gets shorter. I frequently run `make V=1` to see
the command line arguments for the compiler, and there is a lot
of noise.
2) define each of these variables at one place. This makes it easy
to verify that for all compilation units, a particular
define has the same value. Previously that was not obvious or
even not the case (see commit e5d1a71396e107d1909744d26ad401f206c0c915
and commit d63cf1ef2faba57595112a82e962b9643cce4718).
The point is to avoid redundancy.
3) not all compilation units need all defines. In fact, most modules
would only need a few of these defines. We aimed to pass the necessary
minium of defines to each compilation unit, but that was non-obvious
to get right and often we set a define that wasn't used. See for example
"src_settings_plugins_ibft_cppflags" which needlessly had "-DSYSCONFDIR".
This question is now entirely avoided by just defining all variables in
a header. We don't care to find the minimum, because every component
gets anyway all defines from the header.
4) this also avoids the situation, where a module that previously did
not use a particular define gets modified to require it. Previously,
that would have required to identify the missing define, and add
it to the CFLAGS of the complation unit. Since every compilation
now includes "config-extra.h", all defines are available everywhere.
5) the fact that each define is now available in all compilation units
could be perceived as a downside. But it isn't, because these defines
should have a unique name and one specific value. Defining the same
name with different values, or refer to the same value by different
names is a bug, not a desirable feature. Since these defines should
be unique accross the entire tree, there is no problem in providing
them to every compilation unit.
6) the reason why we generate "config-extra.h" this way, instead of using
AC_DEFINE() in configure.ac, is due to the particular handling of
autoconf for directory variables. See [1].
With meson, it would be trivial to put them into "config.h.meson".
While that is not easy with autoconf, the "config-extra.h" workaround
seems still preferable to me.
[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html
30 files changed, 114 insertions, 146 deletions
diff --git a/.gitignore b/.gitignore index febc17298a..968c444584 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ test-*.trs /autom4te.cache /build-aux /config.* +/config-extra.h /configure /intltool-* diff --git a/Makefile.am b/Makefile.am index 45074fa1e7..4fff329b04 100644 --- a/Makefile.am +++ b/Makefile.am @@ -107,10 +107,43 @@ endif ############################################################################### -nm_build_cflags = \ - -DNM_BUILD_SRCDIR=\"$(abs_srcdir)\" \ - -DNM_BUILD_BUILDDIR=\"$(abs_builddir)\" \ - $(NULL) +# with autotools, it is not easily possible to generate these defines +# from configure.ac. +# +# See https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html +# +# With meson-only, they could just be set via config.h.meson +config-extra.h: Makefile + $(AM_V_GEN) \ + echo "/* Generated by Makefile.am */" >$@ && \ + echo "#define BINDIR \"$(bindir)\"" >>$@ && \ + echo "#define DATADIR \"$(datadir)\"" >>$@ && \ + echo "#define DHCLIENT_PATH \"$(DHCLIENT_PATH)\"" >>$@ && \ + echo "#define DHCPCANON_PATH \"$(DHCPCANON_PATH)\"" >>$@ && \ + echo "#define DHCPCD_PATH \"$(DHCPCD_PATH)\"" >>$@ && \ + echo "#define LIBEXECDIR \"$(libexecdir)\"" >>$@ && \ + echo "#define LOCALSTATEDIR \"$(localstatedir)\"" >>$@ && \ + echo "#define NMCONFDIR \"$(nmconfdir)\"" >>$@ && \ + echo "#define NMLIBDIR \"$(nmlibdir)\"" >>$@ && \ + echo "#define NMLOCALEDIR \"$(nmlocaledir)\"" >>$@ && \ + echo "#define NMPLUGINDIR \"$(plugindir)\"" >>$@ && \ + echo "#define NMRUNDIR \"$(nmrundir)\"" >>$@ && \ + echo "#define NMSTATEDIR \"$(nmstatedir)\"" >>$@ && \ + echo "#define NMVPNDIR \"$(pkglibdir)\"" >>$@ && \ + echo "#define NM_BUILD_BUILDDIR \"$(abs_builddir)\"" >>$@ && \ + echo "#define NM_BUILD_SRCDIR \"$(abs_srcdir)\"" >>$@ && \ + echo "#define PPPD_PLUGIN_DIR \"$(PPPD_PLUGIN_DIR)\"" >>$@ && \ + echo "#define PREFIX \"$(prefix)\"" >>$@ && \ + echo "#define RUNDIR \"$(rundir)\"" >>$@ && \ + echo "#define RUNSTATEDIR \"$(runstatedir)\"" >>$@ && \ + echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@ && \ + true + +DISTCLEANFILES += config-extra.h + +libnm-core/.dirstamp: config-extra.h + +############################################################################### set_sanitizer_env = \ [ -n "$(SANITIZER_ENV)" ] && export $(SANITIZER_ENV) ; \ @@ -604,12 +637,6 @@ libnm_core_libnm_core_la_CPPFLAGS = \ $(dflt_cppflags_libnm_core) \ -DG_LOG_DOMAIN=\""libnm"\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE \ - -DNMLOCALEDIR=\"$(nmlocaledir)\" \ - -DNMCONFDIR=\"$(nmconfdir)\" \ - -DNMLIBDIR=\"$(nmlibdir)\" \ - -DNMVPNDIR=\"$(pkglibdir)\" \ - -DNMPLUGINDIR=\"$(plugindir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" \ $(NULL) if WITH_JSON_VALIDATION @@ -694,7 +721,6 @@ libnm_core_tests_cppflags = \ $(dflt_cppflags_libnm_core) \ -I$(srcdir)/libnm-core/tests \ -I$(builddir)/libnm-core/tests \ - $(nm_build_cflags) \ -DNETWORKMANAGER_COMPILATION_TEST \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE \ $(NULL) @@ -1015,7 +1041,7 @@ INTROSPECTION_GIRS += libnm/NM-1.0.gir if WITH_FAKE_TYPELIBS libnm/fake-typelib/NetworkManager.typelib: libnm/fake-typelib/NetworkManager.gir libnm/fake-typelib/.dirstamp - $(AM_V_GEN) $(INTROSPECTION_COMPILER) $< -o $@ + $(AM_V_GEN) $(INTROSPECTION_COMPILER) $< -o $@ libnm/fake-typelib/NMClient.typelib: libnm/fake-typelib/NMClient.gir libnm/fake-typelib/.dirstamp $(AM_V_GEN) $(INTROSPECTION_COMPILER) $< -o $@ @@ -1118,7 +1144,6 @@ libnm_tests_cppflags = \ $(dflt_cppflags_libnm_core) \ -I$(srcdir)/libnm \ -I$(builddir)/libnm \ - $(nm_build_cflags) \ -DNETWORKMANAGER_COMPILATION_TEST \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM \ $(NULL) @@ -1214,29 +1239,8 @@ src_cppflags = \ -I$(srcdir)/src \ -I$(builddir)/src \ \ - -DPREFIX=\"$(prefix)\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \ \ - -DBINDIR=\"$(bindir)\" \ - -DDATADIR=\"$(datadir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" \ - -DLOCALSTATEDIR=\"$(localstatedir)\" \ - -DRUNSTATEDIR=\"$(runstatedir)\" \ - -DSBINDIR=\"$(sbindir)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DRUNDIR=\"$(rundir)\" \ - \ - -DNMCONFDIR=\"$(nmconfdir)\" \ - -DNMLOCALEDIR=\"$(nmlocaledir)\" \ - -DNMPLUGINDIR=\"$(plugindir)\" \ - -DNMRUNDIR=\"$(nmrundir)\" \ - -DNMSTATEDIR=\"$(nmstatedir)\" \ - -DNMLIBDIR=\"$(nmlibdir)\" \ - \ - -DDHCPCANON_PATH=\"$(DHCPCANON_PATH)\" \ - -DDHCLIENT_PATH=\"$(DHCLIENT_PATH)\" \ - -DDHCPCD_PATH=\"$(DHCPCD_PATH)\" \ - \ $(LIBUDEV_CFLAGS) \ $(LIBNDP_CFLAGS) \ $(LIBPSL_CFLAGS) \ @@ -1847,7 +1851,7 @@ src_dhcp_nm_dhcp_helper_CPPFLAGS = \ -I$(builddir)/shared \ -DG_LOG_DOMAIN=\""nm-dhcp-helper"\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_GLIB \ - -DNMRUNDIR=\"$(nmrundir)\" + $(NULL) src_dhcp_nm_dhcp_helper_SOURCES = \ src/dhcp/nm-dhcp-helper.c \ @@ -1868,7 +1872,6 @@ EXTRA_DIST += \ src_dhcp_tests_cppflags = \ $(src_tests_cppflags) \ - $(nm_build_cflags) \ $(NULL) src_dhcp_tests_ldadd = \ @@ -1944,7 +1947,6 @@ src_ppp_libnm_ppp_plugin_la_CPPFLAGS = \ -I$(builddir)/shared \ -I$(builddir)/libnm-core \ -I$(srcdir)/libnm-core \ - -DPPPD_PLUGIN_DIR=\"$(PPPD_PLUGIN_DIR)\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \ $(GLIB_CFLAGS) @@ -1970,7 +1972,6 @@ check_programs += src/settings/plugins/keyfile/tests/test-keyfile src_settings_plugins_keyfile_tests_test_keyfile_CPPFLAGS = \ $(src_tests_cppflags) \ - $(nm_build_cflags) \ $(NULL) src_settings_plugins_keyfile_tests_test_keyfile_LDFLAGS = \ @@ -2043,8 +2044,7 @@ src_settings_plugins_ibft_cppflags = \ -I$(builddir)/libnm-core \ $(GLIB_CFLAGS) \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSBINDIR=\"$(sbindir)\" + $(NULL) src_settings_plugins_ibft_libnms_ibft_core_la_CPPFLAGS = $(src_settings_plugins_ibft_cppflags) @@ -2081,7 +2081,6 @@ src_settings_plugins_ibft_tests_test_ibft_CPPFLAGS = \ -I$(srcdir)/libnm-core \ -I$(builddir)/libnm-core \ -I$(srcdir)/src \ - $(nm_build_cflags) \ -DNETWORKMANAGER_COMPILATION_TEST \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \ $(NULL) @@ -2142,8 +2141,7 @@ src_settings_plugins_ifcfg_rh_cppflags = \ $(NSS_CFLAGS) \ $(SANITIZER_EXEC_CFLAGS) \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DSBINDIR=\"$(sbindir)\" + $(NULL) ############################################################################### @@ -2222,7 +2220,6 @@ src_settings_plugins_ifcfg_rh_tests_test_ifcfg_rh_SOURCES = \ src_settings_plugins_ifcfg_rh_tests_test_ifcfg_rh_CPPFLAGS = \ $(src_tests_cppflags) \ - $(nm_build_cflags) \ $(NULL) src_settings_plugins_ifcfg_rh_tests_test_ifcfg_rh_LDFLAGS = \ @@ -2489,7 +2486,7 @@ src_settings_plugins_ifupdown_cppflags = \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \ $(GLIB_CFLAGS) \ $(LIBUDEV_CFLAGS) \ - -DSYSCONFDIR=\"$(sysconfdir)\" + $(NULL) src_settings_plugins_ifupdown_libnms_ifupdown_core_la_SOURCES = \ @@ -2539,7 +2536,6 @@ src_settings_plugins_ifupdown_tests_test_ifupdown_CPPFLAGS = \ $(GLIB_CFLAGS) \ -DNETWORKMANAGER_COMPILATION_TEST \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \ - $(nm_build_cflags) \ $(NULL) src_settings_plugins_ifupdown_tests_test_ifupdown_LDFLAGS = \ @@ -2936,7 +2932,6 @@ src_devices_ovs_libnm_device_plugin_ovs_la_CPPFLAGS = \ -I$(srcdir)/libnm-core \ \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DAEMON \ - -DRUNSTATEDIR=\"$(runstatedir)\" \ \ $(JANSSON_CFLAGS) \ $(GLIB_CFLAGS) @@ -3140,7 +3135,6 @@ check_programs += src/supplicant/tests/test-supplicant-config src_supplicant_tests_test_supplicant_config_CPPFLAGS = \ $(src_tests_cppflags) \ - $(nm_build_cflags) \ $(NULL) src_supplicant_tests_test_supplicant_config_LDADD = \ @@ -3169,7 +3163,6 @@ src_tests_config_test_config_SOURCES = \ src_tests_config_test_config_CPPFLAGS = \ $(src_tests_cppflags) \ - $(nm_build_cflags) \ $(NULL) src_tests_config_test_config_LDADD = \ @@ -3286,9 +3279,7 @@ dispatcher_cppflags = \ $(GLIB_CFLAGS) \ -DG_LOG_DOMAIN=\""nm-dispatcher"\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \ - -DNMCONFDIR=\"$(nmconfdir)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" + $(NULL) dispatcher_nmdbus_dispatcher_sources = \ @@ -3382,7 +3373,6 @@ dispatcher_tests_test_dispatcher_envp_CPPFLAGS = \ -I$(builddir)/libnm \ -I$(srcdir)/dispatcher \ -I$(builddir)/dispatcher \ - $(nm_build_cflags) \ -DNETWORKMANAGER_COMPILATION_TEST \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \ $(GLIB_CFLAGS) \ @@ -3425,7 +3415,7 @@ clients_nm_online_CPPFLAGS = \ $(GLIB_CFLAGS) \ -DG_LOG_DOMAIN=\""nm-online"\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \ - -DNMLOCALEDIR=\"$(nmlocaledir)\" + $(NULL) clients_nm_online_LDFLAGS = \ -Wl,--version-script="$(srcdir)/linker-script-binary.ver" @@ -3453,7 +3443,6 @@ clients_cppflags = \ -I$(srcdir)/clients/common \ -I$(builddir)/clients/common \ $(GLIB_CFLAGS) \ - -DNMLOCALEDIR=\"$(nmlocaledir)\" \ $(NULL) check_ltlibraries += clients/common/libnmc-base.la @@ -3605,10 +3594,9 @@ clients_cli_nmcli_CPPFLAGS = \ -I$(srcdir)/clients/cli \ $(clients_cppflags) \ $(SANITIZER_EXEC_CFLAGS) \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ -DG_LOG_DOMAIN=\""nmcli"\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \ - -DNMLOCALEDIR=\"$(nmlocaledir)\" + $(NULL) clients_cli_nmcli_LDADD = \ libnm/libnm.la \ @@ -3814,7 +3802,7 @@ clients_tui_nmtui_CPPFLAGS = \ $(NEWT_CFLAGS) \ -DG_LOG_DOMAIN=\""nmtui"\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT \ - -DNMLOCALEDIR=\""$(nmlocaledir)"\" + $(NULL) clients_tui_nmtui_LDFLAGS = \ -Wl,--version-script="$(srcdir)/linker-script-binary.ver" \ @@ -3975,7 +3963,6 @@ libnm_util_cppflags = \ -I$(builddir)/shared \ -DG_LOG_DOMAIN=\""libnm-util"\" \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL \ - -DNMLOCALEDIR=\"$(nmlocaledir)\" \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ $(UUID_CFLAGS) @@ -4187,7 +4174,6 @@ libnm_util_tests_cppflags = \ -I$(builddir)/libnm-util \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ - $(nm_build_cflags) \ -DNETWORKMANAGER_COMPILATION_TEST \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL \ $(SANITIZER_EXEC_CFLAGS) \ @@ -4544,7 +4530,6 @@ libnm_glib_tests_cppflags = \ -I$(srcdir)/libnm-util \ -I$(builddir)/libnm-util \ -I$(srcdir)/libnm-glib \ - $(nm_build_cflags) \ -DNETWORKMANAGER_COMPILATION_TEST \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_GLIB \ $(GLIB_CFLAGS) \ diff --git a/clients/cli/meson.build b/clients/cli/meson.build index 9449ce63c0..c5669c9694 100644 --- a/clients/cli/meson.build +++ b/clients/cli/meson.build @@ -27,9 +27,7 @@ deps = [ ] cflags = clients_cflags + [ - '-DSYSCONFDIR="@0@"'.format(nm_sysconfdir), '-DG_LOG_DOMAIN="@0@"'.format(name), - '-DNMLOCALEDIR="@0@"'.format(nm_localedir) ] if enable_polkit_agent diff --git a/clients/meson.build b/clients/meson.build index 46e1f1cd74..68170c4a63 100644 --- a/clients/meson.build +++ b/clients/meson.build @@ -7,7 +7,6 @@ deps = [ clients_cflags = [ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT', - '-DNMLOCALEDIR="@0@"'.format(nm_localedir), ] cflags = clients_cflags + [ diff --git a/clients/tui/meson.build b/clients/tui/meson.build index 40eb4b4ac7..5f7f0fbb50 100644 --- a/clients/tui/meson.build +++ b/clients/tui/meson.build @@ -7,7 +7,6 @@ deps = [ cflags = clients_cflags + [ '-DG_LOG_DOMAIN="@0@"'.format(name), - '-DNMLOCALEDIR="@0@"'.format(nm_localedir) ] subdir('newt') diff --git a/config-extra.h.meson b/config-extra.h.meson new file mode 100644 index 0000000000..dbe077d4fa --- /dev/null +++ b/config-extra.h.meson @@ -0,0 +1,21 @@ +#mesondefine BINDIR +#mesondefine DATADIR +#mesondefine DHCLIENT_PATH +#mesondefine DHCPCANON_PATH +#mesondefine DHCPCD_PATH +#mesondefine LIBEXECDIR +#mesondefine LOCALSTATEDIR +#mesondefine NMCONFDIR +#mesondefine NMLIBDIR +#mesondefine NMLOCALEDIR +#mesondefine NMPLUGINDIR +#mesondefine NMRUNDIR +#mesondefine NMSTATEDIR +#mesondefine NMVPNDIR +#mesondefine NM_BUILD_BUILDDIR +#mesondefine NM_BUILD_SRCDIR +#mesondefine PPPD_PLUGIN_DIR +#mesondefine PREFIX +#mesondefine RUNDIR +#mesondefine RUNSTATEDIR +#mesondefine SYSCONFDIR diff --git a/dispatcher/meson.build b/dispatcher/meson.build index 5859a6ed85..7c92fc55c2 100644 --- a/dispatcher/meson.build +++ b/dispatcher/meson.build @@ -31,9 +31,6 @@ deps = [ ] cflags = [ - '-DLIBEXECDIR="@0@"'.format(nm_libexecdir), - '-DSYSCONFDIR="@0@"'.format(nm_sysconfdir), - '-DNMCONFDIR="@0@"'.format(nm_pkgconfdir), '-DG_LOG_DOMAIN="@0@"'.format(name), '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT', ] diff --git a/dispatcher/tests/meson.build b/dispatcher/tests/meson.build index 6ead88bf87..b18c66e53c 100644 --- a/dispatcher/tests/meson.build +++ b/dispatcher/tests/meson.build @@ -13,8 +13,7 @@ exe = executable( c_args: [ '-DNETWORKMANAGER_COMPILATION_TEST', '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT', - ] + - nm_build_cflags, + ], link_with: libnm_dispatcher_core ) diff --git a/libnm-core/meson.build b/libnm-core/meson.build index edee801ab5..686f6ad360 100644 --- a/libnm-core/meson.build +++ b/libnm-core/meson.build @@ -144,12 +144,6 @@ deps = [ cflags = [ '-DG_LOG_DOMAIN="@0@"'.format(libnm_name), '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', - '-DLIBEXECDIR="@0@"'.format(nm_libexecdir), - '-DNMLOCALEDIR="@0@"'.format(nm_localedir), - '-DNMCONFDIR="@0@"'.format(nm_pkgconfdir), - '-DNMLIBDIR="@0@"'.format(nm_pkglibdir), - '-DNMPLUGINDIR="@0@"'.format(nm_plugindir), - '-DNMVPNDIR="@0@"'.format(nm_vpndir) ] if enable_json_validation diff --git a/libnm-core/tests/meson.build b/libnm-core/tests/meson.build index 2eeadd8825..627e6b53bd 100644 --- a/libnm-core/tests/meson.build +++ b/libnm-core/tests/meson.build @@ -37,8 +37,7 @@ foreach test_unit: test_units c_args: [ '-DNETWORKMANAGER_COMPILATION_TEST', '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', - ] + - nm_build_cflags, + ], link_with: libnm_core ) test( diff --git a/libnm-glib/tests/meson.build b/libnm-glib/tests/meson.build index 3477901817..3fd37c4ff9 100644 --- a/libnm-glib/tests/meson.build +++ b/libnm-glib/tests/meson.build @@ -19,8 +19,7 @@ foreach test_unit: test_units c_args: common_cflags + [ '-DNETWORKMANAGER_COMPILATION_TEST', - ] + - nm_build_cflags, + ], ) test( diff --git a/libnm-util/meson.build b/libnm-util/meson.build index 0ba7b6ee36..da807bc6a8 100644 --- a/libnm-util/meson.build +++ b/libnm-util/meson.build @@ -102,7 +102,6 @@ deps = [ common_cflags = [ '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_UTIL', - '-DNMLOCALEDIR="@0@"'.format(nm_localedir), ] cflags = common_cflags + [ diff --git a/libnm-util/tests/meson.build b/libnm-util/tests/meson.build index cf46ad1402..49c35a516e 100644 --- a/libnm-util/tests/meson.build +++ b/libnm-util/tests/meson.build @@ -7,7 +7,7 @@ deps = [ cflags = common_cflags + [ '-DNETWORKMANAGER_COMPILATION_TEST', -] + nm_build_cflags +] test = 'test-libnm-linking' diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build index e2b882733d..27fafb77e4 100644 --- a/libnm/tests/meson.build +++ b/libnm/tests/meson.build @@ -8,7 +8,7 @@ test_units = [ cflags = [ '-DNETWORKMANAGER_COMPILATION_TEST', '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM', -] + nm_build_cflags +] foreach test_unit: test_units exe = executable( diff --git a/meson.build b/meson.build index 24e860d1df..38b01d189c 100644 --- a/meson.build +++ b/meson.build @@ -54,11 +54,6 @@ nm_pkgstatedir = join_paths(nm_localstatedir, nm_name) nm_vpndir = join_paths(nm_libdir, nm_name) nm_plugindir = join_paths(nm_libdir, nm_name, dist_version) -nm_build_cflags = [ - '-DNM_BUILD_SRCDIR="@0@"'.format(meson.source_root()), - '-DNM_BUILD_BUILDDIR="@0@"'.format(meson.build_root()), -] - libnm_name = 'libnm' current = 1 @@ -874,6 +869,44 @@ configure_file( configuration: config_h ) +config_extra_h = configuration_data() + +config_extra_h.set_quoted('BINDIR', nm_bindir) +config_extra_h.set_quoted('DATADIR', nm_datadir) +if enable_dhclient + config_extra_h.set_quoted('DHCLIENT_PATH', dhclient.path()) +endif +if enable_dhcpcanon + config_extra_h.set_quoted('DHCPCANON_PATH', dhcpcanon.path()) +endif +if enable_dhcpcd + config_extra_h.set_quoted('DHCPCD_PATH', dhcpcd.path()) +endif +config_extra_h.set_quoted('LIBEXECDIR', nm_libexecdir) +config_extra_h.set_quoted('LOCALSTATEDIR', nm_localstatedir) +config_extra_h.set_quoted('NMCONFDIR', nm_pkgconfdir) +config_extra_h.set_quoted('NMLIBDIR', nm_pkglibdir) +config_extra_h.set_quoted('NMLIBDIR', nm_pkglibdir) +config_extra_h.set_quoted('NMLOCALEDIR', nm_localedir) +config_extra_h.set_quoted('NMPLUGINDIR', nm_plugindir) +config_extra_h.set_quoted('NMRUNDIR', nm_pkgrundir) +config_extra_h.set_quoted('NMSTATEDIR', nm_pkgstatedir) +config_extra_h.set_quoted('NMVPNDIR', nm_vpndir) +config_extra_h.set_quoted('NM_BUILD_BUILDDIR', meson.build_root()) +config_extra_h.set_quoted('NM_BUILD_SRCDIR', meson.source_root()) +config_extra_h.set_quoted('PPPD_PLUGIN_DIR', pppd_plugin_dir) +config_extra_h.set_quoted('PREFIX', nm_prefix) +config_extra_h.set_quoted('RUNDIR', nm_pkgrundir) +config_extra_h.set_quoted('RUNSTATEDIR', nm_runstatedir) +config_extra_h.set_quoted('SBINDIR', nm_sbindir) +config_extra_h.set_quoted('SYSCONFDIR', nm_sysconfdir) + +configure_file( + input: 'config-extra.h.meson', + output: 'config-extra.h', + configuration: config_extra_h +) + meson.add_install_script( 'meson_post_install.py', nm_datadir, diff --git a/shared/nm-default.h b/shared/nm-default.h index b9be4768cf..8bcc5c7043 100644 --- a/shared/nm-default.h +++ b/shared/nm-default.h @@ -112,6 +112,8 @@ #include <config.h> #endif +#include "config-extra.h" + /* for internal compilation we don't want the deprecation macros * to be in effect. Define the widest range of versions to effectively * disable deprecation checks */ diff --git a/src/devices/ovs/meson.build b/src/devices/ovs/meson.build index 731965d61e..9d637fe9a2 100644 --- a/src/devices/ovs/meson.build +++ b/src/devices/ovs/meson.build @@ -15,7 +15,6 @@ libnm_device_plugin_ovs = shared_module( 'nm-device-plugin-ovs', sources: sources, dependencies: deps, - c_args: '-DRUNSTATEDIR="@0@"'.format(nm_runstatedir), link_args: ldflags_linker_script_devices, link_depends: linker_script_devices, install: true, diff --git a/src/dhcp/meson.build b/src/dhcp/meson.build index 289a16ca36..76707bcada 100644 --- a/src/dhcp/meson.build +++ b/src/dhcp/meson.build @@ -3,7 +3,6 @@ name = 'nm-dhcp-helper' cflags = [ '-DG_LOG_DOMAIN="@0@"'.format(name), '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_GLIB', - '-DNMRUNDIR="@0@"'.format(nm_pkgrundir), ] executable( diff --git a/src/dhcp/tests/meson.build b/src/dhcp/tests/meson.build index 9d8be427f3..0fee26b2a8 100644 --- a/src/dhcp/tests/meson.build +++ b/src/dhcp/tests/meson.build @@ -8,7 +8,6 @@ foreach test_unit: test_units test_unit, test_unit + '.c', dependencies: test_nm_dep, - c_args: nm_build_cflags, ) test( diff --git a/src/meson.build b/src/meson.build index abc3069a17..661c8d660d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -17,35 +17,7 @@ nm_dep = declare_dependency( compile_args: nm_cflags ) -cflags = nm_cflags + [ - '-DPREFIX="@0@"'.format(nm_prefix), - '-DBINDIR="@0@"'.format(nm_bindir), - '-DDATADIR="@0@"'.format(nm_datadir), - '-DLIBEXECDIR="@0@"'.format(nm_libexecdir), - '-DLOCALSTATEDIR="@0@"'.format(nm_localstatedir), - '-DRUNSTATEDIR="@0@"'.format(nm_runstatedir), - '-DSBINDIR="@0@"'.format(nm_sbindir), - '-DSYSCONFDIR="@0@"'.format(nm_sysconfdir), - '-DRUNDIR="@0@"'.format(nm_pkgrundir), - '-DNMCONFDIR="@0@"'.format(nm_pkgconfdir), - '-DNMLOCALEDIR="@0@"'.format(nm_localedir), - '-DNMPLUGINDIR="@0@"'.format(nm_plugindir), - '-DNMRUNDIR="@0@"'.format(nm_pkgrundir), - '-DNMSTATEDIR="@0@"'.format(nm_pkgstatedir), - '-DNMLIBDIR="@0@"'.format(nm_pkglibdir) -] - -if enable_dhcpcanon - cflags += '-DDHCPCANON_PATH="@0@"'.format(dhcpcanon.path()) -endif - -if enable_dhclient - cflags += '-DDHCLIENT_PATH="@0@"'.format(dhclient.path()) -endif - -if enable_dhcpcd - cflags += '-DDHCPCD_PATH="@0@"'.format(dhcpcd.path()) -endif +cflags = nm_cflags sources = files( 'dhcp/nm-dhcp-client.c', diff --git a/src/ppp/meson.build b/src/ppp/meson.build index 38f9a0f140..20ed64edd5 100644 --- a/src/ppp/meson.build +++ b/src/ppp/meson.build @@ -31,7 +31,6 @@ core_plugins += shared_module( name, sources: 'nm-ppp-manager.c', dependencies: deps, - c_args: '-DPPPD_PLUGIN_DIR="@0@"'.format(pppd_plugin_dir), link_args: [ '-Wl,--version-script,@0@'.format(linker_script), ], diff --git a/src/settings/plugins/ibft/meson.build b/src/settings/plugins/ibft/meson.build index 1b6ff28adc..c7dbe4590a 100644 --- a/src/settings/plugins/ibft/meson.build +++ b/src/settings/plugins/ibft/meson.build @@ -1,15 +1,9 @@ name = 'nm-settings-plugin-ibft' -cflags = [ - '-DSBINDIR="@0@"'.format(nm_sbindir), - '-DSYSCONFDIR="@0@"'.format(nm_sysconfdir) -] - libnms_ibft_core = static_library( 'nms-ibft-core', 'nms-ibft-reader.c', dependencies: nm_dep, - c_args: cflags ) sources = files( @@ -21,7 +15,6 @@ libnm_settings_plugin_ibft = shared_module( name, sources: sources, dependencies: nm_dep, - c_args: cflags, link_with: libnms_ibft_core, link_args: ldflags_linker_script_settings, link_depends: linker_script_settings, diff --git a/src/settings/plugins/ibft/tests/meson.build b/src/settings/plugins/ibft/tests/meson.build index 59f49c3104..8b5e143acf 100644 --- a/src/settings/plugins/ibft/tests/meson.build +++ b/src/settings/plugins/ibft/tests/meson.build @@ -6,7 +6,6 @@ exe = executable( test_unit, test_unit + '.c', dependencies: test_nm_dep, - c_args: nm_build_cflags, link_with: libnms_ibft_core ) diff --git a/src/settings/plugins/ifcfg-rh/meson.build b/src/settings/plugins/ifcfg-rh/meson.build index 964ce22db6..00892c22f4 100644 --- a/src/settings/plugins/ifcfg-rh/meson.build +++ b/src/settings/plugins/ifcfg-rh/meson.build @@ -3,11 +3,6 @@ install_data( install_dir: dbus_conf_dir ) -cflags = [ - '-DSBINDIR="@0@"'.format(nm_sbindir), - '-DSYSCONFDIR="@0@"'.format(nm_sysconfdir) -] - name = 'nmdbus-ifcfg-rh' dbus_sources = gnome.gdbus_codegen( @@ -21,7 +16,6 @@ libnmdbus_ifcfg_rh = static_library( name, sources: dbus_sources, dependencies: glib_dep, - c_args: cflags ) sources = files( @@ -41,7 +35,6 @@ libnms_ifcfg_rh_core = static_library( 'nms-ifcfg-rh-core', sources: sources, dependencies: deps, - c_args: cflags ) sources = [dbus_sources] + files('nms-ifcfg-rh-connection.c') @@ -50,7 +43,6 @@ libnm_settings_plugin_ifcfg_rh = shared_module( 'nm-settings-plugin-ifcfg-rh', sources: sources, dependencies: deps, - c_args: cflags, link_with: [libnms_ifcfg_rh_core], link_args: ldflags_linker_script_settings, link_depends: linker_script_settings, diff --git a/src/settings/plugins/ifcfg-rh/tests/meson.build b/src/settings/plugins/ifcfg-rh/tests/meson.build index 3d72d89257..0593f12d88 100644 --- a/src/settings/plugins/ifcfg-rh/tests/meson.build +++ b/src/settings/plugins/ifcfg-rh/tests/meson.build @@ -6,7 +6,6 @@ exe = executable( test_unit, test_unit + '.c', dependencies: test_nm_dep, - c_args: nm_build_cflags, link_with: libnms_ifcfg_rh_core ) diff --git a/src/settings/plugins/ifupdown/meson.build b/src/settings/plugins/ifupdown/meson.build index fd028f4d3e..826c745870 100644 --- a/src/settings/plugins/ifupdown/meson.build +++ b/src/settings/plugins/ifupdown/meson.build @@ -8,13 +8,10 @@ deps = [ nm_dep ] -cflags = '-DSYSCONFDIR="@0@"'.format(nm_sysconfdir) - libnms_ifupdown_core = static_library( 'nms-ifupdown-core', sources: sources, dependencies: deps, - c_args: cflags ) sources = files( @@ -26,7 +23,6 @@ libnm_settings_plugin_ifupdown = shared_module( 'nm-settings-plugin-ifupdown', sources: sources, dependencies: deps, - c_args: cflags, link_with: libnms_ifupdown_core, link_args: ldflags_linker_script_settings, link_depends: linker_script_settings, diff --git a/src/settings/plugins/ifupdown/tests/meson.build b/src/settings/plugins/ifupdown/tests/meson.build index ee3b6a340b..5a2383d99b 100644 --- a/src/settings/plugins/ifupdown/tests/meson.build +++ b/src/settings/plugins/ifupdown/tests/meson.build @@ -4,7 +4,6 @@ exe = executable( test_unit, test_unit + '.c', dependencies: test_nm_dep, - c_args: nm_build_cflags, link_with: libnms_ifupdown_core ) diff --git a/src/settings/plugins/keyfile/tests/meson.build b/src/settings/plugins/keyfile/tests/meson.build index 33aaa26436..8b94b256c6 100644 --- a/src/settings/plugins/keyfile/tests/meson.build +++ b/src/settings/plugins/keyfile/tests/meson.build @@ -6,7 +6,6 @@ exe = executable( test_unit, test_unit + '.c', dependencies: test_nm_dep, - c_args: nm_build_cflags, ) test( diff --git a/src/supplicant/tests/meson.build b/src/supplicant/tests/meson.build index b8bad7f3b8..5e4cbdbef5 100644 --- a/src/supplicant/tests/meson.build +++ b/src/supplicant/tests/meson.build @@ -4,7 +4,6 @@ exe = executable( test_unit, test_unit + '.c', dependencies: test_nm_dep, - c_args: nm_build_cflags, ) test( diff --git a/src/tests/config/meson.build b/src/tests/config/meson.build index f542c45354..fd6c89b7f8 100644 --- a/src/tests/config/meson.build +++ b/src/tests/config/meson.build @@ -11,7 +11,6 @@ exe = executable( test_unit, sources, dependencies: test_nm_dep, - c_args: nm_build_cflags, ) test( |