blob: d369874cebaf3db904bac619bec778fb372753e1 [file] [log] [blame]
Stewart Smith471d3df2017-03-20 15:29:33 +11001From 88a9eed95a72e6cbc8956585308599bf07aec70a Mon Sep 17 00:00:00 2001
2From: Stewart Smith <stewart@linux.vnet.ibm.com>
3Date: Mon, 20 Mar 2017 13:31:35 +1100
4Subject: [PATCH] Only build attributeOverride if compiler supports
5 -std=gnu++11
6
7GCC prior to 4.8 doesn't support -std=gnu++11, which the attributeOverride
8tool requires to build.
9
10Since this is only a host side utility, we can not build it if we're
11building hostboot with ancient host compilers (e.g. on RHEL6.x)
12
13Change-Id: I53ad31b56dd90c2cd77f5ca1f91b46e519cdfe48
14Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
15---
16 src/build/mkrules/cc.rules.mk | 10 +++++++++-
17 src/build/mkrules/dist.targets.mk | 7 ++++++-
18 src/usr/targeting/attroverride/makefile | 8 +++++++-
19 3 files changed, 22 insertions(+), 3 deletions(-)
20
21diff --git a/src/build/mkrules/cc.rules.mk b/src/build/mkrules/cc.rules.mk
22index cb00ea001072..c89995f825df 100644
23--- a/src/build/mkrules/cc.rules.mk
24+++ b/src/build/mkrules/cc.rules.mk
25@@ -5,7 +5,9 @@
26 #
27 # OpenPOWER HostBoot Project
28 #
29-# COPYRIGHT International Business Machines Corp. 2013,2014
30+# Contributors Listed Below - COPYRIGHT 2013,2017
31+# [+] International Business Machines Corp.
32+#
33 #
34 # Licensed under the Apache License, Version 2.0 (the "License");
35 # you may not use this file except in compliance with the License.
36@@ -74,3 +76,9 @@ $(IMGDIR)/lib$(MODULE).so : $(OBJECTS) $(ROOTPATH)/src/module.ld $(MODULE_INIT)
37 $(OBJECTS) $(MODULE_INIT) \
38 -T $(ROOTPATH)/src/module.ld -o $@
39 endif
40+
41+try = $(shell set -e; if ($(1)) >/dev/null 2>&1; \
42+ then echo "$(2)"; \
43+ else echo "$(3)"; fi )
44+
45+try-cflag = $(call try,$(1) $(2) -x c -c /dev/null -o /dev/null,$(2))
46diff --git a/src/build/mkrules/dist.targets.mk b/src/build/mkrules/dist.targets.mk
47index 2f047bcda0b7..ba6114db9aae 100644
48--- a/src/build/mkrules/dist.targets.mk
49+++ b/src/build/mkrules/dist.targets.mk
50@@ -71,7 +71,6 @@ COPY_FILES = \
51 obj/genfiles/targAttrInfo.csv:vpo \
52 obj/genfiles/target_types_merged.xml:openpower \
53 obj/genfiles/fapiattrs.xml:openpower \
54- obj/genfiles/attributeOverride:tools,openpower \
55 src/usr/targeting/attroverride/README.attr_override:tools,openpower \
56 src/build/hwpf/prcd_compile.tcl:tools \
57 src/build/buildpnor/buildSbePart.pl:openpower \
58@@ -94,6 +93,12 @@ COPY_FILES = \
59 src/usr/targeting/common/xmltohb/bios_metadata_petitboot.xslt:openpower \
60 $(foreach file, $(call ROOTPATH_WILDCARD,releaseNotes.html), $(file):fsp)\
61
62+ifeq ($(call try-cflag,$(CCACHE) $(HOST_PREFIX)g++,-std=gnu++11),-std=gnu++11)
63+COPY_FILES += obj/genfiles/attributeOverride:tools,openpower
64+else
65+COPY_FILES += obj/genfiles/attributeOverride:tools
66+endif
67+
68 include ${ROOTPATH}/config.mk
69 COPY_FILES += $(if $(CONFIG_INCLUDE_XML_OPPOWERVM),src/usr/targeting/common/xmltohb/target_types_oppowervm.xml:openpower) \
70 $(if $(CONFIG_INCLUDE_XML_OPPOWERVM),src/usr/targeting/common/xmltohb/attribute_types_oppowervm.xml:openpower) \
71diff --git a/src/usr/targeting/attroverride/makefile b/src/usr/targeting/attroverride/makefile
72index 8ab26fd5009b..d9f0e85b324c 100644
73--- a/src/usr/targeting/attroverride/makefile
74+++ b/src/usr/targeting/attroverride/makefile
75@@ -5,7 +5,7 @@
76 #
77 # OpenPOWER HostBoot Project
78 #
79-# Contributors Listed Below - COPYRIGHT 2014,2016
80+# Contributors Listed Below - COPYRIGHT 2014,2017
81 # [+] International Business Machines Corp.
82 #
83 #
84@@ -49,8 +49,14 @@ include $(ROOTPATH)/config.mk
85 vpath %.C $(GENDIR)
86 vpath %.H $(GENDIR)
87
88+ifeq ($(call try-cflag,$(CCACHE) $(HOST_PREFIX)g++,-std=gnu++11),-std=gnu++11)
89 $(OUT_FILE): $(C_FILES) $(H_FILES)
90 $(C2) " CC $(notdir $@)"
91 $(C1)$(CCACHE) $(HOST_PREFIX)g++ -std=gnu++11 -O3 -g -o $(OUT_FILE)\
92 $(foreach dir,$(INC_DIRS), -I $(dir)) -iquote.\
93 $(foreach file,$^,$(if $(findstring .H,$(file)),,$(file)))
94+else
95+$(OUT_FILE): $(C_FILES) $(H_FILES)
96+ $(C2) " GEN-NULL $(notdir $@)"
97+ @(echo '#!/bin/sh'; echo 'exit -1';) > $(OUT_FILE)
98+endif
99--
1002.9.3
101