	Configuring libstdc++-2.8.1

Like most GNU software, libstdc++ must be configured before it can be built.
This document attempts to describe the recommended configuration procedure
for both native and cross targets.

We use srcdir to refer to the toplevel source directory for
libstdc++; we use objdir to refer to the toplevel build/object
directory for libstdc++.

First, we highly recommend that libstdc++ be built into a separate
directory than the sources.  This is how we generally build libstdc++; building
where srcdir == objdir should still work, but doesn't get
extensive testing.

Second, when configuring a native system, either "cc" must be in your
path or you must set CC in your environment before running configure.
Otherwise the configuration scripts may fail.

Third, beginning with this version of libstdc++ we highly recommend that
gcc will not be built separately. One advantage of this is that gcc
and the runtime libraries agree about where the runtime libs' include
files will be installed. Rather untar gcc-m.x.y into the toplevel
directory of libstdc++ (where this INSTALL file lives), rename the
gcc-m.x.y directory to gcc, and optionally apply the patch
at the end of this file (you can actually feed this file as input to
patch). This patch allows you to check the built compiler (if you
actually intend to do this, you'd need to get a testsuite for gcc
- e.g. egcs' one from <ftp://egcs.cygnus.com/pub/egcs/releases/>
and move that directory into the gcc directory):

  % cd srcdir
  % gunzip < /where/you/store/GNU/packages/gcc-m.x.y.tar.gz | tar xf -
  % mv gcc-m.x.y gcc
  % patch < INSTALL
  % gunzip < /where/you/store/GNU/packages/egcs-n.x.y.tar.gz | \
    tar xf - egcs-n.x.y/gcc/teststuite
  % mv egcs-n.x.y/gcc/teststuite gcc
  % rmdir -p egcs-n.x.y/gcc

To configure libstdc++:

  % mkdir objdir
  % cd objdir
  % srcdir/configure [target] [options]


target specification

  libstdc++ has code to correctly determine the correct value for
  target for nearly all native systems.  Therefore, we highly
  recommend you not provide a configure target when configuring a
  native package.

  target must be specified when configuring a cross package;
  examples of valid targets would be i960-rtems, m68k-coff, sh-elf, etc.


options specification

Use options to override several configure time options for
libstdc++.  A partial list of supported options:


  --prefix=dirname -- Specify the toplevel installation
  directory.  This is the recommended way to install the tools into a directory
  other than the default.  The toplevel installation directory defaults to
  /usr/local.

  These additional options control where certain parts of the distribution
  are installed.  Normally you should not need to use these options.
  
     --with-local-prefix=dirname -- Specify the installation
     directory for local include files.  The default is /usr/local.

     --with-gxx-include-dir=dirname -- Specify the installation
     directory for g++ header files.  The default is /usr/local/include/g++.
  

  --enable-shared -- Build shared versions of the C++ runtime
  libraries if supported --disable-shared is the default.

  --with-gnu-as -- Specify that the compiler should assume the GNU
  assembler (aka gas) is available. 

  --with-gnu-ld -- Specify that the compiler should assume the GNU
  linker (aka gld) is available. 

  --enable-multilib -- Specify that multiple target libraries
  should be built to support different target variants, calling conventions,
  etc.  This is the default. 

 
Note that each --enable option has a corresponding --disable option and
that each --with option has a corresponding --without option.



	Building libstdc++-2.8.1

Now that libstdc++ is configured, you are ready to build the compiler
(if you unpacked the compiler sources as recommended above) and
runtime libraries.

We highly recommend that libstdc++ be built using gnu-make; other
versions may work, then again they might not.  To be safe build with gnu-make.



	Testing libstdc++-2.8.1

To see if the built compiler (optionally) and runtime libraries actually
work, you can check them with `cd objdir; make check'.



	Final install libstdc++-2.8.1

Now that libstdc++ has been built and tested, you can install it with
`cd objdir; make install'.

That step completes the installation of libstdc++; user level binaries can
be found in prefix/bin where prefix is the value you specified
with the --prefix to configure (or /usr/local by default).



