a patch for buildroot to use crosstool build glibc-based toolchain
Dears,
buildroot builds uclibc-based toolchain and uses it to build userland
programs.
here is a patch to enable buildroot to use crosstool build glibc-based
toolchain.
you have to set correct crosstool toolchain location and prefix to use
this feature.
-- shuhao
--- buildroot.old/Config.in 2005-03-27 07:15:11.000000000 +0000
+++ buildroot/Config.in 2005-04-26 12:13:25.000000000 +0000
@@ -7,70 +7,20 @@
default y
choice
- prompt "Target Architecture"
- default BR2_i386
- help
- Stuff
-
-config BR2_arm
- bool "arm"
-
-config BR2_armeb
- bool "armeb"
-
-config BR2_cris
- bool "cris"
-
-config BR2_i386
- bool "i386"
-
-config BR2_m68k
- bool "m68k"
-
-config BR2_mips
- bool "mips"
-
-config BR2_mipsel
- bool "mipsel"
-
-config BR2_powerpc
- bool "powerpc"
-
-config BR2_sh3
- bool "sh3"
-
-config BR2_sh3eb
- bool "sh3eb"
-
-config BR2_sh4
- bool "sh4"
-
-config BR2_sh4eb
- bool "sh4eb"
-
-config BR2_sparc
- bool "sparc"
+ prompt "Which Toolchain"
+ default BR2_UCLIBC
+ config BR2_UCLIBC
+ bool
+ prompt "uclibc based buildroot"
+
+ config BR2_GLIBC
+ bool
+ prompt "glibc based crosstool"
+
endchoice
-config BR2_ARCH
- string
- default "arm" if BR2_arm
- default "armeb" if BR2_armeb
- default "cris" if BR2_cris
- default "i386" if BR2_i386
- default "m68k" if BR2_m68k
- default "mips" if BR2_mips
- default "mipsel" if BR2_mipsel
- default "powerpc" if BR2_powerpc
- default "sh3" if BR2_sh3
- default "sh3eb" if BR2_sh3eb
- default "sh4" if BR2_sh4
- default "sh4eb" if BR2_sh4eb
- default "sparc" if BR2_sparc
-
-
-menu "Build options"
+menu "Build Options"
config BR2_WGET
string "Wget command"
@@ -84,19 +34,6 @@
bool "Tar verbose"
default n
-config BR2_STAGING_DIR
- string "Toolchain and header file location?"
- default "$(BUILD_DIR)/staging_dir"
- help
- This is the location where the toolchain will be installed. The
- toolchain will not work if it is moved from this location.
- Therefore, if you wish to package up a uClibc toolchain, it is
- important that is is set to the final location where the toolchain
- will be used.
-
- Most people will leave this set to the default value of
- "$(BUILD_DIR)/staging_dir".
-
config BR2_JLEVEL
int "Number of jobs to run simultaneously"
default "1"
@@ -107,6 +44,10 @@
source "toolchain/Config.in"
+source "crosstool/Config.in"
+
+source "toolchain/gdb/Config.in"
+
source "package/Config.in"
source "target/Config.in"
--- buildroot.old/Makefile 2005-03-27 07:15:11.000000000 +0000
+++ buildroot/Makefile 2005-04-26 12:13:25.891134408 +0000
@@ -70,7 +70,12 @@
# We also need the various per-package makefiles, which also add
# each selected package to TARGETS if that package was selected
# in the .config file.
+ifeq ($(BR2_UCLIBC),y)
include toolchain/*/*.mk
+endif
+ifeq ($(BR2_GLIBC),y)
+include crosstool/*.mk
+endif
include package/*/*.mk
include target/*/*.mk
diff -urN buildroot.old/crosstool/Config.in buildroot/crosstool/Config.in
--- buildroot.old/crosstool/Config.in 1970-01-01 00:00:00.000000000 +0000
+++ buildroot/crosstool/Config.in 2005-04-26 14:37:30.000000000 +0000
@@ -0,0 +1,131 @@
+menu "Toolchain Options"
+ depends BR2_GLIBC
+
+config BR2_STAGING_DIR
+ string "Toolchain and header file location?"
+ default ""
+ help
+ This is the location where the crosstool toolchain was installed.
+
+config BR2_CROSSTOOL_PREFIX
+ string "Toolchain prefix?"
+ default ""
+ help
+ This the the crosstool toolchain prefix.
+ For example, armeb-unknown-linux-gnu, mipsel-unknown-linux-gnu.
+
+config BR2_GLIBC_INSTALL
+ depends BR2_GLIBC
+ bool
+ default y
+ prompt "Install glibc shared libraries?"
+
+config BR2_GLIBC_STRIP
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Strip glibc shared libraries?"
+
+config BR2_GLIBC_LD_LINUX
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install ld-linux.so.2?"
+
+config BR2_GLIBC_LIBC
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libc.so?"
+
+config BR2_GLIBC_PTHREAD
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libpthread.so?"
+
+config BR2_GLIBC_THREAD_DB
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libthread_db.so?"
+
+config BR2_GLIBC_RT
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install librt.so?"
+
+config BR2_GLIBC_DL
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libdl.so?"
+
+config BR2_GLIBC_CRYPT
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libcrypt.so?"
+
+config BR2_GLIBC_UTIL
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libutil.so?"
+
+config BR2_GLIBC_LIBM
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libm.so?"
+
+config BR2_GLIBC_NSS_DNS
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libnss_dns.so?"
+
+config BR2_GLIBC_NSS_FILES
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libnss_files.so?"
+
+config BR2_GLIBC_NSS_HESIOD
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libnss_hesiod.so?"
+
+config BR2_GLIBC_NSS_NIS
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libnss_nis.so?"
+
+config BR2_GLIBC_NSS_NISPLUS
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libnss_nisplus.so?"
+
+config BR2_GLIBC_NSS_COMPAT
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libnss_compat.so?"
+
+config BR2_GLIBC_RESOLV
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libresolv.so?"
+
+config BR2_GLIBC_NSL
+ depends BR2_GLIBC_INSTALL
+ bool
+ default y
+ prompt "Install libnsl.so?"
+
+endmenu
diff -urN buildroot.old/crosstool/glibc.mk buildroot/crosstool/glibc.mk
--- buildroot.old/crosstool/glibc.mk 1970-01-01 00:00:00.000000000 +0000
+++ buildroot/crosstool/glibc.mk 2005-04-26 15:33:01.142619464 +0000
@@ -0,0 +1,117 @@
+#
+# copy_toolchain_lib_root
+#
+# $1: source
+# $2: destination
+# $2: strip (y|n) default is to strip
+#
+copy_toolchain_lib_root = \
+ LIB="$(strip $1)"; \
+ DST="$(strip $2)"; \
+ STRIP="$(strip $3)"; \
+ \
+ LIB_DIR=`$(TARGET_CC) -print-file-name=$${LIB} | sed -e "s,/$${LIB}\$$,,"`; \
+ \
+ if test -z "$${LIB_DIR}"; then \
+ echo "copy_toolchain_lib_root: lib=$${LIB} not found"; \
+ exit -1; \
+ fi; \
+ \
+ LIB="$(strip $1)"; \
+ for FILE in `find $${LIB_DIR} -type l -name "$${LIB}*" -maxdepth 1`; do \
+ LIB=`basename $${FILE}`; \
+ while test \! -z "$${LIB}"; do \
+ echo "copy_toolchain_lib_root lib=$${LIB} dst=$${DST}"; \
+ rm -fr $(TARGET_DIR)$${DST}/$${LIB}; \
+ mkdir -p $(TARGET_DIR)$${DST}; \
+ if test -h $${LIB_DIR}/$${LIB}; then \
+ cp -d $${LIB_DIR}/$${LIB} $(TARGET_DIR)$${DST}/; \
+ elif test -f $${LIB_DIR}/$${LIB}; then \
+ cp $${LIB_DIR}/$${LIB} $(TARGET_DIR)$${DST}/$${LIB}; \
+ case "$${STRIP}" in \
+ (0 | n | no) \
+ ;; \
+ (*) \
+ $(TARGET_CROSS)strip "$(TARGET_DIR)$${DST}/$${LIB}"; \
+ ;; \
+ esac; \
+ else \
+ exit -1; \
+ fi; \
+ LIB="`readlink $${LIB_DIR}/$${LIB}`"; \
+ done; \
+ done; \
+ \
+ echo -n
+
+uclibc: $(TARGET_DIR)/lib/libc.so
+
+$(TARGET_DIR)/lib/libc.so:
+ mkdir -p $(TARGET_DIR)/lib
+ifdef BR2_GLIBC_LD_LINUX
+ @$(call copy_toolchain_lib_root, ld-linux.so.2, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_LIBC
+ @$(call copy_toolchain_lib_root, libc.so.6, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_PTHREAD
+ @$(call copy_toolchain_lib_root, libpthread.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_THREAD_DB
+ @$(call copy_toolchain_lib_root, libthread_db.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_RT
+ @$(call copy_toolchain_lib_root, librt.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_DL
+ @$(call copy_toolchain_lib_root, libdl.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_CRYPT
+ @$(call copy_toolchain_lib_root, libcrypt.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_UTIL
+ @$(call copy_toolchain_lib_root, libutil.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_LIBM
+ @$(call copy_toolchain_lib_root, libm.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_NSS_DNS
+ @$(call copy_toolchain_lib_root, libnss_dns.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_NSS_FILES
+ @$(call copy_toolchain_lib_root, libnss_files.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_NSS_HESIOD
+ @$(call copy_toolchain_lib_root, libnss_hesiod.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_NSS_NIS
+ @$(call copy_toolchain_lib_root, libnss_nis.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_NSS_NISPLUS
+ @$(call copy_toolchain_lib_root, libnss_nisplus.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_NSS_COMPAT
+ @$(call copy_toolchain_lib_root, libnss_compat.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_RESOLV
+ @$(call copy_toolchain_lib_root, libresolv.so, /lib, $(BR2_GLIBC_STRIP))
+endif
+
+ifdef BR2_GLIBC_NSL
+ @$(call copy_toolchain_lib_root, libnsl.so, /lib, $(BR2_GLIBC_STRIP))
+endif
diff -urN buildroot.old/package/Makefile.in buildroot/package/Makefile.in
--- buildroot.old/package/Makefile.in 2005-03-27 07:15:11.000000000 +0000
+++ buildroot/package/Makefile.in 2005-04-26 12:20:58.966256520 +0000
@@ -8,6 +8,8 @@
#"
SVN:=$(strip $(subst ",, $(BR2_SVN)))
#"
+CROSSTOOL_PREFIX:=$(strip $(subst ",, $(BR2_CROSSTOOL_PREFIX)))
+#"
@@ -20,18 +22,37 @@
BASE_DIR:=${shell pwd}
DL_DIR:=$(BASE_DIR)/dl
#PATCH_DIR=$(BASE_DIR)/sources/patches
+ifeq ($(BR2_UCLIBC), y)
BUILD_DIR:=$(BASE_DIR)/build_$(ARCH)$(ARCH_FPU_SUFFIX)
+endif
+ifeq ($(BR2_GLIBC), y)
+BUILD_DIR:=$(BASE_DIR)/build_$(CROSSTOOL_PREFIX)
+endif
TARGET_DIR:=$(BUILD_DIR)/root
+ifeq ($(BR2_UCLIBC), y)
TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(ARCH)$(ARCH_FPU_SUFFIX)
+endif
+ifeq ($(BR2_GLIBC), y)
+TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(CROSSTOOL_PREFIX)
+endif
# Strip off the annoying quoting
STAGING_DIR:=$(strip $(subst ",, $(BR2_STAGING_DIR)))
#"
TARGET_PATH=$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin
+ifeq ($(BR2_UCLIBC), y)
IMAGE:=$(BASE_DIR)/root_fs_$(ARCH)$(ARCH_FPU_SUFFIX)
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-
+endif
+ifeq ($(BR2_GLIBC), y)
+IMAGE:=$(BASE_DIR)/root_fs_$(CROSSTOOL_PREFIX)
+REAL_GNU_TARGET_NAME=$(CROSSTOOL_PREFIX)
+GNU_TARGET_NAME=$(CROSSTOOL_PREFIX)
+KERNEL_CROSS=$(STAGING_DIR)/bin/$(CROSSTOOL_PREFIX)-
+TARGET_CROSS=$(STAGING_DIR)/bin/$(CROSSTOOL_PREFIX)-
+endif
TARGET_CC=$(TARGET_CROSS)gcc
STRIP=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
INSTALL=/usr/bin/install
diff -urN buildroot.old/toolchain/Config.in buildroot/toolchain/Config.in
--- buildroot.old/toolchain/Config.in 2005-03-27 07:15:04.000000000 +0000
+++ buildroot/toolchain/Config.in 2005-04-26 12:13:25.893134104 +0000
@@ -1,14 +1,76 @@
#
menu "Toolchain Options"
+ depends BR2_UCLIBC
+choice
+ prompt "Target Architecture"
+ default BR2_i386
+ help
+ Stuff
+
+config BR2_arm
+ bool "arm"
+
+config BR2_armeb
+ bool "armeb"
+
+config BR2_cris
+ bool "cris"
+
+config BR2_i386
+ bool "i386"
+
+config BR2_m68k
+ bool "m68k"
+
+config BR2_mips
+ bool "mips"
+
+config BR2_mipsel
+ bool "mipsel"
+
+config BR2_powerpc
+ bool "powerpc"
+
+config BR2_sh3
+ bool "sh3"
+
+config BR2_sh3eb
+ bool "sh3eb"
+
+config BR2_sh4
+ bool "sh4"
+
+config BR2_sh4eb
+ bool "sh4eb"
+
+config BR2_sparc
+ bool "sparc"
+
+endchoice
+
+config BR2_ARCH
+ string
+ default "arm" if BR2_arm
+ default "armeb" if BR2_armeb
+ default "cris" if BR2_cris
+ default "i386" if BR2_i386
+ default "m68k" if BR2_m68k
+ default "mips" if BR2_mips
+ default "mipsel" if BR2_mipsel
+ default "powerpc" if BR2_powerpc
+ default "sh3" if BR2_sh3
+ default "sh3eb" if BR2_sh3eb
+ default "sh4" if BR2_sh4
+ default "sh4eb" if BR2_sh4eb
+ default "sparc" if BR2_sparc
source "toolchain/kernel-headers/Config.in"
source "toolchain/uClibc/Config.in"
source "toolchain/binutils/Config.in"
source "toolchain/gcc/Config.in"
source "toolchain/ccache/Config.in"
-source "toolchain/gdb/Config.in"
comment "Common Toolchain Options"
@@ -53,6 +115,18 @@
#GCC_WITH_ARCH:=--with-arch=
#GCC_WITH_TUNE:=--with-tune=
+config BR2_STAGING_DIR
+ string "Toolchain and header file location?"
+ default "$(BUILD_DIR)/staging_dir"
+ help
+ This is the location where the toolchain will be installed. The
+ toolchain will not work if it is moved from this location.
+ Therefore, if you wish to package up a uClibc toolchain, it is
+ important that is is set to the final location where the toolchain
+ will be used.
+
+ Most people will leave this set to the default value of
+ "$(BUILD_DIR)/staging_dir".
endmenu
diff -urN buildroot.old/toolchain/gdb/Config.in buildroot/toolchain/gdb/Config.in
--- buildroot.old/toolchain/gdb/Config.in 2005-03-27 07:15:04.000000000 +0000
+++ buildroot/toolchain/gdb/Config.in 2005-04-26 12:13:25.894133952 +0000
@@ -1,4 +1,4 @@
-comment "Gdb Options"
+menu "Gdb Options"
config BR2_PACKAGE_GDB
bool "Build gdb debugger for the Target"
@@ -40,4 +40,4 @@
default "6.2.1" if BR2_GDB_VERSION_6_2_1
default "6.3" if BR2_GDB_VERSION_6_3
-
+endmenu
Reply to: