This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Build-side libiberty


I've finally been able to test out DJ's patch to compile libiberty for
the build machine when build != host.  It had one bug, which I've
corrected here.  Also, this patch begins to flush out the cruft in the
gcc subdirectory that is no longer necessary with DJ's change (just
enough to verify that the build libiberty works.)

Tested as follows:

- native i386-linux build (in progress right now)
- i386-linux -> powerpc-eabisim cross (C only; with simulated testsuite run)
- sparc-sun-solaris2.7 -> i386-pc-cygwin -> powerpc-wrs-vxworks
  Canadian (built C only; it tries to use the already-available
  solaris->vxworks cross compiler to build libgcc, which fails
  miserably because that compiler is 2.95-based, but I doubt that will
  affect anything).

The bug in DJ's original patch was, the top-level Makefile variable
$(CONFIG_ARGUMENTS) contains appropriate switches to run ./configure
to set up to build target libraries with the new cross compiler,
including among other things --build=<host> --host=<target>.  This is
wrong when you want a native library for the build machine.

This patch touches libiberty/configure.in and gcc/configure.in as well
as the top level configure script.  You must re-run autoconf and
autoheader in both subdirectories, but NOT in the top level; that's
not an autoconf script.

zw

top level:
	When build != host, create libiberty for the build machine.

	* Makefile.in (TARGET_CONFIGARGS, BUILD_CONFIGARGS): Replace
	CONFIG_ARGUMENTS.
	(ALL_BUILD_MODULES_LIST, BUILD_CONFIGDIRS, BUILD_SUBDIR):
	New variables.
	(ALL_BUILD_MODULES, CONFIGURE_BUILD_MODULES): New variables
	and rules.
	(all.normal): Depend on ALL_BUILD_MODULES.
	(CONFIGURE_TARGET_MODULES rule): Use TARGET_CONFIGARGS.
	(all-build-libiberty): Depend on configure-build-libiberty.

	* configure: Calculate and substitute proper value for
	ALL_BUILD_MODULES.
	* configure.in: Create the build subdirectory.
	Calculate and substitute TARGET_CONFIGARGS (formerly
	CONFIG_ARGUMENTS); also BUILD_SUBDIR and BUILD_CONFIGARGS
	(new).

gcc:
	Purge cruft now we have build libiberty.

	* Makefile.in (OBSTACK, VFPRINTF, DOPRINT, STRSTR,
	HOST_OBSTACK, HOST_VFPRINTF, HOST_DOPRINT, HOST_STRSTR,
	USE_HOST_OBSTACK, USE_HOST_VFPRINTF, USE_HOST_DOPRINT,
	USE_HOST_STRSTR, vfprintf.o, doprint.o, strstr.o,
	splay-tree.o, obstack.o, hashtab.o, safe-ctype.o,
	$(HOST_PREFIX_1)obstack.o, $(HOST_PREFIX_1)vfprintf.o,
	$(HOST_PREFIX_1)doprint.o, $(HOST_PREFIX_1)strstr.o)): Delete.
	(LIBIBERTY, BUILD_LIBIBERTY): New variables.
	(LIBDEPS): Now just $(INTLDEPS) $(LIBIBERTY).
	(LIBS): Now just $(INTLLIBS) @LIBS@ $(LIBIBERTY).
	(HOST_LIBDEPS): Now just $(BUILD_LIBIBERTY).
	(HOST_LIBS): Ditto.
	(HOST_RTL): Remove hashtab.o safe-ctype.o.
	(OBJS): Remove splay-tree.o.
	(gen-protos$(build_exeext)): Depend on $(HOST_LIBS), not
	../libiberty/libiberty.a.
	(distclean): No need to delete splay-tree.c obstack.c
	hashtab.c safe-ctype.c.
	* aclocal.m4 (gcc_AC_FUNC_VFPRINTF_DOPRNT, gcc_AC_FUNC_STRSTR):
	Delete.
	* configure.in: Don't use them.
	Set and substitute @FORBUILD@.
	* config.in, configure: Regenerate.
	* doprint.c: Move to libiberty/_doprnt.c.

libiberty:
	* _doprnt.c: Moved here from gcc/doprint.c.  Adjust to build
	in libiberty context.
	* configure.in: Fix various AC_DEFINEs so autoheader works.
	If any of vprintf, vsprintf, vfprintf is missing from libc,
	then AC_REPLACE_FUNCS(_doprnt).

===================================================================
Index: Makefile.in
--- Makefile.in	2001/11/06 07:15:44	1.89
+++ Makefile.in	2001/11/23 18:17:14
@@ -178,9 +178,17 @@ TARGET_CONFIGDIRS = libiberty libgloss $
 # Changed by configure to $(target_alias) if cross.
 TARGET_SUBDIR = .
 
-# This is set by the configure script to the arguments passed to configure.
-CONFIG_ARGUMENTS = 
+BUILD_CONFIGDIRS = libiberty
+BUILD_SUBDIR = .
 
+# This is set by the configure script to the arguments to use when configuring
+# directories built for the target.
+TARGET_CONFIGARGS = 
+
+# This is set by the configure script to the arguments to use when configuring
+# directories built for the build system.
+BUILD_CONFIGARGS =
+
 # This is set by configure to REALLY_SET_LIB_PATH if --enable-shared
 # was used.
 SET_LIB_PATH =
@@ -493,6 +501,18 @@ EXTRA_GCC_FLAGS = \
 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS)
 
 # This is a list of the targets for all of the modules which are compiled
+# using the build machine's native compiler.  Configure edits the second
+# macro for build!=host builds.
+ALL_BUILD_MODULES_LIST = \
+	all-build-libiberty
+ALL_BUILD_MODULES = 
+
+# This is a list of the configure targets for all of the modules which
+# are compiled using the native tools.
+CONFIGURE_BUILD_MODULES = \
+	configure-build-libiberty
+
+# This is a list of the targets for all of the modules which are compiled
 # using $(FLAGS_TO_PASS).
 ALL_MODULES = \
 	all-apache \
@@ -947,6 +967,7 @@ CLEAN_X11_MODULES = \
 # The target built for a native build.
 .PHONY: all.normal
 all.normal: \
+	$(ALL_BUILD_MODULES) \
 	$(ALL_MODULES) \
 	$(ALL_X11_MODULES) \
 	$(ALL_TARGET_MODULES) \
