forked from reticulatedpines/magiclantern_simplified
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.setup
152 lines (119 loc) · 3.8 KB
/
Makefile.setup
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Generic makefile
# Include default and user-customized options where needed
# If you want to customize them copy Makefile.user.default to Makefile.user keeping only the options that you want to customize
include $(TOP_DIR)/Makefile.top
-include $(TOP_DIR)/Makefile.user.default
-include $(TOP_DIR)/Makefile.user
-include $(TOP_DIR)/Makefile.setup.toolchain
ifeq ($(CONFIG_CCACHE), y)
CC := $(CCACHE) $(CC)
HOST_CC := $(CCACHE) $(HOST_CC)
endif
# Quiet the build process
build = \
@if [ X"$V" = X"1" ]; then \
echo '$2'; \
else \
printf "[ %-8s ] %s\n" $1 $@; \
fi; \
$2
define rm_files
@printf "[ RM ] %s\n" "$1";
@$(RM) -f $1
endef
define rm_dir
@printf "[ RM dir ] %s\n" "$1";
@-$(RM) -rf $1
endef
FLAGS=\
-Wp,-MMD,$(patsubst %.o,%.d,$(dir $@)$(notdir $@)) \
-Wp,-MT,$@ \
-nostdlib \
-fomit-frame-pointer \
-fno-strict-aliasing \
-I$(TOP_DIR)/include
TARGET_COMPILER ?= arm-gcc
CFLAGS =
ifeq ($(TARGET_COMPILER), arm-gcc)
CFLAGS += -Os -march=$(PLATFORM_ARCH) -D__ARM__
endif
CFLAGS +=\
$(FLAGS) \
-Wall \
-Wextra \
-Wno-unused-parameter \
-Wno-unused-function \
-Werror-implicit-function-declaration \
-Wno-missing-field-initializers \
-Wno-format \
-Wdouble-promotion \
-ffast-math \
-fsingle-precision-constant \
-fno-builtin-printf \
-std=gnu99 \
-Winline \
-I$(PLATFORM_INC) \
-I$(PLATFORM_INC)/include \
-I$(SRC_DIR) \
-ggdb3
# The short-double flag is removed in GCC 6+
GCC_DUMPVERSION := $(shell ${CC} -dumpversion)
ifneq (,$(findstring GCC-4,GCC-$(GCC_DUMPVERSION)))
CFLAGS += -fshort-double
endif
ifneq (,$(findstring GCC-5,GCC-$(GCC_DUMPVERSION)))
CFLAGS += -fshort-double
endif
AFLAGS=\
$(FLAGS)
-LFLAGS=
ifdef CONFIG_SMALL_FONTS
$(error CONFIG_SMALL_FONTS must be renamed to ML_SRC_SMALL_FONTS)
endif
# some recent Linux distros have this defined
# we don't use it, but the checks below will get upset and print a warning
CONFIG_SITE=n
ensureCorrectValue = $(if $(filter $($(1)),y n 1 0), ,$(1)=n $(warning BAD VALUE FOR $(1)=$($(1)) DEFAULTING TO n))
_defined_configs = $(filter CONFIG_%, $(.VARIABLES))
$(foreach config, $(_defined_configs), $(eval $(call ensureCorrectValue,$(config))))
# Functionality that disables all CONFIG_* entries
ifeq ($(ML_SETUP_DISABLE_USER_CONFIGS),y)
#show_config_values=$(foreach c, $(defined_configs), $(c)=$($(c)))
#$(warning before setting to NO $(show_config_values))
$(foreach config, $(_defined_configs), $(eval $(config)=n))
#$(warning after setting to NO $(show_config_values))
endif
-include Makefile.setup.default
-include Makefile.setup.user
ifdef ML_SETUP_EXTENSION
-include Makefile.$(ML_SETUP_EXTENSION).default
-include Makefile.$(ML_SETUP_EXTENSION).user
endif
$(foreach entry, $(_defined_configs), $(eval _CONFIGS-with-$($(entry))+= $(entry)))
# List of defined configs
ML_SETUP_ENABLED_CONFIGS = $(_CONFIGS-with-y)
# List of configs (CONFIG_%) which also have (%_DIR) variable defined
$(foreach entry, $(ML_SETUP_ENABLED_CONFIGS), $(eval _CONFIGS-with-dir-$(origin $(patsubst CONFIG_%,%,$(entry))_DIR)+= $(entry)))
ML_SETUP_CONFIGS_WITH_DIR = $(_CONFIGS-with-dir-file)
CFLAGS += $(CFLAG_USER)
FLAGS += $(LFLAG_USER)
AFLAGS += $(AFLAG_USER)
# install preparing targets are called from both platform and modules
# however, placing these rules at the top will select "install_prepare"
# as the default target, which is not what we want
# fixme: better solution?
.DEFAULT_GOAL := all
install_prepare:
$(INSTALL_PREPARE)
install_finish:
$(INSTALL_FINISH)
.PHONY: install_prepare install_finish
prepare_install_dir: install_prepare
@echo "[ MKDIR ] ML directory structure..."
@$(MKDIR) -p $(INSTALL_ML_DIR)
@$(MKDIR) -p $(INSTALL_MODULES_DIR)
@$(MKDIR) -p $(INSTALL_FONTS_DIR)
@$(MKDIR) -p $(INSTALL_DATA_DIR)
@$(MKDIR) -p $(INSTALL_CROPMARKS_DIR)
@$(MKDIR) -p $(INSTALL_SCRIPTS_DIR)
@$(MKDIR) -p $(INSTALL_DOC_DIR)