This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 0 of 1] Static gcc/binutils


Adds the ability to build a static gcc/binutils.? It does not apply to
anything else, but is a start to this request:
http://sourceware.org/ml/crossgcc/2008-06/msg00021.html.  zlib added
because most distributions do not include a static zlib.

Signed-Off by Joshua Henderson <digitalpeer@digitalpeer.com>


diff -Naur crosstool-ng-1.5.1/config/companion_libs/zlib.in
crosstool-ng-1.5.1-static/config/companion_libs/zlib.in
--- crosstool-ng-1.5.1/config/companion_libs/zlib.in	1969-12-31
16:00:00.000000000 -0800
+++ crosstool-ng-1.5.1-static/config/companion_libs/zlib.in	2010-01-26
21:38:43.000000000 -0800
@@ -0,0 +1,19 @@
+# ZLIB options
+
+choice
+    bool
+    prompt "ZLIB version"
+# Don't remove next line
+# CT_INSERT_VERSION_BELOW
+
+config ZLIB_V_1_2_3
+    bool
+    prompt "1.2.3"
+
+endchoice
+
+config ZLIB_VERSION
+    string
+# Don't remove next line
+# CT_INSERT_VERSION_STRING_BELOW
+    default "1.2.3" if ZLIB_V_1_2_3
diff -Naur crosstool-ng-1.5.1/config/companion_libs.in
crosstool-ng-1.5.1-static/config/companion_libs.in
--- crosstool-ng-1.5.1/config/companion_libs.in	2009-10-28
11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/config/companion_libs.in	2010-01-26
21:44:03.000000000 -0800
@@ -30,6 +30,16 @@
 source config/companion_libs/mpfr.in
 endif

+config ZLIB
+    bool
+    prompt "ZLIB"
+    help
+      zlib
+
+if ZLIB
+source config/companion_libs/zlib.in
+endif
+
 config PPL_CLOOG_MPC
     bool
     prompt "PPL, GLooG/PPL and MPC"
diff -Naur crosstool-ng-1.5.1/config/toolchain.in
crosstool-ng-1.5.1-static/config/toolchain.in
--- crosstool-ng-1.5.1/config/toolchain.in	2009-10-28 11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/config/toolchain.in	2010-01-28
22:04:46.000000000 -0800
@@ -12,6 +12,13 @@

       You definitely want to say 'Y' here. Yes you do. I know you do. Say 'Y'.

+config STATIC_TOOLCHAIN
+    bool
+    prompt "Build Static Toolchain"
+    default y
+    help
+      Compile binutils and gcc as static binaries.
+
 config SYSROOT_DIR_PREFIX
     string
     prompt "sysroot prefix dir (READ HELP)"
diff -Naur crosstool-ng-1.5.1/scripts/build/binutils/binutils.sh
crosstool-ng-1.5.1-static/scripts/build/binutils/binutils.sh
--- crosstool-ng-1.5.1/scripts/build/binutils/binutils.sh	2009-10-28
11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/scripts/build/binutils/binutils.sh	2010-01-26
22:22:59.000000000 -0800
@@ -48,7 +48,12 @@
         ${BINUTILS_SYSROOT_ARG}

     CT_DoLog EXTRA "Building binutils"
-    CT_DoExecLog ALL make ${PARALLELMFLAGS}
+    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+	CT_DoExecLog ALL make configure-host
+	CT_DoExecLog ALL make ${PARALLELMFLAGS} LDFLAGS="-all-static
-L${CT_PREFIX_DIR}/lib"
+    else
+	CT_DoExecLog ALL make ${PARALLELMFLAGS}
+    fi

     CT_DoLog EXTRA "Installing binutils"
     CT_DoExecLog ALL make install
diff -Naur crosstool-ng-1.5.1/scripts/build/cc/gcc.sh
crosstool-ng-1.5.1-static/scripts/build/cc/gcc.sh
--- crosstool-ng-1.5.1/scripts/build/cc/gcc.sh	2009-10-28
11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/scripts/build/cc/gcc.sh	2010-01-29
00:14:34.000000000 -0800
@@ -346,9 +346,14 @@
         CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
     fi

-    CT_DoLog EXTRA "Building final compiler"
-    CT_DoExecLog ALL make ${PARALLELMFLAGS} all
+    extra_make_flags=
+    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+	extra_make_flags="LDFLAGS=-static"
+    fi

+    CT_DoLog EXTRA "Building final compiler"
+    CT_DoExecLog ALL make ${PARALLELMFLAGS} ${extra_make_flags}
+
     CT_DoLog EXTRA "Installing final compiler"
     CT_DoExecLog ALL make install

diff -Naur crosstool-ng-1.5.1/scripts/build/companion_libs/gmp.sh
crosstool-ng-1.5.1-static/scripts/build/companion_libs/gmp.sh
--- crosstool-ng-1.5.1/scripts/build/companion_libs/gmp.sh	2009-10-28
11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/scripts/build/companion_libs/gmp.sh	2010-01-29
00:11:52.000000000 -0800
@@ -28,6 +28,13 @@

     CT_DoStep INFO "Installing GMP"

+    gmp_opt=
+    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+	gmp_opt="$gmp_opt --enable-static"
+    else
+	gmp_opt="$gmp_opt --disable-static"
+    fi
+
     CT_DoLog EXTRA "Configuring GMP"

     CFLAGS="${CT_CFLAGS_FOR_HOST} -fexceptions"     \
