-
Notifications
You must be signed in to change notification settings - Fork 11
/
common.mk
42 lines (35 loc) · 1.24 KB
/
common.mk
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
PSN00BSDK ?= /opt/psn00bsdk/
PREFIX = mipsel-unknown-elf-
INCLUDE := -I$(realpath $(PSN00BSDK)/libpsn00b/include)
LIBDIRS := -L$(realpath $(PSN00BSDK)/libpsn00b)
GCC_VERSION = 7.4.0
GCC_BASE = /usr/local/mipsel-unknown-elf
CFLAGS ?= -g -msoft-float -O3 -D__PLAYSTATION__ -fno-builtin -fdata-sections -ffunction-sections -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare
CPPFLAGS ?= $(CFLAGS) -fno-exceptions -std=c++1z
AFLAGS ?= -g -msoft-float
LDFLAGS ?= -g -Ttext=0x80010000 -gc-sections -T $(GCC_BASE)/mipsel-unknown-elf/lib/ldscripts/elf32elmip.x
# Toolchain programs
CC = $(PREFIX)gcc
CXX = $(PREFIX)g++
AS = $(PREFIX)as
AR = $(PREFIX)ar
LD = $(PREFIX)ld
RANLIB = $(PREFIX)ranlib
OBJCOPY = $(PREFIX)objcopy
LIBS ?=
CFILES = $(notdir $(wildcard *.c))
CPPFILES = $(notdir $(wildcard *.cpp))
AFILES = $(notdir $(wildcard *.s))
OFILES += $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o))
build/%.o: %.c
@mkdir -p $(dir $@)
@echo "CC $<"
@$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
build/%.o: %.cpp
@mkdir -p $(dir $@)
@echo "CXX $<"
@$(CXX) $(CPPFLAGS) $(INCLUDE) -c $< -o $@
build/%.o: %.s
@mkdir -p $(dir $@)
@echo "AS $<"
@$(AS) $(AFLAGS) $(INCLUDE) $< -o $@