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
This commit is contained in:
Dan Nicholson 2012-08-22 17:10:24 -07:00
parent 65e37fe303
commit 6b07296902
2 changed files with 19 additions and 0 deletions

View file

@ -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

View file

@ -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