Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # This file is part of the coreboot project. |
| 3 | # |
| 4 | # Copyright (C) 2011 Patrick Georgi <patrick@georgi-clan.de> |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; version 2 of the License. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program; if not, write to the Free Software |
| 17 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | # |
| 19 | # DESCR: Check that build directories can be chosen freely |
| 20 | |
| 21 | # $1: command to test for GNU make |
| 22 | search_make() { |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 23 | if [ -n "`$1 --version 2>&1 | grep GNU`" ]; then MAKE=$1; fi |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | # if $1 and $2 differ, exit with failure |
| 27 | compare_output() { |
| 28 | if ! [ "$1" = "$2" ]; then |
| 29 | echo \'$1\' should be \'$2\' |
| 30 | exit 1 |
| 31 | fi |
| 32 | } |
| 33 | |
| 34 | # $1: object directory |
| 35 | run_printall() { |
Patrick Georgi | fadbe5f | 2014-05-17 18:26:38 +0200 | [diff] [blame^] | 36 | $MAKE CONFIG_USE_BLOBS=n CONFIG_CCACHE=n NOMKDIR=1 \ |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 37 | DOTCONFIG=$TMPCONFIG obj=$1 printall | \ |
| 38 | sed -e "s,^ *,," -e "s,^r.mstage-objs:=,," \ |
| 39 | -e "s,mainboard/[^/]*/[^/]*/,.../,g" | \ |
Zheng Bao | 615304c | 2012-09-17 16:38:22 +0800 | [diff] [blame] | 40 | tr " " "\n" | GREP_OPTIONS= grep "/static.*\.[co]" | sort | \ |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 41 | tr '\012\015' ' ' | sed -e "s, *, ,g" -e "s, *$,," |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | # find GNU make |
Zheng Bao | 684b8ab | 2012-09-28 20:13:19 +0800 | [diff] [blame] | 45 | MAKE= |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 46 | search_make make |
Zheng Bao | 684b8ab | 2012-09-28 20:13:19 +0800 | [diff] [blame] | 47 | [ -z $MAKE ] && search_make gmake |
| 48 | [ -z $MAKE ] && search_make gnumake |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 49 | |
| 50 | if [ "$MAKE" = "" ]; then |
| 51 | echo Could not identify GNU make |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | # prepare a config to use |
Nico Huber | 1bfe374 | 2013-07-02 16:39:28 +0200 | [diff] [blame] | 56 | TMPOBJ=`mktemp .tmpobj.XXXXXX` |
| 57 | rm $TMPOBJ |
| 58 | mkdir -p ${TMPOBJ} |
Patrick Georgi | 9c7467e | 2012-02-25 15:33:43 +0100 | [diff] [blame] | 59 | TMPCONFIG=`mktemp .tmpconfig.XXXXXX` |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 60 | rm -f $TMPCONFIG |
Nico Huber | 1bfe374 | 2013-07-02 16:39:28 +0200 | [diff] [blame] | 61 | $MAKE obj=$TMPOBJ DOTCONFIG=$TMPCONFIG allyesconfig >/dev/null |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 62 | |
| 63 | # look up parent directory |
Zheng Bao | 9b757dc | 2012-09-28 20:14:38 +0800 | [diff] [blame] | 64 | CURRENTDIR=`pwd -P` |
| 65 | PARENTDIR=`dirname $CURRENTDIR` |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 66 | |
Patrick Georgi | f33e395 | 2012-11-25 17:10:47 +0100 | [diff] [blame] | 67 | compare_output "`run_printall build`" "build/.../static.c build/.../static.c build/.../static.romstage.o" |
| 68 | compare_output "`run_printall ../obj`" "$PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.romstage.o" |
| 69 | compare_output "`run_printall /tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.romstage.o" |
| 70 | compare_output "`run_printall /../tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.romstage.o" |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 71 | |
Nico Huber | 1bfe374 | 2013-07-02 16:39:28 +0200 | [diff] [blame] | 72 | rm -rf $TMPCONFIG $TMPOBJ |
Patrick Georgi | 40ad842 | 2011-05-21 22:18:59 +0000 | [diff] [blame] | 73 | |