libn64: Add a thread for managing the SP.
[n64chain.git] / libn64 / Makefile
1 #
2 # libn64/Makefile: Makefile for libn64.
3 #
4 # n64chain: A (free) open-source N64 development toolchain.
5 # Copyright 2014-16 Tyler J. Stachecki <stachecki.tyler@gmail.com>
6 #
7 # This file is subject to the terms and conditions defined in
8 # 'LICENSE', which is part of this source code package.
9 #
10
11 ifdef SystemRoot
12 FIXPATH = $(subst /,\,$1)
13 RM = del /Q
14 else
15 FIXPATH = $1
16 RM = rm -f
17 endif
18
19 AS = $(call FIXPATH,$(CURDIR)/../tools/bin/mips64-elf-as)
20 AR = $(call FIXPATH,$(CURDIR)/../tools/bin/mips64-elf-gcc-ar)
21 CC = $(call FIXPATH,$(CURDIR)/../tools/bin/mips64-elf-gcc)
22 CPP = $(call FIXPATH,$(CURDIR)/../tools/bin/mips64-elf-cpp)
23
24 RSPASM = $(call FIXPATH,$(CURDIR)/../tools/bin/rspasm)
25
26 CFLAGS = -Wall -Wextra -pedantic -std=c99 -I. -Iinclude -Ipriv_include
27 OPTFLAGS = -Os -march=vr4300 -mtune=vr4300 -mabi=eabi -mgp32 -mlong32 \
28 -flto -ffat-lto-objects -ffunction-sections -fdata-sections \
29 -G4 -mno-extern-sdata -mgpopt -mfix4300 -mbranch-likely \
30 -mno-check-zero-division
31
32 ASMFILES = $(call FIXPATH,\
33 os/asm/boot.s \
34 os/asm/context.s \
35 os/asm/exception.s \
36 os/asm/idle_thread.s \
37 os/asm/message.s \
38 os/asm/syscall.s \
39 )
40
41 CFILES = $(call FIXPATH,\
42 io/init.c \
43 io/pi_thread.c \
44 os/fbtext.c \
45 os/main.c \
46 os/mm.c \
47 os/panic.c \
48 os/thread.c \
49 os/time.c \
50 rcp/vi.c \
51 sp/init.c \
52 sp/sp_thread.c \
53 )
54
55 UCODES = $(call FIXPATH,\
56 ucodes/init.rsp \
57 )
58
59 OBJFILES = \
60 $(CFILES:.c=.o) \
61 $(ASMFILES:.s=.o) \
62 $(UCODES:.rsp=.o)
63
64 DEPFILES = $(OBJFILES:.o=.d)
65
66 #
67 # Primary targets.
68 #
69 libn64.a: $(OBJFILES)
70 @echo $(call FIXPATH,"Building: libn64/$@")
71 @$(AR) rcs $@ $^
72
73 #
74 # Generic compilation/assembly targets.
75 #
76 %.o: %.s
77 @echo $(call FIXPATH,"Assembling: libn64/$<")
78 @$(CC) -x assembler-with-cpp $(CFLAGS) $(OPTFLAGS) -MMD -c $< -o $@
79
80 %.o: %.c include/syscall.h
81 @echo $(call FIXPATH,"Compiling: libn64/$<")
82 @$(CC) $(CFLAGS) $(OPTFLAGS) -MMD -c $< -o $@
83
84 %.o: %.rsp %.rsps
85 @echo $(call FIXPATH,"Assembling: $(ROM_NAME)/$@")
86 @$(CPP) -E -Iucodes $< > $(<:.rsp=.rsppch)
87 @$(RSPASM) $(<:.rsp=.rsppch) -o $(<:.rsp=.bin)
88 @$(CC) -x assembler-with-cpp $(CFLAGS) $(OPTFLAGS) -MMD -c $(<:.rsp=.rsps) -o $@
89
90 #
91 # Clean project target.
92 #
93 .PHONY: clean
94 clean:
95 @echo "Cleaning libn64..."
96 @$(RM) libn64.a $(DEPFILES) $(OBJFILES)
97