forked from reticulatedpines/magiclantern_simplified
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.setup
192 lines (154 loc) · 4.92 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# 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
DEPFLAGS_O=\
-Wp,-MMD,$(patsubst %.o,%.d,$(dir $@)$(notdir $@)) \
-Wp,-MT,$@
DEPFLAGS_I=\
-Wp,-MMD,$(patsubst %.i,%.d,$(dir $@)$(notdir $@)) \
-Wp,-MT,$@
FLAGS=\
-nostdlib \
-fomit-frame-pointer \
-fno-strict-aliasing \
-fno-zero-initialized-in-bss \
-I$(TOP_DIR)/include
TARGET_COMPILER ?= arm-gcc
CFLAGS =
ifeq ($(TARGET_COMPILER), arm-gcc)
CFLAGS += -Os -march=$(PLATFORM_ARCH) -D__ARM__
endif
# Allow devs to make warnings break builds
ifeq ($(FATAL_WARNINGS),y)
CFLAGS += -Werror
endif
# TODO I like these but they're a fair amount of effort to add:
# -Wcast-qual
# -Wshadow
# -Wwrite-strings
# -Wformat NB to enable, only need to remove -Wno-format below
# These are good, but not as valuable and / or very high effort to enable:
# -Wconversion
# This one is a pain, but would have some value:
# - We're memory constrained so reordering (and manually adding padding)
# to our structs to avoid padding is nice
# - We should audit for "packed" attribute and see if we can remove
# via reordering / padding, access to packed is slower / more code
# -Wpadded
CFLAGS +=\
$(FLAGS) \
-Wall \
-Wextra \
-Werror-implicit-function-declaration \
-Wdouble-promotion \
-Winline \
-Wundef \
-Wno-unused-parameter \
-Wno-unused-function \
-Wno-format \
-ffast-math \
-fsingle-precision-constant \
-fno-builtin-printf \
-fno-common \
-std=gnu99 \
-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=
ifeq ($(PYCPARSER),y)
# both core and modules
CFLAGS += -DPYCPARSER
endif
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 changing settings: $(show_config_values))
# Some variables are 1/0, some are y/n, we must respect type
c_vals=$(foreach c,$(_defined_configs),$(c)=$($(c)))
c_vals_force_n=$(patsubst %=y,%=n,$(c_vals))
c_vals_force_0=$(patsubst %=1,%=0,$(c_vals_force_n))
#$(foreach c, $(c_vals_force_0), $(warning $(c)))
$(foreach c, $(c_vals_force_0), $(eval $(c)))
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)
# disable built-in rules
.SUFFIXES:
# do not delete these intermediate files
.PRECIOUS:: %.i