Fri Feb 20 13:55:39 1998  Manfred Hollstein  <manfred@s-direktnet.de>

	* Makefile.in (EXPECT): New macro for `make check'.
	(RUNTEST): Likewise.
	(RUNTESTFLAGS): Likewise.
	(target_subdir): Likewise.
	(CHECK_TARGETS): Likewise.
	(FLAGS_TO_PASS): Add local_prefix and gxx_include_dir.
	(distclean): Remove testsuite specific files.
	(site.exp): New rule to generate gcc specific check information.
	(testsuite/site.exp): Likewise.
	(check-g++): Rule to invoke checking g++.
	(check-gcc): Rule to invoke checking gcc.
	(check-g77): Rule to invoke checking g77.

--- gcc/Makefile.in.orig	Fri Feb 20 13:53:00 1998
+++ gcc/Makefile.in	Fri Feb 20 13:58:33 1998
@@ -411,6 +411,16 @@
 # Source for float.h.  Overridden by cross-make.
 FLOAT_H=float.h-nat
 
+# Setup the testing framework, if you have one
+EXPECT = `if [ -f $${rootme}/../expect/expect ] ; then \
+            echo $${rootme}/../expect/expect ; \
+          else echo expect ; fi`
+
+RUNTEST = `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
+	       echo $${srcdir}/../dejagnu/runtest ; \
+	    else echo runtest; fi`
+RUNTESTFLAGS =
+
 # Extra symbols for fixproto to define when parsing headers.
 FIXPROTO_DEFINES = 
 
@@ -546,7 +556,9 @@
 	"prefix=$(prefix)" \
 	"tooldir=$(tooldir)" \
 	"bindir=$(bindir)" \
-	"libsubdir=$(libsubdir)"
+	"libsubdir=$(libsubdir)" \
+	"local_prefix=$(local_prefix)" \
+	"gxx_include_dir=$(gxx_include_dir)"
 #
 # Lists of files for various purposes.
 
@@ -2100,6 +2112,8 @@
 	-rm -f c-parse.output
 	-rm -f *.asm
 	-rm -f float.h
+	-rm -f site.exp site.bak testsuite/site.exp testsuite/site.bak
+	-rm -f testsuite/{gcc,g++}.{log,sum}
 
 # Delete anything likely to be found in the source directory
 # that shouldn't be in the distribution.
@@ -2383,6 +2397,104 @@
 	-rm -rf $(mandir)/protoize$(manext)
 	-rm -rf $(mandir)/unprotoize$(manext)
 #
+# These targets are for the dejagnu testsuites. The file site.exp 
+# contains global variables that all the testsuites will use.
+
+# Set to $(target_alias)/ for cross.
+target_subdir = libraries/
+
+site.exp: ./config.status Makefile
+	@echo "Making a new config file..."
+	-@rm -f ./tmp?
+	@touch site.exp
+	-@mv site.exp site.bak
+	@echo "## these variables are automatically generated by make ##" > ./tmp0
+	@echo "# Do not edit here. If you wish to override these values" >> ./tmp0
+	@echo "# add them to the last section" >> ./tmp0
+	@echo "set rootme \"`pwd`\"" >> ./tmp0
+	@echo "set srcdir \"`cd ${srcdir}; pwd`\"" >> ./tmp0
+	@echo "set host_triplet $(host_canonical)" >> ./tmp0
+	@echo "set build_triplet $(build_canonical)" >> ./tmp0
+	@echo "set target_triplet $(target)" >> ./tmp0
+	@echo "set target_alias $(target_alias)" >> ./tmp0
+# CFLAGS is set even though it's empty to show we reserve the right to set it.
+	@echo "set CFLAGS \"\"" >> ./tmp0
+	@echo "set CXXFLAGS \"-I$(objdir)/../$(target_subdir)libio -I\$$srcdir/../libg++/src -I\$$srcdir/../libio -I\$$srcdir/../libstdc++ -I\$$srcdir/../libstdc++/stl -L$(objdir)/../$(target_subdir)libg++ -L$(objdir)/../$(target_subdir)libstdc++\"" >> ./tmp0
+# If newlib has been configured, we need to pass -B to gcc so it can find
+# newlib's crt0.o if it exists.  This will cause a "path prefix not used"
+# message if it doesn't, but the testsuite is supposed to ignore the message -
+# it's too difficult to tell when to and when not to pass -B (not all targets
+# have crt0's).  We could only add the -B if ../newlib/crt0.o exists, but that
+# seems like too selective a test.
+# ??? Another way to solve this might be to rely on linker scripts.  Then
+# theoretically the -B won't be needed.
+# We also need to pass -L ../ld so that the linker can find ldscripts.
+	@if [ -d $(objdir)/../$(target_subdir)newlib ] ; then \
+	  echo "set newlib_cflags \"-I$(objdir)/../$(target_subdir)newlib/targ-include -I\$$srcdir/../newlib/libc/include\"" >> ./tmp0; \
+	  echo "set newlib_ldflags \"-B$(objdir)/../$(target_subdir)newlib/\"" >> ./tmp0; \
+	  echo "append CFLAGS \" \$$newlib_cflags\"" >> ./tmp0; \
+	  echo "append CXXFLAGS \" \$$newlib_cflags\"" >> ./tmp0; \
+	  echo "append LDFLAGS \" \$$newlib_ldflags\"" >> ./tmp0; \
+	else true; \
+	fi
+	@if [ -d $(objdir)/../ld ] ; then \
+	  echo "append LDFLAGS \" -L$(objdir)/../ld\"" >> ./tmp0; \
+	else true; \
+	fi
+	@if  [ $(build_canonical) != $(host_canonical) ] ; then \
+	  echo "set tmpdir /tmp" >> ./tmp0 ; \
+	else echo "set tmpdir $(objdir)/testsuite" >> ./tmp0 ; \
+	fi
+	@echo "set srcdir \"\$${srcdir}/testsuite\"" >> ./tmp0
+	@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
+	@cat ./tmp0 > site.exp
+	@cat site.bak | sed \
+		-e '1,/^## All variables above are.*##/ d' >> site.exp
+	-@rm -f ./tmp?
+
+CHECK_TARGETS = check-gcc check-g++
+
+check: $(CHECK_TARGETS)
+
+testsuite/site.exp: site.exp
+	if [ -d testsuite ]; then \
+	  true; \
+	else \
+	  mkdir testsuite; \
+	fi
+	rm -rf testsuite/site.exp
+	cp site.exp testsuite/site.exp
+
+check-g++: testsuite/site.exp
+	-rootme=`pwd`; export rootme; \
+	srcdir=`cd ${srcdir}; pwd` ; export srcdir ; \
+	cd testsuite; \
+	EXPECT=${EXPECT} ; export EXPECT ; \
+	if [ -f $${rootme}/../expect/expect ] ; then  \
+	   TCL_LIBRARY=$${srcdir}/../tcl/library ; \
+	    export TCL_LIBRARY ; fi ; \
+	$(RUNTEST) --tool g++ $(RUNTESTFLAGS)
+
+check-gcc: testsuite/site.exp
+	-rootme=`pwd`; export rootme; \
+	srcdir=`cd ${srcdir}; pwd` ; export srcdir ; \
+	cd testsuite; \
+	EXPECT=${EXPECT} ; export EXPECT ; \
+	if [ -f $${rootme}/../expect/expect ] ; then  \
+	   TCL_LIBRARY=$${srcdir}/../tcl/library ; \
+	   export TCL_LIBRARY ; fi ; \
+	$(RUNTEST) --tool gcc $(RUNTESTFLAGS)
+
+check-g77: testsuite/site.exp
+	-rootme=`pwd`; export rootme; \
+	srcdir=`cd ${srcdir}; pwd` ; export srcdir ; \
+	cd testsuite; \
+	EXPECT=${EXPECT} ; export EXPECT ; \
+	if [ -f $${rootme}/../expect/expect ] ; then  \
+	   TCL_LIBRARY=$${srcdir}/../tcl/library ; \
+	   export TCL_LIBRARY ; fi ; \
+	$(RUNTEST) --tool g77 $(RUNTESTFLAGS)
+
 # These exist for maintenance purposes.
 
 # Update the tags table.
