$NetBSD: patch-ae,v 1.3 2000/10/12 14:56:45 jlam Exp $

--- configure.orig	Thu Oct 12 04:52:53 2000
+++ configure
@@ -193,8 +193,10 @@
   --without-cxx-binding   do not build C++ binding and demo
   --without-ada           suppress check for Ada95, don't build demo
   --without-progs         suppress build with programs (e.g., tic)
+  --without-curses-h      install curses.h as ncurses.h only
   --with-install-prefix   prefixes actual install-location
 Options to Specify the Libraries Built/Used:
+  --with-libtool          generate libraries with libtool
   --with-shared           generate shared-libraries
   --with-normal           generate normal-libraries (default)
   --with-debug            generate debug-libraries (default)
@@ -229,6 +231,7 @@
                           optionally formatted, e.g., gzip,formatted
   --with-manpage-renames  specify manpage-renaming
   --with-manpage-symlinks specify manpage-symlinks
+  --with-manpage-tbl      specify manpage processing with tbl
 EOF
 cat <<EOF
 Extensions:
@@ -1605,6 +1608,19 @@
 
 echo "$ac_t""$cf_with_progs" 1>&6
 
+echo $ac_n "checking if you wish to install curses.h""... $ac_c" 1>&6
+echo "configure:1597: checking if you wish to install curses.h" >&5
+
+# Check whether --with-curses-h or --without-curses-h was given.
+if test "${with_curses_h+set}" = set; then
+  withval="$with_curses_h"
+  with_curses_h=$withval
+else
+  with_curses_h=yes
+fi
+
+echo "$ac_t""$with_curses_h" 1>&6
+
 modules_to_build="ncurses"
 if test "X$cf_with_progs" != Xno ; then
 modules_to_build="$modules_to_build progs tack"
@@ -2141,6 +2157,25 @@
 ### shared, for example.
 cf_list_models=""
 
+echo $ac_n "checking if you want to build libraries with libtool""... $ac_c" 1>&6
+echo "configure:2146: checking if you want to build libraries with libtool" >&5
+
+# Check whether --with-libtool or --without-libtool was given.
+if test "${with_libtool+set}" = set; then
+  withval="$with_libtool"
+  with_libtool=$withval
+else
+  with_libtool=no
+fi
+
+echo "$ac_t""$with_libtool" 1>&6
+if test "$with_libtool" = "yes"; then
+	cf_list_models="$cf_list_models libtool"
+	test -z "$LIBTOOL" && LIBTOOL=libtool
+else
+	LIBTOOL=""
+fi
+
 echo $ac_n "checking if you want to build shared libraries""... $ac_c" 1>&6
 echo "configure:2146: checking if you want to build shared libraries" >&5
 
@@ -2202,6 +2237,9 @@
 echo $ac_n "checking for specified models""... $ac_c" 1>&6
 echo "configure:2204: checking for specified models" >&5
 test -z "$cf_list_models" && cf_list_models=normal
+# If we use libtool to generate libraries, then it must be the only
+# specified model.
+test "$with_libtool" = "yes" && cf_list_models=libtool
 echo "$ac_t""$cf_list_models" 1>&6
 
 ### Use the first model as the default, and save its suffix for use in building
@@ -2496,6 +2534,7 @@
 echo $ac_n "checking for default loader flags""... $ac_c" 1>&6
 echo "configure:2498: checking for default loader flags" >&5
 case $DFT_LWR_MODEL in
+libtool) LD_MODEL=''   ;;
 normal)  LD_MODEL=''   ;;
 debug)   LD_MODEL=$CC_G_OPT ;;
 profile) LD_MODEL='-pg';;
@@ -3469,6 +3508,22 @@
 echo "$ac_t""$cf_manpage_symlinks" 1>&6
 
 
