This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.build
91 lines (68 loc) · 2.3 KB
/
Makefile.build
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
83
84
85
86
87
88
89
90
include $(UAS_ROOT)/Makefile.common
TARGET_BUILD_MAKEFILE= $(TARGET_DIR)/build/build.mk
BINOUT = $(call map_experiment_elf)
OBJDUMP_OUT= $(call map_experiment_dis)
HEX_OUT = $(call map_experiment_hex)
CFLAGS ?=
#
# Makefile which contains the "main" function and BSP headers
include $(UAS_ROOT)/target/share/Makefile.in
#
# Makefile which defines target specific source code to include.
include $(TARGET_BUILD_MAKEFILE)
CFLAGS += -I$(UAS_ROOT)/experiments/$(UAS_EXPERIMENT)
CFLAGS += -I$(UAS_ROOT)/target/share
CFLAGS += -I$(UAS_ROOT)/target/$(UAS_TARGET)
TARGETS =
define get_target_arch
$(subst -DARCH_,,$(firstword $(filter -DARCH_%,${1})))
endef
define get_asm_targets
$(firstword $(filter %.S,${1}))
endef
define get_asm_pp_path
$(UAS_ROOT)/experiments/$(UAS_EXPERIMENT)/arch/$(call get_target_arch,${1}).S
endef
#
# Add a new build target
#
# 1. Experiment variant
# 2. Experiment source code
# 3. CFLAGS
#
define add_experiment_build_target
##
## This snippet was used to generate per-architecture ASM files from when
## all the experiments were meta-programmed using macros.
## Left here for posterity in case it is useful in the future.
##
##ifneq ($(call get_asm_targets,${2}),)
##.PHONY: $(call get_asm_pp_path,${3})
##$(call get_asm_pp_path,${3}) : $(call get_asm_targets,${2})
## @mkdir -p $(dir $(call get_asm_pp_path,${3}))
## $(CC) ${3} -E $${^} -o $${@}.tmp
## sed -i "s/^#.*//g" $${@}.tmp
## echo "#include \"kernel-macros.h\"" > $${@}
## cat -s $${@}.tmp >> $${@}
## rm $${@}.tmp
##
##TARGETS += $(call get_asm_pp_path,${3})
##endif
$(call map_experiment_elf,${1}) : ${2} $(UAS_SRCS) $(TARGET_SRCS)
-mkdir -p $(dir $(call map_experiment_elf,${1}))
$(CC) ${3} -o $${@} $${^}
$(call map_experiment_dis,${1}) : $(call map_experiment_elf,${1})
$(OBJDUMP) -D $${<} > $${@}
$(call map_experiment_hex,${1}) : $(call map_experiment_elf,${1})
$(OBJCOPY) ${OBJCOPY_FLAGS} -O ihex $${<} $${@}
$(call map_experiment_bin,${1}) : $(call map_experiment_elf,${1})
$(OBJCOPY) ${OBJCOPY_FLAGS} -O binary $${<} $${@}
TARGETS += $(call map_experiment_elf,${1})
TARGETS += $(call map_experiment_dis,${1})
TARGETS += $(call map_experiment_hex,${1})
TARGETS += $(call map_experiment_bin,${1})
endef
#
# Makefile which defines the experiment sources
include $(UAS_EXPERIMENT_SRC)/Makefile.build
all: $(TARGETS)