]> git.donarmstrong.com Git - qmk_firmware.git/blob - lib/lufa/LUFA/Build/DMBS/DMBS/avrdude.mk
Merge commit '60b30c036397cb5627fa374bb930794b225daa29' as 'lib/lufa'
[qmk_firmware.git] / lib / lufa / LUFA / Build / DMBS / DMBS / avrdude.mk
1 #
2 #            DMBS Build System
3 #     Released into the public domain.
4 #
5 #  dean [at] fourwalledcubicle [dot] com
6 #        www.fourwalledcubicle.com
7 #
8
9 DMBS_BUILD_MODULES         += AVRDUDE
10 DMBS_BUILD_TARGETS         += avrdude avrdude-ee
11 DMBS_BUILD_MANDATORY_VARS  += MCU TARGET
12 DMBS_BUILD_OPTIONAL_VARS   += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS AVRDUDE_MEMORY
13 DMBS_BUILD_PROVIDED_VARS   +=
14 DMBS_BUILD_PROVIDED_MACROS +=
15
16 # Conditionally import the CORE module of DMBS if it is not already imported
17 DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
18 ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),)
19   include $(DMBS_MODULE_PATH)/core.mk
20 endif
21
22 # Default values of optionally user-supplied variables
23 AVRDUDE_PROGRAMMER ?= jtagicemkii
24 AVRDUDE_PORT       ?= usb
25 AVRDUDE_FLAGS      ?=
26 AVRDUDE_MEMORY     ?= flash
27
28 # Sanity check user supplied values
29 $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
30 $(call ERROR_IF_EMPTY, MCU)
31 $(call ERROR_IF_EMPTY, TARGET)
32 $(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
33 $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
34
35 # Output Messages
36 MSG_AVRDUDE_CMD    := ' [AVRDUDE] :'
37
38 # Construct base avrdude command flags
39 BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
40
41 # Programs in the target FLASH memory using AVRDUDE
42 avrdude: $(TARGET).hex $(MAKEFILE_LIST)
43         @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
44         avrdude $(BASE_AVRDUDE_FLAGS) -U $(AVRDUDE_MEMORY):w:$< $(AVRDUDE_FLAGS)
45
46 # Programs in the target EEPROM memory using AVRDUDE
47 avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
48         @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
49         avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
50
51 # Phony build targets for this module
52 .PHONY: $(DMBS_BUILD_TARGETS)