libn64/os: First pass at an I/O engine implementation.
[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
23 CFLAGS = -Wall -Wextra -pedantic -std=c99 -I. -Iinclude -Ipriv_include
24 OPTFLAGS = -Os -march=vr4300 -mtune=vr4300 -mabi=eabi -mgp32 -mlong32 \
25 -flto -ffat-lto-objects -ffunction-sections -fdata-sections \
26 -G4 -mno-extern-sdata -mgpopt -mfix4300 -mbranch-likely
27
28 ASMFILES = $(call FIXPATH,\
29 os/asm/boot.s \
30 os/asm/context.s \
31 os/asm/exception.s \
32 os/asm/idle_thread.s \
33 os/asm/message.s \
34 os/asm/syscall.s \
35 )
36
37 CFILES = $(call FIXPATH,\
38 io/init.c \
39 io/thread.c \
40 os/fbtext.c \
41 os/main.c \
42 os/mm.c \
43 os/panic.c \
44 os/thread.c \
45 os/time.c \
46 rcp/vi.c \
47 )
48
49 OBJFILES = \
50 $(CFILES:.c=.o) \
51 $(ASMFILES:.s=.o)
52
53 DEPFILES = $(OBJFILES:.o=.d)
54
55 #
56 # Primary targets.
57 #
58 libn64.a: $(OBJFILES)
59 @echo $(call FIXPATH,"Building: libn64/$@")
60 @$(AR) rcs $@ $^
61
62 #
63 # Generic compilation/assembly targets.
64 #
65 %.o: %.s
66 @echo $(call FIXPATH,"Assembling: libn64/$<")
67 @$(CC) -x assembler-with-cpp $(CFLAGS) $(OPTFLAGS) -MMD -c $< -o $@
68
69 %.o: %.c include/syscall.h
70 @echo $(call FIXPATH,"Compiling: libn64/$<")
71 @$(CC) $(CFLAGS) $(OPTFLAGS) -MMD -c $< -o $@
72
73 #
74 # Clean project target.
75 #
76 .PHONY: clean
77 clean:
78 @echo "Cleaning libn64..."
79 @$(RM) libn64.a $(DEPFILES) $(OBJFILES)
80