Permalink
Browse files

check pkg-config before xxx-config scripts

It's easier to manage pkg-config when cross-compiling, and libdvdread
installs .pc files, so check those first.

Patch provided by Mike Frysinger <vapier AT gentoo DOT org>, Thanks!
  • Loading branch information...
1 parent e1c3812 commit 60fd12cd6a854bbc51404fa6a9d00c313bf83f74 @microe committed Apr 17, 2012
Showing with 21 additions and 9 deletions.
  1. +21 −9 configure.ac
View
30 configure.ac
@@ -89,6 +89,7 @@ AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_LN_S
+PKG_PROG_PKG_CONFIG
dnl --------------------------------------------------------------
dnl Libtool
@@ -185,15 +186,26 @@ AC_ARG_WITH([dvdread-config],
[AS_HELP_STRING([--with-dvdread-config=PROG],
[dvdread-config program to use @<:@default=from PATH@:>@])],
[DVDREAD_CONFIG="$withval"],
- [dnl User didn't specify program, search PATH
- AC_PATH_PROG([DVDREAD_CONFIG], [dvdread-config], [no])
- test "x$DVDREAD_CONFIG" = xno && \
- AC_MSG_ERROR([dvdread-config required to link with libdvdread])
- ])
-DVDREAD_CFLAGS=`$DVDREAD_CONFIG --cflags` || \
- AC_MSG_ERROR([Could not get libdvdread CFLAGS from $DVDREAD_CONFIG])
-DVDREAD_LIBS=`$DVDREAD_CONFIG --libs` || \
- AC_MSG_ERROR([Could not get libdvdread LIBS from $DVDREAD_CONFIG])
+ [DVDREAD_CONFIG=""])
+
+dnl by default, search pkg-config, and then fall back to dvdread-config
+DVDREAD_PKG_CONFIG="no"
+if test "x$DVDREAD_CONFIG" = "x"; then
+ PKG_CHECK_MODULES([DVDREAD], [dvdread],
+ [DVDREAD_PKG_CONFIG="yes"],
+ [dnl User didn't specify program, search PATH
+ AC_PATH_PROG([DVDREAD_CONFIG], [dvdread-config], [no])
+ test "x$DVDREAD_CONFIG" = xno && \
+ AC_MSG_ERROR([dvdread-config required to link with libdvdread])
+ ])
+fi
+if test "x$DVDREAD_PKG_CONFIG" != "xyes"; then
+ DVDREAD_CFLAGS=`$DVDREAD_CONFIG --cflags` || \
+ AC_MSG_ERROR([Could not get libdvdread CFLAGS from $DVDREAD_CONFIG])
+ DVDREAD_LIBS=`$DVDREAD_CONFIG --libs` || \
+ AC_MSG_ERROR([Could not get libdvdread LIBS from $DVDREAD_CONFIG])
+fi
+
AC_SUBST([DVDREAD_CFLAGS])
AC_SUBST([DVDREAD_LIBS])

0 comments on commit 60fd12c

Please sign in to comment.