forked from uwrobotics/MarsRoverFirmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (83 loc) · 3.07 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Default Target
.DEFAULT_GOAL := build
# Delete Suffix Rules
.SUFFIXES :=
# Phony Targets
.PHONY := build verify_app_target_tuple_config verify_app_target_tuple_is_specified clean all
# Options
CLEAN ?=
BUILD_PROFILE ?= develop
MBED_TOOLS_FLAGS :=
ifneq (,$(CLEAN))
MBED_TOOLS_FLAGS += --clean
endif
ifneq (,$(BUILD_PROFILE))
MBED_TOOLS_FLAGS += --profile $(BUILD_PROFILE)
endif
# PATHS
MAKEFILE_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
ROVER_APPS_DIR := $(abspath $(MAKEFILE_DIR)/rover-apps)
TEST_ROVER_APPS_DIR := $(abspath $(MAKEFILE_DIR)/test-apps)
TARGETS_DIR := $(abspath $(MAKEFILE_DIR)/targets)
CUSTOM_TARGETS_JSON := $(abspath $(TARGETS_DIR)/custom_targets.json)
# APP and TARGET lists
APPS_LIST := $(sort $(patsubst $(ROVER_APPS_DIR)/%/,%, $(wildcard $(ROVER_APPS_DIR)/*/)))
APPS_LIST += $(sort $(patsubst $(TEST_ROVER_APPS_DIR)/%/,%, $(wildcard $(TEST_ROVER_APPS_DIR)/*/)))
TARGETS_LIST := $(sort $(patsubst $(TARGETS_DIR)/TARGET_%/,%, $(wildcard $(TARGETS_DIR)/TARGET_*/)))
NUMBER_OF_SUPPORTED_CONFIGS := $(shell python3 scripts/build_configurations_helper.py count-supported-configs)
# Lowercase Command Args
ifneq (,$(app))
APP = $(app)
endif
ifneq (,$(target))
TARGET = $(target)
endif
verify_app_target_tuple_is_specified:
ifeq (,$(findstring $(APP), $(APPS_LIST)))
ifeq (,$(APP))
$(warning APP is not set)
else
$(warning $(APP) is not an app within the $(ROVER_APPS_DIR) folder)
endif
$(warning Using APP=app_name, select one of the following detected apps:)
$(foreach APP_NAME,$(APPS_LIST),$(warning $(APP_NAME)))
$(error )
endif
ifeq (,$(findstring $(TARGET), $(TARGETS_LIST)))
ifeq (,$(TARGET))
$(warning TARGET is not set)
else
$(warning $(TARGET) is not a target within the $(TARGETS_DIR) folder)
endif
$(warning Using TARGET=board_name, select one of the following detected board targets:)
$(foreach TARGET_NAME,$(TARGETS_LIST),$(warning $(TARGET_NAME)))
$(error )
endif
verify_app_target_tuple_config: verify_app_target_tuple_is_specified
@python3 scripts/build_configurations_helper.py verify-config --APP=$(APP) --TARGET=$(TARGET) ; \
if [ $$? -ne 0 ]; \
then \
echo "Do you want to try to build anyways? (Y/N)"; \
read RESPONSE; \
if !([ "$$RESPONSE" = "Y" ] || [ "$$RESPONSE" = "y" ] || [ "$$RESPONSE" = "YES" ] || [ "$$RESPONSE" = "yes" ]); \
then \
false ; \
fi; \
fi
build: verify_app_target_tuple_config
@echo Building $(APP) app for $(TARGET) board with $(BUILD_PROFILE) profile
APP=$(APP); mbed-tools compile --toolchain GCC_ARM --mbed-target $(TARGET) --custom-targets-json $(CUSTOM_TARGETS_JSON) $(MBED_TOOLS_FLAGS)
all:
@echo Building all $(NUMBER_OF_SUPPORTED_CONFIGS) supported app/target configs
@n=0; \
success=0; \
while [ $${n} -lt $(NUMBER_OF_SUPPORTED_CONFIGS) ] && [ $${success} -eq 0 ]; do \
make $$(python3 scripts/build_configurations_helper.py print-supported-config $${n}); \
success=$${?}; \
n=`expr $$n + 1`; \
done; \
exit $${success};
@echo Successfully built all $(NUMBER_OF_SUPPORTED_CONFIGS) supported app/target configs
clean:
@echo "Deleting all build files"
rm -rf cmake_build