Bring AC_SUBST(*_CFLAGS) and AC_SUBST(*_LIBS) in the same block of the
corresponding PKG_CHECK_MODULES() call.
Having these variables defined outside of the if tests is more than what
is needed as the corresponding PKG_CHECK_MODULES() might not have been
called at all there.
This is the same logic already used for USB_CFLAGS and USB_LIBS.
Call AC_SUBST unconditionally when specifying --with-* options,
otherwise options like --with-dbusconfdir=DIR or --with-udevdir=DIR have
no effect.
Before this change, configuring with:
$ mkdir build
$ ./configure --disable-systemd \
--prefix=$(pwd)/build \
--with-dbusconfdir=$(pwd)/build/etc
resulted in the option value to be ignored at "make install" time, with
this error:
/bin/mkdir: cannot create directory '/dbus-1/system.d': Permission denied
This is what was going on in configure.ac:
# define the option
AC_ARG_WITH([dbusconfdir] ... [path_dbusconfdir=${withval}])
# when --with-dbusconfdir is NOT used
if (test -z "${path_dbusconfdir}"); then
...
# define the config dir automatically
path_dbusconfdir="`$PKG_CONFIG --variable=sysconfdir dbus-1`"
...
# set DBUS_CONFDIR
AC_SUBST(DBUS_CONFDIR, [${path_dbusconfdir}])
endif
when --with-dbusconfdir=SOMEDIR was used the test above failed, and the
result was that ${path_dbusconfdir} was indeed defined as manually
specified, but DBUS_CONFDIR was not, and the latter was going to be used
in Makefile.am:
dbusdir = @DBUS_CONFDIR@/dbus-1/system.d
The failure in mkdir can be exposed by the use of the "--prefix" option
and by running "make install" as a normal user; when running "make
install" with the root user /dbus-1/system.d would be happily (and
wrongly) created.
By always setting variables relative to --with-* options (like
DBUS_CONFDIR) the cases when --with-someoption=SOMEDIR are used get
covered.
Instead of defining _GNU_SOURCE in each source file (and potentially
forgetting in some), tell the build system we use extensions and let it
define _GNU_SOURCE in config.h.
AM_PROG_MKDIR_P is deprecated since:
configure.ac:23: warning: The 'AM_PROG_MKDIR_P' macro is deprecated, and will soon be removed.
configure.ac:23: You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead,
configure.ac:23: and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files.
We are already using $(MKDIR_P) so we just need to call the right macro.