--- a/config/gdlib-config.in
+++ b/config/gdlib-config.in
@@ -2,14 +2,9 @@
 #
 # Return information about the local GD library installation
 #
-# Modeled after pdflib-config
+# Modified to use pkgconfig
 
-# installation directories
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-bindir=@bindir@
+pkg=gdlib
 
 usage()
 {
@@ -50,43 +45,43 @@ while test $# -gt 0; do
 
     case $1 in
     --libdir)
-	echo $libdir
+	pkg-config --variable=libdir ${pkg}
 	;;
     --includedir)
-	echo $includedir
+	pkg-config --variable=includedir ${pkg}
 	;;
     --version)
-	echo @VERSION@
+	pkg-config --modversion ${pkg}
 	;;
     --majorversion)
-	echo @GDLIB_MAJOR@
+	pkg-config --modversion ${pkg} | cut -f 1 -d .
 	;;
     --minorversion)
-	echo @GDLIB_MINOR@
+	pkg-config --modversion ${pkg} | cut -f 2 -d .
 	;;
     --revision)
-	echo @GDLIB_REVISION@
+	pkg-config --modversion ${pkg} | cut -f 3 -d .
 	;;
     --ldflags)
-	echo @LDFLAGS@
+	pkg-config --libs-only-L ${pkg}
 	;;
     --libs)
-	echo -lgd @LIBS@ @LIBICONV@
+	pkg-config --libs ${pkg}
 	;;
     --cflags|--includes)
-	echo -I@includedir@
+	pkg-config --cflags ${pkg}
 	;;
     --features)
 	echo @FEATURES@
 	;;
     --all)
-	echo "GD library  @VERSION@"
-	echo "includedir: $includedir"
-	echo "cflags:     -I@includedir@"
-	echo "ldflags:    @LDFLAGS@"
-	echo "libs:       @LIBS@ @LIBICONV@"
-	echo "libdir:     $libdir"
-	echo "features:   @FEATURES@"
+	echo "GD library  $($0 --version)@"
+	echo "includedir: $($0 --includedir)"
+	echo "cflags:     $($0 --cflags)"
+	echo "ldflags:    $($0 --ldflags)"
+	echo "libs:       $($0 --libs)"
+	echo "libdir:     $($0 --libdir)"
+	echo "features:   $($0 --features)"
 	;;
     *)
 	usage 1 1>&2
