-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
97 lines (83 loc) · 2.63 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
# crazy colors
RED=\033[0;31m
GREEN=\033[0;32m
ORANGE=\033[0;33m
BLUE=\033[0;34m
PURPLE=\033[0;35m
CYAN=\033[0;36m
LIGHTGRAY=\033[0;37m
DARKGRAY=\033[1;30m
YELLOW=\033[0;33m
NC=\033[0m # No Color
#----------------------------
# Project Configuration
TEST ?= main
PROJECT_TARGET ?= stm32f413rht
# PROJECT_TARGET ?= stm32f446ret
# source and include directories
PROJECT_C_SOURCES = $(wildcard */Src/*.c)
PROJECT_C_INCLUDES = $(wildcard */Inc)
# debug
PRINT_DEBUGS ?= false
ifeq ($(PRINT_DEBUGS), true)
$(info SOURCES: $(PROJECT_C_SOURCES))
$(info INCLUDES: $(PROJECT_C_INCLUDES))
endif
# build directories
PROJECT_BUILD_DIR = Embedded-Sharepoint/build
BUILD_MAKEFILE_DIR = Embedded-Sharepoint
# path files
MAKEFILE_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
ifneq ($(TEST), main)
PROJECT_C_SOURCES := $(filter-out Apps/Src/main.c, $(PROJECT_C_SOURCES))
PROJECT_C_SOURCES := $(addprefix $(MAKEFILE_DIR)/, $(PROJECT_C_SOURCES) Tests/$(TEST).c)
else
PROJECT_C_SOURCES := $(addprefix $(MAKEFILE_DIR)/, $(PROJECT_C_SOURCES))
endif
# debug
ifeq ($(PRINT_DEBUGS), true)
$(info SOURCES: $(PROJECT_C_SOURCES))
$(info INCLUDES: $(PROJECT_C_INCLUDES))
endif
PROJECT_C_INCLUDES := $(addprefix $(MAKEFILE_DIR)/, $(PROJECT_C_INCLUDES))
PROJECT_BUILD_DIR := $(addprefix $(MAKEFILE_DIR)/, $(PROJECT_BUILD_DIR))
# export variables
export PROJECT_TARGET
export PROJECT_C_SOURCES
export PROJECT_C_INCLUDES
export PROJECT_BUILD_DIR
#-------------------------------
# Build
ifeq ($(MAKECMDGOALS),)
default: build_code
else ifeq ($(MAKECMDGOALS), all)
all: build_code
else
%:
$(MAKE) -C $(BUILD_MAKEFILE_DIR) $(MAKECMDGOALS)
endif
build_code:
ifneq ($(TEST), main)
@echo "Making STM32 build for ${BLUE}TEST=${PURPLE} ${TEST}${NC}"
else
@echo "Making STM32 build with ${ORANGE}no test.${NC}"
endif
$(MAKE) -C $(BUILD_MAKEFILE_DIR) all
@echo "${BLUE}Compiled for BPS-Leader! Splendid! Jolly Good!!${NC}"
#-------------------------------
# Help
.PHONY: help
help:
@echo "Format: ${ORANGE}make ${BLUE}TEST=${PURPLE}<Test name>${NC}"
@echo "- Running ${ORANGE}make${NC}by itself will compile the production code (same as running ${ORANGE}make${NC}all) \n"
@echo "TEST:"
@echo "- If you want to run a test, specify ${BLUE}TEST=${PURPLE}<Test name>${NC}, with ${PURPLE}<Test name>${NC}"
@echo " being the exact name of the test file ${RED} without${NC} the .c suffix.\n"
@echo "PRINT_DEBUGS:"
@echo "- For debugs, specify ${BLUE}PRINT_DEBUGS=${PURPLE}true${NC}."
@echo "- For now, this will print the directories that will be compiled (can be useful for troubleshooting)."
#--------------
# Documentation
# .PHONY: docs
# docs:
# cd $(BUILD_MAKEFILE_DIR) && mkdocs serve