Commit 9168e838 authored by Manuel Novoa III 's avatar Manuel Novoa III
Browse files

Enable building <arch>-linux-uclibc toolchains. Note that, due to config

issues for applications, we also create staging_dir/bin/<arch>-linux-*
symlinks which allows us to configure most apps with target=<arch>-linux.

gcc 3.3.2 libstdc++ now correctly identifies uclibc locale support.
There are still some issues (mainly related to wide char time strings
and wcsftime) to be addressed, but those are on hold until the uClibc
locale internals are reworked once again.

With the new stuff, we can also build gcc 2.95 and STLport again, although
the native gcc build for the target is failing.

Archs supported (some archs not yet tested):
 2.95 - i386, arm, mips*, powerpc.
 3.3.2 - Hopefull all for which uClibc has shared lib support.
parent 073534b9
Loading
Loading
Loading
Loading
+48 −13
Original line number Diff line number Diff line
@@ -46,17 +46,26 @@ ARCH:=i386
#ARCH:=sparc
#ARCH:=whatever

# Enable this if you want to use an <arch>-linux-uclibc-* toolchain.
# Note that, to avoid configure problems with apps that don't support
# this tupple, we also put <arch>-linux-* symlinks in staging_dir/bin.
# WARNING -- This does not yet support soft-float builds.
USE_LINUX_UCLIBC:=true
#USE_LINUX_UCLIBC:=false

# If you are building a native gcc toolchain, do you want to
# build the old gcc-2.95 based toolchain, or would you prefer
# a nice and shiny new gcc-3.3.2 toolchain?
# WARNING -- 2.95 currently does not build.
# WARNING -- 2.95 currently does not build unless USE_LINUX_UCLIBC:=true.
# WARNING -- 2.95 currently only builds for i386, arm, mips*, and powerpc.
# WARNING -- 2.95 does not currently build natively for the target.
#GCC_2_95_TOOLCHAIN:=true
GCC_2_95_TOOLCHAIN:=false
# WARNING -- 2.95 currently does not build.

# Enable this to use the uClibc daily snapshot instead of a released
# version.  Daily snapshots may contain new features and bugfixes. Or
# they may not even compile at all, depending on what Erik is doing...
USE_UCLIBC_SNAPSHOT:=false
USE_UCLIBC_SNAPSHOT:=true

# Enable this to use the busybox daily snapshot instead of a released
# version.  Daily snapshots may contain new features and bugfixes. Or
@@ -70,12 +79,15 @@ BUILD_WITH_LARGEFILE:=true
WGET:=wget --passive-ftp

# Optimize toolchain for which type of CPU?
ifeq ($(USE_LINUX_UCLIBC),true)
OPTIMIZE_FOR_CPU=$(ARCH)
#OPTIMIZE_FOR_CPU=i686
#OPTIMIZE_FOR_CPU=whatever
else
# WARNING!!!  CURRENTLY BROKEN!!! LEAVE IT AS $(ARCH)!!!
OPTIMIZE_FOR_CPU=$(ARCH)
# WARNING!!!  CURRENTLY BROKEN!!! LEAVE IT AS $(ARCH)!!!
#OPTIMIZE_FOR_CPU=i486
#OPTIMIZE_FOR_CPU=strongarm
#OPTIMIZE_FOR_CPU=whatever
endif

# Soft floating point options.
# Notes:
@@ -200,6 +212,11 @@ TARGETS+=ext2root
#
#############################################################

# The new stuff doesn't support soft float yet.
ifeq ($(USE_LINUX_UCLIBC),true)
SOFT_FLOAT:=false
endif

ifeq ($(SOFT_FLOAT),true)
SOFT_FLOAT_CONFIG_OPTION:=--without-float
TARGET_SOFT_FLOAT:=-msoft-float
@@ -210,9 +227,13 @@ TARGET_SOFT_FLOAT:=
ARCH_FPU_SUFFIX:=
endif

# The new stuff auto-detects approrpriate locale support.
# So only set this for the old 'hacked' toolchain.
ifneq ($(USE_LINUX_UCLIBC),true)
ifeq ($(ENABLE_LOCALE),true)
EXTRA_GCC_CONFIG_OPTIONS += --enable-clocale=gnu
endif
endif

