-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (68 loc) · 2.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2022-present, Ukama Inc.
include ../config.mk
CURMAKE := $(abspath $(firstword $(MAKEFILE_LIST)))
CURPATH := $(dir $(CURMAKE))
#Source directory
SRCDIR = linux
#Output
ifndef ROOTFSPATH
override ROOTFSPATH = $(CURPATH)_ukamafs
endif
ROOTFSKPATH=$(ROOTFSPATH)/boot
# Config for Builds
ANODE_KCONFIG = ukama_anode_defconfig
CNODE_KCONFIG = comNode_lk_defconfig
#Set build parameters based on targets
ifeq ($(ANODEBOARD), $(TARGETBOARD))
KIMAGE = zImage
override CC = arm-linux-gnueabihf-
override ARCH = arm
KCONFIG = $(ANODE_KCONFIG)
OS_ARTIFACTS = $(KIMAGE) modules dtbs
endif
ifeq ($(CNODEBOARD), $(TARGETBOARD))
KIMAGE = bzImage
override CC =
override ARCH = x86_64
KCONFIG = $(CNODE_KCONFIG)
OS_ARTIFACTS = $(KIMAGE) modules
endif
ifeq ($(LOCAL), $(TARGETBOARD))
KIMAGE = bzImage
override CC =
override ARCH = x86_64
KCONFIG = $(CNODE_KCONFIG)
OS_ARTIFACTS = $(KIMAGE) modules
endif
#Targets based on boards
.PHONY: subdirs $(SRCDIR) info
#Kernel Image
$(OS_ARTIFACTS):
@echo Building $@
$(MAKE) -j$(NPROCS) -C $(SRCDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CC) $(KCONFIG)
$(MAKE) -j$(NPROCS) -C $(SRCDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CC) $(OS_ARTIFACTS)
#Copy Kernel Image
@echo Copying Kernel Image $(SRCDIR)/arch/${ARCH}/boot/$(KIMAGE)
(mkdir -p $(ROOTFSKPATH) && cp -v $(SRCDIR)/arch/${ARCH}/boot/$(KIMAGE) $(ROOTFSKPATH)/$(KIMAGE))
#Install Modules
$(MAKE) -j$(NPROCS) -C $(SRCDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CC) INSTALL_MOD_PATH=$(ROOTFSPATH) modules_install
ifeq ($(ARCH), $(ARCHARM))
#Install DTBS
$(MAKE) -j$(NPROCS) -C $(SRCDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CC) INSTALL_DTBS_PATH=$(ROOTFSPATH)/boot dtbs_install
endif
clean :
rm -rf $(ROOTFSPATH);
for dir in $(SRCDIR); do \
$(MAKE) -j$(NPROCS) -C $$dir -f Makefile $@; \
done
distclean :
rm -rf $(ROOTFSPATH);
for dir in $(SRCDIR); do \
$(MAKE) -j$(NPROCS) -C $$dir -f Makefile $@; \
done
info:
$(info [$@] Building $(TARGETBOARD) for $(ARCH) with $(CC) )