libn64: Don't generate breaks for divides.
[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 -mno-check-zero-division
28
29 ASMFILES = $(call FIXPATH,\
30 os/asm/boot.s \
31 os/asm/context.s \
32 os/asm/exception.s \
33 os/asm/idle_thread.s \
34 os/asm/message.s \
35 os/asm/syscall.s \
36 )
37
38 CFILES = $(call FIXPATH,\
39 io/init.c \
40 io/thread.c \
41 os/fbtext.c \
42 os/main.c \
43 os/mm.c \
44 os/panic.c \
45 os/thread.c \
46 os/time.c \
47 rcp/vi.c \
48 )
49
50 OBJFILES = \
51 $(CFILES:.c=.o) \
52 $(ASMFILES:.s=.o)
53
54 DEPFILES = $(OBJFILES:.o=.d)
55
56 #
57 # Primary targets.
58 #
59 libn64.a: $(OBJFILES)
60 @echo $(call FIXPATH,"Building: libn64/$@")
61 @$(AR) rcs $@ $^
62
63 #
64 # Generic compilation/assembly targets.
65 #
66 %.o: %.s
67 @echo $(call FIXPATH,"Assembling: libn64/$<")
68 @$(CC) -x assembler-with-cpp $(CFLAGS) $(OPTFLAGS) -MMD -c $< -o $@
69
70 %.o: %.c include/syscall.h
71 @echo $(call FIXPATH,"Compiling: libn64/$<")
72 @$(CC) $(CFLAGS) $(OPTFLAGS) -MMD -c $< -o $@
73
74 #
75 # Clean project target.
76 #
77 .PHONY: clean
78 clean:
79 @echo "Cleaning libn64..."
80 @$(RM) libn64.a $(DEPFILES) $(OBJFILES)
81