diff --git a/configure.ac b/configure.ac
index bc9acc9..94449f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1876,12 +1876,12 @@ then
   fi
   AC_CHECK_HEADER([zconf.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
   AC_CHECK_HEADER([zlib.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
-  AC_CHECK_LIB([z],[compress],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-  AC_CHECK_LIB([z],[uncompress],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-  AC_CHECK_LIB([z],[deflate],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-  AC_CHECK_LIB([z],[inflate],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-  AC_CHECK_LIB([z],[gzseek],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-  AC_CHECK_LIB([z],[gztell],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+  AC_SEARCH_LIBS([compress],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+  AC_SEARCH_LIBS([uncompress],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+  AC_SEARCH_LIBS([deflate],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+  AC_SEARCH_LIBS([inflate],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+  AC_SEARCH_LIBS([gzseek],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+  AC_SEARCH_LIBS([gztell],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
   AC_MSG_CHECKING([if ZLIB package is complete])
   if test $passed -gt 0
   then
@@ -1895,8 +1895,7 @@ then
       LDFLAGS=$OLD_LDFLAGS
       LIBS=$OLD_LIBS
     else
-      LIB_ZLIB='-lz'
-      pkg_config_to_flags 'zlib' "${LIB_ZLIB}" ''
+      LIB_ZLIB=''
       AC_DEFINE([HasZLIB],[1],[Define if you have zlib compression library])
       AC_MSG_RESULT([yes])
       have_zlib='yes'
@@ -1922,8 +1921,10 @@ then
   failed=0
   passed=0
   found_libbz=0
+  PKG_CHECK_MODULES([BZIP2], [bzip2], [passed=`expr $passed + 1`], [failed=`expr $failed + 1`])
+  pkg_config_to_flags 'bzip2' "${BZIP2_LIBS}" "${BZIP2_CFLAGS}"
   AC_CHECK_HEADER([bzlib.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
-  AC_CHECK_LIB([bz2],[BZ2_bzDecompress],[found_libbz=`expr $found_libbz + 1`],,)
+  AC_SEARCH_LIBS([BZ2_bzDecompress],[],[found_libbz=`expr $found_libbz + 1`],,)
   if test "$native_win32_build" = 'yes'
   then
     # Under MinGW, libbz2 obfuscates its functions by declaring them
@@ -1931,7 +1932,7 @@ then
     # somehow include bzlib.h during the test but Autoconf does not
     # make that possible.  We check for BZ2_decompress since that is
     # one of the few functions exported from the DLL (very strange).
-    AC_CHECK_LIB([bz2],[_imp__BZ2_decompress],[found_libbz=`expr $found_libbz + 1`],,)
+    :
   fi
   if test $found_libbz -gt 0
   then
@@ -1950,8 +1951,7 @@ then
       AC_MSG_RESULT([no -- some components failed test])
       have_bzlib='no (failed tests)'
     else
-      LIB_BZLIB='-lbz2'
-      LIBS="$LIB_BZLIB $LIBS"
+      LIB_BZLIB=''
       AC_DEFINE([HasBZLIB],[1],[Define if you have the bzip2 library])
       AC_MSG_RESULT([yes])
       have_bzlib='yes'
@@ -2391,7 +2391,18 @@ then
         if test "x${var}" = 'x' ; then
           pnglib='png'
         else
-          pnglib="png1${var}"
+          case "${PNG_LIBS}" in
+          *-lpng1${var}d*)
+            pnglib="png1${var}d"
+            ;;
+          *-lpng1${var}*)
+            pnglib="png1${var}"
+            ;;
+          *)
+            # don't pick system lib
+            pnglib="NOT_IN_PC_FILE"
+            ;;
+          esac
         fi
         if test "$have_png" = 'no'
         then
@@ -2457,8 +2468,7 @@ return 0;
                   LDFLAGS=$OLD_LDFLAGS
                   LIBS=$OLD_LIBS
                 else
-                  LIB_PNG="-l${pnglib}"
-                  pkg_config_to_flags 'libpng' "${LIB_PNG}" ''
+                  LIB_PNG=''
                   #LIBS="$LIB_PNG $LIBS"
                   AC_DEFINE([HasPNG],[1],[Define if you have PNG library])
                   AC_MSG_RESULT([yes])
@@ -2515,7 +2525,7 @@ then
     AC_CHECK_HEADER([jerror.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
     AC_CHECK_HEADER([jmorecfg.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
     AC_CHECK_HEADER([jpeglib.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
-    AC_CHECK_LIB([jpeg],[jpeg_read_header],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+    AC_SEARCH_LIBS([jpeg_read_header],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
     AC_MSG_CHECKING([if JPEG package is complete])
     if test $passed -gt 0
     then
@@ -2527,8 +2537,7 @@ then
         LDFLAGS=$OLD_LDFLAGS
         LIBS=$OLD_LIBS
     else
-        LIB_JPEG='-ljpeg'
-        pkg_config_to_flags 'libjpeg' "${LIB_JPEG}" ''
+        LIB_JPEG=''
         #LIBS="$LIB_JPEG $LIBS"
         AC_DEFINE([HasJPEG],[1],[Define if you have JPEG library])
         AC_MSG_RESULT([yes])
@@ -2624,7 +2633,7 @@ then
     fi
 
 dnl First see if there is a library
-    AC_CHECK_LIB([freetype],[FT_Init_FreeType],[LIB_TTF="-lfreetype"],[LIB_TTF=''],[])
+    AC_SEARCH_LIBS([FT_Init_FreeType],[],[LIB_TTF="-lfreetype"],[LIB_TTF=''],[])
     if test "$LIB_TTF" != ''
     then
       passed=`expr $passed + 1`
@@ -2665,7 +2674,7 @@ dnl Now test for the headers
             LDFLAGS=$OLD_LDFLAGS
             LIBS=$OLD_LIBS
         else
-            pkg_config_to_flags 'freetype2' "${LIB_TTF}" ''
+            LIB_TTF=''
             #LIBS="$LIB_TTF $LIBS"
             AC_DEFINE([HasTTF],[1],[Define if you have FreeType (TrueType font) library])
             if test "$ac_cv_header_ft2build_h" = 'yes'
@@ -2718,7 +2727,6 @@ then
         printf "WEBPMUX_LIBS=${WEBPMUX_LIBS}\n"
         printf "WEBPMUX_CFLAGS=${WEBPMUX_CFLAGS}\n"
       fi
-      pkg_config_to_flags 'libwebpmux' "${WEBPMUX_LIBS}" "${WEBPMUX_CFLAGS}"
     else
       if test -n "${WEBPMUX_PKG_ERRORS}"
       then
@@ -2742,7 +2750,7 @@ then
 
     # pkg-config libwebp --static --libs
     #-L/work/lib -lwebp -lm -lsharpyuv -lm
-    PKG_CHECK_MODULES([WEBP], [libwebp], [passed=`expr $passed + 1`], [failed=`expr $failed + 1`])
+    PKG_CHECK_MODULES([WEBP], [libwebp libwebpmux], [passed=`expr $passed + 1`], [failed=`expr $failed + 1`])
     if test $failed -eq 0 ; then
       if test -n "$VERBOSE"
       then
@@ -2760,9 +2768,9 @@ then
 
     AC_CHECK_HEADER([webp/decode.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],[])
     AC_CHECK_HEADER([webp/encode.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],[])
-    AC_CHECK_LIB([webp],[WebPDecodeRGB],[passed=`expr $passed + 1`; LIB_WEBP='-lwebp'],[failed=`expr $failed + 1`],[])
-    AC_CHECK_LIB([webpmux],[WebPMuxSetImage],[LIB_WEBP="$LIB_WEBP -lwebpmux"],[],[-lwebp])
-    AC_CHECK_LIB([sharpyuv],[SharpYuvConvert],[LIB_WEBP="$LIB_WEBP -lsharpyuv"],[],[])
+    AC_SEARCH_LIBS([WebPDecodeRGB],[],[passed=`expr $passed + 1`; LIB_WEBP='-lwebp'],[failed=`expr $failed + 1`],[])
+    AC_SEARCH_LIBS([WebPMuxSetImage],[],[LIB_WEBP="$LIB_WEBP -lwebpmux"],[],[])
+    AC_SEARCH_LIBS([SharpYuvConvert],[],[LIB_WEBP="$LIB_WEBP -lsharpyuv"],[],[])
     AC_MSG_CHECKING([if WEBP package is complete])
     if test $passed -gt 0
     then
@@ -2774,7 +2782,7 @@ then
             LDFLAGS=$OLD_LDFLAGS
             LIBS=$OLD_LIBS
         else
-            pkg_config_to_flags 'libwebp' "${LIB_WEBP}" ''
+            LIB_WEBP=''
             # LIBS="$LIB_WEBP $LIBS"
             AC_DEFINE([HasWEBP],[1],[Define if you have WEBP library])
             AC_MSG_RESULT([yes])
@@ -2918,11 +2926,11 @@ then
     #set +x
     AC_CHECK_HEADER([tiff.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
     AC_CHECK_HEADER([tiffio.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
-    AC_CHECK_LIB([tiff],[TIFFOpen],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-    AC_CHECK_LIB([tiff],[TIFFClientOpen],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-    AC_CHECK_LIB([tiff],[TIFFIsByteSwapped],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-    AC_CHECK_LIB([tiff],[TIFFReadRGBATile],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
-    AC_CHECK_LIB([tiff],[TIFFReadRGBAStrip],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+    AC_SEARCH_LIBS([TIFFOpen],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+    AC_SEARCH_LIBS([TIFFClientOpen],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+    AC_SEARCH_LIBS([TIFFIsByteSwapped],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+    AC_SEARCH_LIBS([TIFFReadRGBATile],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
+    AC_SEARCH_LIBS([TIFFReadRGBAStrip],[],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
     AC_MSG_CHECKING([if TIFF package is complete])
     if test $passed -gt 0
     then
@@ -2934,8 +2942,7 @@ then
             CPPFLAGS=$OLD_CPPFLAGS
             LIBS=$OLD_LIBS
         else
-            LIB_TIFF='-ltiff'
-            pkg_config_to_flags 'libtiff-4' "${LIB_TIFF}" ''
+            LIB_TIFF=''
             #LIBS="$LIB_TIFF $LIBS"
             AC_DEFINE([HasTIFF],[1],[Define if you have TIFF library])
             AC_MSG_RESULT([yes])
@@ -4266,7 +4273,7 @@ MAGICK_EXTRA_DEP_LIBS=`echo $MAGICK_EXTRA_DEP_LIBS | sed -e 's/  */ /g'`
 
 MAGICK_API_CFLAGS=$CFLAGS
 MAGICK_API_CPPFLAGS=`echo $MAGICK_API_CPPFLAGS | sed -e 's/  */ /g'`
-MAGICK_API_LDFLAGS="-L$LIB_DIR $LDFLAGS"
+MAGICK_API_LDFLAGS="-L$LIB_DIR"
 MAGICK_API_DEP_LIBS="$MAGICK_DEP_LIBS"
 MAGICK_API_LIBS="-lGraphicsMagick $MAGICK_API_DEP_LIBS $MAGICK_EXTRA_DEP_LIBS"
 
diff --git a/magick/GraphicsMagick.pc.in b/magick/GraphicsMagick.pc.in
index e968715..6b7c404 100644
--- a/magick/GraphicsMagick.pc.in
+++ b/magick/GraphicsMagick.pc.in
@@ -9,5 +9,5 @@ Version: @PACKAGE_VERSION@
 Description: GraphicsMagick image processing library
 URL: http://www.graphicsmagick.org/
 Libs: -L${libdir} -lGraphicsMagick
-Libs.private: @LDFLAGS@ @MAGICK_API_DEP_LIBS@ @MAGICK_EXTRA_DEP_LIBS@
+Libs.private: @MAGICK_API_DEP_LIBS@ @MAGICK_EXTRA_DEP_LIBS@
 Cflags: -I${includedir} @MAGICK_API_PC_CPPFLAGS@
