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 /src/meson.build | |
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
Diffstat (limited to 'src/meson.build')
-rw-r--r-- | src/meson.build | 30 |
1 files changed, 1 insertions, 29 deletions
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', |