2 # libn64/Makefile: Makefile for libn64.
4 # n64chain: A (free) open-source N64 development toolchain.
5 # Copyright 2014-16 Tyler J. Stachecki <stachecki.tyler@gmail.com>
7 # This file is subject to the terms and conditions defined in
8 # 'LICENSE', which is part of this source code package.
12 FIXPATH
= $(subst /,\
,$1)
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
)
24 RSPASM
= $(call FIXPATH
,$(CURDIR
)/..
/tools
/bin
/rspasm
)
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
32 ASMFILES
= $(call FIXPATH
,\
36 os
/asm
/idle_thread.s \
41 CFILES
= $(call FIXPATH
,\
57 UCODES
= $(call FIXPATH
,\
66 DEPFILES
= $(OBJFILES
:.o
=.d
)
72 @echo
$(call FIXPATH
,"Building: libn64/$@")
76 # Generic compilation/assembly targets.
79 @echo
$(call FIXPATH
,"Assembling: libn64/$<")
80 @
$(CC
) -x assembler-with-cpp
$(CFLAGS
) $(OPTFLAGS
) -MMD
-c
$< -o
$@
82 %.o
: %.c
include/syscall.h
83 @echo
$(call FIXPATH
,"Compiling: libn64/$<")
84 @
$(CC
) $(CFLAGS
) $(OPTFLAGS
) -MMD
-c
$< -o
$@
87 @echo
$(call FIXPATH
,"Assembling: $(ROM_NAME)/$@")
88 @
$(CPP
) -E
-Iucodes
$< > $(<:.rsp
=.rsppch
)
89 @
$(RSPASM
) $(<:.rsp
=.rsppch
) -o
$(<:.rsp
=.bin
)
90 @
$(CC
) -x assembler-with-cpp
$(CFLAGS
) $(OPTFLAGS
) -MMD
-c
$(<:.rsp
=.rsps
) -o
$@
93 # Clean project target.
97 @echo
"Cleaning libn64..."
98 @
$(RM
) libn64.a
$(DEPFILES
) $(OBJFILES
)