Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 1 | #!/bin/sh |
Kevin O'Connor | 51d6ba3 | 2012-05-30 21:31:42 -0400 | [diff] [blame] | 2 | # Script to test if the build works properly. |
| 3 | |
| 4 | # Test IASL is installed. |
| 5 | $IASL -h > /dev/null 2>&1 |
| 6 | if [ $? -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 |
| 15 | fi |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 16 | |
Kevin O'Connor | 2321912 | 2013-02-17 10:56:10 -0500 | [diff] [blame] | 17 | mkdir -p ${OUT} |
| 18 | TMPFILE1=${OUT}/tmp_testcompile1.c |
| 19 | TMPFILE1o=${OUT}/tmp_testcompile1.o |
| 20 | TMPFILE1_ld=${OUT}/tmp_testcompile1.lds |
| 21 | TMPFILE2=${OUT}/tmp_testcompile2.c |
| 22 | TMPFILE2o=${OUT}/tmp_testcompile2.o |
| 23 | TMPFILE3o=${OUT}/tmp_testcompile3.o |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 24 | |
Kevin O'Connor | 626416e | 2011-05-21 21:05:04 -0400 | [diff] [blame] | 25 | # Test if ld's alignment handling is correct. This is a known problem |
| 26 | # with the linker that ships with Ubuntu 11.04. |
| 27 | cat - > $TMPFILE1 <<EOF |
| 28 | const char v1[] __attribute__((section(".text.v1"))) = "0123456789"; |
| 29 | const char v2[] __attribute__((section(".text.v2"))) = "0123456789"; |
| 30 | EOF |
| 31 | cat - > $TMPFILE1_ld <<EOF |
| 32 | SECTIONS |
| 33 | { |
| 34 | .mysection 0x88f0 : { |
| 35 | . = 0x10 ; |
| 36 | *(.text.v1) |
| 37 | . = 0x20 ; |
| 38 | *(.text.v2) |
| 39 | . = 0x30 ; |
| 40 | } |
| 41 | } |
| 42 | EOF |
| 43 | $CC -O -g -c $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1 |
Kevin O'Connor | bb0808a | 2013-02-18 10:28:55 -0500 | [diff] [blame] | 44 | if [ $? -ne 0 ]; then |
| 45 | echo "Unable to execute the C compiler ($CC)." >&2 |
| 46 | echo "" >&2 |
| 47 | echo "Please install a working compiler and retry." >&2 |
| 48 | echo -1 |
| 49 | exit 0 |
| 50 | fi |
Kevin O'Connor | 626416e | 2011-05-21 21:05:04 -0400 | [diff] [blame] | 51 | $LD -T $TMPFILE1_ld $TMPFILE1o -o $TMPFILE2o > /dev/null 2>&1 |
| 52 | if [ $? -ne 0 ]; then |
Kevin O'Connor | bb0808a | 2013-02-18 10:28:55 -0500 | [diff] [blame] | 53 | echo "The version of LD on this system ($LD) does not properly handle" >&2 |
Ian Campbell | 57929d8 | 2012-03-22 15:25:24 +0000 | [diff] [blame] | 54 | echo "alignments. As a result, this project can not be built." >&2 |
| 55 | echo "" >&2 |
| 56 | echo "The problem may be the result of this LD bug report:" >&2 |
| 57 | echo " http://sourceware.org/bugzilla/show_bug.cgi?id=12726" >&2 |
| 58 | echo "" >&2 |
| 59 | echo "Please update to a working version of binutils and retry." >&2 |
Kevin O'Connor | 626416e | 2011-05-21 21:05:04 -0400 | [diff] [blame] | 60 | echo -1 |
| 61 | exit 0 |
| 62 | fi |
| 63 | |
Kevin O'Connor | ab233da | 2009-06-30 21:13:44 -0400 | [diff] [blame] | 64 | # Test for "-fwhole-program". Older versions of gcc (pre v4.1) don't |
| 65 | # support the whole-program optimization - detect that. |
Kevin O'Connor | 2787680 | 2009-03-27 00:12:00 -0400 | [diff] [blame] | 66 | $CC -fwhole-program -S -o /dev/null -xc /dev/null > /dev/null 2>&1 |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 67 | if [ $? -ne 0 ]; then |
Ian Campbell | 57929d8 | 2012-03-22 15:25:24 +0000 | [diff] [blame] | 68 | echo " Working around no -fwhole-program" >&2 |
Kevin O'Connor | 0942e7f | 2009-06-15 22:27:01 -0400 | [diff] [blame] | 69 | echo 2 |
Kevin O'Connor | 942d495 | 2009-06-10 22:44:06 -0400 | [diff] [blame] | 70 | exit 0 |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 71 | fi |
| 72 | |
Kevin O'Connor | ab233da | 2009-06-30 21:13:44 -0400 | [diff] [blame] | 73 | # Test if "visible" variables and functions are marked global. On |
| 74 | # OpenSuse 10.3 "visible" variables declared with "extern" first |
| 75 | # aren't marked as global in the resulting assembler. On Ubuntu 7.10 |
| 76 | # "visible" functions aren't marked as global in the resulting |
| 77 | # assembler. |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 78 | cat - > $TMPFILE1 <<EOF |
| 79 | void __attribute__((externally_visible)) t1() { } |
Kevin O'Connor | a68287f | 2009-06-26 18:55:50 -0400 | [diff] [blame] | 80 | extern unsigned char v1; |
Kevin O'Connor | 0942e7f | 2009-06-15 22:27:01 -0400 | [diff] [blame] | 81 | unsigned char v1 __attribute__((section(".data16.foo.19"))) __attribute__((externally_visible)); |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 82 | EOF |
Kevin O'Connor | 84452f1 | 2009-03-27 00:07:07 -0400 | [diff] [blame] | 83 | $CC -Os -c -fwhole-program $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1 |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 84 | cat - > $TMPFILE2 <<EOF |
| 85 | void t1(); |
Kevin O'Connor | 0942e7f | 2009-06-15 22:27:01 -0400 | [diff] [blame] | 86 | extern unsigned char v1; |
| 87 | int __attribute__((externally_visible)) main() { t1(); return v1; } |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 88 | EOF |
Kevin O'Connor | 84452f1 | 2009-03-27 00:07:07 -0400 | [diff] [blame] | 89 | $CC -Os -c -fwhole-program $TMPFILE2 -o $TMPFILE2o > /dev/null 2>&1 |
Kevin O'Connor | ff82b24 | 2009-04-19 21:30:48 -0400 | [diff] [blame] | 90 | $CC -nostdlib -Os $TMPFILE1o $TMPFILE2o -o $TMPFILE3o > /dev/null 2>&1 |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 91 | if [ $? -ne 0 ]; then |
Ian Campbell | 57929d8 | 2012-03-22 15:25:24 +0000 | [diff] [blame] | 92 | echo " Working around non-functional -fwhole-program" >&2 |
Kevin O'Connor | 0942e7f | 2009-06-15 22:27:01 -0400 | [diff] [blame] | 93 | echo 2 |
| 94 | exit 0 |
Kevin O'Connor | 03f630e | 2009-03-26 20:45:36 -0400 | [diff] [blame] | 95 | fi |
| 96 | |
Kevin O'Connor | fa2eacb | 2012-12-11 21:59:45 -0500 | [diff] [blame] | 97 | echo 0 |
Kevin O'Connor | 3133e38 | 2009-11-20 09:19:28 -0500 | [diff] [blame] | 98 | |
Kevin O'Connor | ab233da | 2009-06-30 21:13:44 -0400 | [diff] [blame] | 99 | # Also, the Ubuntu 8.04 compiler has a bug causing corruption when the |
| 100 | # "ebp" register is clobberred in an "asm" statement. The code has |
| 101 | # been modified to not clobber "ebp" - no test is available yet. |
| 102 | |
Kevin O'Connor | 626416e | 2011-05-21 21:05:04 -0400 | [diff] [blame] | 103 | rm -f $TMPFILE1 $TMPFILE1o $TMPFILE1_ld $TMPFILE2 $TMPFILE2o $TMPFILE3o |