dnl CF_WITH_PKG_CONFIG_LIBDIR version: 10 updated: 2015/08/22 17:10:56
dnl -------------------------
dnl Allow the choice of the pkg-config library directory to be overridden.
AC_DEFUN([CF_WITH_PKG_CONFIG_LIBDIR],[

case $PKG_CONFIG in
(no|none|yes)
	AC_MSG_CHECKING(for pkg-config library directory)
	;;
(*)
	AC_MSG_CHECKING(for $PKG_CONFIG library directory)
	;;
esac

PKG_CONFIG_LIBDIR=no
AC_ARG_WITH(pkg-config-libdir,
	[  --with-pkg-config-libdir=XXX use given directory for installing pc-files],
	[PKG_CONFIG_LIBDIR=$withval],
	[test "x$PKG_CONFIG" != xnone && PKG_CONFIG_LIBDIR=yes])

case x$PKG_CONFIG_LIBDIR in
(x/*)
	;;
(xyes)
	# Look for the library directory using the same prefix as the executable
	if test "x$PKG_CONFIG" = xnone
	then
		cf_path=$prefix
	else
		cf_path=`echo "$PKG_CONFIG" | sed -e 's,/[[^/]]*/[[^/]]*$,,'`
	fi

	# If you don't like using the default architecture, you have to specify the
	# intended library directory and corresponding compiler/linker options.
	#
	# This case allows for Debian's 2014-flavor of multiarch, along with the
	# most common variations before that point.  Some other variants spell the
	# directory differently, e.g., "pkg-config", and put it in unusual places.
	# pkg-config has always been poorly standardized, which is ironic...
	case x`(arch) 2>/dev/null` in
	(*64)
		cf_search_path="\
			$cf_path/lib/*64-linux-gnu \
			$cf_path/share \
			$cf_path/lib64 \
			$cf_path/lib32 \
			$cf_path/lib"
		;;
	(*)
		cf_search_path="\
			$cf_path/lib/*-linux-gnu \
			$cf_path/share \
			$cf_path/lib32 \
			$cf_path/lib \
			$cf_path/libdata"
		;;
	esac

	CF_VERBOSE(list...)
	for cf_config in $cf_search_path
	do
		CF_VERBOSE(checking $cf_config/pkgconfig)
		if test -d $cf_config/pkgconfig
		then
			PKG_CONFIG_LIBDIR=$cf_config/pkgconfig
			AC_MSG_CHECKING(done)
			break
		fi
	done
	;;
(*)
	;;
esac

if test "x$PKG_CONFIG_LIBDIR" != xno ; then
	AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
fi

AC_SUBST(PKG_CONFIG_LIBDIR)
])dnl
