2019-05-17 16:09:59 +02:00
|
|
|
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
|
|
|
|
|
2019-03-05 00:05:42 +01:00
|
|
|
ifeq ($(strip $(DEVKITARM)),)
|
|
|
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(DEVKITARM)/base_rules
|
|
|
|
|
2019-05-11 23:51:44 +02:00
|
|
|
################################################################################
|
2019-03-05 00:05:42 +01:00
|
|
|
|
2019-05-11 23:51:44 +02:00
|
|
|
IPL_LOAD_ADDR := 0x40003000
|
2019-04-18 17:02:15 +02:00
|
|
|
LPVERSION_MAJOR := 1
|
2019-09-28 00:31:43 +02:00
|
|
|
LPVERSION_MINOR := 6
|
2019-10-21 19:06:39 +02:00
|
|
|
LPVERSION_BUGFX := 4
|
2019-04-19 19:03:11 +02:00
|
|
|
|
2019-05-11 23:51:44 +02:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
TARGET := Lockpick_RCM
|
|
|
|
BUILDDIR := build
|
|
|
|
OUTPUTDIR := output
|
2019-03-05 00:05:42 +01:00
|
|
|
SOURCEDIR = source
|
2019-05-17 16:09:59 +02:00
|
|
|
|
|
|
|
OBJS = $(patsubst $(SOURCEDIR)/%.S, $(BUILDDIR)/$(TARGET)/%.o, \
|
|
|
|
$(patsubst $(SOURCEDIR)/%.c, $(BUILDDIR)/$(TARGET)/%.o, \
|
|
|
|
$(call rwildcard, $(SOURCEDIR), *.S *.c)))
|
2019-03-05 00:05:42 +01:00
|
|
|
|
2019-05-11 23:51:44 +02:00
|
|
|
################################################################################
|
|
|
|
|
2019-03-05 00:05:42 +01:00
|
|
|
CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
|
2019-04-19 19:03:11 +02:00
|
|
|
CUSTOMDEFINES += -DLP_VER_MJ=$(LPVERSION_MAJOR) -DLP_VER_MN=$(LPVERSION_MINOR) -DLP_VER_BF=$(LPVERSION_BUGFX)
|
2019-03-05 00:05:42 +01:00
|
|
|
|
2019-10-22 19:22:55 +02:00
|
|
|
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
2019-03-05 00:05:42 +01:00
|
|
|
CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -std=gnu11 -Wall $(CUSTOMDEFINES)
|
|
|
|
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=IPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
|
|
|
|
|
2019-05-11 23:51:44 +02:00
|
|
|
################################################################################
|
|
|
|
|
2019-05-17 16:09:59 +02:00
|
|
|
.PHONY: all clean
|
2019-03-05 00:05:42 +01:00
|
|
|
|
2019-05-17 16:09:59 +02:00
|
|
|
all: $(OUTPUTDIR)/$(TARGET).bin
|
2019-03-05 00:05:42 +01:00
|
|
|
|
|
|
|
clean:
|
2019-05-11 23:51:44 +02:00
|
|
|
@rm -rf $(BUILDDIR)
|
|
|
|
@rm -rf $(OUTPUTDIR)
|
2019-03-05 00:05:42 +01:00
|
|
|
|
2019-05-17 16:09:59 +02:00
|
|
|
$(OUTPUTDIR)/$(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
$(OBJCOPY) -S -O binary $< $@
|
|
|
|
@echo -n "Payload size is "
|
|
|
|
@wc -c < $@
|
|
|
|
@echo "Max size is 126296 Bytes."
|
2019-03-05 00:05:42 +01:00
|
|
|
|
2019-05-11 23:51:44 +02:00
|
|
|
$(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS)
|
2019-03-05 00:05:42 +01:00
|
|
|
$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
|
|
|
|
|
2019-05-17 16:09:59 +02:00
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: $(SOURCEDIR)/%.c
|
|
|
|
@mkdir -p "$(@D)"
|
2019-03-05 00:05:42 +01:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2019-05-17 16:09:59 +02:00
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: $(SOURCEDIR)/%.S
|
|
|
|
@mkdir -p "$(@D)"
|
2019-03-05 00:05:42 +01:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|