Generate and use compiler dep rules

SDCC supports the `-MMD` option. Use it instead of having every file
depend on *all* the headers. Reduces incremental build time after
modifying headers as it will now only rebuild the actual dependents and
not the entire project.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2023-01-11 12:28:13 -07:00
committed by Tim Crawford
parent 84fe76cad4
commit 9a52042f95
10 changed files with 25 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-only
CC = sdcc -mmcs51 --model-large --code-size $(CODE_SIZE) --xram-size $(SRAM_SIZE) --Werror
CC = sdcc -mmcs51 -MMD --model-large --code-size $(CODE_SIZE) --xram-size $(SRAM_SIZE) --Werror
AS = sdas8051
ASFLAGS = -plosgff
@@ -48,3 +48,7 @@ $(ASM_OBJ): $(BUILD)/%.rel: src/%.asm
$(C_OBJ): $(BUILD)/%.rel: src/%.c $(INCLUDE)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ -c $<
# Add dependency rules
DEP = $(OBJ:%.rel=%.d)
-include $(DEP)

View File

@@ -1,7 +1,8 @@
# SPDX-License-Identifier: GPL-3.0-only
CC=avr-gcc -mmcu=$(EC_VARIANT)
CFLAGS+=-Os -fstack-usage -Wall -Werror -Wl,--gc-sections -Wl,-u,vfprintf -lprintf_flt
CC = avr-gcc -mmcu=$(EC_VARIANT)
CFLAGS += -MMD -Os -fstack-usage -Wall -Werror \
-Wl,--gc-sections -Wl,-u,vfprintf -lprintf_flt
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
ifneq ($(findstring 12.,$(shell avr-gcc --version 2>/dev/null)),)
@@ -35,3 +36,7 @@ $(BUILD)/ec.elf: $(OBJ)
$(BUILD)/%.o: src/%.c $(INCLUDE)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -o $@ -c $<
# Add dependency rules
DEP = $(OBJ:%.o=%.d)
-include $(DEP)