2019-05-17 14:09:59 +00:00
|
|
|
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
|
|
|
|
|
2019-03-04 23:05:42 +00:00
|
|
|
ifeq ($(strip $(DEVKITARM)),)
|
|
|
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(DEVKITARM)/base_rules
|
|
|
|
|
2019-05-11 21:51:44 +00:00
|
|
|
################################################################################
|
2019-03-04 23:05:42 +00:00
|
|
|
|
2019-05-11 21:51:44 +00:00
|
|
|
IPL_LOAD_ADDR := 0x40003000
|
2019-04-18 15:02:15 +00:00
|
|
|
LPVERSION_MAJOR := 1
|
2020-12-11 01:06:07 +00:00
|
|
|
LPVERSION_MINOR := 9
|
2021-04-06 22:45:21 +00:00
|
|
|
LPVERSION_BUGFX := 1
|
2019-04-19 17:03:11 +00:00
|
|
|
|
2019-05-11 21:51:44 +00:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
TARGET := Lockpick_RCM
|
|
|
|
BUILDDIR := build
|
|
|
|
OUTPUTDIR := output
|
2019-03-04 23:05:42 +00:00
|
|
|
SOURCEDIR = source
|
2020-06-26 20:17:06 +00:00
|
|
|
BDKDIR := bdk
|
|
|
|
BDKINC := -I./$(BDKDIR)
|
|
|
|
VPATH = $(dir ./$(SOURCEDIR)/) $(dir $(wildcard ./$(SOURCEDIR)/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/))
|
|
|
|
VPATH += $(dir $(wildcard ./$(BDKDIR)/)) $(dir $(wildcard ./$(BDKDIR)/*/)) $(dir $(wildcard ./$(BDKDIR)/*/*/))
|
2019-05-17 14:09:59 +00:00
|
|
|
|
|
|
|
OBJS = $(patsubst $(SOURCEDIR)/%.S, $(BUILDDIR)/$(TARGET)/%.o, \
|
|
|
|
$(patsubst $(SOURCEDIR)/%.c, $(BUILDDIR)/$(TARGET)/%.o, \
|
|
|
|
$(call rwildcard, $(SOURCEDIR), *.S *.c)))
|
2020-06-26 20:17:06 +00:00
|
|
|
OBJS += $(patsubst $(BDKDIR)/%.S, $(BUILDDIR)/$(TARGET)/%.o, \
|
|
|
|
$(patsubst $(BDKDIR)/%.c, $(BUILDDIR)/$(TARGET)/%.o, \
|
|
|
|
$(call rwildcard, $(BDKDIR), *.S *.c)))
|
|
|
|
|
|
|
|
GFX_INC := '"../$(SOURCEDIR)/gfx/gfx.h"'
|
|
|
|
FFCFG_INC := '"../$(SOURCEDIR)/libs/fatfs/ffconf.h"'
|
2019-03-04 23:05:42 +00:00
|
|
|
|
2019-05-11 21:51:44 +00:00
|
|
|
################################################################################
|
|
|
|
|
2019-03-04 23:05:42 +00:00
|
|
|
CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
|
2019-04-19 17:03:11 +00:00
|
|
|
CUSTOMDEFINES += -DLP_VER_MJ=$(LPVERSION_MAJOR) -DLP_VER_MN=$(LPVERSION_MINOR) -DLP_VER_BF=$(LPVERSION_BUGFX)
|
2020-06-26 20:17:06 +00:00
|
|
|
CUSTOMDEFINES += -DGFX_INC=$(GFX_INC) -DFFCFG_INC=$(FFCFG_INC)
|
2019-03-04 23:05:42 +00:00
|
|
|
|
2020-12-04 18:20:01 +00:00
|
|
|
# 0: UART_A, 1: UART_B.
|
|
|
|
#CUSTOMDEFINES += -DDEBUG_UART_PORT=0
|
|
|
|
|
|
|
|
#CUSTOMDEFINES += -DDEBUG
|
|
|
|
|
2021-05-12 21:38:34 +00:00
|
|
|
#TODO: Considering reinstating some of these when pointer warnings have been fixed.
|
|
|
|
WARNINGS := -Wall -Wno-array-bounds -Wno-stringop-overread -Wno-stringop-overflow
|
|
|
|
|
2019-10-22 17:22:55 +00:00
|
|
|
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
2021-05-12 21:38:34 +00:00
|
|
|
CFLAGS = $(ARCH) -Os -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 $(WARNINGS) $(CUSTOMDEFINES)
|
2019-03-04 23:05:42 +00:00
|
|
|
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=IPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
|
|
|
|
|
2019-05-11 21:51:44 +00:00
|
|
|
################################################################################
|
|
|
|
|
2019-05-17 14:09:59 +00:00
|
|
|
.PHONY: all clean
|
2019-03-04 23:05:42 +00:00
|
|
|
|
2019-05-17 14:09:59 +00:00
|
|
|
all: $(OUTPUTDIR)/$(TARGET).bin
|
2020-07-02 15:42:49 +00:00
|
|
|
@echo -n "Payload size is "
|
|
|
|
$(eval BIN_SIZE = $(shell wc -c < $(OUTPUTDIR)/$(TARGET).bin))
|
|
|
|
@echo $(BIN_SIZE)
|
|
|
|
@echo "Max size is 126296 Bytes."
|
|
|
|
@if [ ${BIN_SIZE} -gt 126296 ]; then echo "\e[1;33mPayload size exceeds limit!\e[0m"; fi
|
2019-03-04 23:05:42 +00:00
|
|
|
|
|
|
|
clean:
|
2019-05-11 21:51:44 +00:00
|
|
|
@rm -rf $(BUILDDIR)
|
|
|
|
@rm -rf $(OUTPUTDIR)
|
2019-03-04 23:05:42 +00:00
|
|
|
|
2019-05-17 14:09:59 +00:00
|
|
|
$(OUTPUTDIR)/$(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
$(OBJCOPY) -S -O binary $< $@
|
2019-03-04 23:05:42 +00:00
|
|
|
|
2019-05-11 21:51:44 +00:00
|
|
|
$(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS)
|
2019-03-04 23:05:42 +00:00
|
|
|
$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
|
|
|
|
|
2019-05-17 14:09:59 +00:00
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: $(SOURCEDIR)/%.c
|
|
|
|
@mkdir -p "$(@D)"
|
2020-06-26 20:17:06 +00:00
|
|
|
$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@
|
2019-03-04 23:05:42 +00:00
|
|
|
|
2019-05-17 14:09:59 +00:00
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: $(SOURCEDIR)/%.S
|
|
|
|
@mkdir -p "$(@D)"
|
2019-03-04 23:05:42 +00:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2020-06-26 20:17:06 +00:00
|
|
|
|
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: $(BDKDIR)/%.c
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
$(CC) $(CFLAGS) $(BDKINC) -c $< -o $@
|
|
|
|
|
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: $(BDKDIR)/%.S
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|