# ========================================================================
#
# makefile
#
# A sample makefile for building your projects...
#
# Developed at Ground Zero Development (www.g0dev.com)
#
# ========================================================================

# Select the base name for the project

BASENAME = skel

# Specify the path to a bootable image that bootcode can be read from
# for example, \backups\mario.bin

BOOTCODE = __missing_bootcode_in_makefile__

# Specify the list of object files in the project

OBJS = main.o

# Select options for debug/ optimised

# Uncomment for debugging

CPPFLAGS = -g -DDEBUG
CFLAGS = -g -DDEBUG
AFLAGS =
LFLAGS = -g

# Uncomment for optimising

# CPPFLAGS = -O2
# CFLAGS = -O2
# AFLAGS =
# LFLAGS = 



# ------------------------------------------------------------------------
#
# Common commands and file extensions
#
#

XTRA_GCC_ARGS = -fno-exceptions -fgnu-linker
CC_CMD = mips-g0dev-n64-gcc $(XTRA_GCC_ARGS)
LINK_CMD = mips-g0dev-n64-gcc $(XTRA_GCC_ARGS) -Wl,-T,n64ld.x
AR_CMD = n64ar
EXE2ROM_CMD = exe2n64
CHKSUMROM_CMD = chksum64

#
# System commands
#

DEL_CMD = del
COPY_CMD = copy
ECHO_CMD = echo


# ------------------------------------------------------------------------
#
# Build rules for non-target files
#
#

.SUFFIXES:

.SUFFIXES: .cpp .c .asm .o

.cpp.o:
   $(CC_CMD) -c $(CPPFLAGS) $<

.c.o:
   $(CC_CMD) -c $(CFLAGS) $<

.asm.o:
   $(CC_CMD) -c $(AFLAGS) $<



# ------------------------------------------------------------------------
#
# Make a ROM image.  First creates an EXE in current dir and then converts
# it to a ROM image and removes the intermediate exe
#

$(BASENAME).n64: $(OBJS)
   $(LINK_CMD) $(LFLAGS) -o $(BASENAME).exe $(OBJS)
   $(EXE2ROM_CMD) -in:$(BASENAME).exe -out:$(BASENAME).n64 -addboot:$(BOOTCODE)
   $(DEL_CMD) $(BASENAME).exe
   $(CHKSUMROM_CMD) $(BASENAME).n64


# ------------------------------------------------------------------------
#
# Useful rules
#
#

clean:
   -$(DEL_CMD) *.o
   -$(DEL_CMD) *.exe
   -$(DEL_CMD) *.n64
   -$(DEL_CMD) log

