From 430ed90eafaae32c5622bd5e17762880c9bfc721 Mon Sep 17 00:00:00 2001 From: bauen1 Date: Tue, 4 Jul 2017 23:49:57 +0200 Subject: [PATCH] Overhaul of bundles building nweb --- src/05_prepare_sysroot.sh | 13 ++++++++++++ src/minimal_overlay/bundles/nweb/bundle.sh | 10 ++++----- src/minimal_overlay/common.sh | 24 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100755 src/minimal_overlay/common.sh diff --git a/src/05_prepare_sysroot.sh b/src/05_prepare_sysroot.sh index 8ea51839c..a6dfd09c2 100755 --- a/src/05_prepare_sysroot.sh +++ b/src/05_prepare_sysroot.sh @@ -41,6 +41,19 @@ ln -s ../../kernel/kernel_installed/include/asm include/asm ln -s ../../kernel/kernel_installed/include/asm-generic include/asm-generic ln -s ../../kernel/kernel_installed/include/mtd include/mtd +cd .. + +echo "generating sysroot.specs" +SYSROOT="$PWD/sysroot" + +# gcc has a "internal" path that needs to be added to find the static versions of libgcc_* +GCC_INTERNAL_PATH=$(dirname $(gcc -print-libgcc-file-name)) + +cat << CEOF > sysroot.specs +*link_libgcc +-L$SYSROOT/lib -L$SYSROOT/lib64 -L$SYSROOT/usr/lib -L$SYSROOT/usr/lib64 -L$SYSROOT/usr/local/lib -L$SYSROOT/usr/local/lib64 -L$GCC_INTERNAL_PATH +CEOF + cd $SRC_DIR echo "*** PREPARE SYSROOT END ***" diff --git a/src/minimal_overlay/bundles/nweb/bundle.sh b/src/minimal_overlay/bundles/nweb/bundle.sh index 1ea6d676b..6ecda4986 100755 --- a/src/minimal_overlay/bundles/nweb/bundle.sh +++ b/src/minimal_overlay/bundles/nweb/bundle.sh @@ -1,24 +1,24 @@ #!/bin/sh + SRC_DIR=$(pwd) +. ../common.sh + # Find the main source directory cd ../../.. MAIN_SRC_DIR=$(pwd) cd $SRC_DIR -# Read the 'CFLAGS' property from '.config' -CFLAGS="$(grep -i ^CFLAGS $MAIN_SRC_DIR/.config | cut -f2 -d'=')" - echo "removing previous work area" rm -rf $MAIN_SRC_DIR/work/overlay/nweb mkdir -p $MAIN_SRC_DIR/work/overlay/nweb cd $MAIN_SRC_DIR/work/overlay/nweb # nweb -cc $CFLAGS $SRC_DIR/nweb23.c -o nweb +${CC-gcc} $CFLAGS $SRC_DIR/nweb23.c -o nweb # client -#cc $CFLAGS $SRC_DIR/client.c -o client +#${CC-gcc} $CFLAGS $SRC_DIR/client.c -o client echo "nweb has been build." diff --git a/src/minimal_overlay/common.sh b/src/minimal_overlay/common.sh new file mode 100755 index 000000000..681ef84ef --- /dev/null +++ b/src/minimal_overlay/common.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# common code use by almost all bundles +# this should be sourced in bundle.sh of every bundle + +# Read the 'JOB_FACTOR' property from '.config' +JOB_FACTOR="$(grep -i ^JOB_FACTOR $MAIN_SRC_DIR/.config | cut -f2 -d'=')" + +# Read the 'CFLAGS' property from '.config' +CFLAGS="$(grep -i ^CFLAGS $MAIN_SRC_DIR/.config | cut -f2 -d'=')" + +# Find the number of available CPU cores. +NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) + +# Calculate the number of 'make' jobs to be used later. +NUM_JOBS=$((NUM_CORES * JOB_FACTOR)) + +# sysroot + +# some of these are duplicate, but there are always bad packages that ignore one of these +SPECS=$PWD/../../../work/sysroot.specs +CC="gcc -specs=$SPECS -static-libgcc -Wl,-nostdlib" +CFLAGSC="-specs=$SPECS -static-libgcc $CFLAGS -Wl,-nostdlib" +CPPFLAGS="-specs=$SPECS -static-libgcc $CPPFLAGS -Wl,-nostdlib" +LDFLAGS="-Wl,-nostdlib $(grep -- \"-L\" $SPECS)"