summaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
authordankm <dan.mcgregor@usask.ca>2018-03-26 14:08:08 -0600
committerJack Humbert <jack.humb@gmail.com>2018-03-26 16:08:08 -0400
commit19a1fbaca2137a9d4cd529e363039a612a4f941d (patch)
tree83f88e254ccb527b2272b012d982ffa80086fb5a /tmk_core
parentae7284edb8bd8ed7fcab29415049bf03baf57f8d (diff)
Better non-Linux support (#2524)
* grep -> $(GREP) Some UNIXy systems (FreeBSD for example) don't use GNU grep by default. Allow the user to specify which grep implementation to use so that GNU grep can be specified. * Allow using versioned avr-gcc command Don't hardcode "avr-gcc", and allow strings such as "avr-gcc8", or "avr-gcc-7.3.0" to match checks for "avr-gcc".
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/avr.mk23
-rw-r--r--tmk_core/rules.mk4
2 files changed, 14 insertions, 13 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index 10b043caa2..eb55dba95c 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -135,13 +135,14 @@ flip: $(BUILD_DIR)/$(TARGET).hex check-size
$(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0
DFU_PROGRAMMER ?= dfu-programmer
+GREP ?= grep
dfu: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size
until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\
echo "Error: Bootloader not found. Trying again in 5s." ;\
sleep 5 ;\
done
- if $(DFU_PROGRAMMER) --version 2>&1 | grep -q 0.7 ; then\
+ if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\
$(DFU_PROGRAMMER) $(MCU) erase --force;\
else\
$(DFU_PROGRAMMER) $(MCU) erase;\
@@ -161,7 +162,7 @@ flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
$(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex
dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
- if $(DFU_PROGRAMMER) --version 2>&1 | grep -q 0.7 ; then\
+ if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\
$(DFU_PROGRAMMER) $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep;\
else\
$(DFU_PROGRAMMER) $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep;\
@@ -169,7 +170,7 @@ dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
$(DFU_PROGRAMMER) $(MCU) reset
avrdude: $(BUILD_DIR)/$(TARGET).hex check-size
- if grep -q -s Microsoft /proc/version; then \
+ if $(GREP) -q -s Microsoft /proc/version; then \
echo 'ERROR: AVR flashing cannot be automated within the Windows Subsystem for Linux (WSL) currently. Instead, take the .hex file generated and flash it using AVRDUDE, AVRDUDESS, or XLoader.'; \
else \
printf "Detecting USB port, reset your controller now."; \
@@ -178,12 +179,12 @@ avrdude: $(BUILD_DIR)/$(TARGET).hex check-size
sleep 0.5; \
printf "."; \
ls /dev/tty* > /tmp/2; \
- USB=`comm -13 /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`; \
+ USB=`comm -13 /tmp/1 /tmp/2 | $(GREP) -o '/dev/tty.*'`; \
mv /tmp/2 /tmp/1; \
done; \
echo ""; \
echo "Detected controller on USB port at $$USB"; \
- if grep -q -s 'MINGW\|MSYS' /proc/version; then \
+ if $(GREP) -q -s 'MINGW\|MSYS' /proc/version; then \
USB=`echo "$$USB" | perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e'`; \
echo "Remapped MSYS2 USB port to $$USB"; \
fi; \
@@ -252,12 +253,12 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
bootloader:
make -C lib/lufa/Bootloaders/DFU/ clean
echo -e "#ifndef QMK_KEYBOARD\n#define QMK_KEYBOARD\n" > lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `grep "MANUFACTURER" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `grep "PRODUCT" $(ALL_CONFIGS) -h | tail -1` Bootloader >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `grep "QMK_ESC_OUTPUT" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `grep "QMK_ESC_INPUT" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `grep "QMK_LED" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
- echo -e `grep "QMK_SPEAKER" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ echo -e `$(GREP) "MANUFACTURER" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ echo -e `$(GREP) "PRODUCT" $(ALL_CONFIGS) -h | tail -1` Bootloader >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ echo -e `$(GREP) "QMK_ESC_OUTPUT" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ echo -e `$(GREP) "QMK_ESC_INPUT" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ echo -e `$(GREP) "QMK_LED" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
+ echo -e `$(GREP) "QMK_SPEAKER" $(ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e "\n#endif" >> lib/lufa/Bootloaders/DFU/Keyboard.h
make -C lib/lufa/Bootloaders/DFU/
echo -e "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex"
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index ff6af4a882..b556c4609b 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -370,9 +370,9 @@ show_path:
@echo SRC=$(SRC)
@echo OBJ=$(OBJ)
-ifeq ($(CC),avr-gcc)
+ifeq ($(findstring avr-gcc,$(CC)),avr-gcc)
check-size:
- $(eval MAX_SIZE=$(shell n=`avr-gcc -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'`; echo $$(($$n)) || echo 0))
+ $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi))
if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \
$(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \