OSDN Git Service

Use CROSS_LIBGCC1 for a cross-compiler
[pf3gnuchains/gcc-fork.git] / gcc / Makefile.in
index 6a64ab2..46d777b 100644 (file)
@@ -121,6 +121,9 @@ RANLIB_TEST_FOR_TARGET = [ -f $(TARGET_TOOLPREFIX)ranlib ]
 # Dir to search for system headers.  Overridden by cross-make.
 SYSTEM_HEADER_DIR = /usr/include
 
+# Uncomment following line for fixproto support.  (May become the default!)
+# STMP_FIXPROTO = stmp-fixproto
+
 # There may be a premade insn-attrtab.c for this machine.
 # (You could rebuild it with genattrtab as usual, but it takes a long time.)
 # PREMADE_ATTRTAB is the file name of the file to use.
@@ -151,7 +154,7 @@ bindir = $(exec_prefix)/bin
 libdir = $(exec_prefix)/lib
 # Directory in which the compiler finds executables, libraries, etc.
 libsubdir = $(libdir)/gcc-lib/$(target)/$(version)
-# Directory for header file assert.h.
+# Directory to search for site-specific includes.
 includedir = $(local_prefix)/include
 # assertdir is overridden in cross-make.
 # (But this currently agrees with what is in cross-make.)
@@ -175,11 +178,20 @@ CLIB=
 # system library.
 OBSTACK=obstack.o
 
+# Specify the rule for actually making libgcc.a,
+LIBGCC = libgcc.a
+# and the rule for installing it.
+INSTALL_LIBGCC = install-libgcc
+
 # Specify the rule for actually making libgcc1.a.
 # The value may be empty; that means to do absolutely nothing
 # with or for libgcc1.a.
 LIBGCC1 = libgcc1.a
 
+# Specify the rule for making libgcc1.a for a cross-compiler.
+# The default rule assumes that libgcc1.a is supplied by the user.
+CROSS_LIBGCC1 = libgcc1.cross
+
 # Specify the rule for actually making libgcc2.a.
 LIBGCC2 = libgcc2.a
 
@@ -247,6 +259,10 @@ TAROUTOPTS = xpBf
 FIXINCLUDES=fixincludes
 
 # Additional directories of header files to run fixincludes on.
+# These should be directories searched automatically by default
+# just as /usr/include is.
+# *Do not* use this for directories that happen to contain 
+# header files, but are not searched automatically by default.
 # On most systems, this is empty.
 OTHER_FIXINCLUDES_DIRS=
 
@@ -256,7 +272,7 @@ GCC_PASSES=xgcc cc1 cpp $(EXTRA_PASSES)
 
 # List of things which should already be built whenever we try to use xgcc
 # to link anything.
-GCC_PARTS=$(GCC_PASSES) libgcc.a $(EXTRA_PROGRAMS) $(USE_COLLECT2) $(EXTRA_PARTS)
+GCC_PARTS=$(GCC_PASSES) $(LIBGCC) $(EXTRA_PROGRAMS) $(USE_COLLECT2) $(EXTRA_PARTS)
 
 # Directory to link to, when using the target `maketest'.
 DIR = ../gcc
@@ -408,7 +424,7 @@ STAGESTUFF = *.o insn-flags.h insn-config.h insn-codes.h \
  stamp-attr stamp-attrtab stamp-opinit stamp-proto \
  genemit genoutput genrecog genextract genflags gencodes genconfig genpeep \
  genattrtab genattr genopinit \
- $(GCC_PASSES) $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross cccp \
+ $(GCC_PASSES) $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross cccp g++ g++-cross \
  cc1plus cc1obj enquire protoize unprotoize specs collect2 $(USE_COLLECT2)
 
 # Members of libgcc1.a.
@@ -431,7 +447,7 @@ LIB2FUNCS = _muldi3 _divdi3 _moddi3 _udivdi3 _umoddi3 _negdi2 \
 
 # Header files that are made available under the same name
 # to programs compiled with GCC.
