-
Notifications
You must be signed in to change notification settings - Fork 10
/
makefile
212 lines (171 loc) · 5.91 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
#
# LUFA Library
# Copyright (C) Dean Camera, 2012.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------
MCU = atmega32u4
#MCU = at90usb1286
ARCH = AVR8
BOARD = TEENSY2
#BOARD = MICRO # for LEONARDO ADAFxxx
F_CPU = 16000000
F_USB = $(F_CPU)
OPTIMIZATION = s
TARGET = adnw
SRCDIR = ./src
# -----------------------------------------------------------
# Keyboard selection below: Override from environment variable
# -----------------------------------------------------------
KB_HW_SUPPORTED = BLUECUBE HYPERNANO REDTILT HYPERMICRO BLACKFLAT BLACKBOWL
KB_HW ?= BLACKFLAT
KB_DBG ?= 1
KB_EXT ?= 1
# Acknowledged USB ID limitations and restrictions
KB_USB_ID = ""
##################################################################
#
# Should not need to change anything below ...
#
##################################################################
# List C source files here. (C dependencies are automatically generated.)
SRC = $(LUFA_SRC_USB_DEVICE) \
$(LUFA_PATH)/Drivers/USB/Class/Device/HIDClassDevice.c \
$(SRCDIR)/Keyboard.c \
$(SRCDIR)/Descriptors.c \
$(SRCDIR)/keyboard_class.c \
$(SRCDIR)/keymap.c \
$(SRCDIR)/matrix.c \
$(SRCDIR)/macro.c \
$(SRCDIR)/command.c \
$(SRCDIR)/ascii2hid.c \
$(SRCDIR)/mousekey.c \
$(SRCDIR)/external/jump_bootloader.c \
$(SRCDIR)/external/i2cmaster/twimaster.c \
$(SRCDIR)/global_config.c \
$(SRCDIR)/external/mem-check.c \
$(SRCDIR)/b64.c \
$(SRCDIR)/helpers.c \
LUFA_PATH = LUFA/LUFA
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/
CC_FLAGS += -fdata-sections
CC_FLAGS += -Werror
LD_FLAGS =
CC_FLAGS += -D$(KB_HW)
ifeq ($(KB_DBG), 1)
CC_FLAGS += -DDEBUG_OUTPUT
endif
ifneq (,$(findstring frobiac,$(KB_USB_ID)))
CC_FLAGS += -DFROBIAC_USB_ID
endif
ifneq (,$(findstring LUFA,$(KB_USB_ID)))
CC_FLAGS += -DLUFA_USB_ID
endif
ifeq ($(KB_EXT), 1)
CC_FLAGS += -DEXTRA
SRC += $(SRCDIR)/extra.c
endif
ifneq (,$(findstring REDTILT,$(CC_FLAGS)))
CC_FLAGS += -DPS2MOUSE
PS2_USE_BUSYWAIT = yes # uses primitive reference code
endif
ifneq (,$(findstring BLACKFLAT,$(CC_FLAGS)))
CC_FLAGS += -DPS2MOUSE
PS2_USE_BUSYWAIT = yes # uses primitive reference code
endif
ifneq (,$(findstring BLACKBOWL,$(CC_FLAGS)))
CC_FLAGS += -DPS2MOUSE
PS2_USE_USART = yes # uses primitive reference code
endif
ifneq (,$(findstring HYPERNANO,$(CC_FLAGS)))
CC_FLAGS += -DPINKYDROP
CC_FLAGS += -DPS2MOUSE
PS2_USE_BUSYWAIT = yes # uses primitive reference code
endif
SRC += \
$(SRCDIR)/external/avr-cryptolib/sha1-asm.S \
$(SRCDIR)/external/avr-cryptolib/hmac-sha1.c \
SRC += $(SRCDIR)/xor.c
SRC += $(SRCDIR)/tabularecta.c
ifneq (,$(findstring DEBUG_OUTPUT,$(CC_FLAGS)))
SRC += \
$(SRCDIR)/print.c \
$(SRCDIR)/external/xprintf.S \
endif
ifneq (,$(findstring ANALOGSTICK,$(CC_FLAGS)))
SRC += $(SRCDIR)/analog.c
endif
ifneq (,$(findstring PS2MOUSE,$(CC_FLAGS)))
PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
# Define variant used per board above
#PS2_USE_BUSYWAIT = yes # uses primitive reference code
#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recommended)
TMK_PS2_DIR = ./src/external/tmk_ps2
-include $(TMK_PS2_DIR)/tmk_ps2.mk
CC_FLAGS += $(OPT_DEFS)
SRC += $(SRCDIR)/ps2mouse.c
SRC += $(SRCDIR)/trackpoint.c
endif
FW_VERSION := $(shell git describe --tags --always --long --dirty="-D")-$(shell git log --pretty=format:%cd --date=short -n1)
ifeq ('',$(FW_VERSION))
FW_VERSION := unknown_version-$(shell date +%Y%m%d)
endif
CC_FLAGS += -DFW_VERSION=\"$(FW_VERSION)\"
# generate a sample uuid for passhash secret
HMAC_TAG_BASE := $(shell tr -dc 'a-f0-9' </dev/urandom | head -c 40 | sed 's/\(..\)/\\\\x\1/g')
# Random xorshift init 32
XOR_RND_INIT := $(shell tr -dc 'a-f0-9' </dev/urandom | head -c 8 )
CC_FLAGS += -DXOR_RND_INIT=0x$(XOR_RND_INIT)
# Default target
all: lufacheck configtest private_data_check submodule
# Should check length of given data...
private_data_check:
ifneq ("$(wildcard $(SRCDIR)/_private_data.h)","")
@echo "*** Private data definition found ";
else
@echo "*** PRIVATE DATA $(SRCDIR)/_private_data.h NOT found.";
@echo "*** Creating default one. Please edit template to your needs (file is ignored in git)";
@sed 's/^const char \* HMAC_TAG_BASE.*/const char * HMAC_TAG_BASE = \"$(HMAC_TAG_BASE)\";/' $(SRCDIR)/_private_data_template.h > $(SRCDIR)/_private_data.h ;
@chmod 600 $(SRCDIR)/_private_data.h ;
@false;
endif
# check that LUFA is there
lufacheck:
@if test -d LUFA/LUFA ; then \
echo "*** LUFA found.";\
else \
echo "*** ERROR: LUFA/LUFA missing - see README for install instructions.\n*** Try to checkout LUFA source with\n*** git submodule init && git submodule update\n\n"; false;\
fi
configtest:
# check that KB_HW is defined and valid
ifneq (,$(filter $(KB_HW), $(KB_HW_SUPPORTED)))
@echo "*** HW = $(KB_HW) from $(origin KB_HW)"
@echo "*** DBG = $(KB_DBG) from $(origin KB_DBG)"
else
$(error *** KB_HW defined as "$(KB_HW)" not valid: not in $(KB_HW_SUPPORTED))
endif
ifneq (,$(findstring DEBUG_OUTPUT,$(CC_FLAGS)))
@echo "*** DEBUG is defined" ;
else
@echo "*** DEBUG is NOT defined";
endif
ifneq (,$(findstring USB_ID,$(CC_FLAGS)))
@echo "*** USB_ID set to $(KB_USB_ID)" ;
else
@echo "*** USB_ID unset, use KB_USB_ID=xxx or define yours in src/config.h";
endif
submodule:
@git submodule update
sizecheck:
@echo HW=$(KB_HW) DBG=$(KB_DBG)
@avr-size --mcu=atmega32u4 -B adnw.elf
# Include LUFA build script makefiles
# lines begin with "-" so if not found, the lufacheck above prints message
#-include $(LUFA_PATH)/Build/lufa_core.mk
-include $(LUFA_PATH)/Build/lufa_sources.mk
-include $(LUFA_PATH)/Build/lufa_build.mk