-changequote(,)dnl
-NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
-NCURSES_MINOR="`egrep '^NCURSES_MINOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
-NCURSES_PATCH="`egrep '^NCURSES_PATCH[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
-changequote([,])dnl
-nc_cv_abi_version=${NCURSES_MAJOR}
-nc_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
-dnl Show the computed version, for logging
-AC_MSG_RESULT(Configuring NCURSES $nc_cv_rel_version ABI $nc_cv_abi_version (`date`))
-dnl We need these values in the generated headers
-AC_SUBST(NCURSES_MAJOR)
-AC_SUBST(NCURSES_MINOR)
-AC_SUBST(NCURSES_PATCH)
-dnl We need these values in the generated makefiles
-AC_SUBST(nc_cv_rel_version)
-AC_SUBST(nc_cv_abi_version)
-AC_SUBST(nc_cv_builtin_bool)
-AC_SUBST(nc_cv_type_of_bool)
+AC_REQUIRE([CF_TYPEOF_CHTYPE])
+AC_MSG_CHECKING([for number of bits in chtype])
+AC_CACHE_VAL(cf_cv_shift_limit,[
+ AC_TRY_RUN([
+#include <stdio.h>
+int main()
+{
+ FILE *fp = fopen("cf_test.out", "w");
+ if (fp != 0) {
+ int n;
+ unsigned TYPEOF_CHTYPE x = 1L;
+ for (n = 0; ; n++) {
+ unsigned long y = (x >> n);
+ if (y != 1 || x == 0)
+ break;
+ x <<= 1;
+ }
+ fprintf(fp, "%d", n);
+ fclose(fp);
+ }
+ exit(0);
+}
+ ],
+ [cf_cv_shift_limit=`cat cf_test.out`],
+ [cf_cv_shift_limit=32],
+ [cf_cv_shift_limit=32])
+ rm -f cf_test.out
+ ])
+AC_MSG_RESULT($cf_cv_shift_limit)
+AC_SUBST(cf_cv_shift_limit)
+
+AC_MSG_CHECKING([for width of character-index])
+AC_CACHE_VAL(cf_cv_widec_shift,[
+if test ".$with_widec" = ".yes" ; then
+ cf_attrs_width=39
+ if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
+ then
+ cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
+ else
+ cf_cv_widec_shift=16
+ fi
+else
+ cf_cv_widec_shift=8
+fi
+])
+AC_MSG_RESULT($cf_cv_widec_shift)
+AC_SUBST(cf_cv_widec_shift)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
+dnl defaulting to yes/no.
+dnl
+dnl $1 = option name
+dnl $2 = help-text
+dnl $3 = environment variable to set
+dnl $4 = default value, shown in the help-message, must be a constant
+dnl $5 = default value, if it's an expression & cannot be in the help-message
+dnl
+AC_DEFUN([CF_WITH_PATH],
+[AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
+ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
+CF_PATH_SYNTAX(withval)
+eval $3="$withval"
+AC_SUBST($3)dnl
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl Process an option specifying a list of colon-separated paths.
+dnl
+dnl $1 = option name
+dnl $2 = help-text
+dnl $3 = environment variable to set
+dnl $4 = default value, shown in the help-message, must be a constant
+dnl $5 = default value, if it's an expression & cannot be in the help-message
+dnl
+AC_DEFUN([CF_WITH_PATHLIST],[
+AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
+ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
+
+IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+cf_dst_path=
+for cf_src_path in $withval
+do
+ CF_PATH_SYNTAX(cf_src_path)
+ test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
+ cf_dst_path="${cf_dst_path}${cf_src_path}"
+done
+IFS="$ac_save_ifs"
+
+eval $3="$cf_dst_path"
+AC_SUBST($3)dnl