-USER_H = va-alpha.h va-i860.h va-i960.h va-mips.h va-m88k.h \
+USER_H = va-alpha.h va-h8300.h va-i860.h va-i960.h va-mips.h va-m88k.h \
     va-pa.h va-pyr.h va-sparc.h va-clipper.h va-spur.h proto.h $(EXTRA_HEADERS)
 
 # The files that "belong" in CONFIG_H are deliberately omitted
@@ -457,15 +473,15 @@ all.internal: start.encap rest.encap
 # This is what to compile if making a cross-compiler.
 # Note that we can compile enquire using the cross-compiler just build,
 # although we can't run it on this machine.
-all.cross: native gcc-cross specs libgcc.a stmp-headers cross-test enquire $(EXTRA_PARTS)
+all.cross: native gcc-cross g++-cross specs $(LIBGCC) stmp-headers $(STMP_FIXPROTO) cross-test enquire $(EXTRA_PARTS)
 # This is what to compile if making gcc with a cross-compiler.
-all.build: native xgcc $(EXTRA_PARTS)
+all.build: native xgcc g++ $(EXTRA_PARTS)
 # This is what must be made before installing GCC and converting libraries.
-start.encap: native xgcc specs $(LIBGCC1) xlimits.h
+start.encap: native xgcc g++ specs $(LIBGCC1) xlimits.h
 # Use this to make a GCC that will be used only to recompile GCC.
-for-bootstrap: start.encap libgcc.a
+for-bootstrap: start.encap $(LIBGCC)
 # These can't be made, with COFF encapsulation, until after GCC can run.
-rest.encap: libgcc.a stmp-headers $(EXTRA_PARTS)
+rest.encap: $(LIBGCC) stmp-headers $(STMP_FIXPROTO) $(EXTRA_PARTS)
 # This is what is made with the host's compiler
 # whether making a cross compiler or not.
 native: config.status cpp $(LANGUAGES) $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(USE_COLLECT2)
@@ -491,11 +507,11 @@ config.status:
 
 # On the target machine, finish building a cross compiler.
 # This does the things that can't be done on the host machine.
-rest.cross: libgcc.a gfloat.h specs
+rest.cross: $(LIBGCC) gfloat.h specs
 
 # Verify that it works to compile and link cross-test.
 # If it does, then there are sufficient replacements for libgcc1.a.
-cross-test: cross-test.o native gcc-cross libgcc.a $(GCC_PARTS)
+cross-test: cross-test.o native gcc-cross $(LIBGCC) $(GCC_PARTS)
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) cross-test.o -o $@
 cross-test.o: cross-test.c native gcc-cross
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(ALL_CPPFLAGS) -c $(srcdir)/cross-test.c
@@ -514,12 +530,21 @@ xgcc: gcc.o version.o $(LIBDEPS)
 specs: xgcc
        $(GCC_FOR_TARGET) -dumpspecs > specs
 
+# Create the compiler driver for g++.
+g++: g++.o $(LIBDEPS)
+       $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o g++ g++.o $(LIBS)
+
 # We do want to create an executable named `xgcc', so we can use it to
 # compile libgcc2.a.
 # Also create gcc-cross, so that install-common will install properly.
 gcc-cross: xgcc
        cp xgcc gcc-cross
 
+# Create a version of the g++ driver which calls the cross-compiler.
+g++-cross: $(srcdir)/g++.c
+       $(CC) $(ALL_CFLAGS) $(INCLUDES) $(LDFLAGS) -o g++-cross \
+          -DGCC_NAME=\"$(target)-gcc\" $(srcdir)/g++.c version.o $(LIBS)
+
 cc1:$(P) $(C_OBJS) $(OBJS) $(LIBDEPS)
        $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cc1 $(C_OBJS) $(OBJS) $(LIBS)
 
@@ -596,7 +621,10 @@ libgcc1.a: libgcc1.c $(CONFIG_H) $(LIB1FUNCS_EXTRA) config.status
 # so that libgcc1.a itself remains nonexistent if compilation is aborted.
 # -e causes any failing command to make this rule fail.
 # -e doesn't work in certain shells, so we test $$? as well.
