Bug 153

Summary: pkg.m4 is not robust
Product: pkg-config Reporter: J.H.M. Dassen (Ray) <jdassen>
Component: srcAssignee: Havoc Pennington <hp>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: high    
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
URL: http://bugs.debian.org/221818
Whiteboard:
i915 platform: i915 features:

Description J.H.M. Dassen (Ray) 2003-11-20 02:22:05 UTC
[Originally submitted as http://bugs.debian.org/221818]

From: Akim Demaille <akim@epita.fr>
Date: Thu, 20 Nov 2003 10:21:22 +0100

Package: pkg-config
Version: 0.15.0-3
Severity: normal

pkg.m4 is underquoted, this is somewhat dangerous.  The most problematic
underquotation is that of AC_DEFUN itself, which now triggers warnings with
modern Automake.  I suggest the following patch.  It is fully 2.13
compliant.

Thanks!

--- /usr/local/share/aclocal/pkg.m4     2003-10-31 09:34:17.000000000 +0100
+++ /tmp/pkg.m4 2003-11-20 10:12:01.000000000 +0100
@@ -1,12 +1,18 @@
+#                                              -*- Autoconf -*-

-dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
-dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
-dnl also defines GSTUFF_PKG_ERRORS on error
-AC_DEFUN(PKG_CHECK_MODULES, [
+
+# PKG_CHECK_MODULES(GSTUFF,
+#                   gtk+-2.0 >= 1.3 glib = 1.3.4,
+#                   action-if, action-not)
+# -----------------------------------------------
+# defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
+# also defines GSTUFF_PKG_ERRORS on error
+AC_DEFUN([PKG_CHECK_MODULES],
+[
   succeeded=no

   if test -z "$PKG_CONFIG"; then
-    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+    AC_PATH_PROG([PKG_CONFIG], [pkg-config], no)
   fi

   if test "$PKG_CONFIG" = "no" ; then
@@ -17,30 +23,30 @@
   else
      PKG_CONFIG_MIN_VERSION=0.9.0
      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        AC_MSG_CHECKING(for $2)
+        AC_MSG_CHECKING([for $2])

         if $PKG_CONFIG --exists "$2" ; then
             AC_MSG_RESULT(yes)
             succeeded=yes

-            AC_MSG_CHECKING($1_CFLAGS)
+            AC_MSG_CHECKING([$1_CFLAGS])
             $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
-            AC_MSG_RESULT($$1_CFLAGS)
+            AC_MSG_RESULT([$$1_CFLAGS])

-            AC_MSG_CHECKING($1_LIBS)
+            AC_MSG_CHECKING([$1_LIBS])
             $1_LIBS=`$PKG_CONFIG --libs "$2"`
-            AC_MSG_RESULT($$1_LIBS)
+            AC_MSG_RESULT([$$1_LIBS])
         else
             $1_CFLAGS=""
             $1_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
+            ## If we have a custom action on failure, don't print errors, but
             ## do set a variable so people can do so.
             $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
-            ifelse([$4], ,echo $$1_PKG_ERRORS,)
+            ifelse([$4], [], [echo $$1_PKG_ERRORS])
         fi

-        AC_SUBST($1_CFLAGS)
-        AC_SUBST($1_LIBS)
+        AC_SUBST([$1_CFLAGS])
+        AC_SUBST([$1_LIBS])
      else
         echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
         echo "*** See http://www.freedesktop.org/software/pkgconfig"
@@ -48,10 +54,12 @@
   fi

   if test $succeeded = yes; then
-     ifelse([$3], , :, [$3])
+     ifelse([$3],
+            [], :,
+            [$3])
   else
-     ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
+     ifelse([$4],
+            [], [AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.])],
+            [$4])
   fi
 ])
-
-


-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux nostromo 2.4.22 #1 SMP mer sep 17 19:49:48 CEST 2003 i686
Locale: LANG=fr_FR, LC_CTYPE=fr_FR

Versions of packages pkg-config depends on:
ii  libc6                       2.3.2.ds1-10 GNU C Library: Shared libraries an
ii  libglib2.0-0                2.2.3-1      The GLib library of C routines

-- no debconf information
Comment 1 Scott James Remnant 2004-03-18 07:06:48 UTC

*** This bug has been marked as a duplicate of 346 ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.