Submitted By:            Kevin Day <kevin AT kevux DOT org>
Date:                    2006-08-07
Initial Package Version: 4.1.1
Upstream Status:         uClibc specific
Description:             The fix from the HLFS project for getting uClibc support.
The original patch was undocumented, but I imagine it was done by: Robert Connellly <robert at linuxfromscratch dot org> (ashes)
--- gcc-4.1.1/gcc/config.gcc.orig	2006-08-07 23:12:29.000000000 -0500
+++ gcc-4.1.1/gcc/config.gcc	2006-08-07 23:15:45.000000000 -0500
@@ -1041,6 +1041,11 @@
 	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/i386-coff.h"
 	use_fixproto=yes
 	;;
+i[34567]86-*-linux*uclibc*)   # Intel 80386's running GNU/Linux
+			      # with ELF format using uClibc
+	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h i386/linux.h"
+	tmake_file="t-slibgcc-elf-ver t-linux-uclibc i386/t-crtstuff i386/t-crtfm"
+	;;
 i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu)
 			# Intel 80386's running GNU/*
 			# with ELF format using glibc 2
--- gcc-4.1.1/gcc/config/t-linux-uclibc.orig	2006-08-07 23:29:49.000000000 -0500
+++ gcc-4.1.1/gcc/config/t-linux-uclibc	2006-08-07 23:30:49.000000000 -0500
@@ -0,0 +1,15 @@
+T_CFLAGS = -DUSE_UCLIBC
+
+# Compile crtbeginS.o and crtendS.o with pic.
+CRTSTUFF_T_CFLAGS_S = $(CRTSTUFF_T_CFLAGS) -fPIC
+# Compile libgcc2.a with pic.
+TARGET_LIBGCC2_CFLAGS = -fPIC
+
+# Override t-slibgcc-elf-ver to export some libgcc symbols with
+# the symbol versions that glibc used.
+#SHLIB_MAPFILES += $(srcdir)/config/libgcc-glibc.ver
+
+# Use unwind-dw2-fde
+LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \
+  $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c
+LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h
--- gcc-4.1.1/libtool.m4.orig	2006-08-07 23:30:21.000000000 -0500
+++ gcc-4.1.1/libtool.m4	2006-08-07 23:30:49.000000000 -0500
@@ -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]+$']
--- gcc-4.1.1/ltconfig.orig	2006-08-07 23:30:31.000000000 -0500
+++ gcc-4.1.1/ltconfig	2006-08-07 23:30:49.000000000 -0500
@@ -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,24 @@
   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.
+  # Note: copied from linux-gnu, and may not be appropriate.
+  hardcode_into_libs=yes
+  # Assume using the uClibc dynamic linker.
+  dynamic_linker="uClibc ld.so"
+  ;;
+
 netbsd*)
   need_lib_prefix=no
   need_version=no
