diff --git a/Changelog b/Changelog
--- a/Changelog
+++ b/Changelog
@@ -1,5 +1,9 @@
 # Changelog of `terminfo`
 
+## Changed in version 0.4.1.7:
+
+- Fix POSIX compliance issue in `configure` script
+
 ## Changed in version 0.4.1.6:
 
 - Minor documentation fixes
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -669,6 +669,7 @@
 ac_user_opts='
 enable_option_checking
 with_curses_libraries
+with_curses_library
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1296,6 +1297,9 @@
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-curses-libraries directory containing curses library
+  --with-curses-library   the curses library to link against (tinfow, tinfo,
+                          ncursesw, ncurses, curses, ...); default is
+                          autodetect.
 
 Some influential environment variables:
   CC          C compiler command
@@ -2156,12 +2160,22 @@
 
 
 
+# Check whether --with-curses-library was given.
+if test ${with_curses_library+y}
+then :
+  withval=$with_curses_library; curses_library=$withval
+else $as_nop
+  curses_library=NONE
+fi
+
+
 TERMINFO_LIB_DIRS=
 if test "x$curses_libraries" != "xNONE"; then
   LDFLAGS="-L$curses_libraries $LDFLAGS"
   TERMINFO_LIB_DIRS=$curses_libraries
 fi
 
+if test "x$curses_library" = "xNONE"; then
 
 
 
@@ -3237,6 +3251,45 @@
 then :
   HaveLibCurses=YES; LibCurses=tinfo
 else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setupterm in -lterminfo" >&5
+printf %s "checking for setupterm in -lterminfo... " >&6; }
+if test ${ac_cv_lib_terminfo_setupterm+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lterminfo  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+char setupterm ();
+int
+main (void)
+{
+return setupterm ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  ac_cv_lib_terminfo_setupterm=yes
+else $as_nop
+  ac_cv_lib_terminfo_setupterm=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_terminfo_setupterm" >&5
+printf "%s\n" "$ac_cv_lib_terminfo_setupterm" >&6; }
+if test "x$ac_cv_lib_terminfo_setupterm" = xyes
+then :
+  HaveLibCurses=YES; LibCurses=terminfo
+else $as_nop
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setupterm in -lncursesw" >&5
 printf %s "checking for setupterm in -lncursesw... " >&6; }
 if test ${ac_cv_lib_ncursesw_setupterm+y}
@@ -3365,7 +3418,9 @@
 
 fi
 
+fi
 
+
 if test "x$HaveLibCurses" = "xNO" ; then
     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -3375,6 +3430,9 @@
     TERMINFO_LIB=$LibCurses
 fi
 
+else
+    TERMINFO_LIB=$curses_library
+fi
 
 
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@
   TERMINFO_LIB_DIRS=$curses_libraries
 fi
 
-if test "x$curses_library" == "xNONE"; then
+if test "x$curses_library" = "xNONE"; then
 AC_PROG_CC()
 
 AC_CHECK_LIB(tinfow, setupterm, HaveLibCurses=YES; LibCurses=tinfow,
diff --git a/terminfo.cabal b/terminfo.cabal
--- a/terminfo.cabal
+++ b/terminfo.cabal
@@ -1,6 +1,6 @@
 Name:           terminfo
 Cabal-Version:  >=1.10
-Version:        0.4.1.6
+Version:        0.4.1.7
 Category:       User Interfaces
 License:        BSD3
 License-File:   LICENSE
@@ -28,7 +28,7 @@
     other-extensions: CPP, DeriveDataTypeable, FlexibleInstances, ScopedTypeVariables
     if impl(ghc>=7.3)
       other-extensions: Safe, Trustworthy
-    build-depends:    base >= 4.9 && < 4.19
+    build-depends:    base >= 4.9 && < 4.22
     ghc-options:      -Wall
     exposed-modules:
                     System.Console.Terminfo
