3575f377732fd719000be305afa1989e09d6bf05
[pub/USBasp.git] / LUFA / Build / DMBS / DMBS / hid.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 += HID
10 DMBS_BUILD_TARGETS += hid hid-ee teensy teensy-ee
11 DMBS_BUILD_MANDATORY_VARS += MCU TARGET
12 DMBS_BUILD_OPTIONAL_VARS +=
13 DMBS_BUILD_PROVIDED_VARS +=
14 DMBS_BUILD_PROVIDED_MACROS +=
15
16 SHELL = /bin/sh
17
18 DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
19
20 ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
21 ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
22 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
23
24 # Sanity-check values of mandatory user-supplied variables
25 $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
26 $(call ERROR_IF_EMPTY, MCU)
27 $(call ERROR_IF_EMPTY, TARGET)
28
29 # Output Messages
30 MSG_HID_BOOTLOADER_CMD := ' [HID] :'
31 MSG_OBJCPY_CMD := ' [OBJCPY] :'
32 MSG_MAKE_CMD := ' [MAKE] :'
33
34 # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
35 hid: $(TARGET).hex $(MAKEFILE_LIST)
36 @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
37 hid_bootloader_cli -mmcu=$(MCU) -v $<
38
39 # Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
40 hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
41 @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
42 avr-objcopy -I ihex -O binary $< $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
43 @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
44 $(MAKE) -C $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean hid
45
46 # Programs in the target FLASH memory using the TEENSY_BOOTLOADER_CLI tool
47 teensy: $(TARGET).hex $(MAKEFILE_LIST)
48 @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
49 teensy_loader_cli -mmcu=$(MCU) -v $<
50
51 # Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
52 teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)
53 @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
54 avr-objcopy -I ihex -O binary $< $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
55 @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
56 $(MAKE) -s -C $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean teensy
57
58 # Phony build targets for this module
59 .PHONY: $(DMBS_BUILD_TARGETS)