blob: 93509077b340d8dc77a3584be3de321dc34df4eb [file] [log] [blame]
Patrick Georgi40ad8422011-05-21 22:18:59 +00001#!/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
22search_make() {
Stefan Reinauer57879c92012-07-31 16:47:25 -070023if [ -n "`$1 --version 2>&1 | grep GNU`" ]; then MAKE=$1; fi
Patrick Georgi40ad8422011-05-21 22:18:59 +000024}
25
26# if $1 and $2 differ, exit with failure
27compare_output() {
28if ! [ "$1" = "$2" ]; then
29 echo \'$1\' should be \'$2\'
30 exit 1
31fi
32}
33
34# $1: object directory
35run_printall() {
Stefan Reinauer57879c92012-07-31 16:47:25 -070036$MAKE CONFIG_USE_BLOBS=n CONFIG_CCACHE=n CONFIG_SCANBUILD_ENABLE=n NOMKDIR=1 \
37 DOTCONFIG=$TMPCONFIG obj=$1 printall | \
38 sed -e "s,^ *,," -e "s,^r.mstage-objs:=,," \
39 -e "s,mainboard/[^/]*/[^/]*/,.../,g" | \
Zheng Bao615304c2012-09-17 16:38:22 +080040 tr " " "\n" | GREP_OPTIONS= grep "/static.*\.[co]" | sort | \
Stefan Reinauer57879c92012-07-31 16:47:25 -070041 tr '\012\015' ' ' | sed -e "s, *, ,g" -e "s, *$,,"
Patrick Georgi40ad8422011-05-21 22:18:59 +000042}
43
44# find GNU make
Zheng Bao684b8ab2012-09-28 20:13:19 +080045MAKE=
Patrick Georgi40ad8422011-05-21 22:18:59 +000046search_make make
Zheng Bao684b8ab2012-09-28 20:13:19 +080047[ -z $MAKE ] && search_make gmake
48[ -z $MAKE ] && search_make gnumake
Patrick Georgi40ad8422011-05-21 22:18:59 +000049
50if [ "$MAKE" = "" ]; then
51 echo Could not identify GNU make
52 exit 1
53fi
54
55# prepare a config to use
Patrick Georgi9c7467e2012-02-25 15:33:43 +010056TMPCONFIG=`mktemp .tmpconfig.XXXXXX`
Patrick Georgi40ad8422011-05-21 22:18:59 +000057rm -f $TMPCONFIG
Stefan Reinauer8ebd11e2012-03-08 11:06:25 -080058$MAKE DOTCONFIG=$TMPCONFIG allyesconfig >/dev/null
Patrick Georgi40ad8422011-05-21 22:18:59 +000059
60# look up parent directory
61PARENTDIR=`dirname $PWD`
62
Stefan Reinauer57879c92012-07-31 16:47:25 -070063compare_output "`run_printall build`" "build/.../static.c build/.../static.c build/.../static.ramstage.o build/.../static.romstage.o"
64compare_output "`run_printall ../obj`" "$PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.ramstage.o $PARENTDIR/obj/.../static.romstage.o"
65compare_output "`run_printall /tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.ramstage.o /tmp/.../static.romstage.o"
66compare_output "`run_printall /../tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.ramstage.o /tmp/.../static.romstage.o"
Patrick Georgi40ad8422011-05-21 22:18:59 +000067
68rm -f $TMPCONFIG
69