Enhance makefile to autodetect if AVOIDCOMBINE is needed.
[seabios.git] / tools / test-combine.sh
1 #!/bin/sh
2 # Script to test if gcc's -combine option works properly.
3
4 TMPFILE1=out/tmp_testcompile1.c
5 TMPFILE2=out/tmp_testcompile.o
6
7 mkdir -p out
8 cat - > $TMPFILE1 <<EOF
9 struct ts { union { int u1; struct { int u2; }; }; };
10 void t1(struct ts *r);
11 EOF
12
13 $CC -c -fwhole-program -combine $TMPFILE1 $TMPFILE1 -o $TMPFILE2 > /dev/null 2>&1
14
15 if [ $? -eq 0 ]; then
16     #echo "  Setting AVOIDCOMBINE=0" > /dev/fd/2
17     echo 0
18 else
19     echo "  Enabling AVOIDCOMBINE=1" > /dev/fd/2
20     echo 1
21 fi
22
23 rm -f $TMPFILE1 $TMPFILE2