2019-08-14 20:29:04 +01:00
|
|
|
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
|
|
|
|
|
|
|
|
ifeq ($(strip $(DEVKITARM)),)
|
|
|
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(DEVKITARM)/base_rules
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
IPL_LOAD_ADDR := 0x40003000
|
2019-11-21 15:02:45 +00:00
|
|
|
LPVERSION_MAJOR := 2
|
2020-04-05 16:25:35 +01:00
|
|
|
LPVERSION_MINOR := 5
|
2020-03-19 15:19:56 +00:00
|
|
|
LPVERSION_BUGFX := 0
|
2019-08-14 20:29:04 +01:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
2019-08-15 21:16:48 +01:00
|
|
|
TARGET := TegraExplorer
|
2019-08-14 20:29:04 +01:00
|
|
|
BUILDDIR := build
|
|
|
|
OUTPUTDIR := output
|
|
|
|
SOURCEDIR = source
|
|
|
|
|
|
|
|
OBJS = $(patsubst $(SOURCEDIR)/%.S, $(BUILDDIR)/$(TARGET)/%.o, \
|
|
|
|
$(patsubst $(SOURCEDIR)/%.c, $(BUILDDIR)/$(TARGET)/%.o, \
|
|
|
|
$(call rwildcard, $(SOURCEDIR), *.S *.c)))
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
|
|
|
|
CUSTOMDEFINES += -DLP_VER_MJ=$(LPVERSION_MAJOR) -DLP_VER_MN=$(LPVERSION_MINOR) -DLP_VER_BF=$(LPVERSION_BUGFX)
|
|
|
|
|
2019-11-21 15:02:45 +00:00
|
|
|
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
2019-08-14 20:29:04 +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)
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
|
|
|
all: $(OUTPUTDIR)/$(TARGET).bin
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@rm -rf $(BUILDDIR)
|
|
|
|
@rm -rf $(OUTPUTDIR)
|
|
|
|
|
|
|
|
$(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."
|
|
|
|
|
|
|
|
$(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS)
|
|
|
|
$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
|
|
|
|
|
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: $(SOURCEDIR)/%.c
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
$(BUILDDIR)/$(TARGET)/%.o: $(SOURCEDIR)/%.S
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|