mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 19:40:31 +03:00
Improved Makefile by taking out compile_file function for repeated statements.
This commit is contained in:
parent
4c62d362ee
commit
51d11bdee8
1 changed files with 13 additions and 12 deletions
25
Makefile
25
Makefile
|
@ -312,33 +312,34 @@ $(TARGET_ELF): $(TARGET_OBJS) $(LD_SCRIPT)
|
||||||
$(V1) $(SIZE) $(TARGET_ELF)
|
$(V1) $(SIZE) $(TARGET_ELF)
|
||||||
|
|
||||||
# Compile
|
# Compile
|
||||||
|
|
||||||
|
## compile_file takes two arguments: (1) optimisation description string and (2) optimisation compiler flag
|
||||||
|
define compile_file
|
||||||
|
echo "%% ($(1)) $<" "$(STDOUT)" && \
|
||||||
|
$(CROSS_CC) -c -o $@ $(CFLAGS) $(2) $<
|
||||||
|
endef
|
||||||
|
|
||||||
ifeq ($(DEBUG),GDB)
|
ifeq ($(DEBUG),GDB)
|
||||||
$(OBJECT_DIR)/$(TARGET)/%.o: %.c
|
$(OBJECT_DIR)/$(TARGET)/%.o: %.c
|
||||||
$(V1) mkdir -p $(dir $@)
|
$(V1) mkdir -p $(dir $@)
|
||||||
$(V1) $(if $(findstring $<,$(NOT_OPTIMISED_SRC)), \
|
$(V1) $(if $(findstring $<,$(NOT_OPTIMISED_SRC)), \
|
||||||
echo "%% (not optimised) $<" "$(STDOUT)" && \
|
$(call compile_file,not optimised, $(CC_NO_OPTIMISATION)) \
|
||||||
$(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_NO_OPTIMISATION) $< \
|
|
||||||
, \
|
, \
|
||||||
echo "%% (debug) $<" "$(STDOUT)" && \
|
$(call compile_file,debug,$(CC_DEBUG_OPTIMISATION)) \
|
||||||
$(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_DEBUG_OPTIMISATION) $< \
|
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
$(OBJECT_DIR)/$(TARGET)/%.o: %.c
|
$(OBJECT_DIR)/$(TARGET)/%.o: %.c
|
||||||
$(V1) mkdir -p $(dir $@)
|
$(V1) mkdir -p $(dir $@)
|
||||||
$(V1) $(if $(findstring $<,$(NOT_OPTIMISED_SRC)), \
|
$(V1) $(if $(findstring $<,$(NOT_OPTIMISED_SRC)), \
|
||||||
echo "%% (not optimised) $<" "$(STDOUT)" && \
|
$(call compile_file,not optimised,$(CC_NO_OPTIMISATION)) \
|
||||||
$(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_NO_OPTIMISATION) $< \
|
|
||||||
, \
|
, \
|
||||||
$(if $(findstring $(subst ./src/main/,,$<),$(SPEED_OPTIMISED_SRC)), \
|
$(if $(findstring $(subst ./src/main/,,$<),$(SPEED_OPTIMISED_SRC)), \
|
||||||
echo "%% (speed optimised) $<" "$(STDOUT)" && \
|
$(call compile_file,speed optimised,$(CC_SPEED_OPTIMISATION)) \
|
||||||
$(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_SPEED_OPTIMISATION) $< \
|
|
||||||
, \
|
, \
|
||||||
$(if $(findstring $(subst ./src/main/,,$<),$(SIZE_OPTIMISED_SRC)), \
|
$(if $(findstring $(subst ./src/main/,,$<),$(SIZE_OPTIMISED_SRC)), \
|
||||||
echo "%% (size optimised) $<" "$(STDOUT)" && \
|
$(call compile_file,size optimised,$(CC_SIZE_OPTIMISATION)) \
|
||||||
$(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_SIZE_OPTIMISATION) $< \
|
|
||||||
, \
|
, \
|
||||||
echo "%% (optimised) $<" "$(STDOUT)" && \
|
$(call compile_file,optimised,$(CC_DEFAULT_OPTIMISATION)) \
|
||||||
$(CROSS_CC) -c -o $@ $(CFLAGS) $(CC_DEFAULT_OPTIMISATION) $< \
|
|
||||||
) \
|
) \
|
||||||
) \
|
) \
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue