dhcpcd-discuss

[PATCH] configure: Don't hard-code pkg-config executable

Heiko Becker

Mon Jun 20 23:21:44 2016

Helpful if your pkg-config executable has a prefix based on the
architecture, for example.

Signed-off-by: Heiko Becker <heirecka@xxxxxxxxxxx>
---
 configure | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index f11c797..7f8992c 100755
--- a/configure
+++ b/configure
@@ -56,6 +56,7 @@ for x do
 	--datadir) DATADIR=$var;;
 	--with-ccopts|CFLAGS) CFLAGS=$var;;
 	CC) CC=$var;;
+	PKG_CONFIG) PKG_CONFIG=$var;;
 	CPPFLAGS) CPPFLAGS=$var;;
 	--with-hook) HOOKSCRIPTS="$HOOKSCRIPTS${HOOKSCRIPTS:+ }$var";;
 	--with-hooks|HOOKSCRIPTS) HOOKSCRIPTS=$var; HOOKSET=true;;
@@ -141,6 +142,7 @@ Some influential environment variables:
   CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
               headers in a nonstandard directory <include dir>
   CPP         C preprocessor
+  PKG_CONFIG  pkg-config executable
 
 Use these variables to override the choices made by \`configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -280,6 +282,10 @@ if ! type "$CC" >/dev/null 2>&1; then
 	done
 fi
 
+if [ -z "$PKG_CONFIG" ]; then
+	PKG_CONFIG=pkg-config
+fi
+
 # Set to blank, then append user config
 # We do this so our SED call to append to XCC remains portable
 if [ -n "$CFLAGS" ]; then
@@ -1204,9 +1210,9 @@ fi
 
 if [ "$DEV" != no -a "$UDEV" != no ]; then
 	printf "Checking for libudev ... "
-	if type pkg-config >/dev/null 2>&1; then
-		LIBUDEV_CFLAGS=$(pkg-config --cflags libudev 2>&3)
-		LIBUDEV_LIBS=$(pkg-config --libs libudev 2>&3)
+	if type "$PKG_CONFIG" >/dev/null 2>&1; then
+		LIBUDEV_CFLAGS=$("$PKG_CONFIG" --cflags libudev 2>&3)
+		LIBUDEV_LIBS=$("$PKG_CONFIG" --libs libudev 2>&3)
 	fi
 fi
 if [ "$DEV" != no -a "$UDEV" != no -a -n "$LIBUDEV_LIBS" ]; then
-- 
2.9.0


Follow-Ups:
Re: [PATCH] configure: Don't hard-code pkg-config executableRoy Marples
Archive administrator: postmaster@marples.name