@@ -1193,6 +1214,106 @@ gcc-no-fixedincludes:
 	  mv gcc/tmp-include gcc/include 2>/dev/null; \
 	else true; fi
 
+# This rule is used to build the modules which are built with the
+# build machine's native compiler.
+.PHONY: $(ALL_BUILD_MODULES)
+$(ALL_BUILD_MODULES):
+	dir=`echo $@ | sed -e 's/all-build-//'`; \
+	if [ -f ./$${dir}/Makefile ] ; then \
+	  r=`pwd`; export r; \
+	  s=`cd $(srcdir); pwd`; export s; \
+	  (cd $(BUILD_SUBDIR)/$${dir} && $(MAKE) all); \
+	else \
+	  true; \
+	fi
+
+# This rule is used to configure the modules which are built with the
+# native tools.
+.PHONY: $(CONFIGURE_BUILD_MODULES)
+$(CONFIGURE_BUILD_MODULES):
+	@dir=`echo $@ | sed -e 's/configure-build-//'`; \
+	if [ ! -d $(BUILD_SUBDIR) ]; then \
+	  true; \
+	elif [ -f $(BUILD_SUBDIR)/$${dir}/Makefile ] ; then \
+	  true; \
+	elif echo " $(BUILD_CONFIGDIRS) " | grep " $${dir} " >/dev/null 2>&1; then \
+	  if [ -d $(srcdir)/$${dir} ]; then \
+	    [ -d $(BUILD_SUBDIR)/$${dir} ] || mkdir $(BUILD_SUBDIR)/$${dir};\
+	    r=`pwd`; export r; \
+	    s=`cd $(srcdir); pwd`; export s; \
+	    AR="$(AR_FOR_BUILD)"; export AR; \
+	    AS="$(AS_FOR_BUILD)"; export AS; \
+	    CC="$(CC_FOR_BUILD)"; export CC; \
+	    CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
+	    CXX="$(CXX_FOR_BUILD)"; export CXX; \
+	    CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
+	    GCJ="$(GCJ_FOR_BUILD)"; export GCJ; \
+	    DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \
+	    LD="$(LD_FOR_BUILD)"; export LD; \
+            LDFLAGS="$(LDFLAGS_FOR_BUILD)"; export LDFLAGS; \
+	    NM="$(NM_FOR_BUILD)"; export NM; \
+	    RANLIB="$(RANLIB_FOR_BUILD)"; export RANLIB; \
+	    WINDRES="$(WINDRES_FOR_BUILD)"; export WINDRES; \
+	    echo Configuring in $(BUILD_SUBDIR)/$${dir}; \
+	    cd "$(BUILD_SUBDIR)/$${dir}" || exit 1; \
+	    case $(srcdir) in \
+	    /* | [A-Za-z]:[\\/]*) \
+	      topdir=$(srcdir) ;; \
+	    *) \
+	      case "$(BUILD_SUBDIR)" in \
+	      .) topdir="../$(srcdir)" ;; \
+	      *) topdir="../../$(srcdir)" ;; \
+	      esac ;; \
+	    esac; \
+	    if [ "$(srcdir)" = "." ] ; then \
+	      if [ "$(BUILD_SUBDIR)" != "." ] ; then \
+		if $(SHELL) $$s/symlink-tree $${topdir}/$${dir} "no-such-file" ; then \
+		  if [ -f Makefile ]; then \
+		    if $(MAKE) distclean; then \
+		      true; \
+		    else \
+		      exit 1; \
+		    fi; \
+		  else \
+		    true; \
+		  fi; \
+		else \
+		  exit 1; \
+		fi; \
+	      else \
+		true; \
+	      fi; \
+	      srcdiroption="--srcdir=."; \
+	      libsrcdir="."; \
+	    else \
+	      srcdiroption="--srcdir=$${topdir}/$${dir}"; \
+	      libsrcdir="$$s/$${dir}"; \
+	    fi; \
+	    if [ -f $${libsrcdir}/configure ] ; then \
+	      rm -f no-such-file skip-this-dir; \
+	      CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
+		$(BUILD_CONFIGARGS) $${srcdiroption} \
+		--with-build-subdir="$(BUILD_SUBDIR)"; \
+	    else \
+	      rm -f no-such-file skip-this-dir; \
+	      CONFIG_SITE=no-such-file $(SHELL) $$s/configure \
+		$(BUILD_CONFIGARGS) $${srcdiroption} \
+		--with-build-subdir="$(BUILD_SUBDIR)"; \
+	    fi || exit 1; \
+	    if [ -f skip-this-dir ] ; then \
+	      sh skip-this-dir; \
+	      rm -f skip-this-dir; \
+	      cd ..; rmdir $${dir} || true; \
+	    else \
+	      true; \
+	    fi; \
+	  else \
+	    true; \
+	  fi; \
+	else \
+	  true; \
+	fi
+
 # This rule is used to build the modules which use FLAGS_TO_PASS.  To
 # build a target all-X means to cd to X and make all.
 #
@@ -1338,12 +1459,12 @@ $(CONFIGURE_TARGET_MODULES):
 	    if [ -f $${libsrcdir}/configure ] ; then \
 	      rm -f no-such-file skip-this-dir; \
 	      CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
-		$(CONFIG_ARGUMENTS) $${srcdiroption} \
+		$(TARGET_CONFIGARGS) $${srcdiroption} \
 		--with-target-subdir="$(TARGET_SUBDIR)"; \
 	    else \
 	      rm -f no-such-file skip-this-dir; \
 	      CONFIG_SITE=no-such-file $(SHELL) $$s/configure \
-		$(CONFIG_ARGUMENTS) $${srcdiroption} \
+		$(TARGET_CONFIGARGS) $${srcdiroption} \
 		--with-target-subdir="$(TARGET_SUBDIR)"; \
 	    fi || exit 1; \
 	    if [ -f skip-this-dir ] ; then \
@@ -1641,6 +1762,9 @@ configure-target-libgloss: $(ALL_GCC)
 all-target-libgloss: configure-target-libgloss configure-target-newlib
 all-libgui: all-tcl all-tk all-tcl8.1 all-tk8.1 all-itcl
 all-libiberty:
+
+all-build-libiberty: configure-build-libiberty
+
 configure-target-libffi: $(ALL_GCC_C) 
 all-target-libffi: configure-target-libffi
 configure-target-libjava: $(ALL_GCC_CXX) configure-target-zlib configure-target-boehm-gc configure-target-qthreads configure-target-libffi
===================================================================
Index: configure
--- configure	2001/10/28 12:08:43	1.38
+++ configure	2001/11/23 18:17:14
@@ -1088,6 +1088,12 @@ else
 	GDB_TK=""
 fi
 
+all_build_modules=
+if test x"${build_alias}" != x"${host_alias}"
+then
+  all_build_modules='$(ALL_BUILD_MODULES_LIST)'
+fi
+
 for subdir in . ${subdirs} ; do
 
     # ${subdir} is relative path from . to the directory we're currently
@@ -1384,6 +1390,7 @@ EOF
                     -e "s|^oldincludedir[ 	]*=.*$|oldincludedir = ${oldincludedir}|" \
                     -e "s|^infodir[ 	]*=.*$|infodir = ${infodir}|" \
                     -e "s|^mandir[ 	]*=.*$|mandir = ${mandir}|" \
+		    -e "s|^ALL_BUILD_MODULES =.*|ALL_BUILD_MODULES =${all_build_modules}|" \
 		    -e "/^CC[ 	]*=/{
 			:loop1
 			/\\\\$/ N
===================================================================
Index: configure.in
--- configure.in	2001/11/14 21:39:36	1.114
+++ configure.in	2001/11/23 18:17:14
@@ -445,6 +445,18 @@ if [ ! -d ${target_subdir} ] ; then
   fi
 fi
 
+build_subdir=${build_alias}
+
+if [ x"${build_alias}" != x"${host}" ] ; then
+  if [ ! -d ${build_subdir} ] ; then
+    if mkdir ${build_subdir} ; then true
+    else
+      echo "'*** could not make ${PWD=`pwd`}/${build_subdir}" 1>&2
+      exit 1
+    fi
+  fi
+fi
+
 copy_dirs=
 
 # Handle --with-headers=XXX.  The contents of the named directory are
@@ -1349,7 +1361,8 @@ if [ "${shared}" = "yes" ]; then
   esac
 fi
 
-# Record target_configdirs and the configure arguments in Makefile.
+# Record target_configdirs and the configure arguments for target and
+# build configuration in Makefile.
 target_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'`
 targargs=`echo "${arguments}" | \
 	sed -e 's/--no[^ 	]*//' \
@@ -1357,6 +1370,7 @@ targargs=`echo "${arguments}" | \
 	    -e 's/--ho[a-z-]*=[^ 	]*//' \
 	    -e 's/--bu[a-z-]*=[^ 	]*//' \
 	    -e 's/--ta[a-z-]*=[^ 	]*//'`
+buildargs="--cache-file=../config.cache --host=${build_alias} ${targargs}"
 
 # Passing a --with-cross-host argument lets the target libraries know
 # whether they are being built with a cross-compiler or being built
@@ -1535,7 +1549,7 @@ qqCXX_FOR_TARGET=`echo "$qCXX_FOR_TARGET
 
 targargs="--cache-file=../config.cache --host=${target_alias} --build=${build_alias} ${targargs}"
 sed -e "s:^TARGET_CONFIGDIRS[ 	]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:" \
