blob: 7bd6d1fe4c9f8a6e29dbe209769bc82e0a5ffd42 [file] [log] [blame]
Kevin O'Connor03f630e2009-03-26 20:45:36 -04001#!/bin/sh
Kevin O'Connor51d6ba32012-05-30 21:31:42 -04002# Script to test if the build works properly.
3
4# Test IASL is installed.
5$IASL -h > /dev/null 2>&1
6if [ $? -ne 0 ]; then
7 echo "The SeaBIOS project requires the 'iasl' package be installed." >&2
8 echo "Many Linux distributions have this package." >&2
9 echo "Try: sudo yum install iasl" >&2
10 echo "Or: sudo apt-get install iasl" >&2
11 echo "" >&2
12 echo "Please install iasl and retry." >&2
13 echo -1
14 exit 0
15fi
Kevin O'Connor03f630e2009-03-26 20:45:36 -040016
17mkdir -p out
18TMPFILE1=out/tmp_testcompile1.c
19TMPFILE1o=out/tmp_testcompile1.o
Kevin O'Connor626416e2011-05-21 21:05:04 -040020TMPFILE1_ld=out/tmp_testcompile1.lds
Kevin O'Connor03f630e2009-03-26 20:45:36 -040021TMPFILE2=out/tmp_testcompile2.c
22TMPFILE2o=out/tmp_testcompile2.o
23TMPFILE3o=out/tmp_testcompile3.o
24
Kevin O'Connor626416e2011-05-21 21:05:04 -040025# Test if ld's alignment handling is correct. This is a known problem
26# with the linker that ships with Ubuntu 11.04.
27cat - > $TMPFILE1 <<EOF
28const char v1[] __attribute__((section(".text.v1"))) = "0123456789";
29const char v2[] __attribute__((section(".text.v2"))) = "0123456789";
30EOF
31cat - > $TMPFILE1_ld <<EOF
32SECTIONS
33{
34 .mysection 0x88f0 : {
35. = 0x10 ;
36*(.text.v1)
37. = 0x20 ;
38*(.text.v2)
39. = 0x30 ;
40 }
41}
42EOF
43$CC -O -g -c $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1
44$LD -T $TMPFILE1_ld $TMPFILE1o -o $TMPFILE2o > /dev/null 2>&1
45if [ $? -ne 0 ]; then
Ian Campbell57929d82012-03-22 15:25:24 +000046 echo "The version of LD on this system does not properly handle" >&2
47 echo "alignments. As a result, this project can not be built." >&2
48 echo "" >&2
49 echo "The problem may be the result of this LD bug report:" >&2
50 echo " http://sourceware.org/bugzilla/show_bug.cgi?id=12726" >&2
51 echo "" >&2
52 echo "Please update to a working version of binutils and retry." >&2
Kevin O'Connor626416e2011-05-21 21:05:04 -040053 echo -1
54 exit 0
55fi
56
Kevin O'Connorab233da2009-06-30 21:13:44 -040057# Test for "-fwhole-program". Older versions of gcc (pre v4.1) don't
58# support the whole-program optimization - detect that.
Kevin O'Connor27876802009-03-27 00:12:00 -040059$CC -fwhole-program -S -o /dev/null -xc /dev/null > /dev/null 2>&1
Kevin O'Connor03f630e2009-03-26 20:45:36 -040060if [ $? -ne 0 ]; then
Ian Campbell57929d82012-03-22 15:25:24 +000061 echo " Working around no -fwhole-program" >&2
Kevin O'Connor0942e7f2009-06-15 22:27:01 -040062 echo 2
Kevin O'Connor942d4952009-06-10 22:44:06 -040063 exit 0
Kevin O'Connor03f630e2009-03-26 20:45:36 -040064fi
65
Kevin O'Connorab233da2009-06-30 21:13:44 -040066# Test if "visible" variables and functions are marked global. On
67# OpenSuse 10.3 "visible" variables declared with "extern" first
68# aren't marked as global in the resulting assembler. On Ubuntu 7.10
69# "visible" functions aren't marked as global in the resulting
70# assembler.
Kevin O'Connor03f630e2009-03-26 20:45:36 -040071cat - > $TMPFILE1 <<EOF
72void __attribute__((externally_visible)) t1() { }
Kevin O'Connora68287f2009-06-26 18:55:50 -040073extern unsigned char v1;
Kevin O'Connor0942e7f2009-06-15 22:27:01 -040074unsigned char v1 __attribute__((section(".data16.foo.19"))) __attribute__((externally_visible));
Kevin O'Connor03f630e2009-03-26 20:45:36 -040075EOF
Kevin O'Connor84452f12009-03-27 00:07:07 -040076$CC -Os -c -fwhole-program $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1
Kevin O'Connor03f630e2009-03-26 20:45:36 -040077cat - > $TMPFILE2 <<EOF
78void t1();
Kevin O'Connor0942e7f2009-06-15 22:27:01 -040079extern unsigned char v1;
80int __attribute__((externally_visible)) main() { t1(); return v1; }
Kevin O'Connor03f630e2009-03-26 20:45:36 -040081EOF
Kevin O'Connor84452f12009-03-27 00:07:07 -040082$CC -Os -c -fwhole-program $TMPFILE2 -o $TMPFILE2o > /dev/null 2>&1
Kevin O'Connorff82b242009-04-19 21:30:48 -040083$CC -nostdlib -Os $TMPFILE1o $TMPFILE2o -o $TMPFILE3o > /dev/null 2>&1
Kevin O'Connor03f630e2009-03-26 20:45:36 -040084if [ $? -ne 0 ]; then
Ian Campbell57929d82012-03-22 15:25:24 +000085 echo " Working around non-functional -fwhole-program" >&2
Kevin O'Connor0942e7f2009-06-15 22:27:01 -040086 echo 2
87 exit 0
Kevin O'Connor03f630e2009-03-26 20:45:36 -040088fi
89
Kevin O'Connorfa2eacb2012-12-11 21:59:45 -050090echo 0
Kevin O'Connor3133e382009-11-20 09:19:28 -050091
Kevin O'Connorab233da2009-06-30 21:13:44 -040092# Also, the Ubuntu 8.04 compiler has a bug causing corruption when the
93# "ebp" register is clobberred in an "asm" statement. The code has
94# been modified to not clobber "ebp" - no test is available yet.
95
Kevin O'Connor626416e2011-05-21 21:05:04 -040096rm -f $TMPFILE1 $TMPFILE1o $TMPFILE1_ld $TMPFILE2 $TMPFILE2o $TMPFILE3o