Fix r3434 check-in. Added missing end to Options.lb. Not entirely sure how it
[coreboot.git] / targets / buildtarget
index 273a26bab2c894f7197d6c7a4e4ee92b7082118f..2b3b83bfce02552f4e979cdec8e021dfe6da9a12 100755 (executable)
@@ -1,9 +1,9 @@
 #!/bin/sh
-
+PYTHON=python
 # Target build script
 
 if [ $# -lt 1 ]; then
-       echo "usage: buildtarget target [path-to-linuxbios]"
+       echo "usage: buildtarget target [path-to-coreboot]"
        exit 1
 fi
 
@@ -15,9 +15,10 @@ else
 fi
 
 target_dir=$lbpath/targets
-config_lb=$1/Config.lb
+config_lb=$1
 config_dir=$lbpath/util/newconfig
-config_py=$config_dir/config.py
+yapps2_py=$config_dir/yapps2.py
+config_g=$config_dir/config.g
 
 if [ ! -d $target_dir ]; then
        echo "Target directory not found"
@@ -26,25 +27,56 @@ fi
 
 cd $target_dir
 
+if [ ! -f $config_lb ]; then
+       config_lb=$1/Config.lb
+fi
 if [ ! -f $config_lb ]; then
        echo "No target config file found"
+       echo "Tried both $1 and $config_lb"
        exit 1
 fi
 
+build_dir=`dirname $config_lb`/`sed -n -e 's/^target \(.*\)$/\1/p' $config_lb`
+echo "build_dir=$build_dir"
+config_py=$build_dir/config.py
+
+if [ ! -d $build_dir ] ; then
+       mkdir -p $build_dir
+fi
 if [ ! -f $config_py ]; then
-       echo "No linuxbios config script found. Rebuilding it.."
-       ( 
-         cd $config_dir 
-         make config.py
-       )
-       echo "done."
-       # exit 1
+       echo "No coreboot config script found. Rebuilding it.."
+       $PYTHON $yapps2_py $config_g $config_py
 fi
 
 # make sure config.py is up-to-date
 
-(cd $config_dir && make config.py)
+export PYTHONPATH=$config_dir
+$PYTHON $config_py $config_lb $lbpath
+
+# 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
+
+$CC -fno-stack-protector -S -xc /dev/null -o .$$.tmp 2>/dev/null
+
+if [ $? -eq 0 ]; then
+       EXTRA_CFLAGS=-fno-stack-protector
+fi
+
+rm -rf .$$.tmp
+
+if $CC -Wl,--help | grep -q build-id; then
+       EXTRA_LFLAGS="$EXTRA_LFLAGS -Wl,--build-id=none"
+fi
 
-python $config_py $config_lb $lbpath
+for i in $build_dir/Makefile.settings $build_dir/*/Makefile.settings
+do
+       echo DISTRO_CFLAGS+=$EXTRA_CFLAGS >>$i
+       echo DISTRO_LFLAGS+=$EXTRA_LFLAGS >>$i
+done
 
 exit $?