-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile.base
72 lines (62 loc) · 2.97 KB
/
Makefile.base
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
# Our venv python3 so that dependencies work properly.
VENV_PYTHON3 := ${NAOMI_BASE}/tools/pyenv/bin/python3
# Top-level makefile compiling this project
TOPLEVEL_MAKEFILE := $(abspath $(firstword $(MAKEFILE_LIST)))
# Our makefile location for several tools.
MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TOOLS_DIR := ${MAKEFILE_DIR}/tools/
# Set up common library path definitions.
NAOMI_SH_INCLUDEPATHS = -I${MAKEFILE_DIR}libnaomi/ -I${MAKEFILE_DIR}libnaomi/overrides/ -I${NAOMI_SH_BASE}/include/ -I${NAOMI_SH_BASE}/sh-elf/include/
# For some reason, freetype expects to be special and different.
NAOMI_SH_INCLUDEPATHS += -I${NAOMI_SH_BASE}/include/freetype2/
# Add the path to libnaomi, built in this repository.
NAOMI_SH_LDLIBPATHS = -L${MAKEFILE_DIR}libnaomi/
# Add the path to libnaomimessage, built in this repository.
NAOMI_SH_LDLIBPATHS += -L${MAKEFILE_DIR}libnaomi/message/
# Add the path to libnaomisprite, built in this repository.
NAOMI_SH_LDLIBPATHS += -L${MAKEFILE_DIR}libnaomi/sprite/
# Add the path to libnaomisramfs, built in this repository.
NAOMI_SH_LDLIBPATHS += -L${MAKEFILE_DIR}libnaomi/sramfs/
# Set up the libraries we care about.
NAOMI_SH_LDLIBPATHS += -L${NAOMI_SH_BASE}/sh-elf/lib/ -L${NAOMI_SH_BASE}/lib/ -L${NAOMI_SH_BASE}/lib/gcc/sh-elf/${NAOMI_SH_GCC_VER}/
# SH-4 little endian ELF format.
NAOMI_SH_LDFLAGS = -mshlelf
# Use our supplied naomi linkscript.
NAOMI_SH_LDFLAGS += -T${MAKEFILE_DIR}naomi.ld
# Garbage collect (trim dead functions)
NAOMI_SH_LDFLAGS += --gc-sections
# Add library paths so we can link against newlib-provided system libs.
NAOMI_SH_LDFLAGS += ${NAOMI_SH_LDLIBPATHS}
# Set up gcc default options for AICA .c files.
ARMCC = ${NAOMI_ARM_CC}
# Set up processor flags.
ARMCC += -mcpu=arm7
# Don't use the system standard library (We supply our own stubs for necessary files).
# These largely have the same justification as their counterparts in the above CC section.
ARMCC += -ffreestanding -fomit-frame-pointer -nostdlib -nostartfiles -fno-stack-protector
# Add libnaomi to include path.
ARMCC += -I${MAKEFILE_DIR}libnaomi/aica/
# Make sure we compile optimized
ARMCC += -O3
# Make sure we error about a bunch of stuff.
ARMCC += -Wall -Werror
# Include debugging information for addr2line.
ARMCC += -g
# Set up linker default options for AICA binaries.
ARMLD = ${NAOMI_ARM_LD}
# Make sure we use the right ELF format.
ARMLD += -marmelf
# Force linking with simple linkscript that guarantees entrypoint.
ARMLD += -T${MAKEFILE_DIR}aica.ld
# Add libnaomi to library path.
ARMLD += -L${MAKEFILE_DIR}libnaomi/
# Add system library paths so we can link against libgcc.
ARMLD += -L${NAOMI_ARM_BASE}/arm-eabi/lib/ -L${NAOMI_ARM_BASE}/lib/gcc/arm-eabi/${NAOMI_ARM_GCC_VER}/
# Stuff we can share between the libnaomi makefile and the distributed one.
include ${MAKEFILE_DIR}Makefile.shared
# For our own C/C++ stuff, we want to enable -Werror as well as -Wall.
ENABLE_WALL ?= 1
ifeq ($(ENABLE_WALL), 1)
NAOMI_SH_CCFLAGS += -Werror
NAOMI_SH_CPPFLAGS += -Werror
endif