diff --git a/configure.ac b/configure.ac
index 5aeda60..6913062 100644
--- a/configure.ac
+++ b/configure.ac
@@ -423,16 +423,10 @@ dnl checking for iniparser
 dnl ######################
 
 AC_CHECK_LIB(iniparser,iniparser_load, have_iniparser=yes, have_iniparser=no)
+    PKG_CHECK_MODULES(INIPARSER, iniparser, have_iniparser=yes, have_iniparser=no)
     if [[ $have_iniparser = "yes" ]] ; then
-    LIBS="$LIBS -liniparser"
-      CPPFLAGS="$CPPFLAGS -I/usr/include/iniparser"
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iniparser.h>]],
-      [[dictionary* ini;
-      const char *keys[3];
-      iniparser_getseckeys(ini, "eq", keys);]])],
-      [AC_MSG_RESULT(iniparser > 3.2 test OK)],
-      [AC_MSG_RESULT(iniparser > 3.2 test failed falling back to legacy iniparser mode)
-      CPPFLAGS="$CPPFLAGS -DLEGACYINIPARSER"])
+      LIBS="$LIBS $INIPARSER_LIBS"
+      CPPFLAGS="$CPPFLAGS $INIPARSER_CFLAGS"
     fi
     if [[ $have_iniparser = "no" ]] ; then
       AC_MSG_ERROR([iniparser library is required!])
