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
,\
56 UCODES
= $(call FIXPATH
,\
65 DEPFILES
= $(OBJFILES
:.o
=.d
)
71 @echo
$(call FIXPATH
,"Building: libn64/$@")
75 # Generic compilation/assembly targets.
78 @echo
$(call FIXPATH
,"Assembling: libn64/$<")
79 @
$(CC
) -x assembler-with-cpp
$(CFLAGS
) $(OPTFLAGS
) -MMD
-c
$< -o
$@
81 %.o
: %.c
include/syscall.h
82 @echo
$(call FIXPATH
,"Compiling: libn64/$<")
83 @
$(CC
) $(CFLAGS
) $(OPTFLAGS
) -MMD
-c
$< -o
$@
86 @echo
$(call FIXPATH
,"Assembling: $(ROM_NAME)/$@")
87 @
$(CPP
) -E
-Iucodes
$< > $(<:.rsp
=.rsppch
)
88 @
$(RSPASM
) $(<:.rsp
=.rsppch
) -o
$(<:.rsp
=.bin
)
89 @
$(CC
) -x assembler-with-cpp
$(CFLAGS
) $(OPTFLAGS
) -MMD
-c
$(<:.rsp
=.rsps
) -o
$@
92 # Clean project target.
96 @echo
"Cleaning libn64..."
97 @
$(RM
) libn64.a
$(DEPFILES
) $(OBJFILES
)