forked from d0k3/GodMode9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (62 loc) · 2.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/base_tools
include Makefile.common
# Base definitions
export VERSION := $(shell git describe --tags --abbrev=8)
export DBUILTS := $(shell date +'%Y%m%d%H%M%S')
export DBUILTL := $(shell date +'%Y-%m-%d %H:%M:%S')
export OUTDIR := output
export RELDIR := release
# Definitions for initial RAM disk
VRAM_OUT := $(OUTDIR)/vram0.tar
VRAM_FLAGS := --format=v7 --blocking-factor=1
VRAM_DATA := data
# Definitions for ARM binaries
export INCLUDE := -I"$(shell pwd)/common"
export ASFLAGS := -g -x assembler-with-cpp $(INCLUDE)
export CFLAGS := -DDBUILTS="\"$(DBUILTS)\"" -DDBUILTL="\"$(DBUILTL)\"" -DVERSION="\"$(VERSION)\"" -DFLAVOR="\"$(FLAVOR)\"" \
-g -O2 -Wall -Wextra -Wpedantic -Wcast-align -Wno-main \
-fomit-frame-pointer -ffast-math -std=gnu11 \
-Wno-unused-function $(INCLUDE)
export LDFLAGS := -Tlink.ld -nostartfiles -Wl,--gc-sections,-z,max-page-size=512
ELF := arm9/arm9.elf arm11/arm11.elf
.PHONY: all firm vram0 elf release clean
all: firm
clean:
@set -e; for elf in $(ELF); do \
$(MAKE) --no-print-directory -C $$(dirname $$elf) clean; \
done
@rm -rf $(OUTDIR) $(RELDIR) $(FIRM) $(FIRMD) $(VRAM_OUT)
release: clean
@$(MAKE) --no-print-directory firm
@$(MAKE) --no-print-directory firm NTRBOOT=1
@mkdir -p $(RELDIR)
@mkdir -p $(RELDIR)/ntrboot
@mkdir -p $(RELDIR)/elf
@cp $(FIRM) $(RELDIR)
@cp $(OUTDIR)/$(FLAVOR)_ntr.firm $(RELDIR)/ntrboot/
@cp $(OUTDIR)/$(FLAVOR)_ntr_dev.firm $(RELDIR)/ntrboot/
@cp $(OUTDIR)/$(FLAVOR).firm $(RELDIR)/
@cp $(OUTDIR)/$(FLAVOR)_dev.firm $(RELDIR)/
@cp $(ELF) $(RELDIR)/elf
@cp $(CURDIR)/README.md $(RELDIR)
@cp $(CURDIR)/HelloScript.gm9 $(RELDIR)
@cp -R $(CURDIR)/resources/gm9 $(RELDIR)/gm9
@-7z a $(RELDIR)/$(FLAVOR)-$(VERSION)-$(DBUILTS).zip ./$(RELDIR)/*
vram0:
@mkdir -p "$(OUTDIR)"
@echo "Creating $(VRAM_OUT)"
@tar cf $(VRAM_OUT) $(VRAM_FLAGS) --xform='s/^.*\///' $(README) $(SPLASH)
@-tar rf $(VRAM_OUT) $(VRAM_FLAGS) --xform='s/^$(VRAM_DATA)\///' $(VRAM_DATA)/*
elf:
@set -e; for elf in $(ELF); do \
echo "Building $$elf"; \
$(MAKE) --no-print-directory -C $$(dirname $$elf); \
done
firm: elf vram0
@test `wc -c <$(VRAM_OUT)` -le 3145728
@mkdir -p $(call dirname,"$(FIRM)") $(call dirname,"$(FIRMD)")
firmtool build $(FIRM) $(FTFLAGS) -g -A 0x18000000 -D $(ELF) $(VRAM_OUT) -C NDMA XDMA memcpy
firmtool build $(FIRMD) $(FTDFLAGS) -g -A 0x18000000 -D $(ELF) $(VRAM_OUT) -C NDMA XDMA memcpy