diff mbox

scripts: add support for a pre-built sysroot

Message ID 1c30b090c664d9ca063f.1321413798@crucis
State New
Headers show

Commit Message

Michael Hope Nov. 16, 2011, 3:23 a.m. UTC
# HG changeset patch
# User Michael Hope <michael.hope@linaro.org>
# Date 1321413746 -46800
# Branch prebuilt-sysroot-2
# Node ID 1c30b090c664d9ca063f1c1d0926d49f512c3a14
# Parent  c6d10ee4ab25a8b0547b69e9a101d856d3b951a1
scripts: add support for a pre-built sysroot.

Useful when building a compiler that targets an existing system such
as Ubuntu or Debian.  Fetches a tarball that contains the libc
libraries, libc headers, and kernel headers and uses that as the
sysroot.  Assumes the libc is GLIBC-like and the kernel is
Linux-like.   Adds a new libc option called 'prebuilt'.  Adds a new
kernel option called 'prebuilt'.

Messy:  I haven't scattered 'depends ! PREBUILT_SYSROOT' across the
config files.  It's possible to configure something inconsistent.

For discussion.  I'm happy to keep this in our own tree.

Signed-off-by: Michael Hope <michael.hope@linaro.org>
diff mbox

Patch

diff -r c6d10ee4ab25 -r 1c30b090c664 config/kernel/prebuilt.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/kernel/prebuilt.in	Wed Nov 16 16:22:26 2011 +1300
@@ -0,0 +1,8 @@ 
+# Prebuilt Linux kernel options
+
+## depends on PREBUILT_SYSROOT
+##
+## select KERNEL_SUPPORTS_SHARED_LIBS
+##
+## help Build a toolchain targeting systems running Linux as a kernel.
+##
\ No newline at end of file
diff -r c6d10ee4ab25 -r 1c30b090c664 config/libc/prebuilt.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/libc/prebuilt.in	Wed Nov 16 16:22:26 2011 +1300
@@ -0,0 +1,8 @@ 
+# Prebuilt libc options
+
+## depends on PREBUILT_SYSROOT
+##
+## select LIBC_SUPPORT_NPTL
+##
+## help Use the EGLIBC/GLIBC from the prebuilt sysroot.
+##
diff -r c6d10ee4ab25 -r 1c30b090c664 config/toolchain.in
--- a/config/toolchain.in	Mon Nov 14 13:29:12 2011 +0100
+++ b/config/toolchain.in	Wed Nov 16 16:22:26 2011 +1300
@@ -17,6 +17,28 @@ 
       
       You definitely want to say 'Y' here. Yes you do. I know you do. Say 'Y'.
 
+config PREBUILT_SYSROOT
+    bool
+    depends on USE_SYSROOT
+    prompt "Use a pre-built sysroot"
+    help
+      A pre-built sysroot contains the headers and libraries that were
+      built elsewhere for the target system.  Useful when building
+      a compiler that targets an existing distribution like Debian or
+      Ubuntu.
+
+config PREBUILT_NAME
+    string
+    prompt "Pre-built sysroot name"
+    depends on PREBUILT_SYSROOT
+    help
+      Base name of the pre-built sysroot without the URL or extension.
+
+config PREBUILT_BASE_URL
+    string
+    prompt "Pre-built sysroot base URL"
+    depends on PREBUILT_SYSROOT
+
 config SYSROOT_NAME
     string
     prompt "sysroot directory name" if ! BACKEND
diff -r c6d10ee4ab25 -r 1c30b090c664 scripts/build/arch/arm.sh
--- a/scripts/build/arch/arm.sh	Mon Nov 14 13:29:12 2011 +0100
+++ b/scripts/build/arch/arm.sh	Wed Nov 16 16:22:26 2011 +1300
@@ -7,6 +7,7 @@ 
     # The system part of the tuple:
     case "${CT_LIBC},${CT_ARCH_ARM_EABI}" in
         *glibc,y)   CT_TARGET_SYS=gnueabi;;
+        prebuilt,y) CT_TARGET_SYS=gnueabi;;
         uClibc,y)   CT_TARGET_SYS=uclibcgnueabi;;
         *,y)        CT_TARGET_SYS=eabi;;
     esac
diff -r c6d10ee4ab25 -r 1c30b090c664 scripts/build/kernel/prebuilt.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/build/kernel/prebuilt.sh	Wed Nov 16 16:22:26 2011 +1300
@@ -0,0 +1,19 @@ 
+# This file declares functions for pre-built Linux kernel
+# Copyright 2011  Linaro Limited
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+CT_DoKernelTupleValues() {
+    CT_TARGET_KERNEL="linux"
+}
+
+do_kernel_get() {
+    :
+}
+
+do_kernel_extract() {
+    :
+}
+
+do_kernel_headers() {
+    :
+}
diff -r c6d10ee4ab25 -r 1c30b090c664 scripts/build/libc/prebuilt.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/build/libc/prebuilt.sh	Wed Nov 16 16:22:26 2011 +1300
@@ -0,0 +1,32 @@ 
+# This file adds functions to fetch and use a prebuilt sysroot.
+# Copyright 2011  Linaro Limited
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_libc_get() {
+    CT_DoLog DEBUG "Fetching ${CT_PREBUILT_NAME}"
+    CT_GetFile "${CT_PREBUILT_NAME}" "${CT_PREBUILT_BASE_URL}"
+
+    return 0
+}
+
+do_libc_extract() {
+    CT_Extract "${CT_PREBUILT_NAME}"
+}
+
+do_libc_check_config() {
+    :
+}
+
+do_libc_start_files() {
+    # do_kernel_headers has already run
+    CT_DoLog EXTRA "Installing the pre-built sysroot"
+    CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/${CT_PREBUILT_NAME}"/* "${CT_SYSROOT_DIR}"
+}
+
+do_libc() {
+    :
+}
+
+do_libc_finish() {
+    :
+}
diff -r c6d10ee4ab25 -r 1c30b090c664 scripts/functions
--- a/scripts/functions	Mon Nov 14 13:29:12 2011 +0100
+++ b/scripts/functions	Wed Nov 16 16:22:26 2011 +1300
@@ -971,6 +971,7 @@ 
     # by architecture-specific values.
     case "${CT_LIBC}" in
         *glibc) CT_TARGET_SYS=gnu;;
+        prebuilt) CT_TARGET_SYS=gnu;;
         uClibc) CT_TARGET_SYS=uclibc;;
         *)      CT_TARGET_SYS=elf;;
     esac