Propagation of configured installation paths to Makefile.am and .c code

This commit is a continuation of the previous one in which all the configured
paths obtained in configure.ac are propagated to the Makefile.am and .c files
via AM_CPPFLAGS of the form -DUDEV_CONF_FILE=\"$(udevconffile)\". This should
address the issue in

  https://github.com/gentoo/eudev/issues/17

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
This commit is contained in:
Anthony G. Basile 2012-11-23 18:56:16 -05:00
parent e5cc2b881f
commit 6cb86c3a33
11 changed files with 33 additions and 27 deletions

View File

@ -145,12 +145,12 @@ AC_SUBST([udevlibexecdir], [${with_rootlibdir}/udev])
# sysconfdir paths
AC_SUBST([udevconfdir],[${sysconfdir}/udev])
AC_SUBST([udevhwdbdir],[${sysconfdir}/hwdb.d])
AC_SUBST([udevkeymapdir],[${sysconfdir}/keymaps])
AC_SUBST([udevkeymapforcereldir],[${sysconfdir}/keymaps/force-release])
# libexecdir paths
AC_SUBST([udevrulesdir],[${udevlibexecdir}/rules.d])
AC_SUBST([udevconffile],[${udevconfdir}/udev.conf])
AC_SUBST([udevhwdbdir],[${udevconfdir}/hwdb.d])
AC_SUBST([udevhwdbbin],[${udevconfdir}/hwdb.bin])
AC_SUBST([udevkeymapdir],[${udevconfdir}/keymaps])
AC_SUBST([udevkeymapforceredir],[${udevkeymapdir}/force-release])
AC_SUBST([udevrulesdir],[${udevconfdir}/rules.d])
# pkgconfigdir paths
AC_SUBST([sharepkgconfigdir],[${datadir}/pkgconfig])

View File

@ -1,8 +1,8 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
udevkeymapforcereldir = @udevkeymapforcereldir@
udevkeymapforceredir = @udevkeymapforceredir@
dist_udevkeymapforcerel_DATA = \
dist_udevkeymapforcere_DATA = \
dell-touchpad \
dell-xps \
hp-other \

View File

@ -5,7 +5,7 @@ udevlibexecdir=@udevlibexecdir@
AM_CPPFLAGS = \
-I $(top_srcdir)/src/libudev \
-I $(top_srcdir)/src/udev \
-DUDEVLIBEXECDIR=\"$(udevlibexecdir)\"
-DUDEV_LIBEXEC_DIR=\"$(udevlibexecdir)\"
udevlibexec_PROGRAMS = \
keymap

View File