-    -e "s%^CONFIG_ARGUMENTS[ 	]*=.*$%CONFIG_ARGUMENTS = ${targargs}%" \
+    -e "s%^TARGET_CONFIGARGS[ 	]*=.*$%TARGET_CONFIGARGS = ${targargs}%" \
     -e "s%^FLAGS_FOR_TARGET[ 	]*=.*$%FLAGS_FOR_TARGET = ${FLAGS_FOR_TARGET}%" \
     -e "s%^CC_FOR_TARGET[ 	]*=.*$%CC_FOR_TARGET = ${CC_FOR_TARGET}%" \
     -e "s%^CHILL_FOR_TARGET[ 	]*=.*$%CHILL_FOR_TARGET = ${CHILL_FOR_TARGET}%" \
@@ -1543,6 +1557,8 @@ sed -e "s:^TARGET_CONFIGDIRS[ 	]*=.*$:TA
     -e "s%^CXX_FOR_TARGET[ 	]*=.*$%CXX_FOR_TARGET = ${qCXX_FOR_TARGET}%" \
     -e "s%^CXX_FOR_TARGET_FOR_RECURSIVE_MAKE[ 	]*=.*$%CXX_FOR_TARGET_FOR_RECURSIVE_MAKE = ${qqCXX_FOR_TARGET}%" \
     -e "s%^TARGET_SUBDIR[ 	]*=.*$%TARGET_SUBDIR = ${target_subdir}%" \
+    -e "s%^BUILD_SUBDIR[ 	]*=.*$%BUILD_SUBDIR = ${build_subdir}%" \
+    -e "s%^BUILD_CONFIGARGS[ 	]*=.*$%BUILD_CONFIGARGS = ${buildargs}%" \
     -e "s%^gxx_include_dir[ 	]*=.*$%gxx_include_dir=${gxx_include_dir}%" \
        Makefile > Makefile.tem
 rm -f Makefile
===================================================================
Index: gcc/Makefile.in
--- gcc/Makefile.in	2001/11/22 02:32:52	1.787
+++ gcc/Makefile.in	2001/11/23 18:17:14
@@ -341,21 +341,12 @@ LIBICONV = @LIBICONV@
 # List of internationalization subdirectories.
 INTL_SUBDIRS = intl
 
-# Change this to a null string if obstacks are installed in the
-# system library.
-OBSTACK=obstack.o
-
 # The GC method to be used on this system.
 GGC=@GGC@.o
 
 # If a supplementary library is being used for the GC.
 GGC_LIB=
 
-# Configure will set these if you need vfprintf and possibly _doprnt support.
-VFPRINTF=@vfprintf@
-DOPRINT=@doprint@
-STRSTR=@strstr@
-
 # libgcc.a may be built directly or via stmp-multilib,
 # and installed likewise.  Overridden by t-fragment.
 LIBGCC = libgcc.a
@@ -478,10 +469,6 @@ HOST_CC=$(CC)
 HOST_CFLAGS=$(ALL_CFLAGS) -DGENERATOR_FILE
 HOST_LDFLAGS=$(LDFLAGS)
 HOST_CPPFLAGS=$(ALL_CPPFLAGS)