# WARNING -- uClibc currently disables large file support on cris.
ifeq ("$(strip $(ARCH))","cris")
@@ -234,15 +255,24 @@ TARGET_DIR:=$(BUILD_DIR)/root
STAGING_DIR=$(BUILD_DIR)/staging_dir
TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(ARCH)$(ARCH_FPU_SUFFIX)
TARGET_PATH=$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin
#TARGET_CROSS=$(STAGING_DIR)/bin/$(ARCH)-uclibc-
TARGET_CROSS=$(STAGING_DIR)/bin/$(ARCH)-linux-
TARGET_CC=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT)
STRIP=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
#STRIP:=/bin/true
IMAGE:=$(BASE_DIR)/root_fs_$(ARCH)$(ARCH_FPU_SUFFIX)

ifeq ($(USE_LINUX_UCLIBC),true)
REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
KERNEL_CROSS=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
TARGET_CROSS=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
else
REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
#KERNEL_CROSS=$(STAGING_DIR)/bin/$(ARCH)-uclibc-
KERNEL_CROSS=$(STAGING_DIR)/bin/$(ARCH)-linux-
KERNEL_CROSS=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-
TARGET_CROSS=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-
endif

TARGET_CC=$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT)
STRIP=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note


HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
	-e 's/sparc.*/sparc/' \
	-e 's/arm.*/arm/g' \
@@ -301,7 +331,12 @@ $(STAGING_DIR):
	rm -rf $(STAGING_DIR)
	mkdir -p $(STAGING_DIR)/lib
	mkdir -p $(STAGING_DIR)/usr
ifneq ($(GCC_2_95_TOOLCHAIN),true)
	mkdir -p $(STAGING_DIR)/include
else
	mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/include
	(cd $(STAGING_DIR); ln -fs $(REAL_GNU_TARGET_NAME)/include)
endif
	ln -fs ../lib $(STAGING_DIR)/usr/lib

$(TARGET_DIR):
+105 −0
Original line number Diff line number Diff line
ifeq ($(USE_LINUX_UCLIBC),true)
#############################################################
#
# build binutils for use on the host system
#
#############################################################
BINUTILS_SITE:=http://ftp.kernel.org/pub/linux/devel/binutils
BINUTILS_SOURCE:=binutils-2.14.90.0.6.tar.bz2
BINUTILS_DIR:=$(TOOL_BUILD_DIR)/binutils-2.14.90.0.6
BINUTILS_CAT:=bzcat

BINUTILS_DIR1:=$(TOOL_BUILD_DIR)/binutils-build

$(DL_DIR)/$(BINUTILS_SOURCE):
	$(WGET) -P $(DL_DIR) $(BINUTILS_SITE)/$(BINUTILS_SOURCE)

