diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,5 +1,9 @@
 # Revision history for `resolv`
 
+## 0.1.1.1
+
+* Improve Autoconf script
+
 ## 0.1.1.0
 
 * Use Autoconf to detect which library (if any) to link for `res_query(3)`
diff --git a/cbits/hs_resolv.h b/cbits/hs_resolv.h
--- a/cbits/hs_resolv.h
+++ b/cbits/hs_resolv.h
@@ -22,7 +22,15 @@
 # define QUERY ns_o_query
 #endif
 
-#if HAVE_DECL_RES_NQUERY && HAVE_DECL___RES_STATE && (SIZEOF_STRUCT___RES_STATE > 0)
+#if !defined(USE_RES_NQUERY)
+# error USE_RES_NQUERY not defined
+#endif
+
+#if USE_RES_NQUERY && (SIZEOF_STRUCT___RES_STATE <= 0)
+# error broken invariant
+#endif
+
+#if USE_RES_NQUERY
 
 inline static int
 res_opt_set_use_dnssec(struct __res_state *s)
diff --git a/cbits/hs_resolv_config.h.in b/cbits/hs_resolv_config.h.in
--- a/cbits/hs_resolv_config.h.in
+++ b/cbits/hs_resolv_config.h.in
@@ -11,10 +11,6 @@
    don't. */
 #undef HAVE_DECL_RES_QUERY
 
-/* Define to 1 if you have the declaration of `__res_state', and to 0 if you
-   don't. */
-#undef HAVE_DECL___RES_STATE
-
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -68,6 +64,9 @@
 
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
+
+/* Define to 1 in order to use res_nquery(3) API */
+#undef USE_RES_NQUERY
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -1632,52 +1632,6 @@
 
 } # ac_fn_c_check_header_compile
 
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
 # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
 # ---------------------------------------------
 # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
@@ -1724,6 +1678,52 @@
 
 } # ac_fn_c_check_decl
 
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
 # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
 # --------------------------------------------
 # Tries to find the compile-time value of EXPR in a program that includes
@@ -3544,7 +3544,17 @@
 
 done
 
-ac_fn_c_check_header_mongrel "$LINENO" "resolv.h" "ac_cv_header_resolv_h" "$ac_includes_default"
+ac_fn_c_check_header_compile "$LINENO" "resolv.h" "ac_cv_header_resolv_h" "
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
+#include <resolv.h>
+
+"
 if test "x$ac_cv_header_resolv_h" = xyes; then :
 
 else
@@ -3553,6 +3563,49 @@
 
 
 
+ac_fn_c_check_decl "$LINENO" "res_query" "ac_cv_have_decl_res_query" "
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
+#include <resolv.h>
+
+"
+if test "x$ac_cv_have_decl_res_query" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RES_QUERY $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "res_nquery" "ac_cv_have_decl_res_nquery" "
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
+#include <resolv.h>
+
+"
+if test "x$ac_cv_have_decl_res_nquery" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RES_NQUERY $ac_have_decl
+_ACEOF
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing res_query" >&5
 $as_echo_n "checking for library containing res_query... " >&6; }
 if ${ac_cv_search_res_query+:} false; then :
@@ -3561,7 +3614,16 @@
   ac_func_search_save_LIBS=$LIBS
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
+
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
 #include <resolv.h>
+
 int
 main ()
 {
@@ -3607,71 +3669,11 @@
 fi
 
 
-ac_fn_c_check_decl "$LINENO" "res_query" "ac_cv_have_decl_res_query" "
-        #include <sys/types.h>
-	#ifdef HAVE_NETINET_IN_H
-	# include <netinet/in.h>
-	#endif
-	#ifdef HAVE_ARPA_NAMESER_H
-	# include <arpa/nameser.h>
-	#endif
-	#include <resolv.h>
 
-"
-if test "x$ac_cv_have_decl_res_query" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
 
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_RES_QUERY $ac_have_decl
-_ACEOF
-ac_fn_c_check_decl "$LINENO" "res_nquery" "ac_cv_have_decl_res_nquery" "
-        #include <sys/types.h>
-	#ifdef HAVE_NETINET_IN_H
-	# include <netinet/in.h>
-	#endif
-	#ifdef HAVE_ARPA_NAMESER_H
-	# include <arpa/nameser.h>
-	#endif
-	#include <resolv.h>
-
-"
-if test "x$ac_cv_have_decl_res_nquery" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_RES_NQUERY $ac_have_decl
-_ACEOF
-ac_fn_c_check_decl "$LINENO" "__res_state" "ac_cv_have_decl___res_state" "
-        #include <sys/types.h>
-	#ifdef HAVE_NETINET_IN_H
-	# include <netinet/in.h>
-	#endif
-	#ifdef HAVE_ARPA_NAMESER_H
-	# include <arpa/nameser.h>
-	#endif
-	#include <resolv.h>
-
-"
-if test "x$ac_cv_have_decl___res_state" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL___RES_STATE $ac_have_decl
-_ACEOF
-
-
-CPP_OPTIONS="-DUSE_RES_NQUERY=1 -DSIZEOF_RES_STATE=0"
+USE_RES_NQUERY=0
 
-if test "x$ac_cv_have_decl_res_nquery$ac_cv_have_decl___res_state" = xyesyes; then
+if test "x$ac_cv_have_decl_res_nquery" = xyes; then
 
 # The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
@@ -3683,7 +3685,7 @@
   $as_echo_n "(cached) " >&6
 else
   if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct __res_state))" "ac_cv_sizeof_struct___res_state"        "
