summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
Diffstat (limited to 'make')
-rw-r--r--make/gcc_target.mk111
1 files changed, 101 insertions, 10 deletions
diff --git a/make/gcc_target.mk b/make/gcc_target.mk
index 06e61c014..2e60b81f7 100644
--- a/make/gcc_target.mk
+++ b/make/gcc_target.mk
@@ -27,6 +27,20 @@ TARGET_LANGUAGES:=c,c++
# If you want multilib enabled, enable this...
MULTILIB:=--enable-multilib
+ifeq ($(USE_UCLIBC_TOOLCHAIN),true)
+GCC_DEPENDANCY=gcc_final
+GCC_INSTALL_TARGET=install-gcc
+else
+BINUTILS_SITE:=ftp://ftp.gnu.org/gnu/binutils/
+BINUTILS_SOURCE:=binutils-2.13.2.1.tar.bz2
+BINUTILS_DIR:=$(TOOL_BUILD_DIR)/binutils-2.13.2.1
+
+GCC_SITE:=ftp://ftp.gnu.org/gnu/gcc/
+GCC_SOURCE:=gcc-3.2.2.tar.gz
+GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-3.2.2
+GCC_INSTALL_TARGET=install
+endif
+
#############################################################
#
# Where we can find things....
@@ -44,7 +58,32 @@ GCC_BUILD_DIR3:=$(BUILD_DIR)/gcc-target
# build binutils
#
#############################################################
-$(BINUTILS_DIR2)/.configured:
+ifneq ($(USE_UCLIBC_TOOLCHAIN),true)
+$(DL_DIR)/$(BINUTILS_SOURCE):
+ $(WGET) -P $(DL_DIR) $(BINUTILS_SITE)/$(BINUTILS_SOURCE)
+
+$(BINUTILS_DIR)/.unpacked: $(DL_DIR)/$(BINUTILS_SOURCE)
+ bzcat $(DL_DIR)/$(BINUTILS_SOURCE) | tar -C $(TOOL_BUILD_DIR) -xvf -
+ touch $(BINUTILS_DIR)/.unpacked
+
+$(BINUTILS_DIR)/.patched: $(BINUTILS_DIR)/.unpacked
+ # Apply any files named binutils-*.patch from the source directory to binutils
+ $(SOURCE_DIR)/patch-kernel.sh $(BINUTILS_DIR) $(SOURCE_DIR) binutils-*.patch
+ #
+ # Enable combreloc, since it is such a nice thing to have...
+ #
+ -perl -i -p -e "s,link_info.combreloc = false,link_info.combreloc = true,g;" \
+ $(BINUTILS_DIR)/ld/ldmain.c
+ #
+ # Hack binutils to use the correct shared lib loader
+ #
+ (cd $(BINUTILS_DIR); perl -i -p -e "s,#.*define.*ELF_DYNAMIC_INTERPRETER.*\".*\"\
+ ,#define ELF_DYNAMIC_INTERPRETER \"/lib/ld-uClibc.so.0\",;" \
+ `grep -lr "#.*define.*ELF_DYNAMIC_INTERPRETER.*\".*\"" $(BINUTILS_DIR)`);
+ touch $(BINUTILS_DIR)/.patched
+endif
+
+$(BINUTILS_DIR2)/.configured: $(BINUTILS_DIR)/.patched
mkdir -p $(BINUTILS_DIR2)
mkdir -p $(TARGET_DIR)/usr/include
mkdir -p $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/
@@ -119,7 +158,7 @@ $(TARGET_DIR)/usr/lib/libg.a:
cp -a $(BINUTILS_DIR2)/opcodes/.libs/* $(TARGET_DIR)/usr/lib/
cp -a $(BINUTILS_DIR2)/libiberty/libiberty.a $(TARGET_DIR)/usr/lib/
-binutils_target: gcc_final $(TARGET_DIR)/usr/bin/ld $(TARGET_DIR)/usr/lib/libg.a
+binutils_target: $(GCC_DEPENDANCY) $(TARGET_DIR)/usr/bin/ld $(TARGET_DIR)/usr/lib/libg.a
binutils_target-clean:
rm -f $(TARGET_DIR)/bin/$(GNU_TARGET_NAME)*
@@ -154,7 +193,7 @@ $(TARGET_DIR)/usr/lib/libc.a: $(STAGING_DIR)/lib/libc.a
ln -fs /lib/libnsl.so.0 libnsl.so; \
)
-uclibc_target: gcc_final $(TARGET_DIR)/usr/lib/libc.a
+uclibc_target: $(GCC_DEPENDANCY) $(TARGET_DIR)/usr/lib/libc.a
uclibc_target-clean:
rm -f $(TARGET_DIR)/include
@@ -169,7 +208,59 @@ uclibc_target-dirclean:
# Next build target gcc compiler
#
#############################################################
-$(GCC_BUILD_DIR3)/.gcc_build_hacks:
+ifneq ($(USE_UCLIBC_TOOLCHAIN),true)
+$(DL_DIR)/$(GCC_SOURCE):
+ $(WGET) -P $(DL_DIR) $(GCC_SITE)/$(GCC_SOURCE)
+
+$(GCC_DIR)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)
+ zcat $(DL_DIR)/$(GCC_SOURCE) | tar -C $(TOOL_BUILD_DIR) -xvf -
+ touch $(GCC_DIR)/.unpacked
+
+$(GCC_DIR)/.patched: $(GCC_DIR)/.unpacked
+ # Apply any files named gcc-*.patch from the source directory to gcc
+ $(SOURCE_DIR)/patch-kernel.sh $(GCC_DIR) $(SOURCE_DIR) gcc-*.patch
+ touch $(GCC_DIR)/.patched
+
+$(GCC_DIR)/.gcc_build_hacks: $(GCC_DIR)/.patched
+ #
+ # Hack things to use the correct shared lib loader
+ #
+ (cd $(GCC_DIR); set -e; export LIST=`grep -lr -- "-dynamic-linker.*\.so[\.0-9]*" *`;\
+ if [ -n "$$LIST" ] ; then \
+ perl -i -p -e "s,-dynamic-linker.*\.so[\.0-9]*},\
+ -dynamic-linker /lib/ld-uClibc.so.0},;" $$LIST; fi);
+ #
+ # Prevent gcc from using the unwind-dw2-fde-glibc code
+ #
+ perl -i -p -e "s,^#ifndef inhibit_libc,#define inhibit_libc\n\
+ #ifndef inhibit_libc,g;" $(GCC_DIR)/gcc/unwind-dw2-fde-glibc.c;
+ touch $(GCC_DIR)/.gcc_build_hacks
+
+$(GCC_DIR)/.g++_build_hacks: $(GCC_DIR)/.gcc_build_hacks
+ #
+ # Hack up the soname for libstdc++
+ #
+ perl -i -p -e "s,\.so\.1,.so.0.9.9,g;" $(GCC_DIR)/gcc/config/t-slibgcc-elf-ver;
+ perl -i -p -e "s,-version-info.*[0-9]:[0-9]:[0-9],-version-info 9:9:0,g;" \
+ $(GCC_DIR)/libstdc++-v3/src/Makefile.am $(GCC_DIR)/libstdc++-v3/src/Makefile.in;
+ perl -i -p -e "s,3\.0\.0,9.9.0,g;" $(GCC_DIR)/libstdc++-v3/acinclude.m4 \
+ $(GCC_DIR)/libstdc++-v3/aclocal.m4 $(GCC_DIR)/libstdc++-v3/configure;
+ #
+ # For now, we don't support locale-ified ctype (we will soon),
+ # so bypass that problem for now...
+ #
+ perl -i -p -e "s,defined.*_GLIBCPP_USE_C99.*,1,g;" \
+ $(GCC_DIR)/libstdc++-v3/config/locale/generic/c_locale.cc;
+ cp $(GCC_DIR)/libstdc++-v3/config/os/generic/bits/ctype_base.h \
+ $(GCC_DIR)/libstdc++-v3/config/os/gnu-linux/bits/
+ cp $(GCC_DIR)/libstdc++-v3/config/os/generic/bits/ctype_inline.h \
+ $(GCC_DIR)/libstdc++-v3/config/os/gnu-linux/bits/
+ cp $(GCC_DIR)/libstdc++-v3/config/os/generic/bits/ctype_noninline.h \
+ $(GCC_DIR)/libstdc++-v3/config/os/gnu-linux/bits/
+ touch $(GCC_DIR)/.g++_build_hacks
+endif
+
+$(GCC_BUILD_DIR3)/.gcc_build_hacks: $(GCC_DIR)/.g++_build_hacks
#
# Make certain the uClibc start files are found
#
@@ -268,7 +359,7 @@ $(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_DIR3)/.compiled
gxx_include_dir=$(TARGET_DIR)/usr/include/c++ \
tooldir=$(TARGET_DIR)/usr/$(GNU_TARGET_NAME) \
build_tooldir=$(TARGET_DIR)/usr/$(GNU_TARGET_NAME) \
- -C $(GCC_BUILD_DIR3) install-gcc;
+ -C $(GCC_BUILD_DIR3) $(GCC_INSTALL_TARGET);
(cd $(TARGET_DIR)/usr/bin; ln -fs gcc cc)
(cd $(TARGET_DIR)/lib; ln -fs /usr/bin/cpp)
rm -rf $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/include
@@ -280,13 +371,13 @@ $(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_DIR3)/.compiled
-mv $(TARGET_DIR)/usr/bin/$(GNU_TARGET_NAME)-g++ $(TARGET_DIR)/usr/bin/g++
-mv $(TARGET_DIR)/usr/bin/$(GNU_TARGET_NAME)-c++filt $(TARGET_DIR)/usr/bin/c++filt
-cp -dpf $(STAGING_DIR)/lib/libgcc* $(TARGET_DIR)/lib/
- chmod a-x $(STAGING_DIR)/lib/*++*
- cp -a $(STAGING_DIR)/lib/*++* $(TARGET_DIR)/lib/
- cp -a $(STAGING_DIR)/include/c++ $(TARGET_DIR)/usr/include/
+ -chmod a-x $(STAGING_DIR)/lib/*++*
+ -cp -a $(STAGING_DIR)/lib/*++* $(TARGET_DIR)/lib/
+ -cp -a $(STAGING_DIR)/include/c++ $(TARGET_DIR)/usr/include/
-mv $(TARGET_DIR)/lib/*.a $(TARGET_DIR)/usr/lib/
-mv $(TARGET_DIR)/lib/*.la $(TARGET_DIR)/usr/lib/
rm -f $(TARGET_DIR)/lib/libstdc++.so
- (cd $(TARGET_DIR)/usr/lib; ln -fs /lib/libstdc++.so.5.0.2 libstdc++.so)
+ -(cd $(TARGET_DIR)/usr/lib; ln -fs /lib/libstdc++.so.5.0.2 libstdc++.so)
-$(STRIP) $(TARGET_DIR)/bin/*
-$(STRIP) $(TARGET_DIR)/usr/bin/*
rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
@@ -295,7 +386,7 @@ $(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_DIR3)/.compiled
# gcc "fixincludes" step is totally broken and takes unwanted
# stuff from the host system. Fix that here.
rm -rf $(TARGET_DIR)/usr/lib/gcc-lib/$(GNU_TARGET_NAME)/*/include/*
- cp -a $(STAGING_DIR)/usr/lib/gcc-lib/$(GNU_TARGET_NAME)/*/include/* \
+ -cp -a $(STAGING_DIR)/usr/lib/gcc-lib/$(GNU_TARGET_NAME)/*/include/* \
$(TARGET_DIR)/usr/lib/gcc-lib/$(GNU_TARGET_NAME)/*/include/
touch -c $(TARGET_DIR)/usr/bin/gcc