$(BINUTILS_DIR)/.unpacked: $(STAGING_DIR) $(DL_DIR)/$(BINUTILS_SOURCE)
	mkdir -p $(TOOL_BUILD_DIR)
	mkdir -p $(DL_DIR)
	$(BINUTILS_CAT) $(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-uclibc*.patch
	touch $(BINUTILS_DIR)/.patched

$(BINUTILS_DIR1)/.configured: $(BINUTILS_DIR)/.patched
	mkdir -p $(BINUTILS_DIR1)
	(cd $(BINUTILS_DIR1); \
		$(BINUTILS_DIR)/configure \
		--prefix=$(STAGING_DIR) \
		--build=$(GNU_HOST_NAME) \
		--host=$(GNU_HOST_NAME) \
		--target=$(REAL_GNU_TARGET_NAME) \
		$(MULTILIB) \
		$(SOFT_FLOAT_CONFIG_OPTION) );
	touch $(BINUTILS_DIR1)/.configured

$(BINUTILS_DIR1)/binutils/objdump: $(BINUTILS_DIR1)/.configured
	$(MAKE) $(JLEVEL) -C $(BINUTILS_DIR1) all

# Make install will put gettext data in staging_dir/share/locale.
# Unfortunatey, it isn't configureable.
$(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/bin/ld: $(BINUTILS_DIR1)/binutils/objdump 
	$(MAKE) $(JLEVEL) -C $(BINUTILS_DIR1) install

binutils: $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/bin/ld

binutils-source: $(DL_DIR)/$(BINUTILS_SOURCE)

binutils-clean:
	rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
	-$(MAKE) -C $(BINUTILS_DIR1) clean

binutils-dirclean:
	rm -rf $(BINUTILS_DIR1)



#############################################################
#
# build binutils for use on the target system
#
#############################################################
BINUTILS_DIR2:=$(BUILD_DIR)/binutils-target
$(BINUTILS_DIR2)/.configured: $(BINUTILS_DIR)/.patched
	mkdir -p $(BINUTILS_DIR2)
	(cd $(BINUTILS_DIR2); \
		PATH=$(TARGET_PATH) \
		CFLAGS="$(TARGET_CFLAGS)" \
		$(BINUTILS_DIR)/configure \
		--prefix=/usr \
		--exec-prefix=/usr \
		--build=$(GNU_HOST_NAME) \
		--host=$(REAL_GNU_TARGET_NAME) \
		--target=$(REAL_GNU_TARGET_NAME) \
		$(MULTILIB) \
		$(SOFT_FLOAT_CONFIG_OPTION) );
	touch $(BINUTILS_DIR2)/.configured

$(BINUTILS_DIR2)/binutils/objdump: $(BINUTILS_DIR2)/.configured
	PATH=$(TARGET_PATH) \
	$(MAKE) $(JLEVEL) -C $(BINUTILS_DIR2) all

$(TARGET_DIR)/usr/bin/ld: $(BINUTILS_DIR2)/binutils/objdump 
	PATH=$(TARGET_PATH) \
	$(MAKE) $(JLEVEL) DESTDIR=$(TARGET_DIR) \
		tooldir=/usr build_tooldir=/usr \
		-C $(BINUTILS_DIR2) install
	#rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
	#	$(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
	-$(STRIP) $(TARGET_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/* > /dev/null 2>&1
	-$(STRIP) $(TARGET_DIR)/usr/bin/* > /dev/null 2>&1 

binutils_target: $(GCC_DEPENDANCY) $(TARGET_DIR)/usr/bin/ld

binutils_target-clean:
	rm -f $(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
	-$(MAKE) -C $(BINUTILS_DIR2) clean

binutils_target-dirclean:
	rm -rf $(BINUTILS_DIR2)

endif	#ifeq ($(USE_LINUX_UCLIBC),true)
+3 −1
Original line number Diff line number Diff line
ifneq ($(USE_LINUX_UCLIBC),true)
#############################################################
#
# build binutils for use on the host system
@@ -28,7 +29,7 @@ $(BINUTILS_DIR)/.unpacked: $(DL_DIR)/$(BINUTILS_SOURCE)

$(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
	$(SOURCE_DIR)/patch-kernel.sh $(BINUTILS_DIR) $(SOURCE_DIR) binutils-[0-9]*.patch
	touch $(BINUTILS_DIR)/.patched

$(BINUTILS_DIR1)/.configured: $(BINUTILS_DIR)/.patched
@@ -207,3 +208,4 @@ binutils_target-clean:
binutils_target-dirclean:
	rm -rf $(BINUTILS_DIR2)

endif	#ifneq ($(USE_LINUX_UCLIBC),true)
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

ifneq ($(USE_LINUX_UCLIBC),true)
ifeq ($(GCC_2_95_TOOLCHAIN),true)

GCC_SITE:=http://www.uclibc.org/downloads/toolchain
@@ -294,3 +295,4 @@ gcc2_95-dirclean:
	rm -rf $(GCC_BUILD_DIR2)

endif
endif	#ifneq ($(USE_LINUX_UCLIBC),true)
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

ifneq ($(USE_LINUX_UCLIBC),true)
ifneq ($(GCC_2_95_TOOLCHAIN),true)

# Older stuff...
@@ -67,7 +68,7 @@ $(GCC_DIR)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)

$(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
	$(SOURCE_DIR)/patch-kernel.sh $(GCC_DIR) $(SOURCE_DIR) gcc-[0-9]*.patch
ifeq ($(SOFT_FLOAT),true)
ifeq ("$(strip $(ARCH))","i386")
	$(SOURCE_DIR)/patch-kernel.sh $(GCC_DIR) $(SOURCE_DIR) i386-gcc-soft-float.patch
@@ -360,7 +361,7 @@ $(GCC_BUILD_DIR3)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)

$(GCC_BUILD_DIR3)/.patched: $(GCC_BUILD_DIR3)/.unpacked
	# Apply any files named gcc-*.patch from the source directory to gcc
	$(SOURCE_DIR)/patch-kernel.sh $(GCC_BUILD_DIR3) $(SOURCE_DIR) gcc-*.patch
	$(SOURCE_DIR)/patch-kernel.sh $(GCC_BUILD_DIR3) $(SOURCE_DIR) gcc-[0-9]**.patch
ifeq ("$(strip $(ARCH))","i386")
	$(SOURCE_DIR)/patch-kernel.sh $(GCC_BUILD_DIR3) $(SOURCE_DIR) i386-gcc-*.patch
endif
@@ -451,3 +452,4 @@ gcc3_3_target-dirclean:
	rm -rf $(GCC_BUILD_DIR3)

endif
endif	#ifneq ($(USE_LINUX_UCLIBC),true)
Loading