dnl CF_WITH_PKG_CONFIG_LIBDIR version: 2 updated: 2011/12/10 18:58:47
dnl -------------------------
dnl Allow the choice of the pkg-config library directory to be overridden.
AC_DEFUN([CF_WITH_PKG_CONFIG_LIBDIR],[
if test "$PKG_CONFIG" != none ; then
	AC_MSG_CHECKING(for $PKG_CONFIG library directory)
	AC_ARG_WITH(pkg-config-libdir,
		[  --with-pkg-config-libdir=XXX use given directory for installing pc-files],
		[PKG_CONFIG_LIBDIR=$withval],
		[PKG_CONFIG_LIBDIR=yes])

	case x$PKG_CONFIG_LIBDIR in #(vi
	x/*) #(vi
		;;
	xyes) #(vi
		# look for the library directory using the same prefix as the executable
		cf_path=`echo "$PKG_CONFIG" | sed -e 's,/[[^/]]*/[[^/]]*$,,'`
		case x`(arch) 2>/dev/null` in #(vi
		*64) #(vi
			for cf_config in $cf_path/share $cf_path/lib64 $cf_path/lib32 $cf_path/lib
			do
				if test -d $cf_config/pkgconfig
				then
					PKG_CONFIG_LIBDIR=$cf_config/pkgconfig
					break
				fi
			done
			;;
		*)
			PKG_CONFIG_LIBDIR=$cf_path/lib/pkgconfig
			;;
		esac
		;;
	*)
		;;
	esac

	AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
fi

AC_SUBST(PKG_CONFIG_LIBDIR)
])dnl
