Skip to content

Commit

Permalink
Makefile: Reduce use of $^ in build rules
Browse files Browse the repository at this point in the history
It's rare to use all of a target's prerequisites in a recipe - replace
most cases with $< (the target's first prerequisite).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
  • Loading branch information
KevinOConnor committed Mar 2, 2019
1 parent 9430fea commit 399d539
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/atsam/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ lib/bossac/bin/bossac:
$(Q)make -C lib/bossac bin/bossac

flash: $(OUT)klipper.bin lib/bossac/bin/bossac
@echo " Flashing $^ to $(FLASH_DEVICE) via bossac"
@echo " Flashing $< to $(FLASH_DEVICE) via bossac"
$(Q)if [ -z $(FLASH_DEVICE) ]; then echo "Please specify FLASH_DEVICE"; exit 1; fi
$(Q)lib/bossac/bin/bossac -U -p "$(FLASH_DEVICE)" -a -e -w $(OUT)klipper.bin -v -b
$(Q)lib/bossac/bin/bossac -U -p "$(FLASH_DEVICE)" -a -e -w $< -v -b
$(Q)lib/bossac/bin/bossac -p "$(FLASH_DEVICE)" -b -R > /dev/null 2>&1 || true
4 changes: 2 additions & 2 deletions src/atsamd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ BOSSAC_OFFSET-$(CONFIG_MACH_SAMD21) := 0x2000
BOSSAC_OFFSET-$(CONFIG_MACH_SAMD51) := 0x4000

flash: $(OUT)klipper.bin lib/bossac/bin/bossac
@echo " Flashing $^ to $(FLASH_DEVICE) via bossac"
@echo " Flashing $< to $(FLASH_DEVICE) via bossac"
$(Q)if [ -z $(FLASH_DEVICE) ]; then echo "Please specify FLASH_DEVICE"; exit 1; fi
$(Q)lib/bossac/bin/bossac -U -p "$(FLASH_DEVICE)" -a --offset=$(BOSSAC_OFFSET-y) -w $(OUT)klipper.bin -v -b -R
$(Q)lib/bossac/bin/bossac -U -p "$(FLASH_DEVICE)" -a --offset=$(BOSSAC_OFFSET-y) -w $< -v -b -R
4 changes: 2 additions & 2 deletions src/avr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ $(OUT)klipper.elf.hex: $(OUT)klipper.elf
$(Q)$(OBJCOPY) -j .text -j .data -O ihex $< $@

flash: $(OUT)klipper.elf.hex
@echo " Flashing $^ to $(FLASH_DEVICE) via avrdude"
@echo " Flashing $< to $(FLASH_DEVICE) via avrdude"
$(Q)if [ -z $(FLASH_DEVICE) ]; then echo "Please specify FLASH_DEVICE"; exit 1; fi
$(Q)avrdude -p$(CONFIG_MCU) -c$(CONFIG_AVRDUDE_PROTOCOL) -P"$(FLASH_DEVICE)" -D -U"flash:w:$(OUT)klipper.elf.hex:i"
$(Q)avrdude -p$(CONFIG_MCU) -c$(CONFIG_AVRDUDE_PROTOCOL) -P"$(FLASH_DEVICE)" -D -U"flash:w:$(<):i"
2 changes: 1 addition & 1 deletion src/pru/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $(OUT)pru0.elf: $(patsubst %.c, $(OUT)src/%.o,$(pru0-y))

$(OUT)pru1.elf: $(OUT)klipper.elf
@echo " Linking $@"
$(Q)$(CC) $(CFLAGS_pru1.elf) $^ -o $@
$(Q)$(CC) $(CFLAGS_pru1.elf) $< -o $@

flash: $(OUT)pru0.elf $(OUT)pru1.elf
@echo " Flashing"
Expand Down
4 changes: 2 additions & 2 deletions src/stm32f1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ $(OUT)klipper.bin: $(OUT)klipper.elf
$(Q)$(OBJCOPY) -O binary $< $@

flash: $(OUT)klipper.bin
@echo " Flashing $^ to $(FLASH_DEVICE) via stm32flash"
$(Q)stm32flash -w $(OUT)klipper.bin -v -g 0 $(FLASH_DEVICE)
@echo " Flashing $< to $(FLASH_DEVICE) via stm32flash"
$(Q)stm32flash -w $< -v -g 0 $(FLASH_DEVICE)

0 comments on commit 399d539

Please sign in to comment.