-       set -e; \
+# lynx has a broken ar, it always complains when the initial library is
+# empty, thus this command works only if we don't do -e
+# There is a trailing backslash (\) deleted from the following line.
+#      set -e;
        for name in $(LIB1FUNCS); \
        do \
          echo $${name}; \
@@ -648,7 +676,10 @@ libgcc2.a: libgcc2.c libgcc2.ready $(CONFIG_H) $(LIB2FUNCS_EXTRA) \
        -rm -f tmplibgcc2.a
 # -e causes any failing command to make this rule fail.
 # -e doesn't work in certain shells, so we test $$? as well.
-       set -e; \
+# lynx has a broken ar, it always complains when the initial library is
+# empty, thus this command works only if we don't do -e
+# There is a trailing backslash (\) deleted from the following line.
+#      set -e;
        for name in $(LIB2FUNCS); \
        do \
          echo $${name}; \
@@ -694,6 +725,11 @@ libgcc.a: $(LIBGCC1) $(LIBGCC2)
        then (cd tmpcopy; $(AR) x ../$(LIBGCC1));       \
        else true;                                      \
        fi
+# Some versions of ar (specifically the one in RISC/os 5.x), create an
+# unwritable table of contents file, and then print an error message when
+# the second ar command tries to overwrite this file.  To avoid the error
+# message from ar, we make sure all files are writable.
+       (cd tmpcopy; chmod +w * > /dev/null 2>&1)
        (cd tmpcopy; $(AR) x ../$(LIBGCC2))
        (cd tmpcopy; $(AR) $(AR_FLAGS) ../tmplibgcc.a *.o)
        rm -rf tmpcopy
@@ -775,7 +811,7 @@ cp-parse.o : $(srcdir)/cp-parse.c $(CONFIG_H) $(CPLUS_TREE_H) flags.h cp-lex.h
   `echo $(srcdir)/cp-parse.c | sed 's,^\./,,'`
 
 $(srcdir)/cp-parse.c $(srcdir)/cp-parse.h : $(srcdir)/cp-parse.y
-       @echo expect 29 shift/reduce conflicts and 14 reduce/reduce conflicts
+       @echo expect 29 shift/reduce conflicts and 13 reduce/reduce conflicts
        cd $(srcdir); $(BISON) $(BISONFLAGS) -d -o cp-parse.c cp-parse.y
        cd $(srcdir); grep '^#define[   ]*YYEMPTY' cp-parse.c >>cp-parse.h
 
@@ -939,7 +975,7 @@ reorg.o : reorg.c $(CONFIG_H) $(RTL_H) conditions.h hard-reg-set.h \
    flags.h output.h
 sched.o : sched.c $(CONFIG_H) $(RTL_H) basic-block.h regs.h hard-reg-set.h \
    flags.h insn-config.h insn-attr.h
-final.o : final.c $(CONFIG_H) $(RTL_H) gvarargs.h flags.h regs.h \
+final.o : final.c $(CONFIG_H) $(RTL_H) $(TREE_H) gvarargs.h flags.h regs.h \
    recog.h conditions.h insn-config.h insn-attr.h real.h output.h \
    hard-reg-set.h insn-flags.h insn-codes.h gstab.h xcoffout.h defaults.h
 recog.o : recog.c $(CONFIG_H) $(RTL_H)  \
@@ -1283,6 +1319,7 @@ SYSCALLS.c.X: $(srcdir)/sys-types.h $(srcdir)/sys-protos.h $(GCC_PASSES)
          -aux-info $@ -S -o tmp-SYSCALLS.s SYSCALLS.c
        -rm -f SYSCALLS.c tmp-SYSCALLS.s
 
+
 test-protoize-simple: ./protoize ./unprotoize $(GCC_PASSES)
        -rm -f tmp-proto.[cso]
        cp $(srcdir)/protoize.c tmp-proto.c
@@ -1354,7 +1391,7 @@ stmp-headers: stmp-int-hdrs gfloat.h
        touch stmp-headers
 
 # Build fixed copies of system files.
