# Makefile by kaw

# Requires PDCSDL, set PDCSDLDIR to point to a compiled version.

PDCSVER=3.4
PDCSDLDIR = ./PDCurses-$(PDCSVER)

PACKAGENAME = asciiportal-linux64
WINDOWSZIP = asciiportal.zip

GPPOPTS = -mips32 -O3 -fstrength-reduce -fthread-jumps -fexpensive-optimizations -fomit-frame-pointer -frename-registers -pipe -G 0 -ffast-math -msoft-float

all: asciiportal

clean:
	rm -f *.o
	rm -f asciiportal

fullclean: clean
	rm -rf $(PACKAGENAME)
	rm -f $(PACKAGENAME).tar.gz
#	rm -rf $(PDCSDLDIR)

package: fullclean asciiportal
	strip asciiportal
	upx asciiportal
	mkdir $(PACKAGENAME)
	unzip -d $(PACKAGENAME) $(WINDOWSZIP)
	cp Makefile $(PACKAGENAME)/source
	rm $(PACKAGENAME)/*.exe
	rm $(PACKAGENAME)/*.bat
	rm $(PACKAGENAME)/*.dll
	cp asciiportal $(PACKAGENAME)/
	tar cvfz $(PACKAGENAME).tar.gz $(PACKAGENAME)

%.o: %.cpp $(PDCSDLDIR)
	mipsel-linux-g++ -I $(PDCSDLDIR) -c $(GPPOPTS) $<

asciiportal: ap_draw.o ap_input.o ap_play.o ap_sound.o main.o menu.o $(PDCSDLDIR)/sdl1/libpdcurses.a
	mipsel-linux-g++ -static $^ -lSDL_mixer -lSDL -lmad -ldl -lpthread -o $@

#$(PDCSDLDIR)/sdl1/libpdcurses.a: $(PDCSDLDIR)
#	cd `dirname $@` && make

#$(PDCSDLDIR): PDCurses-$(PDCSVER).tar.gz
#	tar xvfz $<

#PDCurses-$(PDCSVER).tar.gz:
#	wget http://sourceforge.net/projects/pdcurses/files/pdcurses/$(PDCSVER)/PDCurses-$(PDCSVER).tar.gz/download
#	if [[ ! -f $@ ]]; then echo "Download of $@ failed, please provide file."; exit; fi