-HOST_OBSTACK=$(OBSTACK)
-HOST_VFPRINTF=$(VFPRINTF)
-HOST_DOPRINT=$(DOPRINT)
-HOST_STRSTR=$(STRSTR)
 
 # Actual name to use when installing a native compiler.
 GCC_INSTALL_NAME = `echo gcc|sed '$(program_transform_name)'`
@@ -606,34 +593,29 @@ ALL_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLA
 # Likewise.
 ALL_CPPFLAGS = $(CPPFLAGS) $(X_CPPFLAGS) $(T_CPPFLAGS)
 
-USE_HOST_OBSTACK= ` case "${HOST_OBSTACK}" in ?*) echo ${HOST_PREFIX}${HOST_OBSTACK} ;; esac `
-USE_HOST_VFPRINTF= ` case "${HOST_VFPRINTF}" in ?*) echo ${HOST_PREFIX}${HOST_VFPRINTF} ;; esac `
-USE_HOST_DOPRINT= ` case "${HOST_DOPRINT}" in ?*) echo ${HOST_PREFIX}${HOST_DOPRINT} ;; esac `
-USE_HOST_STRSTR= ` case "${HOST_STRSTR}" in ?*) echo ${HOST_PREFIX}${HOST_STRSTR} ;; esac `
+# Build and host support libraries.  FORBUILD is either
+# ../ or ../$(build_alias)/ depending on whether host != build.
+LIBIBERTY = ../libiberty/libiberty.a
+BUILD_LIBIBERTY = @FORBUILD@/libiberty/libiberty.a
 
 # Dependency on obstack or whatever library facilities
 # are not installed in the system libraries.
-# We don't use USE_* because backquote expansion doesn't work in deps.
-LIBDEPS= $(INTLDEPS) $(OBSTACK) $(VFPRINTF) $(DOPRINT) $(STRSTR)
+LIBDEPS= $(INTLDEPS) $(LIBIBERTY)
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-HOST_LIBDEPS= $(HOST_PREFIX)$(HOST_OBSTACK) \
-	$(HOST_PREFIX)$(HOST_VFPRINTF) $(HOST_PREFIX)$(HOST_DOPRINT) \
-	$(HOST_PREFIX)$(HOST_STRSTR)
+HOST_LIBDEPS= $(BUILD_LIBIBERTY)
 
 # How to link with both our special library facilities
 # and the system's installed libraries.
-LIBS =	$(OBSTACK) $(INTLLIBS) @LIBS@ $(VFPRINTF) $(DOPRINT) \
-	$(STRSTR) ../libiberty/libiberty.a
+LIBS =	$(INTLLIBS) @LIBS@ $(LIBIBERTY)
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-HOST_LIBS = $(USE_HOST_OBSTACK) $(USE_HOST_VFPRINTF) \
-	    $(USE_HOST_DOPRINT) $(USE_HOST_STRSTR)
+HOST_LIBS = $(BUILD_LIBIBERTY)
 
 HOST_RTL = $(HOST_PREFIX)rtl.o read-rtl.o $(HOST_PREFIX)bitmap.o \
-		$(HOST_PREFIX)ggc-none.o gensupport.o hashtab.o safe-ctype.o
+		$(HOST_PREFIX)ggc-none.o gensupport.o
 
 HOST_PRINT = $(HOST_PREFIX)print-rtl.o
 HOST_ERRORS = $(HOST_PREFIX)errors.o
@@ -744,7 +726,7 @@ OBJS = alias.o bb-reorder.o bitmap.o bui
  profile.o real.o recog.o reg-stack.o regclass.o regmove.o regrename.o	\
  reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o	\
  sbitmap.o sched-deps.o sched-ebb.o sched-rgn.o sched-vis.o sdbout.o	\
- sibcall.o simplify-rtx.o splay-tree.o ssa.o ssa-ccp.o ssa-dce.o stmt.o	\
+ sibcall.o simplify-rtx.o ssa.o ssa-ccp.o ssa-dce.o stmt.o	\
  stor-layout.o stringpool.o timevar.o toplev.o tree.o tree-dump.o 	\
  tree-inline.o unroll.o varasm.o varray.o version.o xcoffout.o 		\
  cfglayout.o								\
@@ -1207,29 +1189,6 @@ tlink.o: tlink.c $(DEMANGLE_H) hash.h $(
 hash.o: hash.c hash.h $(SYSTEM_H) toplev.h $(GCONFIG_H)
 	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
 
-vfprintf.o: $(srcdir)/../libiberty/vfprintf.c $(GCONFIG_H) $(SYSTEM_H)
-	rm -f vfprintf.c
-	$(LN_S) $(srcdir)/../libiberty/vfprintf.c vfprintf.c
-	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) \
-		vfprintf.c $(OUTPUT_OPTION)
-
-doprint.o: $(srcdir)/doprint.c $(GCONFIG_H) $(SYSTEM_H)
-	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) \
-		$(srcdir)/doprint.c $(OUTPUT_OPTION)
-
-strstr.o: $(srcdir)/../libiberty/strstr.c $(GCONFIG_H) $(SYSTEM_H)
-	rm -f strstr.c
-	$(LN_S) $(srcdir)/../libiberty/strstr.c strstr.c
-	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) \
-		strstr.c $(OUTPUT_OPTION)
-
-splay-tree.o: $(srcdir)/../libiberty/splay-tree.c $(GCONFIG_H) \
-  $(srcdir)/../include/splay-tree.h $(srcdir)/../include/libiberty.h
-	rm -f splay-tree.c
-	$(LN_S) $(srcdir)/../libiberty/splay-tree.c splay-tree.c
-	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) \
-		splay-tree.c $(OUTPUT_OPTION)
-
 underscore.c: s-under ; @true
 
 s-under: $(GCC_PASSES)
@@ -1332,12 +1291,6 @@ line-map.o: line-map.c line-map.h intl.h
 ggc-none.o: ggc-none.c $(GCONFIG_H) $(SYSTEM_H) $(GGC_H)
 	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
 