-stmp-fixinc: $(srcdir)/$(FIXINCLUDES) gsyslimits.h
+stmp-fixinc: $(srcdir)/$(FIXINCLUDES) gsyslimits.h xgcc cpp
        rm -rf include
        mkdir include
        if [ x$(FIXINCLUDES) != xMakefile.in ]; \
@@ -1362,7 +1399,7 @@ stmp-fixinc: $(srcdir)/$(FIXINCLUDES) gsyslimits.h
          for dir in $(SYSTEM_HEADER_DIR) $(OTHER_FIXINCLUDES_DIRS); do \
            if [ -d $$dir ]; \
            then \
-             $(srcdir)/$(FIXINCLUDES) include $$dir $(srcdir); \
+             $(srcdir)/$(FIXINCLUDES) include $$dir $(srcdir) "`pwd`/xgcc -B`pwd`/"; \
            else true; fi; \
          done; \
        else true; \
@@ -1387,6 +1424,37 @@ objc-headers:
        GCC_FOR_TARGET="$${thisdir1}/xgcc -B$${thisdir1}/" \
        GCC_CFLAGS="$(GCC_CFLAGS)" incinstalldir=$${thisdir1}/include
        touch objc-headers
+
+# Files related to the fixproto script.
+
+deduced.h: $(srcdir)/scan-types.sh
+       CC="$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(ALL_CPPFLAGS) -nostdinc -Iinclude -I${SYSTEM_HEADER_DIR}"; \
+         export CC; \
+         $(srcdir)/scan-types.sh >tmp-deduced.h
+       mv tmp-deduced.h deduced.h
+
+gen-protos: gen-protos.o scan.o
+       ${HOST_CC} -o gen-protos gen-protos.o scan.o
+
+xsys-protos.h: $(srcdir)/sys-protos.h deduced.h gen-protos Makefile
+       cat deduced.h $(srcdir)/sys-protos.h > fixtmp.c
+       $(GCC_FOR_TARGET) fixtmp.c -E \
+         | sed -e 's/  / /g' -e 's/ *(/ (/g' -e 's/ [ ]*/ /g' -e 's/( )/()/' \
+         | ./gen-protos >xsys-protos.h
+       rm -rf fixtmp.c
+
+scan-decls: scan-decls.o scan.o
+       $(HOST_CC) -o scan-decls scan-decls.o scan.o
+
+patch-header: patch-header.o scan.o xsys-protos.h $(HOST_OBSTACK)
+       $(HOST_CC) -o patch-header patch-header.o scan.o $(HOST_OBSTACK)
+
+patch-header.o: xsys-protos.h
+
+stmp-fixproto: patch-header scan-decls xsys-protos.h
+       CPP="$(GCC_FOR_TARGET) -E"; export CPP; \
+         ${srcdir}/fixproto include include $(SYSTEM_HEADER_DIR)
+       touch stmp-fixproto
 \f
 # Remake the info files.
 
@@ -1394,14 +1462,14 @@ doc: info
 info: $(srcdir)/cpp.info $(srcdir)/gcc.info
 
 $(srcdir)/cpp.info: cpp.texi
-       $(MAKEINFO) `echo $(srcdir)/cpp.texi | sed 's,^\./,,'`
+       cd $(srcdir); $(MAKEINFO) cpp.texi
 
 #$(srcdir)/gplus.info: gplus.texi
 #      $(MAKEINFO) `echo $(srcdir)/gplus.texi | sed 's,^\./,,'`
 
 $(srcdir)/gcc.info: gcc.texi extend.texi install.texi invoke.texi \
                md.texi rtl.texi tm.texi 
-       $(MAKEINFO) `echo $(srcdir)/gcc.texi | sed 's,^\./,,'`
+       cd $(srcdir); $(MAKEINFO) gcc.texi
 
 dvi: $(srcdir)/gcc.dvi $(srcdir)/cpp.dvi
 
@@ -1444,7 +1512,7 @@ mostlyclean:
        -rm -f tmplibgcc* tmpcopy xlimits.h
        for name in $(LIB1FUNCS); do rm -f $${name}.c; done
 # Delete other temporary files.
