diff options
Diffstat (limited to 'payloads/libpayload')
-rw-r--r-- | payloads/libpayload/bin/lp.functions | 4 | ||||
-rwxr-xr-x | payloads/libpayload/bin/lpgcc | 71 |
2 files changed, 50 insertions, 25 deletions
diff --git a/payloads/libpayload/bin/lp.functions b/payloads/libpayload/bin/lp.functions index 21b6e918b8..31f005d355 100644 --- a/payloads/libpayload/bin/lp.functions +++ b/payloads/libpayload/bin/lp.functions @@ -49,11 +49,13 @@ fi if [ -f $BASE/../lib/libpayload.a ]; then _LIBDIR=$BASE/../lib +elif [ -f $BASE/../build/libpayload.a ]; then + _LIBDIR=$BASE/../build else _LIBDIR=$LIBPAYLOAD_PREFIX/lib fi -if [ -d $BASE/../include/ ]; then +if [ -d $BASE/../include ]; then _INCDIR=$BASE/../include else _INCDIR=$LIBPAYLOAD_PREFIX/include diff --git a/payloads/libpayload/bin/lpgcc b/payloads/libpayload/bin/lpgcc index 06b9021fbf..f0b24170e4 100755 --- a/payloads/libpayload/bin/lpgcc +++ b/payloads/libpayload/bin/lpgcc @@ -59,9 +59,42 @@ BASE=`dirname $0` . $BASE/lp.functions # include libpayload config -. $BASE/../libpayload.config +if [ -f $BASE/../libpayload.config ]; then + . $BASE/../libpayload.config +elif [ -f $BASE/../.config ]; then + . $BASE/../.config +else + echo "Can't find config" + exit 1 +fi + +if [ "$CONFIG_ARCH_ARMV7" = "y" ]; then + _ARCHINCDIR=$_INCDIR/armv7 + _ARCHLIBDIR=$_LIBDIR/armv7 + _ARCHEXTRA="" + _ARCH=armv7 +fi + +if [ "$CONFIG_ARCH_POWERPC" = "y" ]; then + _ARCHINCDIR=$_INCDIR/powerpc + _ARCHLIBDIR=$_LIBDIR/powerpc + _ARCHEXTRA="" + _ARCH=powerpc +fi + +if [ "$CONFIG_ARCH_X86" = "y" ]; then + _ARCHINCDIR=$_INCDIR/x86 + _ARCHLIBDIR=$_LIBDIR/x86 + _ARCHEXTRA="-m32 " + _ARCH=x86 +fi -_LDSCRIPT="-Wl,-T,$_LIBDIR/libpayload.ldscript" +if [ -f $_LIBDIR/libpayload.ldscript ]; then + _LDDIR=$_LIBDIR +elif [ -f $BASE/../arch/$_ARCH/libpayload.ldscript ]; then + _LDDIR=$BASE/../arch/$_ARCH +fi +_LDSCRIPT="-Wl,-T,$_LDDIR/libpayload.ldscript" trygccoption() { $DEFAULT_CC $1 -S -xc /dev/null -o /dev/null &> /dev/null @@ -107,25 +140,7 @@ while [ $# -gt 0 ]; do shift done -if [ "$CONFIG_ARCH_ARMV7" = "y" ]; then - _ARCHINCDIR=$_INCDIR/armv7 - _ARCHLIBDIR=$_LIBDIR/armv7 - _ARCHEXTRA="" -fi - -if [ "$CONFIG_ARCH_POWERPC" = "y" ]; then - _ARCHINCDIR=$_INCDIR/powerpc - _ARCHLIBDIR=$_LIBDIR/powerpc - _ARCHEXTRA="" -fi - -if [ "$CONFIG_ARCH_X86" = "y" ]; then - _ARCHINCDIR=$_INCDIR/x86 - _ARCHLIBDIR=$_LIBDIR/x86 - _ARCHEXTRA="-m32 " -fi - -_CFLAGS="$_ARCHEXTRA -nostdinc -nostdlib -I$_INCDIR -I$_ARCHINCDIR -D__LIBPAYLOAD__=1" +_CFLAGS="$_ARCHEXTRA -nostdinc -nostdlib -I$BASE/../build -I$_INCDIR -I$_ARCHINCDIR -D__LIBPAYLOAD__=1" # Check for the -fno-stack-protector silliness @@ -134,7 +149,7 @@ trygccoption -fno-stack-protector _CFLAGS="$_CFLAGS -I`$DEFAULT_CC $_ARCHEXTRA -print-search-dirs | head -n 1 | cut -d' ' -f2`include" -_LDFLAGS="-L$BASE/../lib $_LDSCRIPT -static" +_LDFLAGS="-L$BASE/../lib -L$_LIBDIR $_LDSCRIPT -static" if [ $DOLINK -eq 0 ]; then if [ $DEBUGME -eq 1 ]; then @@ -144,8 +159,16 @@ if [ $DOLINK -eq 0 ]; then $DEFAULT_CC $_CFLAGS $CMDLINE else _LIBGCC=`$DEFAULT_CC $_ARCHEXTRA -print-libgcc-file-name` + if [ -f $_ARCHLIBDIR/head.o ]; then + HEAD_O=$_ARCHLIBDIR/head.o + elif [ -f $BASE/../build/head.o ]; then + HEAD_O=$BASE/../build/head.o + else + echo "Could not find head.o" + exit 1 + fi if [ $DEBUGME -eq 1 ]; then - echo "$DEFAULT_CC $_CFLAGS $_LDFLAGS $_ARCHLIBDIR/head.o $CMDLINE -lpayload $_LIBGCC" + echo "$DEFAULT_CC $_CFLAGS $_LDFLAGS $HEAD_O $CMDLINE -lpayload $_LIBGCC" fi # Note: $_ARCHLIBDIR/head.o must be the first object being linked, because it @@ -153,5 +176,5 @@ else # header to be placed below 0x2000 in the resulting image. See: # http://www.gnu.org/software/grub/manual/multiboot/html_node/OS-image-format.html - $DEFAULT_CC $_CFLAGS $_LDFLAGS $_ARCHLIBDIR/head.o $CMDLINE -lpayload $_LIBGCC + $DEFAULT_CC $_CFLAGS $_LDFLAGS $HEAD_O $CMDLINE -lpayload $_LIBGCC fi |