Makefile: Improve build when changing micro-controller architecture
Try to clean up the dependency files when changing the micro-controller architecture so that an explicit "make clean" isn't needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
4c2d074967
commit
85300a4aad
41
Makefile
41
Makefile
|
@ -1,6 +1,6 @@
|
||||||
# Klipper build system
|
# Klipper build system
|
||||||
#
|
#
|
||||||
# Copyright (C) 2016-2019 Kevin O'Connor <kevin@koconnor.net>
|
# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
@ -57,27 +57,22 @@ endif
|
||||||
include src/Makefile
|
include src/Makefile
|
||||||
-include src/$(patsubst "%",%,$(CONFIG_BOARD_DIRECTORY))/Makefile
|
-include src/$(patsubst "%",%,$(CONFIG_BOARD_DIRECTORY))/Makefile
|
||||||
|
|
||||||
################ Common build rules
|
################ Main build rules
|
||||||
|
|
||||||
$(OUT)%.o: %.c $(OUT)autoconf.h $(OUT)board-link
|
$(OUT)%.o: %.c $(OUT)autoconf.h
|
||||||
@echo " Compiling $@"
|
@echo " Compiling $@"
|
||||||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(OUT)%.ld: %.lds.S $(OUT)autoconf.h $(OUT)board-link
|
$(OUT)%.ld: %.lds.S $(OUT)autoconf.h
|
||||||
@echo " Preprocessing $@"
|
@echo " Preprocessing $@"
|
||||||
$(Q)$(CPP) -I$(OUT) -P -MD -MT $@ $< -o $@
|
$(Q)$(CPP) -I$(OUT) -P -MD -MT $@ $< -o $@
|
||||||
|
|
||||||
################ Main build rules
|
$(OUT)klipper.elf: $(OBJS_klipper.elf)
|
||||||
|
@echo " Linking $@"
|
||||||
|
$(Q)$(CC) $(OBJS_klipper.elf) $(CFLAGS_klipper.elf) -o $@
|
||||||
|
$(Q)scripts/check-gcc.sh $@ $(OUT)compile_time_request.o
|
||||||
|
|
||||||
$(OUT)board-link: $(KCONFIG_CONFIG)
|
################ Compile time requests
|
||||||
@echo " Creating symbolic link $(OUT)board"
|
|
||||||
$(Q)mkdir -p $(addprefix $(OUT), $(dirs-y))
|
|
||||||
$(Q)touch $@
|
|
||||||
$(Q)rm -f $(OUT)board
|
|
||||||
$(Q)ln -sf $(PWD)/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
|
|
||||||
|
|
||||||
$(OUT)%.o.ctr: $(OUT)%.o
|
$(OUT)%.o.ctr: $(OUT)%.o
|
||||||
$(Q)$(OBJCOPY) -j '.compile_time_request' -O binary $^ $@
|
$(Q)$(OBJCOPY) -j '.compile_time_request' -O binary $^ $@
|
||||||
|
@ -88,10 +83,20 @@ $(OUT)compile_time_request.o: $(patsubst %.c, $(OUT)src/%.o.ctr,$(src-y)) ./scri
|
||||||
$(Q)$(PYTHON) ./scripts/buildcommands.py -d $(OUT)klipper.dict -t "$(CC);$(AS);$(LD);$(OBJCOPY);$(OBJDUMP);$(STRIP)" $(OUT)compile_time_request.txt $(OUT)compile_time_request.c
|
$(Q)$(PYTHON) ./scripts/buildcommands.py -d $(OUT)klipper.dict -t "$(CC);$(AS);$(LD);$(OBJCOPY);$(OBJDUMP);$(STRIP)" $(OUT)compile_time_request.txt $(OUT)compile_time_request.c
|
||||||
$(Q)$(CC) $(CFLAGS) -c $(OUT)compile_time_request.c -o $@
|
$(Q)$(CC) $(CFLAGS) -c $(OUT)compile_time_request.c -o $@
|
||||||
|
|
||||||
$(OUT)klipper.elf: $(OBJS_klipper.elf)
|
################ Auto generation of "board/" include file link
|
||||||
@echo " Linking $@"
|
|
||||||
$(Q)$(CC) $(OBJS_klipper.elf) $(CFLAGS_klipper.elf) -o $@
|
$(OUT)board-link: $(KCONFIG_CONFIG)
|
||||||
$(Q)scripts/check-gcc.sh $@ $(OUT)compile_time_request.o
|
@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)board
|
||||||
|
$(Q)ln -sf $(PWD)/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
|
||||||
|
|
||||||
|
include $(OUT)board-link
|
||||||
|
|
||||||
################ Kconfig rules
|
################ Kconfig rules
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue