[SUBMITTED]

This patch adds the uClinux target definition to GCC and libstdc++.

Unlike the official, 2.95.x based toolchain, uClinux support for GCC 3.4
uses the "m68k-uclinux-uclibc" target tuple instead of abusing of the
existing m68k-elf target.

The script for building the full uClinux toolchain ensures backwards
compatibility by creating a few soft-links.


top-level:

2003-09-22  Bernardo Innocenti  <bernie@develer.com>

	* config.sub (m68k-unknown-linux-uclibc, m68k-unknown-uclinux-uclibc):
	New targets.

GCC:

2003-09-22  Bernardo Innocenti  <bernie@develer.com>

	* config/m68k/t-uclinux: New target Makefile fragment.
	* config/m68k/uclinux.h: New target macro file.
	* config.gcc (m68k-*-uclinux): New target definition.

libstdc++:

2003-09-22 Bernardo Innocenti <bernie@develer.com>

	* crossconfig.m4 (*-uclinux*): New target.
	* configure: Regenerate (well, not really).

diff -Nru gcc-3.4.orig/config.sub gcc-3.4/config.sub
--- gcc-3.4.orig/config.sub	2003-06-14 16:08:09.000000000 +0200
+++ gcc-3.4/config.sub	2003-09-19 19:36:58.000000000 +0200
@@ -118,7 +118,7 @@
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+  nto-qnx* | linux-gnu* | linux-uclibc* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -1126,12 +1126,12 @@
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* \
-	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
-	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
-	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
-	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* | -mingw32* \
+	      | -linux-gnu* | -linux-uclibc* | -uclinux-uclibc* | -uxpv* | -beos* \
+	      | -mpeix* | -udk* | -interix* | -uwin* | -mks* | -rhapsody* \
+	      | -darwin* | -opened* | -openstep* | -oskit* | -conix* | -pw32* \
+	      | -nonstopux* | -storm-chaos* | -tops10* | -tenex* | -tops20* \
+	      | -its* | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7)
 	# Remember, each alternative MUST END IN *, to match a version number.
diff -Nru gcc-3.4.orig/gcc/config.gcc gcc-3.4/gcc/config.gcc
--- gcc-3.4.orig/gcc/config.gcc	2003-08-08 23:13:37.000000000 +0200
+++ gcc-3.4/gcc/config.gcc	2003-08-19 21:36:32.000000000 +0200
@@ -1289,6 +1289,12 @@
 	tmake_file=t-svr4
 	extra_parts="crtbegin.o crtend.o"
 	;;
+m68k-*-uclinux*)		# Motorola m68k/ColdFire running uClinux with uClibc
+	tm_file="m68k/m68k.h m68k/m68k-none.h m68k/m68kelf.h dbxelf.h elfos.h m68k/uclinux.h"
+ 	tm_defines="MOTOROLA USE_GAS"
+	tmake_file=m68k/t-uclinux
+	use_fixproto=no
+	;;
 m68k-*-linux*)		# Motorola m68k's running GNU/Linux
 				# with ELF format using glibc 2
 				# aka the GNU/Linux C library 6.