+echo $ac_n "checking for manpage tbl""... $ac_c" 1>&6
+echo "configure:3458: checking for manpage tbl" >&5
+
+
+# Check whether --with-manpage-tbl or --without-manpage-tbl was given.
+if test "${with_manpage_tbl+set}" = set; then
+  withval="$with_manpage_tbl"
+  cf_manpage_tbl=$withval
+else
+  cf_manpage_tbl=yes
+fi
+
+
+echo "$ac_t""$cf_manpage_tbl" 1>&6
+
+
   if test "$prefix" = "NONE" ; then
      cf_prefix="$ac_default_prefix"
   else
@@ -3580,6 +3635,18 @@
 	test \$verb = installing && sed -e "s,@DATADIR@,\$datadir," < \$i | sed -f edit_man.sed >\$TMP
 CF_EOF
 fi
+if test $cf_manpage_tbl = yes ; then
+cat >>man/edit_man.sh <<CF_EOF
+	tbl \$TMP >\$TMP.out
+	mv \$TMP.out \$TMP
+CF_EOF
+fi
+if test $with_curses_h != yes ; then 
+cat >>man/edit_man.sh <<CF_EOF
+	sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
+	mv \$TMP.out \$TMP
+CF_EOF
+fi
 if test $cf_format = yes ; then
 cat >>man/edit_man.sh <<CF_EOF
 	nroff -man \$TMP >\$TMP.out
@@ -6964,6 +7031,7 @@
 echo "configure:6965: checking default library suffix" >&5
 
 	case $DFT_LWR_MODEL in
+	libtool) DFT_ARG_SUFFIX=''   ;;
 	normal)  DFT_ARG_SUFFIX=''   ;;
 	debug)   DFT_ARG_SUFFIX='_g' ;;
 	profile) DFT_ARG_SUFFIX='_p' ;;
@@ -6977,6 +7045,7 @@
 
 	
 	case $DFT_LWR_MODEL in
+	libtool) DFT_DEP_SUFFIX='.la'  ;;
 	normal)  DFT_DEP_SUFFIX='.a'   ;;
 	debug)   DFT_DEP_SUFFIX='_g.a' ;;
 	profile) DFT_DEP_SUFFIX='_p.a' ;;
@@ -6993,6 +7062,7 @@
 echo "configure:6994: checking default object directory" >&5
 
 	case $DFT_LWR_MODEL in
+	libtool) DFT_OBJ_SUBDIR='obj_lo'  ;;
 	normal)  DFT_OBJ_SUBDIR='objects' ;;
 	debug)   DFT_OBJ_SUBDIR='obj_g' ;;
 	profile) DFT_OBJ_SUBDIR='obj_p' ;;
@@ -7018,7 +7088,11 @@
 ### could override this.
 if test "$with_termlib" = yes ; then
 	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_NAME}${DFT_DEP_SUFFIX}"
-	TEST_ARGS="-l${TINFO_NAME}${DFT_ARG_SUFFIX}"
+	if test "$DFT_LWR_MODEL" = "libtool"; then
+		TEST_ARGS="${TEST_DEPS}"
+	else
+		TEST_ARGS="-l${TINFO_NAME}${DFT_ARG_SUFFIX}"
+	fi
 fi
 PROG_DEPS="$TEST_DEPS"
 PROG_ARGS="$TEST_ARGS"
@@ -7032,7 +7106,11 @@
 
 # dependencies and linker-arguments for test-programs
 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
-TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
+if test "$DFT_LWR_MODEL" = "libtool"; then
+	TEST_ARGS="${TEST_DEPS}"
+else
+	TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
+fi
 
 # dependencies and linker-arguments for utility-programs
 PROG_ARGS="$TEST_ARGS"
@@ -7075,7 +7153,11 @@
 EOF
 
 			TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
-			TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
+			if test "$DFT_LWR_MODEL" = "libtool"; then
+				TEST_ARGS="${TEST_DEPS}"
+			else
+				TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
+			fi
 		fi
 	fi
 done
@@ -7121,6 +7203,7 @@
 do
 	
 	case $cf_item in
+	libtool) cf_subdir='obj_lo'  ;;
 	normal)  cf_subdir='objects' ;;
 	debug)   cf_subdir='obj_g' ;;
 	profile) cf_subdir='obj_p' ;;
