mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 19:20:30 +08:00
c40d75b876
This instructs make to run the tinyusb and directory rules before building any objects. Docs: [1]. After this change, `make clean` started running the tinyusb submodule rule before cleaning. This appears to have been caused by one of the `build/*.d` files overlapping with the `tinyusb` name, triggering that rule. I didn't trace this all the way down to a root cause, but switching the include to something less broad solved the issue. Roughly guided by [2]. 1: https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html 2: http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
66 lines
1.3 KiB
Makefile
66 lines
1.3 KiB
Makefile
CFLAGS += $(INCLUDES) $(DEFINES)
|
|
|
|
OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS))))
|
|
|
|
SUBMODULES = tinyusb
|
|
|
|
COBRA = cobra -f
|
|
|
|
ifndef EMSCRIPTEN
|
|
all: $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size
|
|
else
|
|
all: $(BUILD)/$(BIN).html
|
|
endif
|
|
|
|
$(BUILD)/$(BIN).html: $(OBJS)
|
|
@echo HTML $@
|
|
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ \
|
|
-s ASYNCIFY=1 \
|
|
-s EXPORTED_FUNCTIONS=_main \
|
|
--shell-file=$(TOP)/watch-library/simulator/shell.html
|
|
|
|
$(BUILD)/$(BIN).elf: $(OBJS)
|
|
@echo LD $@
|
|
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
|
|
|
|
$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf
|
|
@echo OBJCOPY $@
|
|
@$(OBJCOPY) -O ihex $^ $@
|
|
|
|
$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf
|
|
@echo OBJCOPY $@
|
|
@$(OBJCOPY) -O binary $^ $@
|
|
|
|
$(BUILD)/$(BIN).uf2: $(BUILD)/$(BIN).bin
|
|
@echo UF2CONV $@
|
|
@$(UF2) $^ -co $@
|
|
|
|
.phony: $(SUBMODULES)
|
|
$(SUBMODULES):
|
|
git submodule update --init
|
|
|
|
install:
|
|
@$(UF2) -D $(BUILD)/$(BIN).uf2
|
|
|
|
$(BUILD)/%.o: | $(SUBMODULES) directory
|
|
@echo CC $@
|
|
@$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@
|
|
|
|
directory:
|
|
@$(MKDIR) -p $(BUILD)
|
|
|
|
size: $(BUILD)/$(BIN).elf
|
|
@echo size:
|
|
@$(SIZE) -t $^
|
|
|
|
clean:
|
|
@echo clean
|
|
@-rm -rf $(BUILD)
|
|
|
|
analyze:
|
|
@$(COBRA) basic $(INCLUDES) $(DEFINES) $(SRCS)
|
|
|
|
DEPFILES := $(SRCS:%.c=$(BUILD)/%.d)
|
|
|
|
-include $(wildcard $(DEPFILES))
|