-       -rm -f tmp-float.h tmp-gcc.xtar.z
+       -rm -f tmp-float.h tmp-gcc.xtar.gz
        -rm -f tmp-foo1 tmp-foo2 tmp-proto.* tmp-unproto.1 tmp-SYSCALLS.s
 # Delete the stamp files.
        -rm -f stamp-* tmp-*
@@ -1454,6 +1522,9 @@ mostlyclean:
 # Delete some files made during installation.
        -rm -f specs gfloat.h float.h-* enquire SYSCALLS.c.X SYSCALLS.c
        -rm -f collect collect2 ld mips-tfile mips-tdump alloca.s
+# Delete files generated for fixproto
+       -rm -rf patch-header scan-decls xsys-protos.h deduced.h tmp-deduced.h \
+         gen-protos fixproto.list fixtmp.?
 # Delete unwanted output files from TeX.
        -rm -f *.toc *.log *.vr *.fn *.cp *.tp *.ky *.pg
 # Delete sorted indices we don't actually use.
@@ -1471,7 +1542,7 @@ clean: mostlyclean
        -rm -f libgcc.a libgcc1.a libgcc2.a libgcc2.ready libgcc1.null
        -rm -f *.dvi
 # Delete the include directory.
-       -rm -rf stmp-* include
+       -rm -rf stmp-* include objc-headers
 
 # Delete all files that users would normally create
 # while building and installing GCC.
@@ -1492,7 +1563,8 @@ extraclean: distclean
        -rm -f config/*/*.orig config/*/*.rej
        -rm -f objc/=* objc/"#"* objc/*~*
        -rm -f objc/*.orig objc/*.rej
-       -rm -f *.dvi *.oaux *.d *.[zZ] *.tar *.xtar *diff
+       -rm -f *.dvi *.oaux *.d *.[zZ] *.gz
+       -rm -f *.tar *.xtar *diff *.diff.* *.tar.* *.xtar.* *diffs
        -rm -f *lose config/*lose config/*/*lose
        -rm -f *.s *.s[0-9] *.i install1.texi config/ChangeLog
 
@@ -1517,8 +1589,8 @@ realclean: distclean
 install: $(INSTALL_TARGET) ; @true
 
 # Copy the compiler files into directories where they will be run.
-install-normal: install-common $(INSTALL_HEADERS) install-libgcc install-man \
-    install-info
+install-normal: install-common $(INSTALL_HEADERS) $(INSTALL_LIBGCC) \
+    install-man install-info
 
 # Do nothing while making gcc with a cross-compiler. The person who
 # makes gcc for the target machine has to know how to put a complete
@@ -1565,7 +1637,7 @@ install-dir:
 # Install the compiler executables built during cross compilation.
 # Deps on  $(srcdir)/g++ $(srcdir)/c++  would be natural here,
 # but the latter would get confused with the target `c++'.
-install-common: native install-dir xgcc $(EXTRA_PARTS)
+install-common: native install-dir xgcc g++ $(EXTRA_PARTS)
        for file in $(COMPILERS); do \
          if [ -f $$file ] ; then \
            rm -f $(libsubdir)/$$file; \
@@ -1593,6 +1665,13 @@ install-common: native install-dir xgcc $(EXTRA_PARTS)
            rm -f $(tooldir)/bin/gcc; \
            $(INSTALL_PROGRAM) gcc-cross $(tooldir)/bin/gcc; \
          else true; fi; \
+         if [ -f cc1plus ] ; then \
+           rm -f $(bindir)/$(target)-g++; \
+           $(INSTALL_PROGRAM) g++-cross $(bindir)/$(target)-g++; \
+           chmod a+x $(bindir)/$(target)-g++; \
+           rm -f $(bindir)/$(target)-c++; \
+           ln $(bindir)/$(target)-g++ $(bindir)/$(target)-c++; \
+         fi ; \
        else \
          rm -f $(bindir)/gcc; \
          $(INSTALL_PROGRAM) xgcc $(bindir)/gcc; \
@@ -1612,10 +1691,11 @@ install-common: native install-dir xgcc $(EXTRA_PARTS)
            chmod a-x $(libsubdir)/SYSCALLS.c.X; \
        fi
        -if [ -f cc1plus ] ; then \
