-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmakefile
225 lines (188 loc) · 7.63 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#
# USBMIDIKLIK (LUFA) Makefile
# Copyright (C) TheKikGen Labs , 2018.
#
#
# Run "make help" for LUFA target help.
# Run "make mdkhelp" for USBMIDIKLIK target help.
# COMMON DEFs ================================================================
SHELL=sh
# From gcc 4.7
CC_FLAGS = -std=gnu++11
# Before gcc 4.7
#CC_FLAGS += -std=c++0x
LD_FLAGS =
SOURCE_FILE = USBMidiKliK_dual
AVRDUDE_PATH = "/c/Program Files (x86)/Arduino/hardware/tools/avr/bin"
COM = 4
# DEPENDANCIES. You must download these packages to compile
# https://github.com/TheKikGen/midiXparser
# https://github.com/abcminiuser/lufa
LUFA_PATH = ./lufa/LUFA
MIDI_XPARSER = ./midiXparser
# ARDUINO MICRO / LEONARDO ==================================================
ifeq ($(TARGET_BOARD),micro)
TARGET_BOARD = micro
TARGET = $(SOURCE_FILE)_$(TARGET_BOARD)
MCU = atmega32u4
CC_FLAGS += -DSINGLE_BOOT_MODE
ARCH = AVR8
BOARD = MICRO
F_CPU = 16000000
F_USB = $(F_CPU)
OPTIMIZATION = s
FLASH_COMMAND_LINE = avrdude -v -patmega32u4 -cavr109 -PCOM$(COM) -b57600 -D -V -Uflash:w:./$(TARGET).hex.build:i
# Specify the Vendor ID, Product ID and device name.
# This is used by Descriptors.c
ARDUINO_DEVICE_VENDORID = 0x2912
ARDUINO_DEVICE_PRODUCTID = 0x0001
ARDUINO_DEVICE_MANUFACTURER_STRING = "The KikGen Labs"
ARDUINO_DEVICE_PRODUCT_STRING = "Arduino Micro dual midi"
ARDUINO_DEVICE_PRODUCT_SERIAL = "55732323430351718180"
# ARDUINO MEGA ========================================================
else ifeq ($(TARGET_BOARD),mega)
TARGET_BOARD = mega
TARGET = $(SOURCE_FILE)_$(TARGET_BOARD)
MCU = atmega16u2
ARCH = AVR8
BOARD = UNO
F_CPU = 16000000
F_USB = $(F_CPU)
OPTIMIZATION = s
FLASH_COMMAND_LINE = avrdude -c usbasp -P usb -b 19200 -p m16u2 -U flash:w:./$(TARGET).hex.build:i
# Specify the Vendor ID, Product ID and device name.
# This is used by Descriptors.c
ARDUINO_DEVICE_VENDORID = 0x2341
ARDUINO_DEVICE_PRODUCTID = 0x0042
ARDUINO_DEVICE_MANUFACTURER_STRING = "Arduino (www.arduino.cc)"
ARDUINO_DEVICE_PRODUCT_STRING = "Arduino Mega dual midi"
ARDUINO_DEVICE_PRODUCT_SERIAL = "55732323430351718180"
# UNO is the default ========================================================
else
TARGET_BOARD = uno
TARGET = $(SOURCE_FILE)_$(TARGET_BOARD)
MCU = atmega16u2
ARCH = AVR8
BOARD = UNO
F_CPU = 16000000
F_USB = $(F_CPU)
OPTIMIZATION = s
FLASH_COMMAND_LINE = avrdude -c usbasp -P usb -b 19200 -p m16u2 -U flash:w:./$(TARGET).hex.build:i
# Specify the Vendor ID, Product ID and device name.
# This is used by Descriptors.c
ARDUINO_DEVICE_VENDORID = 0x2341
ARDUINO_DEVICE_PRODUCTID = 0x0001
ARDUINO_DEVICE_MANUFACTURER_STRING = "Arduino (www.arduino.cc)"
ARDUINO_DEVICE_PRODUCT_STRING = "Arduino Uno dual midi"
ARDUINO_DEVICE_PRODUCT_SERIAL = "55732323430351718180"
endif
# END OF BOARD SPECIFIC DEFs ================================================
# MIDI DEVICE
# Specify the Vender ID, Product ID and device name.
# This is used by Descriptors.c
MIDI_DEVICE_VENDORID = 0x2912
MIDI_DEVICE_PRODUCTID = 0x1967
MIDI_DEVICE_MANUFACTURER_STRING = "The KikGen Labs"
# The MIDI_DEVICE_PRODUCT_STRING size must not be changed as it is used to set
# the max size in the USB header PROGMEM structure, and can be changed dynamically later...
MIDI_DEVICE_PRODUCT_STRING = "USB MidiKliK $(BUILD_STRING) "
CC_FLAGS += -DARDUINO_DEVICE_VENDORID=$(ARDUINO_DEVICE_VENDORID)
CC_FLAGS += -DARDUINO_DEVICE_PRODUCTID=$(ARDUINO_DEVICE_PRODUCTID)
CC_FLAGS += -DARDUINO_DEVICE_MANUFACTURER_STRING=$(ARDUINO_DEVICE_MANUFACTURER_STRING)
CC_FLAGS += -DARDUINO_DEVICE_PRODUCT_STRING=$(ARDUINO_DEVICE_PRODUCT_STRING)
CC_FLAGS += -DARDUINO_DEVICE_PRODUCT_SERIAL=$(ARDUINO_DEVICE_PRODUCT_SERIAL)
CC_FLAGS += -DMIDI_DEVICE_VENDORID=$(MIDI_DEVICE_VENDORID)
CC_FLAGS += -DMIDI_DEVICE_PRODUCTID=$(MIDI_DEVICE_PRODUCTID)
CC_FLAGS += -DMIDI_DEVICE_MANUFACTURER_STRING=$(MIDI_DEVICE_MANUFACTURER_STRING)
CC_FLAGS += -DMIDI_DEVICE_PRODUCT_STRING=$(MIDI_DEVICE_PRODUCT_STRING)
CC_FLAGS += $(BUILD_CFLAGS)
BUILD_NUMBER_FILE=build.txt
BUILD_NUMBER=$(shell cat $(BUILD_NUMBER_FILE))
BUILD_DATE=$(shell date +'%Y.%m.%d-%H:%M:%S')
BUILD_STRING=Build-$(shell cat $(BUILD_NUMBER_FILE))
CC_FLAGS += -DBUILD_NUMBER=$(shell cat $(BUILD_NUMBER_FILE) ) -DBUILD_DATE=$(shell date +'%Y.%m.%d-%H:%M:%S')
SRC = $(SOURCE_FILE).cpp Descriptors.c $(MIDI_XPARSER)/midiXparser.cpp
CC_FLAGS += -I$(MIDI_XPARSER)
# LUFA DEFs ================================================================
SRC += $(LUFA_SRC_USB)
SRC += $(LUFA_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c
SRC += $(LUFA_PATH)/Drivers/USB/Class/Host/CDCClassHost.c
SRC += $(LUFA_PATH)/Drivers/USB/Class/Device/MIDIClassDevice.c
SRC += $(LUFA_PATH)/Drivers/USB/Class/Host/MIDIClassHost.c
SRC += $(LUFA_PATH)/Drivers/Peripheral/AVR8/Serial_AVR8.c
CC_FLAGS += -DUSE_LUFA_CONFIG_HEADER -IConfig/ -fpermissive -Os
#=============================================================================
# Default target
uno:
@make build_midiklik TARGET_BOARD=uno
mega:
@make build_midiklik TARGET_BOARD=mega
micro:
@make build_midiklik TARGET_BOARD=micro
uno_flash:
@make uno
@make flash_uno
micro_flash:
@make micro
@make flash_micro COM=$(COM)
all_target:
make purge
make clean
make uno
make clean
make mega
make clean
make micro
make clean
make purge
build_midiklik:
@make buildinc
@echo ======================================================================
@echo ======== BUILD USBMIDIKLIK - TARGET=$(TARGET_BOARD) - BUILD NO=$(shell cat $(BUILD_NUMBER_FILE)) ========
@echo ======================================================================
@make all TARGET_BOARD=$(TARGET_BOARD)
@make save_bin TARGET_BOARD=$(TARGET_BOARD)
save_bin:
@if test -f $(TARGET).hex; then cp -f $(TARGET).hex $(TARGET).hex.build; fi
flash:
echo $(FLASH_COMMAND_LINE)
$(FLASH_COMMAND_LINE)
flash_uno:
make flash TARGET_BOARD=uno
flash_micro:
make flash COM=$(COM) TARGET_BOARD=micro
purge:
@rm -rf *.elf *.bin *.eep *.hex *.lss *.map *.sym
buildinc:
# Create an auto-incrementing build number.
@if ! test -f $(BUILD_NUMBER_FILE); then echo 0 > $(BUILD_NUMBER_FILE); fi
@echo $$(($$(cat $(BUILD_NUMBER_FILE)) + 1)) > $(BUILD_NUMBER_FILE)
mdkhelp:
@echo ======================================================================
@echo USBMIDIKLIK MAKE HELP
@echo ======================================================================
@echo
@echo make uno, mega, micro, all_target.......: Build the specified target or all targets.
@echo
@echo make uno_flash..........................: Make and flash for Uno with FLASH_COMMAND_LINE
@echo
@echo make micro_flash........................: Make and flash for Micro at comm port COM$(COM)
@echo
@echo make purge..............................: Delete all files created by compilation process
@echo
@echo NB : You need to 'make clean' before compiling for a different target.
@echo
@echo Dependancies :
@echo Current LUFA path is : $(LUFA_PATH)
@echo Current mdiXParser path is : $(MIDI_XPARSER)
@echo
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
include $(LUFA_PATH)/Build/lufa_doxygen.mk
include $(LUFA_PATH)/Build/lufa_dfu.mk
include $(LUFA_PATH)/Build/lufa_hid.mk
include $(LUFA_PATH)/Build/lufa_avrdude.mk
include $(LUFA_PATH)/Build/lufa_atprogram.mk