This commit is contained in:
bauen1 2017-07-05 17:30:05 +02:00
parent 430ed90eaf
commit 06ada0b0dc
3 changed files with 32 additions and 19 deletions

View File

@ -50,7 +50,7 @@ SYSROOT="$PWD/sysroot"
GCC_INTERNAL_PATH=$(dirname $(gcc -print-libgcc-file-name))
cat << CEOF > sysroot.specs
*link_libgcc
*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

View File

@ -2,7 +2,7 @@
SRC_DIR=$(pwd)
. ../common.sh
. ../../common.sh
# Find the main source directory
cd ../../..

View File

@ -1,24 +1,37 @@
#!/bin/sh
# common code use by almost all bundles
# this should be sourced in bundle.sh of every bundle
# common code used by all bundles
# should be included at the top of every *.sh file of each bundle
# Read the 'JOB_FACTOR' property from '.config'
JOB_FACTOR="$(grep -i ^JOB_FACTOR $MAIN_SRC_DIR/.config | cut -f2 -d'=')"
export MAIN_SRC_DIR=$(realpath --no-symlinks $PWD/../../../)
export WORK_DIR="$MAIN_SRC_DIR/work"
export SRC_DIR=$(pwd)
export CONFIG="$MAIN_SRC_DIR/.config"
export SYSROOT="$WORK_DIR/sysroot"
export SYSROOT_SPECS="$WORK_DIR/sysroot.specs"
# Read the 'CFLAGS' property from '.config'
CFLAGS="$(grep -i ^CFLAGS $MAIN_SRC_DIR/.config | cut -f2 -d'=')"
# Read the 'JOB_FACTOR' property from $CONFIG
export JOB_FACTOR="$(grep -i ^JOB_FACTOR $CONFIG | cut -f2 -d'=')"
# Find the number of available CPU cores.
NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l)
# Read the 'CFLAGS' property from $CONFIG
export CFLAGS="$(grep -i ^CFLAGS $CONFIG | cut -f2 -d'=')"
# Calculate the number of 'make' jobs to be used later.
NUM_JOBS=$((NUM_CORES * JOB_FACTOR))
# Find the number of available CPU cores
export NUM_CORES="$(grep ^processor /proc/cpuinfo | wc -l)"
# sysroot
# Calculate the number of make "jobs"
export NUM_JOBS=$((NUM_CORES * JOB_FACTOR))
# 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)"
# Ideally we would export MAKE at this point with -j etc to allow programs to just run $(MAKE) and not worry about extra flags that need to be passed
# export MAKE="${MAKE-make} -j $NUM_JOBS"
# sysroot flags for the compiler
#-Wl,-nostdlib is required to make ld / gcc ignore the host's /usr/lib and /lib
ld_flags="-Wl,-nostdlib $(grep -- \"-L\" $SYSROOT_SPECS)"
#-static-libgcc is neeeded since we don't have the gcc-libs in our sysroot
gcc_flags="-specs=$SYSROOT_SPECS -static-libgcc"
# $ld_flags is passed 2 times because sometimes bundles ignore one of the variables
export CC="${CC-gcc} $gcc_flags $ld_flags"
export CFLAGS="$CFLAGS"
export LDFLAGS="$LDFLAGS $ld_flags"