#GameSpy.net PSP Makefile
#Included from sample-specific Makefiles

DEVKIT_TOP   = /usr/local/psp/devkit
INCDIR       = $(DEVKIT_TOP)/include
PLATFORMDEF  = _PSP
AS           = psp-gcc
CC           = psp-gcc
LD           = psp-ld

DBGFLAG      = -g
OPTFLAG     = -O2
CFLAGS       = -W -Wall $(DBGFLAG) $(OPTFLAG) -D$(PLATFORMDEF) -I$(INCDIR) $(SDK_CFLAGS)
ASFLAGS      = $(DBGFLAG)
LDFLAGS      = $(DBGFLAG)
LDLIBS      = -lgum -lgu -lm
LIB = \
    $(DEVKIT_TOP)/lib/wlan_stub.a \
    $(DEVKIT_TOP)/lib/rtc_stub.a \
    $(DEVKIT_TOP)/lib/pspnet_stub_weak.a \
    $(DEVKIT_TOP)/lib/pspnet_inet_stub_weak.a \
    $(DEVKIT_TOP)/lib/pspnet_resolver_stub_weak.a \
    $(DEVKIT_TOP)/lib/pspnet_apctl_stub_weak.a \
    $(DEVKIT_TOP)/lib/pspnet_ap_dialog_dummy_stub_weak.a

.SUFFIXES: .c .s
	
all:	$(TARGET).prx $(TARGET).elf

clean:
	rm -f $(TARGET).prx $(TARGET).elf $(OBJS) *.o *~ *.bak 

$(TARGET).prx: $(OBJS)
	$(LINK.c) $^ $(LDLIBS) $(LIB) -startfiles -o $@

$(TARGET).elf: $(OBJS)
	$(LINK.c) $^ $(LDLIBS) $(LIB) -zgenelf -o $@

.s.o:
	$(AS) $(ASFLAGS) -I$(INCDIR) -o $@ $< > $*.lst

.c.o:
	$(CC) $(CFLAGS) -D$(PLATFORMDEF) -I$(INCDIR) -c $< -o $*.o > $*.lst
	
#----------- rules --------------
-include PathDefs
PathDefs:
	psp-path-setup > PathDefs || (rm -f PathDefs ; exit 1)
