-
Notifications
You must be signed in to change notification settings - Fork 22
/
setup.mk
58 lines (47 loc) · 1.5 KB
/
setup.mk
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
ifeq ($(NAME),)
$(error NAME not defined)
endif
SRC_DIRS:=
INC_DIRS:=
C_SRC:=
ASM_SRC:=
ifneq ($(MAKECMDGOALS), clean)
ifeq ($(PLATFORM),)
$(error Undefined platform)
endif
endif
define cur_dir
$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
endef
current_dir:=$(cur_dir)
ROOT_DIR?=$(current_dir)
BUILD_DIR?=$(current_dir)/build/$(PLATFORM)
src_dir:=$(current_dir)/src
core_dir:=$(src_dir)/core
platform_dir:=$(src_dir)/platform/$(PLATFORM)
drivers_dir:=$(src_dir)/drivers
src_dirs+=$(src_dir) $(core_dir) $(platform_dir)
SRC_DIRS+=$(src_dirs)
INC_DIRS+=$(addsuffix /inc, $(src_dirs))
ifeq ($(wildcard $(platform_dir)),)
$(error unsupported platform $(PLATFORM))
endif
-include $(core_dir)/sources.mk
C_SRC+=$(addprefix $(core_dir)/, $(core_c_srcs))
-include $(platform_dir)/plat.mk
-include $(platform_dir)/sources.mk
C_SRC+=$(addprefix $(platform_dir)/, $(plat_c_srcs))
ASM_SRC+=$(addprefix $(platform_dir)/, $(plat_s_srcs))
SRC_DIRS+= $(foreach driver, $(drivers), $(drivers_dir)/$(driver))
INC_DIRS+= $(foreach driver, $(drivers), $(drivers_dir)/$(driver)/inc)
-include $(foreach driver, $(drivers), $(drivers_dir)/$(driver)/sources.mk)
C_SRC+=$(addprefix $(drivers_dir)/, $(driver_c_srcs))
ASM_SRC+=$(addprefix $(drivers_dir)/, $(driver_s_srcs))
arch_dir:=$(src_dir)/arch/$(ARCH)
SRC_DIRS+=$(arch_dir)
INC_DIRS+=$(arch_dir)/inc
-include $(arch_dir)/arch.mk
-include $(arch_dir)/sources.mk
C_SRC+=$(addprefix $(arch_dir)/, $(arch_c_srcs))
ASM_SRC+=$(addprefix $(arch_dir)/, $(arch_s_srcs))
LD_FILE:=$(src_dir)/linker.ld