@ -429,7 +429,7 @@ int main(int argc, char **argv)
if (f) {
merge_table(fd, f);
} else {
snprintf(keymap_path, sizeof(keymap_path), UDEVLIBEXECDIR "/keymaps/%s", filearg);
snprintf(keymap_path, sizeof(keymap_path), UDEV_LIBEXEC_DIR "/keymaps/%s", filearg);
f = fopen(keymap_path, "re");
if (f)
merge_table(fd, f);

View File

@ -5,6 +5,8 @@ LIBUDEV_REVISION=0
LIBUDEV_AGE=2
AM_CPPFLAGS = \
-DUDEV_CONF_FILE=\"$(udevconffile)\" \
-DUDEV_HWDB_BIN=\"$(udevhwdbbin)\" \
-I $(top_srcdir)/src/udev
lib_LTLIBRARIES = \

View File

@ -271,30 +271,30 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
hwdb->refcount = 1;
udev_list_init(udev, &hwdb->properties_list, true);
hwdb->f = fopen("/etc/udev/hwdb.bin", "re");
hwdb->f = fopen(UDEV_HWDB_BIN, "re");
if (!hwdb->f) {
log_debug("error reading /etc/udev/hwdb.bin: %m");
log_debug("error reading " UDEV_HWDB_BIN ": %m");
udev_hwdb_unref(hwdb);
return NULL;
}
if (fstat(fileno(hwdb->f), &hwdb->st) < 0 ||
(size_t)hwdb->st.st_size < offsetof(struct trie_header_f, strings_len) + 8) {
log_debug("error reading /etc/udev/hwdb.bin: %m");
log_debug("error reading " UDEV_HWDB_BIN ": %m");
udev_hwdb_unref(hwdb);
return NULL;
}
hwdb->map = mmap(0, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
if (hwdb->map == MAP_FAILED) {
log_debug("error mapping /etc/udev/hwdb.bin: %m");
log_debug("error mapping " UDEV_HWDB_BIN ": %m");
udev_hwdb_unref(hwdb);
return NULL;
}
if (memcmp(hwdb->map, sig, sizeof(hwdb->head->signature)) != 0 ||
(size_t)hwdb->st.st_size != le64toh(hwdb->head->file_size)) {
log_debug("error recognizing the format of /etc/udev/hwdb.bin");
log_debug("error recognizing the format of " UDEV_HWDB_BIN);
udev_hwdb_unref(hwdb);
return NULL;
}

View File

@ -127,7 +127,7 @@ _public_ struct udev *udev_new(void)
udev->log_priority = LOG_ERR;
udev_list_init(udev, &udev->properties_list, true);
f = fopen("/etc/udev/udev.conf", "re");
f = fopen( UDEV_CONF_FILE, "re");
if (f != NULL) {
char line[UTIL_LINE_SIZE];
int line_nr = 0;
@ -151,7 +151,7 @@ _public_ struct udev *udev_new(void)
/* split key/value */
val = strchr(key, '=');
if (val == NULL) {
udev_err(udev, "missing <key>=<value> in /etc/udev/udev.conf[%i]; skip line\n", line_nr);
udev_err(udev, "missing <key>=<value> in " UDEV_CONF_FILE "[%i]; skip line\n", line_nr);
continue;
}
val[0] = '\0';
@ -183,7 +183,7 @@ _public_ struct udev *udev_new(void)
/* unquote */
if (val[0] == '"' || val[0] == '\'') {
if (val[len-1] != val[0]) {
udev_err(udev, "inconsistent quoting in /etc/udev/udev.conf[%i]; skip line\n", line_nr);
udev_err(udev, "inconsistent quoting in " UDEV_CONF_FILE"[%i]; skip line\n", line_nr);
continue;
}
val[len-1] = '\0';

View File

@ -7,7 +7,10 @@ AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
-DMODPROBE=\"$(MODPROBE)\" \
-DROOTPREFIX=\"$(rootprefix)\" \
-DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" \
-DUDEV_HWDB_DIR=\"$(udevhwdbdir)\" \
-DUDEV_HWDB_BIN=\"$(udevhwdbbin)\" \
-DUDEV_RULES_DIR=\"$(udevrulesdir)\" \
-DUDEV_LIBEXEC_DIR=\"$(udevlibexecdir)\" \
-I $(top_srcdir)/src/libudev
sbin_PROGRAMS = \

View File

@ -688,7 +688,7 @@ int udev_event_spawn(struct udev_event *event,
/* allow programs in /usr/lib/udev/ to be called without the path */
if (argv[0][0] != '/') {
util_strscpyl(program, sizeof(program), UDEVLIBEXECDIR "/", argv[0], NULL);
util_strscpyl(program, sizeof(program), UDEV_LIBEXEC_DIR "/", argv[0], NULL);
#ifdef HAVE_SPLIT_USR
if(access(program, X_OK))
util_strscpyl(program, sizeof(program), "/lib/udev/", argv[0], NULL);

View File

@ -1600,9 +1600,9 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
if (!rules->strbuf)
return udev_rules_unref(rules);
rules->dirs = strv_new("/etc/udev/rules.d",
rules->dirs = strv_new(UDEV_RULES_DIR,
"/run/udev/rules.d",
UDEVLIBEXECDIR "/rules.d",
UDEV_LIBEXEC_DIR "/rules.d",
#ifdef HAVE_SPLIT_USR
"/lib/udev/rules.d",
#endif

View File

@ -35,8 +35,8 @@
*/
static const char * const conf_file_dirs[] = {
"/etc/udev/hwdb.d",
UDEVLIBEXECDIR "/hwdb.d",
UDEV_HWDB_DIR,
UDEV_LIBEXEC_DIR "/hwdb.d",
NULL
};
@ -570,10 +570,11 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
log_debug("strings dedup'ed: %8zu bytes (%8zu)\n",
trie->strings->dedup_len, trie->strings->dedup_count);
mkdir_parents("/etc/udev/hwdb.bin", 0755);
err = trie_store(trie, "/etc/udev/hwdb.bin");
mkdir_parents(UDEV_HWDB_BIN, 0755);
err = trie_store(trie, UDEV_HWDB_BIN);
if (err < 0) {
log_error("Failure writing hardware database '%s': %s", "/etc/udev/hwdb.bin", strerror(-err));
log_error("Failure writing hardware database '%s': %s",
UDEV_HWDB_BIN, strerror(-err));
rc = EXIT_FAILURE;
}
}