RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / build / linux / kbuild / kbuild.mk
1 ########################################################################### ###
2 #@Copyright     Copyright (c) Imagination Technologies Ltd. All Rights Reserved
3 #@License       Dual MIT/GPLv2
4
5 # The contents of this file are subject to the MIT license as set out below.
6
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
13
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
16
17 # Alternatively, the contents of this file may be used under the terms of
18 # the GNU General Public License Version 2 ("GPL") in which case the provisions
19 # of GPL are applicable instead of those above.
20
21 # If you wish to allow use of your version of this file only under the terms of
22 # GPL, and not to allow others to use your version of this file under the terms
23 # of the MIT license, indicate your decision by deleting the provisions above
24 # and replace them with the notice and other provisions required by GPL as set
25 # out in the file called "GPL-COPYING" included in this distribution. If you do
26 # not delete the provisions above, a recipient may use your version of this file
27 # under the terms of either the MIT license or GPL.
28
29 # This License is also included in this distribution in the file called
30 # "MIT-COPYING".
31
32 # EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
33 # PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
34 # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
35 # PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
36 # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
37 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
38 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 ### ###########################################################################
40
41 $(TARGET_PRIMARY_OUT)/kbuild/Makefile: $(MAKE_TOP)/kbuild/Makefile.template
42         @[ ! -e $(dir $@) ] && mkdir -p $(dir $@) || true
43         $(CP) -f $< $@
44
45 # We need to make INTERNAL_KBUILD_MAKEFILES absolute because the files will be
46 # read while chdir'd into $(KERNELDIR)
47 INTERNAL_KBUILD_MAKEFILES := $(abspath $(foreach _m,$(KERNEL_COMPONENTS) $(EXTRA_PVRSRVKM_COMPONENTS),$(if $(INTERNAL_KBUILD_MAKEFILE_FOR_$(_m)),$(INTERNAL_KBUILD_MAKEFILE_FOR_$(_m)),$(error Unknown kbuild module "$(_m)"))))
48 INTERNAL_KBUILD_OBJECTS := $(foreach _m,$(KERNEL_COMPONENTS),$(if $(INTERNAL_KBUILD_OBJECTS_FOR_$(_m)),$(INTERNAL_KBUILD_OBJECTS_FOR_$(_m)),$(error BUG: Unknown kbuild module "$(_m)" should have been caught earlier)))
49 INTERNAL_EXTRA_KBUILD_OBJECTS := $(foreach _m,$(EXTRA_PVRSRVKM_COMPONENTS),$(if $(INTERNAL_KBUILD_OBJECTS_FOR_$(_m)),$(INTERNAL_KBUILD_OBJECTS_FOR_$(_m)),$(error BUG: Unknown kbuild module "$(_m)" should have been caught earlier)))
50 .PHONY: kbuild kbuild_clean kbuild_check
51
52 kbuild_check:
53         @: $(if $(strip $(KERNELDIR)),,$(error KERNELDIR must be set))
54         @: $(call directory-must-exist,$(KERNELDIR))
55         @: $(foreach _m,$(ALL_KBUILD_MODULES),$(if $(wildcard $(abspath $(INTERNAL_KBUILD_MAKEFILE_FOR_$(_m)))),,$(error In makefile $(INTERNAL_MAKEFILE_FOR_MODULE_$(_m)): Module $(_m) requires kbuild makefile $(INTERNAL_KBUILD_MAKEFILE_FOR_$(_m)), which is missing)))
56         @: $(if $(filter-out command line override,$(origin build)),,$(error Overriding $$(build) (with "make build=...") will break kbuild))
57
58 # Services server headers are generated as part of running the bridge
59 # generator, which might be included in KM code. So as well as depending on
60 # the kbuild Makefile, we need to make kbuild also depend on each bridge
61 # module (including direct bridges), so that 'make kbuild' in a clean tree
62 # works.
63 kbuild: kbuild_check $(TARGET_PRIMARY_OUT)/kbuild/Makefile $(BRIDGES) $(DIRECT_BRIDGES)
64         $(if $(V),,@)$(MAKE) -Rr --no-print-directory -C $(KERNELDIR) \
65                 M=$(abspath $(TARGET_PRIMARY_OUT)/kbuild) \
66                 INTERNAL_KBUILD_MAKEFILES="$(INTERNAL_KBUILD_MAKEFILES)" \
67                 INTERNAL_KBUILD_OBJECTS="$(INTERNAL_KBUILD_OBJECTS)" \
68                 INTERNAL_EXTRA_KBUILD_OBJECTS="$(INTERNAL_EXTRA_KBUILD_OBJECTS)" \
69                 BRIDGE_SOURCE_ROOT=$(abspath $(BRIDGE_SOURCE_ROOT)) \
70                 TARGET_PRIMARY_ARCH=$(TARGET_PRIMARY_ARCH) \
71                 CROSS_COMPILE="$(CCACHE) $(KERNEL_CROSS_COMPILE)" \
72                 EXTRA_CFLAGS="$(ALL_KBUILD_CFLAGS)" \
73                 CC=$(KERNEL_CROSS_COMPILE)gcc V=$(V) W=$(W) \
74                 CHECK="$(patsubst @%,%,$(CHECK))" $(if $(CHECK),C=1,) \
75                 TOP=$(TOP)
76         @for kernel_module in $(addprefix $(TARGET_PRIMARY_OUT)/kbuild/,$(INTERNAL_KBUILD_OBJECTS:.o=.ko)); do \
77                 cp $$kernel_module $(TARGET_PRIMARY_OUT); \
78         done
79
80 kbuild_clean: kbuild_check $(TARGET_PRIMARY_OUT)/kbuild/Makefile
81         $(if $(V),,@)$(MAKE) -Rr --no-print-directory -C $(KERNELDIR) \
82                 M=$(abspath $(TARGET_PRIMARY_OUT)/kbuild) \
83                 INTERNAL_KBUILD_MAKEFILES="$(INTERNAL_KBUILD_MAKEFILES)" \
84                 INTERNAL_KBUILD_OBJECTS="$(INTERNAL_KBUILD_OBJECTS)" \
85                 INTERNAL_EXTRA_KBUILD_OBJECTS="$(INTERNAL_EXTRA_KBUILD_OBJECTS)" \
86                 BRIDGE_SOURCE_ROOT=$(abspath $(BRIDGE_SOURCE_ROOT)) \
87                 TARGET_PRIMARY_ARCH=$(TARGET_PRIMARY_ARCH) \
88                 CROSS_COMPILE="$(CCACHE) $(KERNEL_CROSS_COMPILE)" \
89                 EXTRA_CFLAGS="$(ALL_KBUILD_CFLAGS)" \
90                 CC=$(KERNEL_CROSS_COMPILE)gcc V=$(V) W=$(W) \
91                 TOP=$(TOP) clean
92
93 kbuild_install: install
94 kbuild: install_script_km