diff options
author | Joey Castillo <jose.castillo@gmail.com> | 2021-08-28 13:58:21 -0400 |
---|---|---|
committer | Joey Castillo <jose.castillo@gmail.com> | 2021-08-28 14:13:03 -0400 |
commit | 39bba27d7dcbe8c22b3f6651f7ae3aa2d6a7c28c (patch) | |
tree | c36e22f6457839232b7f4e79cf2c92a2f4862f7e /rules.mk | |
parent | 3e45de7deade177b5caa921ee72a0e36300474c7 (diff) | |
download | Sensor-Watch-39bba27d7dcbe8c22b3f6651f7ae3aa2d6a7c28c.tar.gz Sensor-Watch-39bba27d7dcbe8c22b3f6651f7ae3aa2d6a7c28c.tar.bz2 Sensor-Watch-39bba27d7dcbe8c22b3f6651f7ae3aa2d6a7c28c.zip |
simplify project makefiles
Diffstat (limited to 'rules.mk')
-rw-r--r-- | rules.mk | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/rules.mk b/rules.mk new file mode 100644 index 00000000..cc442f67 --- /dev/null +++ b/rules.mk @@ -0,0 +1,41 @@ +CFLAGS += $(INCLUDES) $(DEFINES) + +OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) + +all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size + +$(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 $@ + +install: + @$(UF2) -D $(BUILD)/$(BIN).uf2 + +%.o: + @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) + +-include $(wildcard $(BUILD)/*.d) |