@@ -36,8 +43,8 @@
         --build=${CT_BUILD}                         \
         --host=${CT_HOST}                           \
         --prefix="${CT_PREFIX_DIR}"                 \
+        ${gmp_opt}                                  \
         --enable-shared                             \
-        --disable-static                            \
         --enable-fft                                \
         --enable-mpbsd                              \
         --enable-cxx
diff -Naur crosstool-ng-1.5.1/scripts/build/companion_libs/mpfr.sh
crosstool-ng-1.5.1-static/scripts/build/companion_libs/mpfr.sh
--- crosstool-ng-1.5.1/scripts/build/companion_libs/mpfr.sh	2009-10-28
11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/scripts/build/companion_libs/mpfr.sh	2010-01-29
00:12:01.000000000 -0800
@@ -78,6 +78,12 @@
         *)          mpfr_opt="--enable-thread-safe";;
     esac

+    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+	mpfr_opt="$mpfr_opt --enable-static"
+    else
+	mpfr_opt="$mpfr_opt --disable-static"
+    fi
+
     CT_DoLog EXTRA "Configuring MPFR"
     CC="${CT_HOST}-gcc"                                 \
     CFLAGS="${CT_CFLAGS_FOR_HOST}"                      \
@@ -88,7 +94,6 @@
         --prefix="${CT_PREFIX_DIR}"                     \
         ${mpfr_opt}                                     \
         --enable-shared                                 \
-        --disable-static                                \
         --with-gmp="${CT_PREFIX_DIR}"

     CT_DoLog EXTRA "Building MPFR"
diff -Naur crosstool-ng-1.5.1/scripts/build/companion_libs/zlib.sh
crosstool-ng-1.5.1-static/scripts/build/companion_libs/zlib.sh
--- crosstool-ng-1.5.1/scripts/build/companion_libs/zlib.sh	1969-12-31
16:00:00.000000000 -0800
+++ crosstool-ng-1.5.1-static/scripts/build/companion_libs/zlib.sh	2010-01-26
22:10:15.000000000 -0800
@@ -0,0 +1,45 @@
+# This file adds the functions to build the ZLIB library
+# Copyright 2009 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+do_zlib_get() { :; }
+do_zlib_extract() { :; }
+do_zlib() { :; }
+do_zlib_target() { :; }
+
+# Overide functions depending on configuration
+if [ "${CT_ZLIB}" = "y" ]; then
+
+# Download ZLIB
+do_zlib_get() {
+    CT_GetFile "zlib-${CT_ZLIB_VERSION}" .tar.bz2 http://www.zlib.net/
+}
+
+# Extract ZLIB
+do_zlib_extract() {
+    CT_Extract "zlib-${CT_ZLIB_VERSION}"
+    CT_Patch "zlib-${CT_ZLIB_VERSION}"
+}
+
+do_zlib() {
+    cd "${CT_SRC_DIR}/zlib-${CT_ZLIB_VERSION}/"
+
+    CT_DoStep INFO "Installing ZLIB"
+
+    CT_DoLog EXTRA "Configuring ZLIB"
+    CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
+    CXXFLAGS="${CT_CFLAGS_FOR_HOST}"                \
+    CT_DoExecLog ALL                                \
+    "./configure" \
+        --prefix="${CT_PREFIX_DIR}"
+
+    CT_DoLog EXTRA "Building ZLIB"
+    CT_DoExecLog ALL make ${PARALLELMFLAGS}
+
+    CT_DoLog EXTRA "Installing ZLIB"
+    CT_DoExecLog ALL make install
+
+    CT_EndStep
+}
+
+fi # CT_ZLIB
diff -Naur crosstool-ng-1.5.1/scripts/crosstool-NG.sh.in
crosstool-ng-1.5.1-static/scripts/crosstool-NG.sh.in
--- crosstool-ng-1.5.1/scripts/crosstool-NG.sh.in	2009-10-28
11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/scripts/crosstool-NG.sh.in	2010-01-26
21:53:02.000000000 -0800
@@ -120,6 +120,7 @@
 . "${CT_LIB_DIR}/scripts/build/companion_libs/ppl.sh"
 . "${CT_LIB_DIR}/scripts/build/companion_libs/cloog.sh"
 . "${CT_LIB_DIR}/scripts/build/companion_libs/mpc.sh"
+. "${CT_LIB_DIR}/scripts/build/companion_libs/zlib.sh"
 . "${CT_LIB_DIR}/scripts/build/binutils/binutils.sh"
 . "${CT_LIB_DIR}/scripts/build/binutils/elf2flt.sh"
 . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
@@ -491,6 +492,7 @@
     do_ppl_get
     do_cloog_get
     do_mpc_get
+    do_zlib_get
     do_binutils_get
     do_cc_get
     do_libc_get
@@ -510,6 +512,7 @@
         do_ppl_extract
         do_cloog_extract
         do_mpc_extract
+        do_zlib_extract
         do_binutils_extract
         do_cc_extract
         do_libc_extract
diff -Naur crosstool-ng-1.5.1/steps.mk crosstool-ng-1.5.1-static/steps.mk
--- crosstool-ng-1.5.1/steps.mk	2009-10-28 11:43:37.000000000 -0700
+++ crosstool-ng-1.5.1-static/steps.mk	2010-01-26 21:58:20.000000000 -0800
@@ -23,6 +23,7 @@
             ppl                 \
             cloog               \
             mpc                 \
+            zlib                \
             binutils            \
             elf2flt             \
             cc_core_pass_1      \

--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]