#------------------------------------------------------------
# Copyright (C)2002 Sony Computer Entertainment America Inc.
#
# This file is subject to the terms and conditions of the GNU
# General Public Licence Version 2.  See the file "COPYING"
# in the main directory of this archive for more details.
#------------------------------------------------------------

TARGET = main
OBJS = ramfont88.o ramfont1612.o ramfont.o main.o dlib_rfont.o dlib_file.o os.o ps2_dma.o ps2_vif.o debug.o sjoy.o

CDEBUGFLAGS = -g -DDEBUG
DEFINES = 

ifdef __in_source_tree

INCLUDES = -I $(HEADSDIR)
VPU_LDSCRIPT = -T $(OBJSDIR)/ldscripts/vpu.cmd
LIBS = -L $(OBJSDIR) -lm -lps2dev

else

INCLUDES = 
VPU_LDSCRIPT = -T vpu.cmd
LIBS = -lm -lps2dev

endif

CFLAGS = $(CDEBUGFLAGS) $(DEFINES) $(INCLUDES) -Wall -fno-common
ASFLAGS = $(CFLAGS)

VPU_TARGET = dmachainhook.elf
VPU_OBJS = dmachainhook.vo

VPU_AS = ee-dvp-as
VPU_ASFLAGS = 

.SUFFIXES: .c .s .dsm .vo .elf

.s.o:
	$(CC) $(DEBUGFLAGS) -c -o $@ $<

.dsm.vo:
	$(VPU_AS) $(VPU_ASFLAGS) -o $@ $<


all: copy

copy: $(TARGET) $(VPU_TARGET)
	cp -f $(TARGET) ../harness
	cp -f $(VPU_TARGET) ../

$(TARGET): $(OBJS)
	$(CC) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)

$(VPU_TARGET): $(VPU_OBJS)
	$(LD) -o $@ $(VPU_OBJS) $(VPU_LDSCRIPT)

clean:
	rm -f $(TARGET)
	rm -f $(OBJS)
	rm -f $(VPU_TARGET)
	rm -f $(VPU_OBJS)
	rm -f Makefile.bak
	rm -f .depend

run: all
	../harness -h

#
# depend
#
depend: 
	makedepend -f- $(CFALGS) $(INCLUDES) $(wildcard *.[chS]) > .depend

# include dependency files if they exist
ifneq ($(wildcard .depend),)
include .depend
endif

