Submitted By: Robert Connolly <robert at linuxfromscratch dot org> (ashes)
Date: 2007-04-04
Initial Package Version: 4.1.2
Upstream Status: Not submitted - Hack
Origin:	http://www.uclibc.org/cgi-bin/viewcvs.cgi/*checkout*/trunk/buildroot/toolchain/gcc/
	4.1.2/100-uclibc-conf.patch - With modifications...
Description: This adds --target=*-*-linux-uclibc* needed for building a
uClibc toolchain. All the GCC-specs hunks were removed, you will have
to modify the path and name for ld.so yourself.

diff -Naur gcc-4.1.2.orig/configure gcc-4.1.2/configure
--- gcc-4.1.2.orig/configure	2006-11-21 17:48:36.000000000 +0000
+++ gcc-4.1.2/configure	2007-04-04 21:49:52.000000000 +0000
@@ -1133,7 +1133,7 @@
     ;;
 "")
     case "${target}" in
-    *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
+    *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
         # Enable libmudflap by default in GNU and friends.
 	;;
     *-*-freebsd*)
diff -Naur gcc-4.1.2.orig/configure.in gcc-4.1.2/configure.in
--- gcc-4.1.2.orig/configure.in	2006-11-21 17:48:36.000000000 +0000
+++ gcc-4.1.2/configure.in	2007-04-04 21:49:52.000000000 +0000
@@ -341,7 +341,7 @@
     ;;
 "")
     case "${target}" in
-    *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu)
+    *-*-linux*-gnu | *-*-gnu* | *-*-k*bsd*-gnu | *-*-linux-uclibc*)
         # Enable libmudflap by default in GNU and friends.
 	;;
     *-*-freebsd*)
diff -Naur gcc-4.1.2.orig/contrib/regression/objs-gcc.sh gcc-4.1.2/contrib/regression/objs-gcc.sh
--- gcc-4.1.2.orig/contrib/regression/objs-gcc.sh	2005-08-15 00:41:31.000000000 +0000
+++ gcc-4.1.2/contrib/regression/objs-gcc.sh	2007-04-04 21:49:52.000000000 +0000
@@ -105,6 +105,10 @@
  then
   make all-gdb all-dejagnu all-ld || exit 1
   make install-gdb install-dejagnu install-ld || exit 1
+elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
+ then
+  make all-gdb all-dejagnu all-ld || exit 1
+  make install-gdb install-dejagnu install-ld || exit 1
 elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
   make bootstrap || exit 1
   make install || exit 1
diff -Naur gcc-4.1.2.orig/gcc/config/t-linux-uclibc gcc-4.1.2/gcc/config/t-linux-uclibc
--- gcc-4.1.2.orig/gcc/config/t-linux-uclibc	1970-01-01 00:00:00.000000000 +0000
+++ gcc-4.1.2/gcc/config/t-linux-uclibc	2007-04-04 21:49:52.000000000 +0000
@@ -0,0 +1,5 @@
+# Remove glibc specific files added in t-linux
+SHLIB_MAPFILES := $(filter-out $(srcdir)/config/libgcc-glibc.ver, $(SHLIB_MAPFILES))
+
+# Use unwind-dw2-fde instead of unwind-dw2-fde-glibc
+LIB2ADDEH := $(subst unwind-dw2-fde-glibc.c,unwind-dw2-fde.c,$(LIB2ADDEH))
diff -Naur gcc-4.1.2.orig/gcc/config.gcc gcc-4.1.2/gcc/config.gcc
--- gcc-4.1.2.orig/gcc/config.gcc	2006-10-15 23:12:23.000000000 +0000
+++ gcc-4.1.2/gcc/config.gcc	2007-04-04 21:49:52.000000000 +0000
@@ -1884,7 +1884,7 @@
 	;;
 sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
 sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
-  sh-*-linux* | sh[346lbe]*-*-linux* | \
+  sh*-*-linux* | sh[346lbe]*-*-linux* | \
   sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
    sh64-*-netbsd* | sh64l*-*-netbsd*)
 	tmake_file="${tmake_file} sh/t-sh sh/t-elf"
@@ -2338,6 +2338,12 @@
 	;;
 esac
 
+# Rather than hook into each target, just do it after all the linux
+# targets have been processed
+case ${target} in
+*-linux-uclibc*) tm_defines="${tm_defines} USE_UCLIBC" ; tmake_file="${tmake_file} t-linux-uclibc"
+esac
+
 case ${target} in
 i[34567]86-*-linux*aout* | i[34567]86-*-linux*libc1)
 	tmake_file="${tmake_file} i386/t-gmm_malloc"
diff -Naur gcc-4.1.2.orig/libmudflap/configure gcc-4.1.2/libmudflap/configure
--- gcc-4.1.2.orig/libmudflap/configure	2005-10-04 23:54:38.000000000 +0000
+++ gcc-4.1.2/libmudflap/configure	2007-04-04 21:49:52.000000000 +0000
@@ -5382,6 +5382,11 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
+linux-uclibc*)
+  lt_cv_deplibs_check_method=pass_all
+  lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
+  ;;
+
 netbsd* | knetbsd*-gnu)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
diff -Naur gcc-4.1.2.orig/libtool.m4 gcc-4.1.2/libtool.m4
--- gcc-4.1.2.orig/libtool.m4	2005-07-16 02:30:53.000000000 +0000
+++ gcc-4.1.2/libtool.m4	2007-04-04 21:49:52.000000000 +0000
@@ -743,6 +743,11 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
+linux-uclibc*)
+  lt_cv_deplibs_check_method=pass_all
+  lt_cv_file_magic_test_file=`echo /lib/libuClibc-*.so`
+  ;;
+
 netbsd* | knetbsd*-gnu)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$']
diff -Naur gcc-4.1.2.orig/ltconfig gcc-4.1.2/ltconfig
--- gcc-4.1.2.orig/ltconfig	2006-07-04 20:30:34.000000000 +0000
+++ gcc-4.1.2/ltconfig	2007-04-04 21:49:52.000000000 +0000
@@ -603,6 +603,7 @@
 
 # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
 case $host_os in
+linux-uclibc*) ;;
 linux-gnu*) ;;
 linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
 esac
@@ -1274,6 +1275,23 @@
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
+linux-uclibc*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+  # Assume using the uClibc dynamic linker.
+  dynamic_linker="uClibc ld.so"
+  ;;
+
 netbsd*)
   need_lib_prefix=no
   need_version=no
