hekate/Makefile

110 lines
3 KiB
Makefile
Raw Normal View History

2018-05-01 05:15:48 +00:00
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
2018-06-08 09:42:24 +00:00
include $(DEVKITARM)/base_rules
2018-05-01 05:15:48 +00:00
################################################################################
IPL_LOAD_ADDR := 0x40008000
IPL_MAGIC := 0x43544349 #"ICTC"
BLVERSION_MAJOR := 4
2019-02-24 01:09:07 +00:00
BLVERSION_MINOR := 8
BLVERSION_HOTFX := 0
BL_RESERVED := 0
################################################################################
TARGET := hekate
BUILDDIR := build
OUTPUTDIR := output
2018-08-13 08:58:24 +00:00
SOURCEDIR = bootloader
VPATH = $(dir $(wildcard ./$(SOURCEDIR)/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/))
2018-08-07 14:53:58 +00:00
# Main and graphics.
OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \
2018-05-01 05:15:48 +00:00
start.o \
main.o heap.o \
gfx.o tui.o \
fe_emmc_tools.o fe_info.o fe_tools.o \
)
# Hardware.
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
clock.o cluster.o di.o gpio.o i2c.o mc.o sdram.o pinmux.o se.o smmu.o tsec.o uart.o \
fuse.o kfuse.o \
sdmmc.o sdmmc_driver.o \
bq24193.o max17050.o max7762x.o max77620-rtc.o \
2018-11-27 09:45:43 +00:00
hw_init.o \
2018-05-01 05:15:48 +00:00
)
2018-08-07 14:53:58 +00:00
# Utilities.
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
btn.o dirlist.o ianos.o util.o \
config.o ini.o \
)
# Horizon.
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
nx_emmc.o \
hos.o hos_config.o pkg1.o pkg2.o secmon_exo.o sept.o \
)
# Libraries.
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
2018-08-13 08:58:24 +00:00
lz.o blz.o \
diskio.o ff.o ffunicode.o ffsystem.o \
elfload.o elfreloc_arm.o \
)
2018-05-01 05:15:48 +00:00
################################################################################
CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR) -DBL_MAGIC=$(IPL_MAGIC)
CUSTOMDEFINES += -DBL_VER_MJ=$(BLVERSION_MAJOR) -DBL_VER_MN=$(BLVERSION_MINOR) -DBL_VER_HF=$(BLVERSION_HOTFX) -DBL_RESERVED=$(BL_RESERVED)
CUSTOMDEFINES += -DMENU_LOGO_ENABLE
# 0: UART_A, 1: UART_B.
2018-12-16 14:52:38 +00:00
#CUSTOMDEFINES += -DDEBUG_UART_PORT=0
#CUSTOMDEFINES += -DDEBUG
2018-05-01 05:15:48 +00:00
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
2018-08-21 01:14:31 +00:00
CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall $(CUSTOMDEFINES)
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=IPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
2018-05-01 05:15:48 +00:00
2018-08-07 14:53:58 +00:00
MODULEDIRS := $(wildcard modules/*)
################################################################################
2018-08-07 14:53:58 +00:00
.PHONY: all clean $(MODULEDIRS)
2018-05-01 05:15:48 +00:00
2018-05-11 02:28:53 +00:00
all: $(TARGET).bin
2018-07-01 01:56:58 +00:00
@echo -n "Payload size is "
@wc -c < $(OUTPUTDIR)/$(TARGET).bin
2018-07-01 01:56:58 +00:00
@echo "Max size is 126296 Bytes."
2018-05-01 05:15:48 +00:00
clean:
@rm -rf $(OBJS)
@rm -rf $(BUILDDIR)
@rm -rf $(OUTPUTDIR)
2018-08-07 14:53:58 +00:00
$(MODULEDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
2018-05-01 05:15:48 +00:00
$(TARGET).bin: $(BUILDDIR)/$(TARGET)/$(TARGET).elf $(MODULEDIRS)
$(OBJCOPY) -S -O binary $< $(OUTPUTDIR)/$@
@printf ICTC$(BLVERSION_MAJOR)$(BLVERSION_MINOR) >> $(OUTPUTDIR)/$@
2018-05-01 05:15:48 +00:00
$(BUILDDIR)/$(TARGET)/$(TARGET).elf: $(OBJS)
2018-08-13 08:58:24 +00:00
$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
2018-05-01 05:15:48 +00:00
$(BUILDDIR)/$(TARGET)/%.o: %.c
2018-05-01 05:15:48 +00:00
$(CC) $(CFLAGS) -c $< -o $@
$(BUILDDIR)/$(TARGET)/%.o: %.S
@mkdir -p "$(BUILDDIR)"
@mkdir -p "$(BUILDDIR)/$(TARGET)"
@mkdir -p "$(OUTPUTDIR)"
2018-05-01 05:15:48 +00:00
$(CC) $(CFLAGS) -c $< -o $@