RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / build / linux / toplevel.mk
1 ########################################################################### ###
2 #@File
3 #@Copyright     Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 #@License       Dual MIT/GPLv2
5
6 # The contents of this file are subject to the MIT license as set out below.
7
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to deal
10 # in the Software without restriction, including without limitation the rights
11 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 # copies of the Software, and to permit persons to whom the Software is
13 # furnished to do so, subject to the following conditions:
14
15 # The above copyright notice and this permission notice shall be included in
16 # all copies or substantial portions of the Software.
17
18 # Alternatively, the contents of this file may be used under the terms of
19 # the GNU General Public License Version 2 ("GPL") in which case the provisions
20 # of GPL are applicable instead of those above.
21
22 # If you wish to allow use of your version of this file only under the terms of
23 # GPL, and not to allow others to use your version of this file under the terms
24 # of the MIT license, indicate your decision by deleting the provisions above
25 # and replace them with the notice and other provisions required by GPL as set
26 # out in the file called "GPL-COPYING" included in this distribution. If you do
27 # not delete the provisions above, a recipient may use your version of this file
28 # under the terms of either the MIT license or GPL.
29
30 # This License is also included in this distribution in the file called
31 # "MIT-COPYING".
32
33 # EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 # PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 # PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 ### ###########################################################################
41
42 # Define the default goal. This masks a previous definition of the default
43 # goal in config/core.mk, which must match this one
44 .PHONY: build
45 build: components
46
47 MAKE_TOP      := build/linux
48 THIS_MAKEFILE := (top-level makefiles)
49
50 include $(MAKE_TOP)/defs.mk
51
52 ifeq ($(OUT),)
53 $(error Must specify output directory with OUT=)
54 endif
55
56 ifeq ($(TOP),)
57 $(error Must specify root of source tree with TOP=)
58 endif
59 $(call directory-must-exist,$(TOP))
60
61 # RELATIVE_OUT is relative only if it's under $(TOP)
62 RELATIVE_OUT       := $(patsubst $(TOP)/%,%,$(OUT))
63 CONFIG_MK          := $(RELATIVE_OUT)/config.mk
64 CONFIG_H           := $(RELATIVE_OUT)/config.h
65 CONFIG_KERNEL_MK   := $(RELATIVE_OUT)/config_kernel.mk
66 CONFIG_KERNEL_H    := $(RELATIVE_OUT)/config_kernel.h
67
68 # Convert commas to spaces in $(D). This is so you can say "make
69 # D=config-changes,freeze-config" and have $(filter config-changes,$(D))
70 # still work.
71 comma := ,
72 empty :=
73 space := $(empty) $(empty)
74 override D := $(subst $(comma),$(space),$(D))
75
76 ifneq ($(INTERNAL_CLOBBER_ONLY),true)
77 # Create the out directory
78 #
79 $(shell mkdir -p $(OUT))
80
81 # If these generated files differ from any pre-existing ones,
82 # replace them, causing affected parts of the driver to rebuild.
83 #
84 _want_config_diff := $(filter config-changes,$(D))
85 _freeze_config := $(strip $(filter freeze-config,$(D)))
86 _updated_config_files := $(shell \
87     $(if $(_want_config_diff),rm -f $(OUT)/config.diff;,) \
88         for file in $(CONFIG_MK) $(CONFIG_H) \
89                                 $(CONFIG_KERNEL_MK) $(CONFIG_KERNEL_H); do \
90                 diff -U 0 $$file $$file.new \
91                         >>$(if $(_want_config_diff),$(OUT)/config.diff,/dev/null) 2>/dev/null \
92                 && rm -f $$file.new \
93                 || echo $$file; \
94         done)
95
96 ifneq ($(_want_config_diff),)
97 # We send the diff to stderr so it isn't captured by $(shell)
98 $(shell [ -s $(OUT)/config.diff ] && echo >&2 "Configuration changed in $(RELATIVE_OUT):" && cat >&2 $(OUT)/config.diff)
99 endif
100
101 ifneq ($(_freeze_config),)
102 $(if $(_updated_config_files),$(error Configuration change in $(RELATIVE_OUT) prevented by D=freeze-config),)
103 endif
104
105 # Update the config, if changed
106 $(foreach _f,$(_updated_config_files), \
107         $(shell mv -f $(_f).new $(_f) >/dev/null 2>/dev/null))
108
109 endif # INTERNAL_CLOBBER_ONLY
110
111 MAKEFLAGS := -Rr --no-print-directory
112
113 ifneq ($(INTERNAL_CLOBBER_ONLY),true)
114
115 # This is so you can say "find $(TOP) -name Linux.mk > /tmp/something; export
116 # ALL_MAKEFILES=/tmp/something; make" and avoid having to run find. This is
117 # handy if your source tree is mounted over NFS or something
118 override ALL_MAKEFILES := $(call relative-to-top,$(if $(strip $(ALL_MAKEFILES)),$(shell cat $(ALL_MAKEFILES)),$(shell find $(TOP) -type f -name Linux.mk -print -o -type d -name '.*' -prune)))
119 ifeq ($(strip $(ALL_MAKEFILES)),)
120 $(info ** Unable to find any Linux.mk files under $$(TOP). This could mean that)
121 $(info ** there are no makefiles, or that ALL_MAKEFILES is set in the environment)
122 $(info ** and points to a nonexistent or empty file.)
123 $(error No makefiles)
124 endif
125
126 else # clobber-only
127 ALL_MAKEFILES :=
128 endif
129
130 unexport ALL_MAKEFILES
131
132 REMAINING_MAKEFILES := $(ALL_MAKEFILES)
133 ALL_MODULES :=
134 INTERNAL_INCLUDED_ALL_MAKEFILES :=
135
136 ALL_LDFLAGS :=
137
138 # Please do not change the format of the following lines
139 -include $(CONFIG_MK)
140 -include $(CONFIG_KERNEL_MK)
141 # OK to change now
142
143 # If we haven't set host/target archs, set some sensible defaults now.
144 # This allows things like prune.sh to work
145 ifeq ($(HOST_PRIMARY_ARCH),)
146 ifneq ($(FORCE_ARCH),)
147 HOST_PRIMARY_ARCH := host_x86_64
148 HOST_32BIT_ARCH := host_i386
149
150 _ALL_ARCHS := \
151  $(filter-out %target_neutral.mk,$(wildcard $(MAKE_TOP)/moduledefs/target_*.mk))
152 TARGET_PRIMARY_ARCH := \
153  $(patsubst $(MAKE_TOP)/moduledefs/%.mk,%,$(word 1, $(_ALL_ARCHS)))
154
155 TARGET_ALL_ARCH := $(TARGET_PRIMARY_ARCH)
156 endif
157 endif
158
159 # Output directory for configuration, object code,
160 # final programs/libraries, and install/rc scripts.
161 HOST_OUT             := $(RELATIVE_OUT)/$(HOST_PRIMARY_ARCH)
162 HOST_32BIT_OUT       := $(RELATIVE_OUT)/$(HOST_32BIT_ARCH)
163 TARGET_OUT           := $(RELATIVE_OUT)/$(TARGET_PRIMARY_ARCH)
164 TARGET_PRIMARY_OUT   := $(RELATIVE_OUT)/$(TARGET_PRIMARY_ARCH)
165 TARGET_NEUTRAL_OUT   := $(RELATIVE_OUT)/target_neutral
166 BRIDGE_SOURCE_ROOT   := $(call if-exists,$(TOP)/generated,$(TARGET_NEUTRAL_OUT)/intermediates)
167 GENERATED_CODE_OUT   := $(TARGET_NEUTRAL_OUT)/intermediates
168 DOCS_OUT             := $(RELATIVE_OUT)/doc
169
170 #
171 # neutrino/subst_makefiles.mk must be included after Output directories have been defined,
172 # because it overrides BRIDGE_SOURCE_ROOT of bridges to be built. If we include this makefile
173 # earlier, the value of BRIDGE_SOURCE_ROOT set in neutrino/subst_makefiles.mk will be overwritten.
174 ifeq ($(SUPPORT_NEUTRINO_PLATFORM),1)
175 include $(MAKE_TOP)/common/neutrino/subst_makefiles.mk
176 # neutrino/subst_makefiles.mk overrides ALL_MAKEFILES.
177 # Set REMAINING_MAKEFILES to the new value of ALL_MAKEFILES
178 REMAINING_MAKEFILES := $(ALL_MAKEFILES)
179 endif
180
181 # Mark subdirectories of $(OUT) as secondary, and provide rules to create
182 # them.
183 OUT_SUBDIRS := $(addprefix $(RELATIVE_OUT)/,$(TARGET_ALL_ARCH)) \
184  $(TARGET_NEUTRAL_OUT) $(DOCS_OUT) $(if $(HOST_PRIMARY_ARCH),$(sort $(HOST_OUT) $(HOST_32BIT_OUT)))
185 .SECONDARY: $(OUT_SUBDIRS)
186 $(OUT_SUBDIRS):
187         $(make-directory)
188
189 ifneq ($(INTERNAL_CLOBBER_ONLY),true)
190 -include $(MAKE_TOP)/pvrversion.mk
191 ifeq ($(SUPPORT_BUILD_LWS),1)
192 -include $(MAKE_TOP)/lwsconf.mk
193 endif
194 -include $(MAKE_TOP)/llvm.mk
195 -include $(MAKE_TOP)/common/bridges.mk
196 endif
197
198 include $(MAKE_TOP)/commands.mk
199 include $(MAKE_TOP)/buildvars.mk
200
201 HOST_INTERMEDIATES := $(HOST_OUT)/intermediates
202 TARGET_INTERMEDIATES := $(TARGET_OUT)/intermediates
203
204 ifneq ($(KERNEL_COMPONENTS),)
205 build: kbuild
206 endif
207
208 # "make bridges" makes all the modules which are bridges. This is used by
209 # builds which ship pregenerated bridge headers.
210 .PHONY: bridges
211 bridges: $(BRIDGES) $(DIRECT_BRIDGES)
212
213 # Include each Linux.mk, then include modules.mk to save some information
214 # about each module
215 include $(foreach _Linux.mk,$(ALL_MAKEFILES),$(MAKE_TOP)/this_makefile.mk $(_Linux.mk) $(MAKE_TOP)/modules.mk)
216
217 ifeq ($(strip $(REMAINING_MAKEFILES)),)
218 INTERNAL_INCLUDED_ALL_MAKEFILES := true
219 else
220 $(error Impossible: $(words $(REMAINING_MAKEFILES)) makefiles were mysteriously ignored when reading $$(ALL_MAKEFILES))
221 endif
222
223 # At this point, all Linux.mks have been included. Now generate rules to build
224 # each module: for each module in $(ALL_MODULES), set per-makefile variables
225 $(foreach _m,$(ALL_MODULES),$(eval $(call process-module,$(_m))))
226
227 .PHONY: kbuild install
228 kbuild install:
229
230 ifneq ($(INTERNAL_CLOBBER_ONLY),true)
231 -include $(MAKE_TOP)/scripts.mk
232 -include $(MAKE_TOP)/kbuild/kbuild.mk
233 endif
234 # We won't depend on 'build' here so that people can build subsets of
235 # components and still have the install script attempt to install the
236 # subset.
237 install:
238         @if [ ! -d "$(DISCIMAGE)" ]; then \
239                 echo; \
240                 echo "** DISCIMAGE was not set or does not point to a valid directory."; \
241                 echo "** Cannot continue with install."; \
242                 echo; \
243                 exit 1; \
244         fi
245         @if [ ! -f $(RELATIVE_OUT)/install.sh ]; then \
246                 echo; \
247                 echo "** install.sh not found in $(RELATIVE_OUT)."; \
248                 echo "** Cannot continue with install."; \
249                 echo; \
250                 exit 1; \
251         fi
252         @cd $(RELATIVE_OUT) && ./install.sh
253
254 .PHONY: uninstall
255 uninstall: install_script
256 uninstall:
257         @if [ ! -d "$(DISCIMAGE)" ]; then \
258                 echo; \
259                 echo "** DISCIMAGE was not set or does not point to a valid directory."; \
260                 echo "** Cannot continue with uninstall."; \
261                 echo; \
262                 exit 1; \
263         fi
264         @if [ ! -f $(RELATIVE_OUT)/install.sh ]; then \
265                 echo; \
266                 echo "** install.sh not found in $(RELATIVE_OUT)."; \
267                 echo "** Cannot continue with uninstall."; \
268                 echo; \
269                 exit 1; \
270         fi
271         @cd $(RELATIVE_OUT) && ./install.sh -u
272
273 # You can say 'make all_modules' to attempt to make everything, or 'make
274 # components' to only make the things which are listed (in the per-build
275 # makefiles) as components of the build.
276 .PHONY: all_modules all_docs components
277 all_modules: $(ALL_MODULES)
278 all_docs: ;
279 components: $(COMPONENTS)
280
281 # Cleaning
282 .PHONY: clean clobber
283 clean: MODULE_DIRS_TO_REMOVE := $(OUT_SUBDIRS)
284 clean:
285         $(clean-dirs)
286 clobber: MODULE_DIRS_TO_REMOVE := $(OUT)
287 clobber:
288         $(clean-dirs)
289
290 # Saying 'make clean-MODULE' removes the intermediates for MODULE.
291 # clobber-MODULE deletes the output files as well
292 clean-%:
293         $(if $(V),,@echo "  RM      " $(call relative-to-top,$(INTERNAL_CLEAN_TARGETS_FOR_$*)))
294         $(RM) -rf $(INTERNAL_CLEAN_TARGETS_FOR_$*)
295 clobber-%:
296         $(if $(V),,@echo "  RM      " $(call relative-to-top,$(INTERNAL_CLOBBER_TARGETS_FOR_$*)))
297         $(RM) -rf $(INTERNAL_CLOBBER_TARGETS_FOR_$*)
298
299 include $(MAKE_TOP)/bits.mk
300
301 # D=nobuild stops the build before any recipes are run. This line should
302 # come at the end of this makefile.
303 $(if $(filter nobuild,$(D)),$(error D=nobuild given),)