-
Notifications
You must be signed in to change notification settings - Fork 14
/
common.mk
77 lines (64 loc) · 1.99 KB
/
common.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
.DEFAULT_GOAL := default
# Define bash color codes
ifndef NO_COLOR
CLR_RD := \033[0;31m
CLR_GR := \033[0;32m
CLR_YL := \033[0;33m
CLR_CY := \033[0;36m
CLR_BL := \033[34m
CLR_MG := \033[35m
CLR_B := \033[1m
CLR_NB := \033[22m
CLR_D := \033[2m
CLR_ND := \033[22m
CLR_NC := \033[0m
endif
##############################################################################
# Common Checks
# Check RVATOM environment variable
ifeq ($(_mk_check_env), 1)
ifeq ($(RVATOM),)
$(error RVATOM environment variable not set; did you forget to source the sourceme script?)
endif
endif
# Check if soctarget is correct
ifeq ($(_mk_check_soctarget), 1)
ifneq ($(wildcard $(RVATOM)/rtl/config/$(soctarget).json),)
ifneq ($(shell $(RVATOM)/scripts/cfgparse.py $(RVATOM)/rtl/config/$(soctarget).json -a type), soc)
$(error Invalid soctarget=$(soctarget); config type not 'soc')
endif
else
$(error Invalid soctarget=$(soctarget); config not found)
endif
endif
##############################################################################
# common functions
# Print a formatted message
define print_msg_root
@printf "$(CLR_GR)$(CLR_B)❖ %-30b$(CLR_NB)%s$(CLR_NC)\n" "$(1)" "$(2)"
endef
define print_msg
@printf "$(CLR_CY)$(CLR_B)► %-30b$(CLR_NB)%s$(CLR_NC)\n" "$(1)" "$(2)"
endef
# Print a formatted message with target information
define print_msgt_root
@printf "$(CLR_GR)$(CLR_B)❖ %-30b$(CLR_NB)%s$(CLR_NC)\n" "$(1)" "$(@F)"
endef
define print_msgt
@printf "$(CLR_CY)$(CLR_B)► %-30b$(CLR_NB)%s$(CLR_NC)\n" "$(1)" "$(@F)"
endef
define print_info
@printf "$(CLR_CY)$(CLR_B)INFO:$(CLR_NB)$(CLR_NC)$(1)\n"
endef
define print_warn
@printf "$(CLR_YL)$(CLR_B)WARN:$(CLR_NB)$(CLR_NC)$(1)\n"
endef
define print_error
@printf "$(CLR_RD)$(CLR_B)ERROR:$(CLR_NB)$(CLR_NC)$(1)\n"
@printf "Exiting..."; exit 1
endef
##############################################################################
# common targets
.PHONY: help
help: Makefile
@python3 $(RVATOM)/scripts/genmkhelp.py $<