[PATCH app/xkbcomp] Add xkboutputdir to xkbcomp.pc

Adam Jackson ajax at redhat.com
Tue Mar 7 17:42:28 UTC 2017


The X server (and everybody else, really) wants to know where to put
xkbcomp's output, so xkbcomp.pc should say. This should be under
localstatedir, since the output is architecture-dependent (as the note
in xserver/xkb/README.compiled suggests).

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 configure.ac        |  9 +++++++++
 m4/ac_define_dir.m4 | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 xkbcomp.pc.in       |  1 +
 xkbpath.c           |  4 +---
 4 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 m4/ac_define_dir.m4

diff --git a/configure.ac b/configure.ac
index 0c8063e..3c151f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,7 @@ AC_INIT([xkbcomp], [1.3.1],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xkbcomp])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
 
 # Initialize Automake
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
@@ -59,7 +60,15 @@ AC_ARG_WITH([xkb_config_root],
     [XKBCONFIGROOT="$withval"],
     [XKBCONFIGROOT='${datadir}/X11/xkb'])
 AC_SUBST([XKBCONFIGROOT])
+AC_DEFINE_DIR(DFLT_XKB_CONFIG_ROOT, XKBCONFIGROOT, [XKB config root])
 
+AC_ARG_WITH([xkb_output_path],
+    [AS_HELP_STRING([--with-xkb-output-path=<path>],
+        [Set default XKB output path (default: ${localstatedir}/xkb)])],
+    [XKBOUTPUTPATH="$withval"],
+    [XKBOUTPUTPATH='${localstatedir}/xkb'])
+AC_SUBST([XKBOUTPUTPATH])
+AC_DEFINE_DIR(DFLT_XKB_OUTPUT_PATH, XKBOUTPUTPATH, [XKB output path])
 
 AC_CONFIG_FILES([
 	Makefile
diff --git a/m4/ac_define_dir.m4 b/m4/ac_define_dir.m4
new file mode 100644
index 0000000..3a6a359
--- /dev/null
+++ b/m4/ac_define_dir.m4
@@ -0,0 +1,52 @@
+# ===========================================================================
+#             http://autoconf-archive.cryp.to/ac_define_dir.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
+#
+# DESCRIPTION
+#
+#   This macro sets VARNAME to the expansion of the DIR variable, taking
+#   care of fixing up ${prefix} and such.
+#
+#   VARNAME is then offered as both an output variable and a C preprocessor
+#   symbol.
+#
+#   Example:
+#
+#      AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.])
+#
+# LAST MODIFICATION
+#
+#   2017-03-07 - eval ac_define_dir three times instead of two, otherwise I
+#                get ${prefix}/share/X11/xkb in config.h [ajax]
+#
+# COPYLEFT
+#
+#   Copyright (c) 2008 Stepan Kasal <kasal at ucw.cz>
+#   Copyright (c) 2008 Andreas Schwab <schwab at suse.de>
+#   Copyright (c) 2008 Guido U. Draheim <guidod at gmx.de>
+#   Copyright (c) 2008 Alexandre Oliva
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+AC_DEFUN([AC_DEFINE_DIR], [
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
+dnl refers to ${prefix}.  Thus we have to use `eval' twice.
+  eval ac_define_dir="\"[$]$2\""
+  eval ac_define_dir="\"$ac_define_dir\""
+dnl Once more, but with feeling
+  eval ac_define_dir="\"$ac_define_dir\""
+  AC_SUBST($1, "$ac_define_dir")
+  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
+])
diff --git a/xkbcomp.pc.in b/xkbcomp.pc.in
index b8d6023..c5ccde5 100644
--- a/xkbcomp.pc.in
+++ b/xkbcomp.pc.in
@@ -2,6 +2,7 @@ prefix=@prefix@
 datarootdir=@datarootdir@
 datadir=@datadir@
 xkbconfigdir=@XKBCONFIGROOT@
+xkboutputdir=@XKBOUTPUTPATH@
 
 Name: xkbcomp
 Description: XKB keymap compiler
diff --git a/xkbpath.c b/xkbpath.c
index 6f18b86..3345ba9 100644
--- a/xkbpath.c
+++ b/xkbpath.c
@@ -33,9 +33,7 @@
 #include <X11/extensions/XKM.h>
 #include "xkbpath.h"
 
-#ifndef DFLT_XKB_CONFIG_ROOT
-#define DFLT_XKB_CONFIG_ROOT	"/usr/lib/X11/xkb"
-#endif
+#include "config.h"
 
 #ifndef PATH_MAX
 #define	PATH_MAX 1024
-- 
2.9.3



More information about the xorg-devel mailing list