-obstack.o: $(srcdir)/../libiberty/obstack.c $(GCONFIG_H)
-	rm -f obstack.c
-	$(LN_S) $(srcdir)/../libiberty/obstack.c obstack.c
-	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) \
-		obstack.c $(OUTPUT_OPTION)
-
 prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) Makefile prefix.h
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 	-DPREFIX=\"$(prefix)\" \
@@ -1792,16 +1745,6 @@ read-rtl.o: read-rtl.c $(HCONFIG_H) $(SY
 gensupport.o: gensupport.c $(RTL_H) $(OBSTACK_H) $(SYSTEM_H) errors.h gensupport.h
 	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gensupport.c
 
-hashtab.o: $(srcdir)/../libiberty/hashtab.c $(GCONFIG_H)
-	rm -f hashtab.c
-	$(LN_S) $(srcdir)/../libiberty/hashtab.c hashtab.c
-	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) hashtab.c
-
-safe-ctype.o: $(srcdir)/../libiberty/safe-ctype.c $(GCONFIG_H)
-	rm -f safe-ctype.c
-	$(LN_S) $(srcdir)/../libiberty/safe-ctype.c safe-ctype.c
-	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) safe-ctype.c
-
 genconfig$(build_exeext) : genconfig.o $(HOST_RTL) $(HOST_PRINT) $(HOST_ERRORS) $(HOST_LIBDEPS)
 	$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
 	  genconfig.o $(HOST_RTL) $(HOST_PRINT) $(HOST_ERRORS) $(HOST_LIBS)
@@ -1931,28 +1874,6 @@ $(HOST_PREFIX_1)bitmap.o: $(srcdir)/bitm
 	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/bitmap.c > $(HOST_PREFIX)bitmap.c
 	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)bitmap.c
 
-$(HOST_PREFIX_1)obstack.o: $(srcdir)/../libiberty/obstack.c $(HCONFIG_H)
-	rm -f $(HOST_PREFIX)obstack.c
-	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/../libiberty/obstack.c > $(HOST_PREFIX)obstack.c
-	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)obstack.c
-
-$(HOST_PREFIX_1)vfprintf.o: $(srcdir)/../libiberty/vfprintf.c $(HCONFIG_H) \
-  $(SYSTEM_H)
-	rm -f $(HOST_PREFIX)vfprintf.c
-	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/../libiberty/vfprintf.c > $(HOST_PREFIX)vfprintf.c
-	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)vfprintf.c
-
-$(HOST_PREFIX_1)doprint.o: doprint.c $(HCONFIG_H) $(SYSTEM_H)
-	rm -f $(HOST_PREFIX)doprint.c
-	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/doprint.c > $(HOST_PREFIX)doprint.c
-	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)doprint.c
-
-$(HOST_PREFIX_1)strstr.o: $(srcdir)/../libiberty/strstr.c $(HCONFIG_H) \
-  $(SYSTEM_H)
-	rm -f $(HOST_PREFIX)strstr.c
-	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/../libiberty/strstr.c > $(HOST_PREFIX)strstr.c
-	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)strstr.c
-
 $(HOST_PREFIX_1)errors.o: errors.c $(HCONFIG_H) $(SYSTEM_H) errors.h
 	rm -f $(HOST_PREFIX)errors.c
 	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/errors.c > $(HOST_PREFIX)errors.c
@@ -2242,7 +2163,7 @@ deduced.h: $(GCC_PASSES) $(srcdir)/scan-
 GEN_PROTOS_OBJS = gen-protos.o scan.o
 gen-protos$(build_exeext): $(GEN_PROTOS_OBJS)
 	${HOST_CC} $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
-	  $(GEN_PROTOS_OBJS) ../libiberty/libiberty.a
+	  $(GEN_PROTOS_OBJS) $(HOST_LIBS)
 
 gen-protos.o: gen-protos.c scan.h $(HCONFIG_H) $(SYSTEM_H)
 	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gen-protos.c
@@ -2499,7 +2420,7 @@ distclean: clean $(INTL_DISTCLEAN) lang.
 	-rm -f site.exp site.bak testsuite/site.exp testsuite/site.bak
 	-rm -f testsuite/{gcc,g++}.{log,sum}
 	-rm -f intl/libintl.h libintl.h
-	-rm -f cxxmain.c splay-tree.c obstack.c hashtab.c safe-ctype.c
+	-rm -f cxxmain.c
 	-rm -f mklibgcc libgcc.map gccbug .gdbinit configargs.h
 	-rm -f gcov.pod
 	-rm -f fixinc/Makefile
===================================================================
Index: gcc/aclocal.m4
--- gcc/aclocal.m4	2001/11/06 02:39:47	1.56
+++ gcc/aclocal.m4	2001/11/23 18:17:14
@@ -75,27 +75,6 @@ if test x = y ; then
 fi
 ])
 
