]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/protocol/lufa/LUFA-git/LUFA/Build/lufa_avrdude.mk
pc98_usb: Update README
[max/tmk_keyboard.git] / tmk_core / protocol / lufa / LUFA-git / LUFA / Build / lufa_avrdude.mk
1 #
2 #             LUFA Library
3 #     Copyright (C) Dean Camera, 2014.
4 #
5 #  dean [at] fourwalledcubicle [dot] com
6 #           www.lufa-lib.org
7 #
8
9 LUFA_BUILD_MODULES         += AVRDUDE
10 LUFA_BUILD_TARGETS         += avrdude avrdude-ee
11 LUFA_BUILD_MANDATORY_VARS  += MCU TARGET
12 LUFA_BUILD_OPTIONAL_VARS   += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS
13 LUFA_BUILD_PROVIDED_VARS   +=
14 LUFA_BUILD_PROVIDED_MACROS +=
15
16 # -----------------------------------------------------------------------------
17 #             LUFA AVRDUDE Programmer Buildsystem Makefile Module.
18 # -----------------------------------------------------------------------------
19 # DESCRIPTION:
20 #   Provides a set of targets to re-program a device using the open source
21 #   avr-dude utility.
22 # -----------------------------------------------------------------------------
23 # TARGETS:
24 #
25 #    avrdude                   - Program target FLASH with application using
26 #                                avrdude
27 #    avrdude-ee                - Program target EEPROM with application data
28 #                                using avrdude
29 #
30 # MANDATORY PARAMETERS:
31 #
32 #    MCU                       - Microcontroller device model name
33 #    TARGET                    - Application name
34 #
35 # OPTIONAL PARAMETERS:
36 #
37 #    AVRDUDE_PROGRAMMER        - Name of programming hardware to use
38 #    AVRDUDE_PORT              - Name of communication port to use
39 #    AVRDUDE_FLAGS             - Flags to pass to avr-dude
40 #
41 # PROVIDED VARIABLES:
42 #
43 #    (None)
44 #
45 # PROVIDED MACROS:
46 #
47 #    (None)
48 #
49 # -----------------------------------------------------------------------------
50
51 SHELL = /bin/sh
52
53 ERROR_IF_UNSET   ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
54 ERROR_IF_EMPTY   ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
55 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
56
57 # Default values of optionally user-supplied variables
58 AVRDUDE_PROGRAMMER ?= jtagicemkii
59 AVRDUDE_PORT       ?= usb
60 AVRDUDE_FLAGS      ?=
61
62 # Sanity check user supplied values
63 $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
64 $(call ERROR_IF_EMPTY, MCU)
65 $(call ERROR_IF_EMPTY, TARGET)
66 $(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)
67 $(call ERROR_IF_EMPTY, AVRDUDE_PORT)
68
69 # Output Messages
70 MSG_AVRDUDE_CMD    := ' [AVRDUDE] :'
71
72 # Construct base avrdude command flags
73 BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
74
75 # Programs in the target FLASH memory using AVRDUDE
76 avrdude: $(TARGET).hex $(MAKEFILE_LIST)
77         @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
78         avrdude $(BASE_AVRDUDE_FLAGS) -U flash:w:$< $(AVRDUDE_FLAGS)
79
80 # Programs in the target EEPROM memory using AVRDUDE
81 avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)
82         @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"
83         avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)
84
85 # Phony build targets for this module
86 .PHONY: avrdude avrdude-ee