# Makefile for PSP MediaCenter
PSPSDK=$(shell psp-config --pspsdk-path)
PSP_EBOOT = EBOOT.PBP
PSPBIN = $(PSPSDK)/../bin
TARGET = PDA

PSP_FW_VERSION=380
# EBOOT.PBP Settings, to save hand editing
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = PSP-PDA V1.3.2-fw3x
PSP_EBOOT_ICON = ICON1.PNG

# Work thru the codecs, and sort out settings
PSPMC_BASE = ./
include codec.conf

INCDIR = sge
LIBDIR = sge
JOY = NO
CFLAGS = -Wno-long-long -O2 -G0 -DJOY_$(JOY) -I$(PSPDEV)/psp/include/SGE -I$(PSPDEV)/psp/include/tremor/ \
  -DPSPFW30X \
  -DUSE_PSP_IRKEYB  \
  -DNO_STDIO_REDIRECT

BUILD_PRX=1

# Now postprocess the values
OBJS := subprogram.o frontend.o notepad.o imageviewer.o calendar.o calculator.o addressbook.o clock.o music.o p_sprint.o \
     psp_main.o psp_irkeyb.o program.o $(PSP_OBJS)
# LIBS = \
# -lSGE -lSDL_image -lSDL_gfx -lSDL_ttf -lfreetype $(PLAYER_LIBS) \
# -lpspaudiolib  -lpspaudio -lpsphprm -lpspusb -lpspusbstor -lpsputility  \
# -lpng -lz -ljpeg -lstdc++ -lm 

LIBS = $(PLAYER_LIBS) \
-lSGE -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL \
-lfreetype \
-lmad \
-lvorbisidec \
-laac \
-lpspirkeyb \
-lpspaudiolib \
-lpspaudio \
-lpsphprm \
-lpspusb \
-lpspusbstor \
-lpsputility \
-lpsppower \
-lpng \
-ljpeg \
-lpspdebug \
-lpspgu \
-lpspctrl \
-lpspge \
-lpspdisplay \
-lpsphprm \
-lpspsdk \
-lpsprtc \
-lpspaudio \
-lpspnet \
-lpspnet_inet \
-lpspnet_apctl \
-lpspnet_resolver \
-lpsputility \
-lstdc++ \
-lz \
-lm \
-lc \
-lpspsdk \
-lpspuser \
-lpspkernel 

# Take cflags and ldflags from codec script and add them in
CFLAGS  := -G0 $(PSP_CFLAGS) $(CFLAGS)
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
#CXXFLAGS := $(CFLAGS) -fno-exceptions -fno-rtti
CXXFLAGS := $(CFLAGS)
#ASFLAGS := $(CFLAGS)
LDFLAGS := $(PSP_LDFLAGS) $(LDFLAGS) 
EXTRA_TARGETS := header EBOOT.PBP
#USE_PSPSDK_LIBC = 1


# This must be included here
include $(PSPSDK)/lib/build.mak

# Now our own build targets
#deps: 

all: EBOOT.PBP

install: all
	@mkdir -p /media/usbdisk/psp/game380/PDA/
	cp EBOOT.PBP /media/usbdisk/psp/game380/PDA/

cleanall:
	rm -f *.elf *.o *.a $(PSP_EBOOT) $(FINAL_TARGET) 
cleanup:
	@find -name "*.bak" -exec rm -f {} \;
	@find -name "*.?~" -exec rm -f {} \;

indent:
	@find -name "*.[h|c]" -exec indent -kr -l120 '{}' \;

# Generate the headerfile for included codecs
header:
	@echo Generating Header
	@rm -rf codecincs.h
	@echo /*Generated by makefile, do not hand edit!!!*/ > codecincs.h
	@echo -e $(PSP_CODEC_INCLUDE) >> codecincs.h
