Lockpick_RCM/Makefile

98 lines
2.5 KiB
Makefile
Raw Normal View History

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
LPVERSION_MAJOR := 1
LPVERSION_MINOR := 1
2019-04-19 17:03:11 +00:00
LPVERSION_BUGFX := 1
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
VPATH = $(dir $(wildcard ./$(SOURCEDIR)/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/))
2019-05-11 21:51:44 +00:00
# Main and graphics.
OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \
2019-03-04 23:05:42 +00:00
start.o \
2019-05-11 21:51:44 +00:00
main.o heap.o \
2019-03-04 23:05:42 +00:00
keys.o \
gfx.o \
2019-05-11 21:51:44 +00:00
)
# Hardware.
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
clock.o cluster.o di.o gpio.o i2c.o mc.o sdram.o sdram_lp0.o pinmux.o se.o smmu.o tsec.o \
fuse.o \
sdmmc.o sdmmc_driver.o \
max17050.o max7762x.o max77620-rtc.o \
2019-03-04 23:05:42 +00:00
hw_init.o \
)
2019-05-11 21:51:44 +00:00
# Utilities.
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
btn.o util.o \
)
# Horizon.
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
nx_emmc.o \
pkg1.o pkg2.o sept.o \
)
# Libraries.
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
2019-03-04 23:05:42 +00:00
lz.o blz.o \
diskio.o ff.o ffunicode.o ffsystem.o \
)
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)
2019-03-04 23:05:42 +00:00
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb-interwork
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)
MODULEDIRS := $(wildcard modules/*)
2019-05-11 21:51:44 +00:00
################################################################################
2019-03-04 23:05:42 +00:00
.PHONY: all clean $(MODULEDIRS)
all: $(TARGET).bin
@echo -n "Payload size is "
2019-05-11 21:51:44 +00:00
@wc -c < $(OUTPUTDIR)/$(TARGET).bin
2019-03-04 23:05:42 +00:00
@echo "Max size is 126296 Bytes."
clean:
@rm -rf $(OBJS)
2019-05-11 21:51:44 +00:00
@rm -rf $(BUILDDIR)
@rm -rf $(OUTPUTDIR)
2019-03-04 23:05:42 +00:00
$(MODULEDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
2019-05-11 21:51:44 +00:00
$(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf $(MODULEDIRS)
$(OBJCOPY) -S -O binary $< $(OUTPUTDIR)/$@
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-11 21:51:44 +00:00
$(BUILDDIR)/$(TARGET)/%.o: %.c
2019-03-04 23:05:42 +00:00
$(CC) $(CFLAGS) -c $< -o $@
2019-05-11 21:51:44 +00:00
$(BUILDDIR)/$(TARGET)/%.o: %.S
@mkdir -p "$(BUILDDIR)"
@mkdir -p "$(BUILDDIR)/$(TARGET)"
@mkdir -p "$(OUTPUTDIR)"
2019-03-04 23:05:42 +00:00
$(CC) $(CFLAGS) -c $< -o $@