1#
2# Copyright (C) 2010-2012, 2014, 2016-2017 ARM Limited. All rights reserved.
3# 
4# This program is free software and is provided to you under the terms of the GNU General Public License version 2
5# as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6# 
7# A copy of the licence is included with the program, and can also be obtained from Free Software
8# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9#
10
11# For each arch check: CROSS_COMPILE , KDIR , CFLAGS += -DARCH
12
13export ARCH ?= arm
14BUILD ?= debug
15
16check_cc2 = \
17	$(shell if $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
18	then \
19		echo "$(2)"; \
20	else \
21		echo "$(3)"; \
22	fi ;)
23
24# Check that required parameters are supplied.
25ifeq ($(CONFIG),)
26CONFIG := default
27endif
28ifeq ($(CPU)$(KDIR),)
29$(error "KDIR or CPU must be specified.")
30endif
31
32# Get any user defined KDIR-<names> or maybe even a hardcoded KDIR
33-include KDIR_CONFIGURATION
34
35# Define host system directory
36KDIR-$(shell uname -m):=/lib/modules/$(shell uname -r)/build
37
38ifeq ($(ARCH), arm)
39# when compiling for ARM we're cross compiling
40export CROSS_COMPILE ?= $(call check_cc2, arm-linux-gnueabi-gcc, arm-linux-gnueabi-, arm-none-linux-gnueabi-)
41endif
42
43# look up KDIR based om CPU selection
44KDIR ?= $(KDIR-$(CPU))
45
46export CONFIG
47
48export CONFIG_UMP := m
49ifeq ($(BUILD),debug)
50export CONFIG_UMP_DEBUG := y
51else
52export CONFIG_UMP_DEBUG := n
53endif
54
55ifeq ($(KDIR),)
56$(error No KDIR found for platform $(CPU))
57endif
58
59all:
60	$(MAKE) -C $(KDIR) M=$(CURDIR) modules
61
62kernelrelease:
63	$(MAKE) -C $(KDIR) kernelrelease
64
65clean:
66	$(MAKE) -C $(KDIR) M=$(CURDIR) clean
67	$(MAKE) -C $(KDIR) M=$(CURDIR)/../mali clean
68