]> git.donarmstrong.com Git - qmk_firmware.git/blob - protocol/lufa/LUFA-git/LUFA/Build/lufa_hid.mk
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
[qmk_firmware.git] / protocol / lufa / LUFA-git / LUFA / Build / lufa_hid.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         += HID
10 LUFA_BUILD_TARGETS         += hid hid-ee teensy teensy-ee
11 LUFA_BUILD_MANDATORY_VARS  += MCU TARGET
12 LUFA_BUILD_OPTIONAL_VARS   +=
13 LUFA_BUILD_PROVIDED_VARS   +=
14 LUFA_BUILD_PROVIDED_MACROS +=
15
16 # -----------------------------------------------------------------------------
17 #               LUFA HID Bootloader Buildsystem Makefile Module.
18 # -----------------------------------------------------------------------------
19 # DESCRIPTION:
20 #   Provides a set of targets to re-program a device currently running a HID
21 #   class bootloader with a project's FLASH files.
22 # -----------------------------------------------------------------------------
23 # TARGETS:
24 #
25 #    hid                       - Program FLASH into target via
26 #                                hid_bootloader_cli
27 #    hid-ee                    - Program EEPROM into target via a temporary
28 #                                AVR application and hid_bootloader_cli
29 #    teensy                    - Program FLASH into target via
30 #                                teensy_loader_cli
31 #    teensy-ee                 - Program EEPROM into target via a temporary
32 #                                AVR application and teensy_loader_cli
33 #
34 # MANDATORY PARAMETERS:
35 #
36 #    MCU                       - Microcontroller device model name
37 #    TARGET                    - Application name
38 #
39 # OPTIONAL PARAMETERS:
40 #
41 #    (None)
42 #
43 # PROVIDED VARIABLES:
44 #
45 #    (None)
46 #
47 # PROVIDED MACROS:
48 #
49 #    (None)
50 #
51 # -----------------------------------------------------------------------------
52
53 SHELL = /bin/sh
54
55 LUFA_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
56
57 ERROR_IF_UNSET   ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
58 ERROR_IF_EMPTY   ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
59 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
60
61 # Sanity-check values of mandatory user-supplied variables
62 $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
63 $(call ERROR_IF_EMPTY, MCU)
64 $(call ERROR_IF_EMPTY, TARGET)
65
66 # Output Messages
67 MSG_HID_BOOTLOADER_CMD := ' [HID]     :'
68 MSG_OBJCPY_CMD         := ' [OBJCPY]  :'
69 MSG_MAKE_CMD           := ' [MAKE]    :'
70
71 # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
72 hid: $(TARGET).hex $(MAKEFILE_LIST)
73         @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
74         hid_bootloader_cli -mmcu=$(MCU) -v $<
75
76 # Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
77 hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
78         @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
79         avr-objcopy -I ihex -O binary $< $(LUFA_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
80         @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
81         $(MAKE) -C $(LUFA_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean hid
82
83 # Programs in the target FLASH memory using the TEENSY_BOOTLOADER_CLI tool
84 teensy: $(TARGET).hex $(MAKEFILE_LIST)
85         @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
86         teensy_loader_cli -mmcu=$(MCU) -v $<
87
88 # Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
89 teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)
90         @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
91         avr-objcopy -I ihex -O binary $< $(LUFA_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
92         @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
93         $(MAKE) -s -C $(LUFA_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean teensy
94
95 # Phony build targets for this module
96 .PHONY: hid hid-ee teensy teensy-ee