PSP = 1
#WIN = 1

ifdef PSP
TARGET = REminiscence
PSPSDK = $(shell psp-config --pspsdk-path)
PSPBIN = $(PSPSDK)/../bin
endif

ifdef PSP
SDL_CFLAGS := $(shell $(PSPBIN)/sdl-config --cflags)
SDL_LIBS := $(shell $(PSPBIN)/sdl-config --libs)
endif

ifdef WIN
SDL_CFLAGS = -I/mingw/include/SDL
SDL_LIBS = -lSDLmain -lSDL -lz
else
SDL_CFLAGS = `sdl-config --cflags`
SDL_LIBS = `sdl-config --libs`
endif

DEFINES+=-DBYPASS_PROTECTION

ifdef PSP
DEFINES+= -DPSP
endif

ifndef PSP
CXX = g++
CXXFLAGS:= -g -O -Wall -Wuninitialized -Wno-unknown-pragmas -Wshadow -Wimplicit
CXXFLAGS+= -Wundef -Wreorder -Wwrite-strings -Wnon-virtual-dtor -Wno-multichar
endif
CXXFLAGS+= $(SDL_CFLAGS) $(DEFINES)
ifdef PSP
CXXFLAGS+= -O2 -G0 -fno-exceptions -fno-rtti
endif

SRCS = collision.cpp cutscene.cpp file.cpp game.cpp graphics.cpp main.cpp menu.cpp \
	mixer.cpp mod_player.cpp piege.cpp resource.cpp scaler.cpp sfx_player.cpp \
	staticres.cpp systemstub_sdl.cpp unpack.cpp util.cpp video.cpp

OBJS = $(SRCS:.cpp=.o)
DEPS = $(SRCS:.cpp=.d)

ifdef PSP
LIBS = $(SDL_LIBS) -lz -lstdc++

EXTRA_TARGETS = EBOOT.PBP kxploit
PSP_EBOOT_TITLE = REminiscence PSP v0.1.9
PSP_EBOOT_ICON = icon.png
PSP_EBOOT_PIC1 = pic1.png
include $(PSPSDK)/lib/build.mak
endif

rs: $(OBJS)
	$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(SDL_LIBS) -lz

.cpp.o:
	$(CXX) $(CXXFLAGS) -MMD -c $< -o $*.o

ifndef PSP
clean:
	rm -f *.o *.d
else
cleandeps:
	rm -f *.d
endif

-include $(DEPS)