-dnl Check if we have vprintf and possibly _doprnt.
-dnl Note autoconf checks for vprintf even though we care about vfprintf.
-AC_DEFUN(gcc_AC_FUNC_VFPRINTF_DOPRNT,
-[AC_FUNC_VPRINTF
-vfprintf=
-doprint=
-if test $ac_cv_func_vprintf != yes ; then
-  vfprintf=vfprintf.o
-  if test $ac_cv_func__doprnt != yes ; then
-    doprint=doprint.o
-  fi
-fi
-AC_SUBST(vfprintf)
-AC_SUBST(doprint)
-])    
-
-dnl Check if we have strstr.
-AC_DEFUN([gcc_AC_FUNC_STRSTR],
-  [AC_CHECK_FUNCS([strstr], [strstr=], [strstr=strstr.o])
-   AC_SUBST([strstr])])
-
 dnl See if the printf functions in libc support %p in format strings.
 AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
 [AC_CACHE_CHECK(whether the printf functions support %p,
===================================================================
Index: gcc/build-make
--- gcc/build-make	2001/06/28 04:38:50	1.9
+++ gcc/build-make	2001/11/23 18:17:14
@@ -12,8 +12,6 @@ HOST_CFLAGS=$(INTERNAL_CFLAGS) $(T_CFLAG
 	    $(XCFLAGS) -DGENERATOR_FILE
 HOST_LDFLAGS=$(LDFLAGS)
 HOST_CPPFLAGS=$(ALL_CPPFLAGS)
-HOST_MALLOC=$(MALLOC)
-HOST_OBSTACK=$(OBSTACK)
 
 # To build the native compiler with the cross compiler, the headers 
 # for the target are already fixed. And /usr/include is for host, not
===================================================================
Index: gcc/configure.in
--- gcc/configure.in	2001/11/20 10:16:08	1.558
+++ gcc/configure.in	2001/11/23 18:17:15
@@ -606,8 +606,6 @@ else
 fi
 AC_SUBST(TARGET_GETGROUPS_T)
 
-gcc_AC_FUNC_VFPRINTF_DOPRNT
-gcc_AC_FUNC_STRSTR
 gcc_AC_FUNC_PRINTF_PTR
 
 case "${host}" in
@@ -838,6 +836,7 @@ fi
 if test x$host = x$build
 then
 	build_auto=auto-host.h
+	FORBUILD=..
 else
 	# We create a subdir, then run autoconf in the subdir.
 	# To prevent recursion we set host and build for the new
@@ -863,7 +862,9 @@ else
 	cd ..
 	rm -rf $tempdir
 	build_auto=auto-build.h
+	FORBUILD=../$build
 fi
+AC_SUBST(FORBUILD)
 
 tm_file="${tm_file} defaults.h"
 host_xm_file="auto-host.h ansidecl.h ${host_xm_file} ${tm_file}"
===================================================================
Index: gcc/doprint.c
--- gcc/doprint.c	Fri Nov 23 10:17:17 2001
+++ gcc/doprint.c	Tue May  5 13:32:27 1998
@@ -1,284 +0,0 @@
-/* Provide a version _doprnt in terms of fprintf.
-   Copyright (C) 1998, 1999, 2000, 2001   Free Software Foundation, Inc.
-   Contributed by Kaveh Ghazi  (ghazi@caip.rutgers.edu)  3/29/98
-
-This program is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-#include "config.h"
-#include "system.h"
-#undef _doprnt
-
-#ifdef TEST /* Make sure to use the internal one.  */
-#define _doprnt my_doprnt
-#endif
-
-#define COPY_VA_INT \
-  do { \
-	 const int value = abs (va_arg (ap, int)); \
-	 char buf[32]; \
-	 ptr++; /* Go past the asterisk.  */ \
-	 *sptr = '\0'; /* NULL terminate sptr.  */ \
-	 sprintf(buf, "%d", value); \
-	 strcat(sptr, buf); \
-	 while (*sptr) sptr++; \
-     } while (0)
-
-#define PRINT_CHAR(CHAR) \
-  do { \
-	 putc(CHAR, stream); \
-	 ptr++; \
-	 total_printed++; \
-	 continue; \
-     } while (0)
-
-#define PRINT_TYPE(TYPE) \
-  do { \
-	int result; \
-	TYPE value = va_arg (ap, TYPE); \
-	*sptr++ = *ptr++; /* Copy the type specifier.  */ \
-	*sptr = '\0'; /* NULL terminate sptr.  */ \
-	result = fprintf(stream, specifier, value); \
-	if (result == -1) \
-	  return -1; \
-	else \
-	  { \
-	    total_printed += result; \
-	    continue; \
-	  } \
-      } while (0)
-
-int
-_doprnt (format, ap, stream)
-  const char * format;
-  va_list ap;
-  FILE * stream;
-{
-  const char * ptr = format;
-  char specifier[128];
-  int total_printed = 0;
-  
-  while (*ptr != '\0')
-    {
-      if (*ptr != '%') /* While we have regular characters, print them.  */
-	PRINT_CHAR(*ptr);
-      else /* We got a format specifier! */
-	{
-	  char * sptr = specifier;
-	  int wide_width = 0, short_width = 0;
-	  
-	  *sptr++ = *ptr++; /* Copy the % and move forward.  */
-
-	  while (strchr ("-+ #0", *ptr)) /* Move past flags.  */
-	    *sptr++ = *ptr++;
-
-	  if (*ptr == '*')
-	    COPY_VA_INT;
-	  else
-	    while (ISDIGIT(*ptr)) /* Handle explicit numeric value.  */
-	      *sptr++ = *ptr++;
-	  
-	  if (*ptr == '.')
-	    {
-	      *sptr++ = *ptr++; /* Copy and go past the period.  */
-	      if (*ptr == '*')
-		COPY_VA_INT;
-	      else
-		while (ISDIGIT(*ptr)) /* Handle explicit numeric value.  */
-		  *sptr++ = *ptr++;
-	    }
-	  while (strchr ("hlL", *ptr))
-	    {
-	      switch (*ptr)
-		{
-		case 'h':
-		  short_width = 1;
-		  break;
-		case 'l':
-		  wide_width++;
-		  break;
-		case 'L':
-		  wide_width = 2;
-		  break;
-		default:
-		  abort();
-		}
-	      *sptr++ = *ptr++;
-	    }
-
-	  switch (*ptr)
-	    {
-	    case 'd':
-	    case 'i':
-	    case 'o':
-	    case 'u':
-	    case 'x':
-	    case 'X':
-	    case 'c':
-	      {
-		/* Short values are promoted to int, so just copy it
-                   as an int and trust the C library printf to cast it
-                   to the right width.  */
-		if (short_width)
-		  PRINT_TYPE(int);
-		else
-		  {
-		    switch (wide_width)
-		      {
-		      case 0:
-			PRINT_TYPE(int);
-			break;
-		      case 1:
-			PRINT_TYPE(long);
-			break;
-		      case 2:
-		      default:
-#if defined(__GNUC__) || defined(HAVE_LONG_LONG)
-			PRINT_TYPE(long long);
-#else
-			PRINT_TYPE(long); /* Fake it and hope for the best.  */
-#endif
-			break;
-		      } /* End of switch (wide_width) */
-		  } /* End of else statement */
-	      } /* End of integer case */
-	      break;
-	    case 'f':
-	    case 'e':
-	    case 'E':
-	    case 'g':
-	    case 'G':
-	      {
-		if (wide_width == 0)
-		  PRINT_TYPE(double);
-		else
-		  {
-#if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
-		    PRINT_TYPE(long double);
-#else
-		    PRINT_TYPE(double); /* Fake it and hope for the best.  */
-#endif
-		  }
-	      }
-	      break;
-	    case 's':
-	      PRINT_TYPE(char *);
-	      break;
-	    case 'p':
-	      PRINT_TYPE(void *);
-	      break;
-	    case '%':
-	      PRINT_CHAR('%');
-	      break;
-	    default:
-	      abort();
-	    } /* End of switch (*ptr) */
-	} /* End of else statement */
-    }
-
-  return total_printed;
-}
-
-#ifdef TEST
-
-#include <math.h>
-#ifndef M_PI
-#define M_PI (3.1415926535897932385)
-#endif
-
-#define RESULT(x) do \
-{ \
-    int i = (x); \
-    printf ("printed %d characters\n", i); \
-    fflush(stdin); \
-} while (0)
-
-static int checkit PARAMS ((const char * format, ...)) ATTRIBUTE_PRINTF_1;
-
-static int
-checkit VPARAMS ((const char* format, ...))
-{
-  int result;
-  VA_OPEN (args, format);
-  VA_FIXEDARG (args, char *, format);
-
-  result = _doprnt (format, args, stdout);
-  VA_CLOSE (args);
-
-  return result;
-}
-
-int
-main ()
-{
-  RESULT(checkit ("<%d>\n", 0x12345678));
-  RESULT(printf ("<%d>\n", 0x12345678));
-
-  RESULT(checkit ("<%200d>\n", 5));
-  RESULT(printf ("<%200d>\n", 5));
-
-  RESULT(checkit ("<%.300d>\n", 6));
-  RESULT(printf ("<%.300d>\n", 6));
-
-  RESULT(checkit ("<%100.150d>\n", 7));
-  RESULT(printf ("<%100.150d>\n", 7));
-
-  RESULT(checkit ("<%s>\n",
-		  "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
-777777777777777777333333333333366666666666622222222222777777777777733333"));
-  RESULT(printf ("<%s>\n",
-		 "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
-777777777777777777333333333333366666666666622222222222777777777777733333"));
-
-  RESULT(checkit ("<%f><%0+#f>%s%d%s>\n",
-		  1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
-  RESULT(printf ("<%f><%0+#f>%s%d%s>\n",
-		 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
-
-  RESULT(checkit ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
-  RESULT(printf ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
-
-  RESULT(checkit ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
-  RESULT(printf ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
-
-  RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
-		  75, 75, 75, 75, 75, 75, 75));
-  RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
-		 75, 75, 75, 75, 75, 75, 75));
-
-  RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
-		  75, 75, 75, 75, 75, 75, 75));
-  RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
-		 75, 75, 75, 75, 75, 75, 75));
-
-  RESULT(checkit ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
-  RESULT(printf ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
-
-#if defined(__GNUC__) || defined (HAVE_LONG_LONG)
-  RESULT(checkit ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
-  RESULT(printf ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
-  RESULT(checkit ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
-  RESULT(printf ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
-#endif
-
-#if defined(__GNUC__) || defined (HAVE_LONG_DOUBLE)
-  RESULT(checkit ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
-		  1.23456, 1.234567890123456789L, 1.23456));
-  RESULT(printf ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
-		 1.23456, 1.234567890123456789L, 1.23456));
-#endif
-
-  return 0;
-}
-#endif /* TEST */
===================================================================
Index: libiberty/_doprnt.c
--- libiberty/_doprnt.c	Tue May  5 13:32:27 1998
+++ libiberty/_doprnt.c	Fri Nov 23 10:17:15 2001
@@ -0,0 +1,296 @@
+/* Provide a version of _doprnt in terms of fprintf.
+   Copyright (C) 1998, 1999, 2000, 2001   Free Software Foundation, Inc.
+   Contributed by Kaveh Ghazi  (ghazi@caip.rutgers.edu)  3/29/98
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "config.h"
+#include "ansidecl.h"
+#include "safe-ctype.h"
+
+#include <stdio.h>
+#ifdef ANSI_PROTOTYPES
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#undef _doprnt
+
+#ifdef TEST /* Make sure to use the internal one.  */
+#define _doprnt my_doprnt
+#endif
+
+#define COPY_VA_INT \
+  do { \
+	 const int value = abs (va_arg (ap, int)); \
+	 char buf[32]; \
+	 ptr++; /* Go past the asterisk.  */ \
+	 *sptr = '\0'; /* NULL terminate sptr.  */ \
+	 sprintf(buf, "%d", value); \
+	 strcat(sptr, buf); \
+	 while (*sptr) sptr++; \
+     } while (0)
+
+#define PRINT_CHAR(CHAR) \
+  do { \
+	 putc(CHAR, stream); \
+	 ptr++; \
+	 total_printed++; \
+	 continue; \
+     } while (0)
+
+#define PRINT_TYPE(TYPE) \
+  do { \
+	int result; \
+	TYPE value = va_arg (ap, TYPE); \
+	*sptr++ = *ptr++; /* Copy the type specifier.  */ \
+	*sptr = '\0'; /* NULL terminate sptr.  */ \
+	result = fprintf(stream, specifier, value); \
+	if (result == -1) \
+	  return -1; \
+	else \
+	  { \
+	    total_printed += result; \
+	    continue; \
+	  } \
+      } while (0)
+
+int
+_doprnt (format, ap, stream)
+  const char * format;
+  va_list ap;
+  FILE * stream;
+{
+  const char * ptr = format;
+  char specifier[128];
+  int total_printed = 0;
+  
+  while (*ptr != '\0')
+    {
+      if (*ptr != '%') /* While we have regular characters, print them.  */
+	PRINT_CHAR(*ptr);
+      else /* We got a format specifier! */
+	{
+	  char * sptr = specifier;
+	  int wide_width = 0, short_width = 0;
+	  
+	  *sptr++ = *ptr++; /* Copy the % and move forward.  */
+
+	  while (strchr ("-+ #0", *ptr)) /* Move past flags.  */
+	    *sptr++ = *ptr++;
+
+	  if (*ptr == '*')
+	    COPY_VA_INT;
+	  else
+	    while (ISDIGIT(*ptr)) /* Handle explicit numeric value.  */
+	      *sptr++ = *ptr++;
+	  
+	  if (*ptr == '.')
+	    {
+	      *sptr++ = *ptr++; /* Copy and go past the period.  */
+	      if (*ptr == '*')
+		COPY_VA_INT;
+	      else
+		while (ISDIGIT(*ptr)) /* Handle explicit numeric value.  */
+		  *sptr++ = *ptr++;
+	    }
+	  while (strchr ("hlL", *ptr))
+	    {
+	      switch (*ptr)
+		{
+		case 'h':
+		  short_width = 1;
+		  break;
+		case 'l':
+		  wide_width++;
+		  break;
+		case 'L':
+		  wide_width = 2;
+		  break;
+		default:
+		  abort();
+		}
+	      *sptr++ = *ptr++;
+	    }
+
+	  switch (*ptr)
+	    {
+	    case 'd':
+	    case 'i':
+	    case 'o':
+	    case 'u':
+	    case 'x':
+	    case 'X':
+	    case 'c':
+	      {
+		/* Short values are promoted to int, so just copy it
+                   as an int and trust the C library printf to cast it
+                   to the right width.  */
+		if (short_width)
+		  PRINT_TYPE(int);
+		else
+		  {
+		    switch (wide_width)
+		      {
+		      case 0:
+			PRINT_TYPE(int);
+			break;
+		      case 1:
+			PRINT_TYPE(long);
+			break;
+		      case 2:
+		      default:
+#if defined(__GNUC__) || defined(HAVE_LONG_LONG)
+			PRINT_TYPE(long long);
+#else
+			PRINT_TYPE(long); /* Fake it and hope for the best.  */
+#endif
+			break;
+		      } /* End of switch (wide_width) */
+		  } /* End of else statement */
+	      } /* End of integer case */
+	      break;
+	    case 'f':
+	    case 'e':
+	    case 'E':
+	    case 'g':
+	    case 'G':
+	      {
+		if (wide_width == 0)
+		  PRINT_TYPE(double);
+		else
+		  {
+#if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
+		    PRINT_TYPE(long double);
+#else
+		    PRINT_TYPE(double); /* Fake it and hope for the best.  */
+#endif
+		  }
+	      }
+	      break;
+	    case 's':
+	      PRINT_TYPE(char *);
+	      break;
+	    case 'p':
+	      PRINT_TYPE(void *);
+	      break;
+	    case '%':
+	      PRINT_CHAR('%');
+	      break;
+	    default:
+	      abort();
+	    } /* End of switch (*ptr) */
+	} /* End of else statement */
+    }
+
+  return total_printed;
+}
+
+#ifdef TEST
+
+#include <math.h>
+#ifndef M_PI
+#define M_PI (3.1415926535897932385)
+#endif
+
+#define RESULT(x) do \
+{ \
+    int i = (x); \
+    printf ("printed %d characters\n", i); \
+    fflush(stdin); \
+} while (0)
+
+static int checkit PARAMS ((const char * format, ...)) ATTRIBUTE_PRINTF_1;
+
+static int
+checkit VPARAMS ((const char* format, ...))
+{
+  int result;
+  VA_OPEN (args, format);
+  VA_FIXEDARG (args, char *, format);
+
+  result = _doprnt (format, args, stdout);
+  VA_CLOSE (args);
+
+  return result;
+}
+
+int
+main ()
+{
+  RESULT(checkit ("<%d>\n", 0x12345678));
+  RESULT(printf ("<%d>\n", 0x12345678));
+
+  RESULT(checkit ("<%200d>\n", 5));
+  RESULT(printf ("<%200d>\n", 5));
+
+  RESULT(checkit ("<%.300d>\n", 6));
+  RESULT(printf ("<%.300d>\n", 6));
+
+  RESULT(checkit ("<%100.150d>\n", 7));
+  RESULT(printf ("<%100.150d>\n", 7));
+
+  RESULT(checkit ("<%s>\n",
+		  "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
+777777777777777777333333333333366666666666622222222222777777777777733333"));
+  RESULT(printf ("<%s>\n",
+		 "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
+777777777777777777333333333333366666666666622222222222777777777777733333"));
+
+  RESULT(checkit ("<%f><%0+#f>%s%d%s>\n",
+		  1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
+  RESULT(printf ("<%f><%0+#f>%s%d%s>\n",
+		 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
+
+  RESULT(checkit ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
+  RESULT(printf ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
+
+  RESULT(checkit ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
+  RESULT(printf ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
+
+  RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
+		  75, 75, 75, 75, 75, 75, 75));
+  RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
+		 75, 75, 75, 75, 75, 75, 75));
+
+  RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
+		  75, 75, 75, 75, 75, 75, 75));
+  RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
+		 75, 75, 75, 75, 75, 75, 75));
+
+  RESULT(checkit ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
+  RESULT(printf ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
+
+#if defined(__GNUC__) || defined (HAVE_LONG_LONG)
+  RESULT(checkit ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
+  RESULT(printf ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
+  RESULT(checkit ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
+  RESULT(printf ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
+#endif
+
+#if defined(__GNUC__) || defined (HAVE_LONG_DOUBLE)
+  RESULT(checkit ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
+		  1.23456, 1.234567890123456789L, 1.23456));
+  RESULT(printf ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
+		 1.23456, 1.234567890123456789L, 1.23456));
+#endif
+
+  return 0;
+}
+#endif /* TEST */
===================================================================
Index: libiberty/configure.in
--- libiberty/configure.in	2001/11/15 18:11:24	1.39
+++ libiberty/configure.in	2001/11/23 18:17:15
@@ -132,7 +132,7 @@ AC_EGREP_HEADER(uintptr_t, sys/types.h,
 
 if test $libiberty_cv_uintptr_t = yes
 then
-  AC_DEFINE(HAVE_UINTPTR_T)
+  AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
   AC_MSG_RESULT(yes)
 else
   AC_MSG_RESULT(no)
@@ -254,9 +254,9 @@ fi
 AC_SUBST(CHECK)
 
 case "${host}" in
-  *-*-cygwin*) 
-    AC_DEFINE(HAVE_SYS_ERRLIST)
-    AC_DEFINE(HAVE_SYS_NERR)
+  *-*-cygwin*)
+    AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
+    AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
     ;;
 esac
 
@@ -351,6 +351,13 @@ if test -z "${setobjs}"; then
   if test $ac_cv_func_vfork_works = no; then
     LIBOBJS="$LIBOBJS vfork.o"
   fi
+  # We only need _doprnt if we might use it to implement v*printf.
+  if test $ac_cv_func_vprintf != yes \
+     || test $ac_cv_func_vfprintf != yes \
+     || test $ac_cv_func_vsprintf != yes; then
+    AC_REPLACE_FUNCS(_doprnt)
+  fi
+
   for v in $vars; do
     AC_MSG_CHECKING([for $v])
     AC_CACHE_VAL(libiberty_cv_var_$v,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]