#
# psp makefile generics
#

.PHONY: package-pbp

#
# PSP toolchain overrides
#
CC      = psp-gcc
CXX     = psp-g++
AR      = psp-ar
OBJCOPY = psp-objcopy
STRIP   = /bin/true

# flag PSP build and link in c/psppower
ARCH_CFLAGS   += -G0 -isystem ${PREFIX}/sdk/include -DPATH_MAX=4096
ARCH_CXXFLAGS += ${ARCH_CFLAGS}
ARCH_LDFLAGS  += -L${PREFIX}/sdk/lib

SDL_CFLAGS = -I${PREFIX}/include/SDL
SDL_LDFLAGS = -lSDL -lGL -lpspirkeyb -lc -lpspvfpu -lpsprtc -lpsppower -lpspaudio -lpspgu -lpspge -lpspdisplay -lpsphprm -lpspctrl -lpspnet_inet -lpspuser
LIBPNG_CFLAGS = 
LIBPNG_LDFLAGS = -lpng

package: mzx
	psp-fixup-imports ${mzxrun}
	mksfo 'MegaZeux ${VERSION}' PARAM.SFO
	psp-strip ${mzxrun} -o ${mzxrun}.strip
	convert -scale 80x80 -border 32x0 -bordercolor transparent \
	        contrib/icons/quantump.png ICON0.PNG
	pack-pbp EBOOT.PBP PARAM.SFO ICON0.PNG NULL \
		 NULL NULL NULL ${mzxrun}.strip NULL
	rm -f ${mzxrun}.strip

clean:
	@rm -f EBOOT.PBP PARAM.SFO ICON0.PNG

build: package ${build}
	${CP} arch/psp/pad.config ${build}
	${CP} EBOOT.PBP ${build}
	${RM} ${build}/${mzxrun} ${build}/${mzxrun}.debug

#
# Vile hack, remove me ASAP
#
arch/psp/%.o: arch/psp/%.c
	$(if ${V},,@echo "  CC      " $<)
	${CC} -MD ${core_cflags} ${core_flags} -c $< -o $@

include arch/zip.inc