-         rm -f $(bindir)/c++ ; \
-         $(INSTALL_PROGRAM) $(srcdir)/c++ $(bindir)/c++ ; \
-         rm -f $(bindir)/g++ ; \
-         $(INSTALL_PROGRAM) $(srcdir)/g++ $(bindir)/g++ ; \
+           rm -f $(bindir)/g++; \
+           $(INSTALL_PROGRAM) g++ $(bindir)/g++; \
+           chmod a+x $(bindir)/g++; \
+           rm -f $(bindir)/c++; \
+           ln $(bindir)/g++ $(bindir)/c++; \
        fi
        -rm -f $(libsubdir)/cpp
        $(INSTALL_PROGRAM) cpp $(libsubdir)/cpp
@@ -1681,17 +1761,24 @@ install-include-dir: install-dir
        -chmod a+rx $(libsubdir)/include
 
 # Install the include directory using tar.
-install-headers-tar: stmp-headers install-include-dir
-       cd include; tar cf - . | (cd $(libsubdir)/include; tar $(TAROUTOPTS) - )
+install-headers-tar: stmp-headers $(STMP_FIXPROTO) install-include-dir
+       cd include; \
+        (tar cf - .; exit 0) | (cd $(libsubdir)/include; tar $(TAROUTOPTS) - )
+# /bin/sh on some systems returns the status of the first tar,
+# and that can lose with GNU tar which always writes a full block.
+# So use `exit 0' to ignore its exit status.
 
 # Install the include directory using cpio.
-install-headers-cpio: stmp-headers install-include-dir
+install-headers-cpio: stmp-headers $(STMP_FIXPROTO) install-include-dir
        cd include; find . -print | cpio -pdum $(libsubdir)/include
 
-# Put assert.h in /usr/local/include, so it won't override GNU libc's assert.h.
-# Don't replace the assert.h already there if it is not from GCC.
-# This code would be simpler if it tested for -f ... && ! grep ...
-# but supposedly the ! operator is missing in sh on some systems.
+# Put assert.h where it won't override GNU libc's assert.h.
+# It goes in a dir that is searched after GNU libc's headers;
+# thus, the following conditionals are no longer needed.
+# But it's not worth deleting them now.
+## Don't replace the assert.h already there if it is not from GCC.
+## This code would be simpler if it tested for -f ... && ! grep ...
+## but supposedly the ! operator is missing in sh on some systems.
 install-assert-h: assert.h install-dir
        if [ -f $(assertdir)/assert.h ]; \
        then \
@@ -1738,15 +1825,15 @@ TAGS: force
        rmdir temp
 
 # Create the distribution tar file.
-#dist: gcc-$(version).tar.z
-dist: gcc.xtar.z
+#dist: gcc-$(version).tar.gz
+dist: gcc.xtar.gz
 
-gcc.xtar.z: gcc.xtar
-       gzip < gcc.xtar > tmp-gcc.xtar.z
-       mv tmp-gcc.xtar.z gcc.xtar.z
+gcc.xtar.gz: gcc.xtar
+       gzip < gcc.xtar > tmp-gcc.xtar.gz
+       mv tmp-gcc.xtar.gz gcc.xtar.gz
 
-#gcc-$(version).tar.z: gcc-$(version).tar
-#      gzip < gcc-$(version).tar > gcc-$(version).tar.z
+#gcc-$(version).tar.gz: gcc-$(version).tar
+#      gzip < gcc-$(version).tar > gcc-$(version).tar.gz
 
 #gcc-$(version).tar:
 gcc.xtar: distdir
@@ -1843,9 +1930,10 @@ bootstrap3: force
 # Compare the object files in the current directory with those in the
 # stage2 directory.
 
+# ./ avoids bug in some versions of tail.
 compare: force
        for file in *.o; do \
-         tail +16c $$file > tmp-foo1; \
+         tail +16c ./$$file > tmp-foo1; \
          tail +16c stage2/$$file > tmp-foo2 2>/dev/null \
            && (cmp tmp-foo1 tmp-foo2 || echo $$file differs); \
        done