@@ -7257,6 +7340,7 @@
  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
+s%@LIBTOOL@%$LIBTOOL%g
 s%@SHELL@%$SHELL%g
 s%@CFLAGS@%$CFLAGS%g
 s%@CPPFLAGS@%$CPPFLAGS%g
@@ -7611,6 +7695,7 @@
 TINFO_NAME="$TINFO_NAME"
 WITH_ECHO="$with_echo"
 WITH_OVERWRITE="$with_overwrite"
+WITH_CURSES_H="$with_curses_h"
 cf_cv_abi_version="$cf_cv_abi_version"
 cf_cv_do_symlinks="$cf_cv_do_symlinks"
 cf_cv_rel_version="$cf_cv_rel_version"
@@ -7645,6 +7730,7 @@
 			
 	
 	case $cf_item in
+	libtool) cf_suffix='.la'  ;;
 	normal)  cf_suffix='.a'   ;;
 	debug)   cf_suffix='_g.a' ;;
 	profile) cf_suffix='_p.a' ;;
@@ -7695,6 +7781,7 @@
 			
 	
 	case $cf_item in
+	libtool) cf_suffix='.la'  ;;
 	normal)  cf_suffix='.a'   ;;
 	debug)   cf_suffix='_g.a' ;;
 	profile) cf_suffix='_p.a' ;;
@@ -7708,6 +7795,7 @@
 
 			
 	case $cf_item in
+	libtool) cf_subdir='obj_lo'  ;;
 	normal)  cf_subdir='objects' ;;
 	debug)   cf_subdir='obj_g' ;;
 	profile) cf_subdir='obj_p' ;;
@@ -7857,27 +7945,62 @@
 DST=\$1
 REF=\$2
 SRC=\$3
+TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
+TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
 echo installing \$SRC in \$DST
+CF_EOF
+if test $WITH_CURSES_H = yes; then
+	cat >>headers.sh <<CF_EOF
 case \$DST in
 /*/include/*)
-	TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
-	TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
 	END=\`basename \$DST\`
 	for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
 	do
 		NAME=\`basename \$i\`
 		echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
 	done
-	rm -f \$TMPSRC
-	sed -f \$TMPSED \$SRC > \$TMPSRC
-	eval \$PRG \$TMPSRC \$DST/\`basename \$SRC\`
-	rm -f \$TMPSRC \$TMPSED
 	;;
 *)
-	eval \$PRG \$SRC \$DST
+	echo "" >> \$TMPSED
 	;;
 esac
 CF_EOF
+else
+	cat >>headers.sh <<CF_EOF
+case \$DST in
+/*/include/*)
+	END=\`basename \$DST\`
+	for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
+	do
+		NAME=\`basename \$i\`
+		if test "\$NAME" = "curses.h"
+		then
+			echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
+			NAME=ncurses.h
+		fi
+		echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
+	done
+	;;
+*)
+	echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
+	;;
+esac
+CF_EOF
+fi
+cat >>headers.sh <<CF_EOF
+rm -f \$TMPSRC
+sed -f \$TMPSED \$SRC > \$TMPSRC
+NAME=\`basename \$SRC\`
+CF_EOF
+if test $WITH_CURSES_H != yes; then
+	cat >>headers.sh <<CF_EOF
+test "\$NAME" = "curses.h" && NAME=ncurses.h
+CF_EOF
+fi
+cat >>headers.sh <<CF_EOF
+eval \$PRG \$TMPSRC \$DST/\$NAME
+rm -f \$TMPSRC \$TMPSED
+CF_EOF
 
 chmod 0755 headers.sh
 
@@ -7902,7 +8025,7 @@
 		for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
 		do
 			echo "	@ (cd \$(DESTDIR)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(DESTDIR)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
-			test $i = curses.h && echo "	@ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
+			test $i = curses.h && test $WITH_CURSES_H = yes && echo "	@ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
 		done
 
 	cat >>$cf_dir/Makefile <<CF_EOF
