From 6b0729690287d6223269fc4cd8fa084c36ca1f01 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Wed, 22 Aug 2012 17:10:24 -0700 Subject: [PATCH] Install pkg-config link with $host- prefix If pkg-config is used in a multiarch or cross-compiling scenario it's likely pkg-config needs to behave differently for each of them. It's possible to handle this through environment variables with one pkg-config, but another option is to have one pkg-config per platform, each with the host alias prefixed to the program. PKG_PROG_PKG_CONFIG supports this type of installation, and this is also how autoconf/libtool handle other build tools like compilers and linkers. The host-prefixed tool is installed as a hardlink where supported and a copy otherwise. This is how gcc handles it's host-prefixed versions. This feature can be turned off by passing --disable-host-tool to configure. Freedesktop #130 --- Makefile.am | 6 ++++++ configure.ac | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Makefile.am b/Makefile.am index 9c224ac..d3e3c61 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,6 +36,12 @@ pkg_config_SOURCES= \ parse.c \ main.c +if HOST_TOOL +host_tool = $(host)-pkg-config$(EXEEXT) +install-exec-hook: + cd $(DESTDIR)$(bindir) && $(LN) pkg-config$(EXEEXT) $(host_tool) +endif + # Various data files m4dir = $(datadir)/aclocal dist_m4_DATA = pkg.m4 diff --git a/configure.ac b/configure.ac index 3909055..bfb802c 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) dnl Check for programs AC_PROG_CC +AC_CHECK_PROG([LN], [ln], [ln], [cp -Rp]) dnl Check for headers AC_CHECK_HEADERS([dirent.h unistd.h sys/wait.h malloc.h]) @@ -203,6 +204,18 @@ if test "x$with_gcov" = xyes; then fi AC_SUBST([GCOV_CFLAGS]) +dnl See if the user wants a host- prefixed tool +dnl (e.g. i686-pc-linux-gnu-pkg-config) to be installed. +dnl +AC_MSG_CHECKING([if host- prefixed tool should be installed]) +AC_ARG_ENABLE([host-tool], + [AS_HELP_STRING([--disable-host-tool], + [install link to pkg-config with $host- prefix @<:@default=yes@:>@])], + [], + [enable_host_tool=yes]) +AC_MSG_RESULT([$enable_host_tool]) +AM_CONDITIONAL([HOST_TOOL], [test "x$enable_host_tool" = xyes]) + AC_CONFIG_FILES([ Makefile check/Makefile