1 ########################################################################### ###
3 #@Title Set up configuration required by build-directory Makefiles
4 #@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 #@License Dual MIT/GPLv2
7 # The contents of this file are subject to the MIT license as set out below.
9 # Permission is hereby granted, free of charge, to any person obtaining a copy
10 # of this software and associated documentation files (the "Software"), to deal
11 # in the Software without restriction, including without limitation the rights
12 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 # copies of the Software, and to permit persons to whom the Software is
14 # furnished to do so, subject to the following conditions:
16 # The above copyright notice and this permission notice shall be included in
17 # all copies or substantial portions of the Software.
19 # Alternatively, the contents of this file may be used under the terms of
20 # the GNU General Public License Version 2 ("GPL") in which case the provisions
21 # of GPL are applicable instead of those above.
23 # If you wish to allow use of your version of this file only under the terms of
24 # GPL, and not to allow others to use your version of this file under the terms
25 # of the MIT license, indicate your decision by deleting the provisions above
26 # and replace them with the notice and other provisions required by GPL as set
27 # out in the file called "GPL-COPYING" included in this distribution. If you do
28 # not delete the provisions above, a recipient may use your version of this file
29 # under the terms of either the MIT license or GPL.
31 # This License is also included in this distribution in the file called
34 # EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35 # PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 # PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38 # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 ### ###########################################################################
43 # NOTE: Don't put anything in this file that isn't strictly required
44 # by the build-directory Makefiles. It should go in core.mk otherwise.
46 TOP := $(abspath ../../..)
48 # Some miscellaneous things to make comma substitutions easier.
52 space := $(empty) $(empty)
54 ifneq ($(words $(TOP)),1)
55 $(warning This source tree is located in a path which contains whitespace,)
56 $(warning which is not supported.)
58 $(warning $(space)The root is: $(TOP))
60 $(error Whitespace found in $$(TOP))
63 $(call directory-must-exist,$(TOP))
65 ifneq ($(SUPPORT_NEUTRINO_PLATFORM),1)
67 CC_CHECK := ../tools/cc-check.sh
70 # GNU Make has builtin values for CC/CXX which we don't want to trust. This
71 # is because $(CROSS_COMPILE)$(CC) doesn't always expand to a cross compiler
72 # toolchain binary name (e.g. most toolchains have 'gcc' but not 'cc').
74 ifeq ($(origin CC),default)
75 _CC := $(CROSS_COMPILE)gcc
78 _CLANG := $(shell $(CC_CHECK) --clang --cc $(CC))
80 _CC := $(CC) -target $(patsubst %-,%,$(CROSS_COMPILE))
86 ifeq ($(origin CXX),default)
87 _CXX := $(CROSS_COMPILE)g++
90 _CLANGXX := $(shell $(CC_CHECK) --clang --cc $(CXX))
91 ifeq ($(_CLANGXX),true)
92 _CXX := $(CXX) -target $(patsubst %-,%,$(CROSS_COMPILE))
101 # Work out if we are targeting ARM before we start tweaking _CC.
102 TARGETING_AARCH64 := $(shell \
103 $(_CC) -dM -E - </dev/null | grep -q __aarch64__ && echo 1)
105 TARGETING_ARM := $(shell \
106 $(_CC) -dM -E - </dev/null | grep __arm__ >/dev/null 2>&1 && echo 1)
108 TARGETING_MIPS := $(shell \
109 $(_CC) -dM -E - </dev/null | grep __mips__ >/dev/null 2>&1 && echo 1)
111 HOST_CC_IS_LINUX := $(shell \
112 $(HOST_CC) -dM -E - </dev/null | grep __linux__ >/dev/null 2>&1 && echo 1)
114 ifneq ($(strip $(KERNELDIR)),)
115 include ../config/kernel_version.mk
118 # The user didn't set CROSS_COMPILE. There's probably nothing wrong
119 # with that, but we'll let them know anyway.
121 ifeq ($(origin CROSS_COMPILE), undefined)
122 $(warning CROSS_COMPILE is not set. Target components will be built with the host compiler)
127 # The user is trying to set one of the old SUPPORT_ options on the
128 # command line or in the environment. This isn't supported any more
129 # and will often break the build. The user is generally only trying
130 # to remove a component from the list of targets to build, so we'll
131 # point them at the new way of doing this.
132 define sanity-check-support-option-origin
133 ifeq ($$(filter undefined file,$$(origin $(1))),)
134 $$(warning *** Setting $(1) via $$(origin $(1)) is deprecated)
135 $$(error If you are trying to disable a component, use e.g. EXCLUDED_APIS="opengles1 opengl")
138 $(foreach _o,SYS_CFLAGS SYS_CXXFLAGS SYS_INCLUDES SYS_EXE_LDFLAGS SYS_LIB_LDFLAGS,$(eval $(call sanity-check-support-option-origin,$(_o))))
140 # Check for words in EXCLUDED_APIS that aren't understood by the
141 # common/apis/*.mk files. This should be kept in sync with all the tests on
142 # EXCLUDED_APIS in those files
143 _excludable_apis := opencl opengl opengles1 opengles3 openrl unittests renderscript scripts composerhal servicestools hwperftools testchiptools rogue2d memtrackhal camerahal sensorhal
144 _excluded_apis := $(subst $(comma),$(space),$(EXCLUDED_APIS))
146 _unrecognised := $(strip $(filter-out $(_excludable_apis),$(_excluded_apis)))
147 ifneq ($(_unrecognised),)
148 $(warning *** Ignoring unrecognised entries in EXCLUDED_APIS: $(_unrecognised))
149 $(warning *** EXCLUDED_APIS was set via $(origin EXCLUDED_APIS) to: $(EXCLUDED_APIS))
150 $(warning *** Excludable APIs are: $(_excludable_apis))
153 override EXCLUDED_APIS := $(filter $(_excludable_apis), $(_excluded_apis))
155 ifeq ($(SUPPORT_NEUTRINO_PLATFORM),1)
156 include ../common/neutrino/preconfig_neutrino.mk