-      #include <sys/types.h>
+#include <sys/types.h>
 #ifdef HAVE_NETINET_IN_H
 # include <netinet/in.h>
 #endif
@@ -3717,8 +3719,11 @@
 
 
 
-if test "$ac_cv_sizeof_struct___res_state" -gt 0; then
+SIZEOF_RES_STATE="$ac_cv_sizeof_struct___res_state"
 
+if test "$SIZEOF_RES_STATE" -gt 0; then
+
+USE_RES_NQUERY=1
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing res_nquery" >&5
 $as_echo_n "checking for library containing res_nquery... " >&6; }
 if ${ac_cv_search_res_nquery+:} false; then :
@@ -3727,7 +3732,16 @@
   ac_func_search_save_LIBS=$LIBS
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
+
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+# include <arpa/nameser.h>
+#endif
 #include <resolv.h>
+
 int
 main ()
 {
@@ -3768,15 +3782,42 @@
   EXTRA_LIBS="$EXTRA_LIBS $ac_lib"
 else
 
-as_fn_error $? "could not figure out which C library contains res_nquery(3)" "$LINENO" 5
+USE_RES_NQUERY=0
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not figure out which C library contains res_nquery(3)" >&5
+$as_echo "$as_me: WARNING: could not figure out which C library contains res_nquery(3)" >&2;}
 
 fi
 
 
-CPP_OPTIONS="-DUSE_RES_NQUERY=1 -DSIZEOF_RES_STATE=$ac_cv_sizeof_struct___res_state"
+else
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not determine sizeof(struct __res_state)" >&5
+$as_echo "$as_me: WARNING: could not determine sizeof(struct __res_state)" >&2;}
+
 fi
 
 fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which DNS api to use" >&5
+$as_echo_n "checking which DNS api to use... " >&6; }
+
+case "x$USE_RES_NQUERY" in
+  x0) { $as_echo "$as_me:${as_lineno-$LINENO}: result: res_query(3)" >&5
+$as_echo "res_query(3)" >&6; }
+      CPP_OPTIONS="-DUSE_RES_NQUERY=0 -DSIZEOF_RES_STATE=0"
+      ;;
+  x1) { $as_echo "$as_me:${as_lineno-$LINENO}: result: res_nquery(3)" >&5
+$as_echo "res_nquery(3)" >&6; }
+      CPP_OPTIONS="-DUSE_RES_NQUERY=1 -DSIZEOF_RES_STATE=$SIZEOF_RES_STATE"
+      ;;
+  *)  as_fn_error $? "no suitable DNS API detected" "$LINENO" 5
+      ;;
+esac
+
+cat >>confdefs.h <<_ACEOF
+#define USE_RES_NQUERY $USE_RES_NQUERY
+_ACEOF
+
 
 
 
diff --git a/resolv.buildinfo.in b/resolv.buildinfo.in
--- a/resolv.buildinfo.in
+++ b/resolv.buildinfo.in
diff --git a/resolv.cabal b/resolv.cabal
--- a/resolv.cabal
+++ b/resolv.cabal
@@ -1,7 +1,7 @@
 cabal-version:       1.12
 
 name:                resolv
-version:             0.1.1.0
+version:             0.1.1.1
 
 synopsis:            Domain Name Service (DNS) lookup via the libresolv standard library routines
 description: {
@@ -30,7 +30,6 @@
 
 }
 
-homepage:            http://github.com/hvr/resolv
 license:             GPL-3
 license-file:        LICENSE
 author:              Herbert Valerio Riedel
@@ -53,7 +52,7 @@
                      resolv.buildinfo
                      cbits/hs_resolv_config.h
 
-tested-with: GHC==8.2.1, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2
+tested-with: GHC==8.2.1, GHC==8.0.2, GHC==7.10.3, GHC==7.10.1, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2
 
 source-repository head
   type:              git
@@ -81,14 +80,14 @@
 
   build-depends:     base              >= 4.5 && <4.11
                    , base16-bytestring == 0.1.*
-                   , binary            >= 0.7.5 && < 0.9
+                   , binary            >= 0.7.3 && < 0.9
                    , bytestring        >= 0.9.2 && < 0.11
                    , containers        >= 0.4.2.1 && < 0.6
 
   ghc-options:       -Wall
   include-dirs:      cbits
 
-test-suite resolv
+test-suite resolv.
   default-language:    Haskell2010
   hs-source-dirs:      src-test
   main-is:             Tests1.hs
