- LIBRARY is now a SUBST variable.
- Add CFLAGSFORSHARED variable.  configure sets this to CCSHARED if LDLIBRARY
  is a shared library.
- Remove -fPIC from OPT, it has no business there.
- Change CCSHARED option for Linux to -fPIC.  It should probably be
  -fPIC on a few other platforms as well.
- Don't create silly boot Makefile, create Setup files and run makesetup
  instead.
diff --git a/configure.in b/configure.in
index 0b3bf8e..8426b32 100644
--- a/configure.in
+++ b/configure.in
@@ -190,6 +190,14 @@
     esac;;
 esac
 
+AC_SUBST(LIBRARY)
+AC_MSG_CHECKING(LIBRARY)
+if test -z "$LIBRARY"
+then
+	LIBRARY='libpython$(VERSION).a'
+fi
+AC_MSG_RESULT($LIBRARY)
+
 # LDLIBRARY is the name of the library to link against (as opposed to the
 # name of the library into which to insert object files). On systems
 # without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
@@ -197,7 +205,7 @@
 # shared (i.e., DLL) library.
 AC_SUBST(LDLIBRARY)
 AC_SUBST(DLLLIBRARY)
-LDLIBRARY='$(LIBRARY)'
+LDLIBRARY="$LIBRARY"
 DLLLIBRARY=''
 
 # LINKCC is the command that links the python executable -- default is $(CC).
@@ -270,8 +278,8 @@
 	case $GCC in
 	yes)
 		case $ac_cv_prog_cc_g in
-		yes)	OPT="-g -O2 -Wall -Wstrict-prototypes -fPIC";;
-		*)	OPT="-O2 -Wall -Wstrict-prototypes -fPIC";;
+		yes)	OPT="-g -O2 -Wall -Wstrict-prototypes";;
+		*)	OPT="-O2 -Wall -Wstrict-prototypes";;
 		esac
 		;;
 	*)	OPT="-O";;
@@ -283,11 +291,6 @@
 Monterey*) OPT="";;
 esac
 
-# Cygwin does not need PIC compiler option so remove it to prevent warnings
-case $ac_sys_system in
-CYGWIN*) OPT="`echo $OPT | sed 's/ *-fPIC//'`";;
-esac
-
 if test "$ac_arch_flags"
 then
 	OPT="$OPT $ac_arch_flags"
@@ -581,7 +584,7 @@
 		 then CCSHARED="-fpic";
 		 else CCSHARED="+z";
 		 fi;;
-	Linux*) CCSHARED="-fpic";;
+	Linux*) CCSHARED="-fPIC";;
 	BSD/OS*/4*) CCSHARED="-fpic";;
 	OpenBSD*) CCSHARED="-fpic";;
 	FreeBSD*|NetBSD*) CCSHARED="-fPIC";;
@@ -632,6 +635,14 @@
 fi
 AC_MSG_RESULT($LINKFORSHARED)
 
+AC_SUBST(CFLAGSFORSHARED)
+AC_MSG_CHECKING(CFLAGSFORSHARED)
+if test ! "$LIBRARY" = "$LDLIBRARY"
+then
+	CFLAGSFORSHARED='$(CCSHARED)'
+fi
+AC_MSG_RESULT($CFLAGSFORSHARED)
+
 # checks for libraries
 AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
 AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
@@ -1395,13 +1406,21 @@
 AC_MSG_RESULT(done)
 
 # generate output files
-echo "creating Makefile"
-
-# "boot" Makefile
-cat >Makefile <<\EOF
-# This file is automaticly generated by configure.
-all:
-	\$(MAKE) -f Makefile.pre Makefile
-EOF
-
 AC_OUTPUT(Makefile.pre Modules/Setup.config setup.cfg)
+
+echo "creating Setup"
+if test ! -f Modules/Setup
+then
+	cp $srcdir/Modules/Setup.dist Modules/Setup
+fi
+
+echo "creating Setup.local"
+if test ! -f Modules/Setup.local
+then
+	echo "# Edit this file for local setup changes" >Modules/Setup.local
+fi
+
+echo "creating Makefile"
+$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
+			-s Modules Modules/Setup.config \
+			Modules/Setup Modules/Setup.local