From 231f710715a7f6ddf1626fda38ebdb511b5d55dc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 25 Jan 2009 16:11:27 -0500 Subject: [PATCH] Enhance makefile to autodetect if AVOIDCOMBINE is needed. --- Makefile | 6 +++++- tools/test-combine.sh | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 tools/test-combine.sh diff --git a/Makefile b/Makefile index eebc4d1..186ef51 100644 --- a/Makefile +++ b/Makefile @@ -54,10 +54,14 @@ vpath %.S src ################ Build rules +ifndef AVOIDCOMBINE +AVOIDCOMBINE=$(shell CC=$(CC) tools/test-combine.sh) +endif + # Do a whole file compile - two methods are supported. The first # involves including all the content textually via #include # directives. The second method uses gcc's "-combine" option. -ifdef AVOIDCOMBINE +ifeq "$(AVOIDCOMBINE)" "1" define whole-compile @echo " Compiling whole program $3" $(Q)printf '$(foreach i,$2,#include "../$i"\n)' > $3.tmp.c diff --git a/tools/test-combine.sh b/tools/test-combine.sh new file mode 100755 index 0000000..6d17fd0 --- /dev/null +++ b/tools/test-combine.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Script to test if gcc's -combine option works properly. + +TMPFILE1=out/tmp_testcompile1.c +TMPFILE2=out/tmp_testcompile.o + +mkdir -p out +cat - > $TMPFILE1 < /dev/null 2>&1 + +if [ $? -eq 0 ]; then + #echo " Setting AVOIDCOMBINE=0" > /dev/fd/2 + echo 0 +else + echo " Enabling AVOIDCOMBINE=1" > /dev/fd/2 + echo 1 +fi + +rm -f $TMPFILE1 $TMPFILE2 -- 2.25.1