2003-07-17 19:50:11 +02:00
|
|
|
#!/bin/sh
|
2003-10-11 08:20:25 +02:00
|
|
|
PYTHON=python
|
2003-07-17 19:50:11 +02:00
|
|
|
# Target build script
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
2008-01-18 16:08:58 +01:00
|
|
|
echo "usage: buildtarget target [path-to-coreboot]"
|
2003-07-17 19:50:11 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
lbpath=$2
|
|
|
|
else
|
|
|
|
lbpath=`pwd`
|
|
|
|
lbpath=`dirname $lbpath`
|
|
|
|
fi
|
|
|
|
|
|
|
|
target_dir=$lbpath/targets
|
2003-10-01 07:42:31 +02:00
|
|
|
config_lb=$1
|
2003-07-23 23:30:29 +02:00
|
|
|
config_dir=$lbpath/util/newconfig
|
2003-10-11 08:20:25 +02:00
|
|
|
yapps2_py=$config_dir/yapps2.py
|
|
|
|
config_g=$config_dir/config.g
|
2003-07-17 19:50:11 +02:00
|
|
|
|
|
|
|
if [ ! -d $target_dir ]; then
|
|
|
|
echo "Target directory not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $target_dir
|
|
|
|
|
2003-10-01 07:42:31 +02:00
|
|
|
if [ ! -f $config_lb ]; then
|
|
|
|
config_lb=$1/Config.lb
|
|
|
|
fi
|
2003-07-17 19:50:11 +02:00
|
|
|
if [ ! -f $config_lb ]; then
|
|
|
|
echo "No target config file found"
|
2003-10-01 07:42:31 +02:00
|
|
|
echo "Tried both $1 and $config_lb"
|
2003-07-17 19:50:11 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2003-10-14 05:05:04 +02:00
|
|
|
build_dir=`dirname $config_lb`/`sed -n -e 's/^target \(.*\)$/\1/p' $config_lb`
|
2003-10-14 05:33:11 +02:00
|
|
|
echo "build_dir=$build_dir"
|
2003-10-14 05:05:04 +02:00
|
|
|
config_py=$build_dir/config.py
|
2003-10-13 21:48:13 +02:00
|
|
|
|
2003-10-14 05:33:11 +02:00
|
|
|
if [ ! -d $build_dir ] ; then
|
|
|
|
mkdir -p $build_dir
|
2003-10-13 21:48:13 +02:00
|
|
|
fi
|
2003-07-17 19:50:11 +02:00
|
|
|
if [ ! -f $config_py ]; then
|
2008-01-18 16:08:58 +01:00
|
|
|
echo "No coreboot config script found. Rebuilding it.."
|
2003-10-11 08:20:25 +02:00
|
|
|
$PYTHON $yapps2_py $config_g $config_py
|
2003-07-17 19:50:11 +02:00
|
|
|
fi
|
|
|
|
|
2003-07-23 23:30:29 +02:00
|
|
|
# make sure config.py is up-to-date
|
|
|
|
|
2003-10-11 08:20:25 +02:00
|
|
|
export PYTHONPATH=$config_dir
|
|
|
|
$PYTHON $config_py $config_lb $lbpath
|
2003-07-17 19:50:11 +02:00
|
|
|
|
2008-01-11 19:23:47 +01:00
|
|
|
# now start checking for distro-specific breakage.
|
|
|
|
## This check is for the no stack protector mess.
|
|
|
|
EXTRA_CFLAGS=
|
|
|
|
|
|
|
|
if [ -z "$CC" ]; then
|
|
|
|
CC=gcc
|
|
|
|
fi
|
|
|
|
|
2008-02-07 22:50:22 +01:00
|
|
|
$CC -fno-stack-protector -S -xc /dev/null -o .$$.tmp 2>/dev/null
|
2008-01-11 19:23:47 +01:00
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
EXTRA_CFLAGS=-fno-stack-protector
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf .$$.tmp
|
|
|
|
|
2008-08-28 00:25:55 +02:00
|
|
|
# The linker output fd depends on the gcc version.
|
|
|
|
# 1) 'ld-2.15 --help' and 'gcc-4.0 -Wl,--help' use STDOUT.
|
|
|
|
# 2) 'gcc-3.3 --help' and 'gcc-3.4 -Wl,--help' use STDERR.
|
|
|
|
# Thus older versions of GCC (presumably 3.x) implement a redirection of
|
|
|
|
# output to stderr. Re-redirect stderr to stdout to work always.
|
|
|
|
if $CC -Wl,--help 2>&1 | grep -q build-id; then
|
2008-01-25 20:31:26 +01:00
|
|
|
EXTRA_LFLAGS="$EXTRA_LFLAGS -Wl,--build-id=none"
|
2008-01-22 17:09:36 +01:00
|
|
|
fi
|
|
|
|
|
2008-01-11 19:23:47 +01:00
|
|
|
for i in $build_dir/Makefile.settings $build_dir/*/Makefile.settings
|
|
|
|
do
|
2008-01-22 17:09:36 +01:00
|
|
|
echo DISTRO_CFLAGS+=$EXTRA_CFLAGS >>$i
|
|
|
|
echo DISTRO_LFLAGS+=$EXTRA_LFLAGS >>$i
|
2008-01-11 19:23:47 +01:00
|
|
|
done
|
|
|
|
|
2003-07-17 19:50:11 +02:00
|
|
|
exit $?
|