2018-05-31 17:37:57 -06:00
|
|
|
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d))
|
|
|
|
|
|
|
|
BUILD_DIR ?= $(shell pwd)/_build
|
|
|
|
BIN_DIR ?= $(shell pwd)/bin
|
|
|
|
FBARDUINO_FIRMWARE_SRC_DIR ?= src
|
|
|
|
FBARDUINO_FIRMWARE_BUILD_DIR ?= $(BUILD_DIR)/sketch
|
|
|
|
FBARDUINO_FIRMWARE_LIB_BUILD_DIR ?= $(BUILD_DIR)/libraries
|
|
|
|
|
2020-05-15 13:39:25 -06:00
|
|
|
ARDUINO_INSTALL_DIR ?= $(HOME)/arduino-1.8.12
|
2018-05-31 17:37:57 -06:00
|
|
|
|
2020-02-13 09:08:22 -07:00
|
|
|
# Get current commit SHA
|
|
|
|
COMMIT_SHA := $(shell git -C $(FBARDUINO_FIRMWARE_SRC_DIR)/.. rev-parse --short=8 HEAD)
|
|
|
|
MODIFIER := $(shell echo $$(if [ -z "$$(git -C $(FBARDUINO_FIRMWARE_SRC_DIR)/.. status -s -uall)" ];then echo "";else echo "+";fi))
|
|
|
|
CREATE_COMMIT_SHA_H := $(shell echo "\#ifndef COMMIT_SHA_H_\n\#define COMMIT_SHA_H_\n\#define SOFTWARE_COMMIT \"-$(COMMIT_SHA)$(MODIFIER)\"\n\#endif" > $(FBARDUINO_FIRMWARE_SRC_DIR)/CommitSHA.h)
|
|
|
|
|
2018-05-31 17:37:57 -06:00
|
|
|
# Files to be tracked for make to know to rebuild.
|
2020-02-06 10:40:30 -07:00
|
|
|
COPY_INO := $(shell cp $(FBARDUINO_FIRMWARE_SRC_DIR)/src.ino $(FBARDUINO_FIRMWARE_SRC_DIR)/src.ino.cpp)
|
2018-05-31 17:37:57 -06:00
|
|
|
CXX_SRC := $(wildcard $(FBARDUINO_FIRMWARE_SRC_DIR)/*.cpp)
|
|
|
|
SRC := $(CXX_SRC)
|
2020-02-10 17:26:42 -07:00
|
|
|
HEADERS := $(wildcard $(FBARDUINO_FIRMWARE_SRC_DIR)/*.h)
|
2018-05-31 17:37:57 -06:00
|
|
|
|
|
|
|
# Object files and Dependency files That will eventually be built.
|
|
|
|
CXX_OBJ := $(CXX_SRC:.cpp=.o)
|
|
|
|
|
|
|
|
## Commands needed to compile and whatnot.
|
|
|
|
CXX := $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/bin/avr-g++
|
|
|
|
CC := $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/bin/avr-gcc
|
|
|
|
AR := $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/bin/avr-gcc-ar
|
|
|
|
OBJ_COPY := $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/bin/avr-objcopy
|
|
|
|
MKDIR_P := mkdir -p
|
|
|
|
|
|
|
|
CXX_FLAGS := -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10600 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR
|
|
|
|
CFLAGS := -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
include lib/core.Makefile
|
|
|
|
include lib/SPI.Makefile
|
|
|
|
include lib/Servo.Makefile
|
|
|
|
include lib/EEPROM.Makefile
|
|
|
|
|
|
|
|
# Targets
|
|
|
|
include lib/targets/ramps_v14.Makefile
|
|
|
|
include lib/targets/farmduino_v10.Makefile
|
|
|
|
include lib/targets/farmduino_k14.Makefile
|
2020-02-06 10:40:30 -07:00
|
|
|
include lib/targets/farmduino_k15.Makefile
|
2020-01-24 13:35:28 -07:00
|
|
|
include lib/targets/express_k10.Makefile
|
2018-05-31 17:37:57 -06:00
|
|
|
|
2020-02-13 09:08:22 -07:00
|
|
|
.PHONY: all clean strings_test force_clean remove_temp \
|
2018-05-31 17:37:57 -06:00
|
|
|
dep_core dep_core_clean \
|
|
|
|
dep_Servo dep_Servo_clean \
|
|
|
|
dep_SPI dep_SPI_clean \
|
|
|
|
dep_EEPROM dep_EEPROM_clean \
|
|
|
|
target_ramps_v14 target_ramps_v14_clean \
|
|
|
|
target_farmduino_v10 target_farmduino_v10_clean \
|
2020-01-24 13:35:28 -07:00
|
|
|
target_farmduino_k14 target_farmduino_k14_clean \
|
2020-02-06 10:40:30 -07:00
|
|
|
target_farmduino_k15 target_farmduino_k15_clean \
|
2020-01-24 13:35:28 -07:00
|
|
|
target_express_k10 target_express_k10_clean
|
2018-05-31 17:37:57 -06:00
|
|
|
|
|
|
|
DEPS := $(DEP_CORE) $(DEP_SPI) $(DEP_Servo) $(DEP_EEPROM)
|
|
|
|
DEPS_OBJ := $(DEP_SPI_OBJ) $(DEP_Servo_OBJ) $(DEP_EEPROM_OBJ)
|
|
|
|
DEPS_CFLAGS := $(DEP_CORE_CFLAGS) $(DEP_SPI_CFLAGS) $(DEP_Servo_CFLAGS) $(DEP_EEPROM_CFLAGS)
|
|
|
|
|
2020-02-13 09:08:22 -07:00
|
|
|
all: $(BIN_DIR) $(DEPS) target_ramps_v14 target_farmduino_v10 target_farmduino_k14 target_farmduino_k15 target_express_k10 remove_temp
|
2018-05-31 17:37:57 -06:00
|
|
|
|
2020-02-13 09:08:22 -07:00
|
|
|
clean: remove_temp target_ramps_v14_clean target_farmduino_v10_clean target_farmduino_k14_clean target_farmduino_k15_clean target_express_k10_clean
|
2018-05-31 17:37:57 -06:00
|
|
|
|
|
|
|
strings_test: all
|
|
|
|
$(OBJ_COPY) -I ihex $(TARGET_ramps_v14_HEX) -O binary $(TARGET_ramps_v14_HEX).bin
|
|
|
|
$(OBJ_COPY) -I ihex $(TARGET_farmduino_v10_HEX) -O binary $(TARGET_farmduino_v10_HEX).bin
|
|
|
|
$(OBJ_COPY) -I ihex $(TARGET_farmduino_k14_HEX) -O binary $(TARGET_farmduino_k14_HEX).bin
|
2020-02-06 10:40:30 -07:00
|
|
|
$(OBJ_COPY) -I ihex $(TARGET_farmduino_k15_HEX) -O binary $(TARGET_farmduino_k15_HEX).bin
|
2020-01-24 13:35:28 -07:00
|
|
|
$(OBJ_COPY) -I ihex $(TARGET_express_k10_HEX) -O binary $(TARGET_express_k10_HEX).bin
|
2020-02-10 17:26:42 -07:00
|
|
|
@strings $(TARGET_ramps_v14_HEX).bin | grep -q ".R.genesisK12"
|
|
|
|
@strings $(TARGET_farmduino_v10_HEX).bin | grep -q ".F.genesisK13"
|
|
|
|
@strings $(TARGET_farmduino_k14_HEX).bin | grep -q ".G.genesisK14"
|
|
|
|
@strings $(TARGET_farmduino_k15_HEX).bin | grep -q ".H.genesisK15"
|
|
|
|
@strings $(TARGET_express_k10_HEX).bin | grep -q ".E.expressK10"
|
2018-05-31 17:37:57 -06:00
|
|
|
|
2020-02-13 09:08:22 -07:00
|
|
|
force_clean: remove_temp
|
2018-05-31 17:37:57 -06:00
|
|
|
$(RM) -r $(BUILD_DIR) $(BIN_DIR)
|
|
|
|
|
|
|
|
$(BIN_DIR):
|
|
|
|
$(MKDIR_P) $(BIN_DIR)
|
2020-02-06 10:40:30 -07:00
|
|
|
|
2020-02-13 09:08:22 -07:00
|
|
|
remove_temp:
|
2020-02-06 10:40:30 -07:00
|
|
|
$(RM) $(FBARDUINO_FIRMWARE_SRC_DIR)/src.ino.cpp
|
2020-02-13 09:08:22 -07:00
|
|
|
$(RM) $(FBARDUINO_FIRMWARE_SRC_DIR)/CommitSHA.h
|