Makefile: Resync main makefile with Klipper's main makefile

The latest Klipper main Makefile has bugfixes for proper rebuilding on
a change during "make menuconfig".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-05-04 22:51:14 -04:00 committed by Eric Callahan
parent 9c6e72e3a5
commit 00a65c1570

View File

@ -29,10 +29,10 @@ dirs-y = src
cc-option=$(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`" \
; then echo "$(2)"; else echo "$(3)"; fi ;)
CFLAGS := -I$(OUT) -Isrc -I$(OUT)board-generic/ -std=gnu11 -Os -MD -g \
CFLAGS := -I$(OUT) -Isrc -I$(OUT)board-generic/ -std=gnu11 -Os -MD \
-Wall -Wold-style-definition $(call cc-option,$(CC),-Wtype-limits,) \
-ffunction-sections -fdata-sections
CFLAGS += -flto -fwhole-program -fno-use-linker-plugin
CFLAGS += -flto -fwhole-program -fno-use-linker-plugin -ggdb3
OBJS_canboot.elf = $(patsubst %.c, $(OUT)src/%.o,$(src-y))
OBJS_canboot.elf += $(OUT)compile_time_request.o
@ -92,17 +92,21 @@ $(OUT)compile_time_request.o: $(patsubst %.c, $(OUT)src/%.o.ctr,$(src-y)) ./scri
################ Auto generation of "board/" include file link
$(OUT)board-link: $(KCONFIG_CONFIG)
create-board-link:
@echo " Creating symbolic link $(OUT)board"
$(Q)mkdir -p $(addprefix $(OUT), $(dirs-y))
$(Q)echo "#$(CONFIG_BOARD_DIRECTORY)" > $@.temp
$(Q)if ! cmp -s $@.temp $@; then rm -f $(OUT)*.d $(patsubst %,$(OUT)%/*.d,$(dirs-y)) ; mv $@.temp $@ ; fi
$(Q)rm -f $(OUT)*.d $(patsubst %,$(OUT)%/*.d,$(dirs-y))
$(Q)rm -f $(OUT)board
$(Q)ln -sf $(PWD)/src/$(CONFIG_BOARD_DIRECTORY) $(OUT)board
$(Q)ln -sf $(CURDIR)/src/$(CONFIG_BOARD_DIRECTORY) $(OUT)board
$(Q)mkdir -p $(OUT)board-generic
$(Q)rm -f $(OUT)board-generic/board
$(Q)ln -sf $(PWD)/src/generic $(OUT)board-generic/board
$(Q)ln -sf $(CURDIR)/src/generic $(OUT)board-generic/board
# Hack to rebuild OUT directory and reload make dependencies on Kconfig change
$(OUT)board-link: $(KCONFIG_CONFIG)
$(Q)mkdir -p $(OUT)
$(Q)echo "# Makefile board-link rule" > $@
$(Q)$(MAKE) create-board-link
include $(OUT)board-link
################ Kconfig rules
@ -121,7 +125,7 @@ menuconfig:
################ Generic rules
# Make definitions
.PHONY : all clean distclean olddefconfig menuconfig FORCE
.PHONY : all clean distclean olddefconfig menuconfig create-board-link FORCE
.DELETE_ON_ERROR:
all: $(target-y)