# Quick Pandora target to make a compliant SRB2 PND file.

PNDNAME=SRB2.pnd
PNDDIR=$(BIN)/pnd
ICON=sdl/SRB2Pandora/icon.png
PXML=sdl/SRB2Pandora/PXML.xml

SED=sed
CAT=cat
CP=cp
XARGS=xargs
FOR=for
WGET=wget -P $(PNDDIR) -c -nc

SHXARGS:=$(XARGS)
SHSED:=$(SED)

ifndef ECHO
	CP:=@$(CP)
	CAT:=@$(CAT)
	SED:=@$(SED)
	XARGS:=@$(XARGS)
	FOR:=@(FOR)
endif

$(BIN)/$(PNDNAME): $(BIN)/$(EXENAME)
	@echo Linking $(PNDNAME)...
	$(MKDIR) $(PNDDIR)
	$(CP) $(BIN)/$(EXENAME) $(PNDDIR)
	$(CP) $(ICON) $(PNDDIR)
	$(CP) $(PXML) $(PNDDIR)
ifdef WITHDATA
	$(FOR) datafile in $(shell echo $(D_FILES) | $(SHSED) 's/\.srb/\.wad/' | $(SHXARGS) -n 1 basename); do \
		$(WGET) http://alam.srb2.org/SRB2/2.0.6-Final/Resources/$$datafile; \
	done
endif
	$(MKISOFS) -l -r -o $@ $(PNDDIR)
	$(CAT) $(PXML) >> $@
	$(REMOVE) -r $(PNDDIR)
