Skip to content

Commit

Permalink
build: cleanup defining SYSCONFDIR on command line
Browse files Browse the repository at this point in the history
Optimally, ./configure defines things in include/config.h. However,
that does not work well with defines that contain path names (see [1]).

Continue to use "-D" command line option. However, factor out the
definition to one place.

Also, rename from SYSCONFDIR to _NL_SYSCONFDIR_LIBNL.

Note that "src_lib_libnl_cli_3_la_CPPFLAGS" defined to
-DSYSCONFDIR=\"$(sysconfdir)\", without the "libnl" subdirectory. In
this case, the define was never used. The change doesn't matter.

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html
  • Loading branch information
thom311 committed May 29, 2024
1 parent cf47571 commit 81cab7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ warn_cppflags = \
-Wno-unused-parameter \
$(NULL)

defines_cppflags = \
-D_NL_SYSCONFDIR_LIBNL=\"$(sysconfdir)/libnl\" \
$(NULL)

###############################################################################

libnlincludedir = $(includedir)/libnl@MAJ_VERSION@
Expand Down Expand Up @@ -391,8 +395,8 @@ default_includes = \

lib_cppflags = \
$(warn_cppflags) \
$(defines_cppflags) \
-D_GNU_SOURCE \
-DSYSCONFDIR=\"$(sysconfdir)/libnl\" \
$(default_includes) \
$(NULL)

Expand Down Expand Up @@ -709,9 +713,9 @@ EXTRA_src_lib_libnl_cli_3_la_DEPENDENCIES = \
libnl-cli-3.sym
src_lib_libnl_cli_3_la_CPPFLAGS = \
$(warn_cppflags) \
$(defines_cppflags) \
-D_GNU_SOURCE \
-DPKGLIBDIR=\"$(pkglibdir)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
$(default_includes) \
$(NULL)
src_lib_libnl_cli_3_la_LDFLAGS = \
Expand All @@ -729,8 +733,8 @@ src_lib_libnl_cli_3_la_LIBADD = \

src_cppflags = \
$(warn_cppflags) \
$(defines_cppflags) \
-D_GNU_SOURCE \
-DSYSCONFDIR=\"$(sysconfdir)/libnl\" \
$(default_includes) \
$(NULL)

Expand Down Expand Up @@ -909,8 +913,8 @@ src_nl_util_addr_LDADD = $(src_ldadd)

tests_cppflags = \
$(warn_cppflags) \
$(defines_cppflags) \
-D_GNU_SOURCE \
-DSYSCONFDIR=\"$(sysconfdir)/libnl\" \
$(default_includes) \
$(NULL)

Expand Down
2 changes: 1 addition & 1 deletion lib/route/nl-route.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static inline int build_sysconf_path(char **strp, const char *filename)
sysconfdir = getenv("NLSYSCONFDIR");

if (!sysconfdir)
sysconfdir = SYSCONFDIR;
sysconfdir = _NL_SYSCONFDIR_LIBNL;

return asprintf(strp, "%s/%s", sysconfdir, filename);
}
Expand Down

0 comments on commit 81cab7d

Please sign in to comment.