diff -Nru gcc-3.4.orig/gcc/config/m68k/t-uclinux gcc-3.4/gcc/config/m68k/t-uclinux
--- gcc-3.4.orig/gcc/config/m68k/t-uclinux	1970-01-01 01:00:00.000000000 +0100
+++ gcc-3.4/gcc/config/m68k/t-uclinux	2003-08-19 21:29:30.000000000 +0200
@@ -0,0 +1,24 @@
+LIB1ASMSRC = m68k/lb1sf68.asm
+LIB1ASMFUNCS = _mulsi3 _udivsi3 _divsi3 _umodsi3 _modsi3 \
+   _double _float _floatex \
+   _eqdf2 _nedf2 _gtdf2 _gedf2 _ltdf2 _ledf2 \
+   _eqsf2 _nesf2 _gtsf2 _gesf2 _ltsf2 _lesf2
+
+LIB2FUNCS_EXTRA = fpgnulib.c xfgnulib.c
+
+fpgnulib.c: $(srcdir)/config/m68k/fpgnulib.c
+	cp $(srcdir)/config/m68k/fpgnulib.c fpgnulib.c
+xfgnulib.c: $(srcdir)/config/m68k/fpgnulib.c
+	echo '#define EXTFLOAT' > xfgnulib.c
+	cat $(srcdir)/config/m68k/fpgnulib.c >> xfgnulib.c
+
+MULTILIB_OPTIONS = m68000/m5200/m5206e/m528x/m5307/m5407/mcpu32 msep-data/mid-shared-library
+MULTILIB_DIRNAMES =
+MULTILIB_MATCHES = m68000=mc68000 m68000=m68302 mcpu32=m68332 m5206e=m5272
+MULTILIB_EXCEPTIONS = m68000/msep-data* m68000/mid-shared-library* msep-data* mid-shared-library*
+
+LIBGCC = stmp-multilib
+INSTALL_LIBGCC = install-multilib
+
+# We don't use crtbegin.o and crtend.o
+EXTRA_PARTS=
diff -Nru gcc-3.4.orig/gcc/config/m68k/uclinux.h gcc-3.4/gcc/config/m68k/uclinux.h
--- gcc-3.4.orig/gcc/config/m68k/uclinux.h	1970-01-01 01:00:00.000000000 +0100
+++ gcc-3.4/gcc/config/m68k/uclinux.h	2003-08-20 19:26:09.000000000 +0200
@@ -0,0 +1,63 @@
+/* Definitions of target machine for GCC.  m68k/ColdFire based uClinux system
+   using ELF objects with special linker post-processing to produce FLAT
+   executables.
+
+   Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC 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.
+
+GCC 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 GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+
+/* Undo the definition of STARTFILE_SPEC from m68kelf.h so we'll
+   pick the default from gcc.c (just link crt0.o from multilib dir).  */
+#undef	STARTFILE_SPEC
+
+/* Override the default LIB_SPEC from gcc.c.  We don't currently support
+   profiling, or libg.a.  */
+#undef LIB_SPEC
+#define LIB_SPEC "\
+%{mid-shared-library:-R libc.gdb%s} -lc \
+"
+
+/* we don't want a .eh_frame section.  */
+#define EH_FRAME_IN_DATA_SECTION
+
+/* ??? Quick hack to get constructors working.  Make this look more like a
+   COFF target, so the existing dejagnu/libgloss support works.  A better
+   solution would be to make the necessary dejagnu and libgloss changes so
+   that we can use normal the ELF constructor mechanism.  */
+#undef INIT_SECTION_ASM_OP
+#undef FINI_SECTION_ASM_OP
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC ""
+ 
+/* Bring in standard linux defines */
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS()		\
+  do						\
+    {						\
+	builtin_define_std ("mc68000");		\
+	builtin_define ("__uClinux__");		\
+	builtin_define_std ("linux");		\
+	builtin_define_std ("unix");		\
+	builtin_define ("__gnu_linux__");	\
+	builtin_assert ("system=posix");	\
+	if (TARGET_ID_SHARED_LIBRARY)		\
+	  builtin_define ("__ID_SHARED_LIBRARY__"); \
+    }						\
+  while (0)
+
diff -Nru gcc-3.4.orig/libstdc++-v3/crossconfig.m4 gcc-3.4/libstdc++-v3/crossconfig.m4
--- gcc-3.4.orig/libstdc++-v3/crossconfig.m4 2003-08-21 02:34:59.000000000 +0200
+++ gcc-3.4/libstdc++-v3/crossconfig.m4 2003-08-19 00:18:24.000000000 +0200
@@ -125,7 +125,7 @@
 	;;
     esac
     ;;
-  *-linux*)
+  *-linux* | *-uclinux*)
     #os_include_dir="os/gnu-linux"
     AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h \
       machine/endian.h machine/param.h sys/machine.h sys/types.h \
diff -Nru gcc-3.4.orig/libstdc++-v3/configure gcc-3.4/libstdc++-v3/configure
--- gcc-3.4.orig/libstdc++-v3/configure 2003-08-21 02:34:59.000000000 +0200
+++ gcc-3.4/libstdc++-v3/configure 2003-08-19 00:19:25.000000000 +0200
@@ -50539,7 +50539,7 @@
 	;;
     esac
     ;;
-  *-linux*)
+  *-linux* | *-uclinux*)
     #os_include_dir="os/gnu-linux"
 
 
