diff --git a/Makefile.include b/Makefile.include index 699ff7931b80cad3fba94b2e0a79519ad00190e0..82331e03d69c6852ceb4c055353f7ba103be2a6f 100644 --- a/Makefile.include +++ b/Makefile.include @@ -511,16 +511,19 @@ distclean: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done -@rm -rf $(BINDIRBASE) -# if make target != 'flash-only', add target 'all' to ensure build before flash -ifeq (,$(filter flash-only, $(MAKECMDGOALS))) - BUILD_BEFORE_FLASH = all -endif +define flash-recipe + $(call check_cmd,$(FLASHER),Flash program) + $(FLASHER) $(FFLAGS) +endef + +# Do not add dependencies to "flash" directly, use FLASHDEPS, as this is shared +# with flash-only too -flash: $(BUILD_BEFORE_FLASH) $(FLASHDEPS) - $(call check_cmd,$(FLASHER),Flash program) - $(FLASHER) $(FFLAGS) +flash: all $(FLASHDEPS) + $(flash-recipe) -flash-only: flash +flash-only: $(FLASHDEPS) + $(flash-recipe) preflash: $(BUILD_BEFORE_FLASH) $(PREFLASHER) $(PREFFLAGS)