# _____     ___ ____     ___ ____
#  ____|   |    ____|   |        | |____|
# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# $Id: Rules.release 1150 2005-06-12 11:42:08Z pixel $



#
# Creates the base ee directory structure in target directory.
#

RELEASE_EE_DIRS = ee/ ee/include/ ee/lib/ ee/bin/ ee/startup 
RELEASE_EE_DIRS := $(RELEASE_EE_DIRS:%=$(PS2SDK)/%)


release-dirs:
	$(MKDIR) -p $(RELEASE_EE_DIRS)


#
# Most targets will only have a single EE_LIB target.  if the file
# exists then copy it to the ee/lib directory.
#

release-lib: 
	@if test $(EE_LIB) ; then \
	   $(ECHO) Installing $(EE_LIB) to $(PS2SDK)/ee/lib ; \
	   cp -f $(EE_LIB) $(PS2SDK)/ee/lib ; \
	   cp -f $(EE_LIB:%.a=%.erl) $(PS2SDK)/ee/lib ; \
	   chmod 644 $(PS2SDK)/ee/$(EE_LIB) $(PS2SDK)/ee/$(EE_LIB:%.a=%.erl); \
	fi;


#
# Any elf files should go to ee/bin
#

release-bin: 
	@if test $(EE_BIN) ; then \
	   $(ECHO) Installing $(EE_BIN) to $(PS2SDK)/ee/bin ; \
	   cp -f $(EE_BIN) $(PS2SDK)/ee/bin ; \
	   chmod 644 $(PS2SDK)/ee/$(EE_BIN) ; \
	fi;

#
# Any file in the include directory will be copied to the ee/include
# directory.  This does not currently handle subdirectories. 
#

release-include:
	@if test -d include ; then \
	   for file in include/*; do \
	      if test -f $$file ; then \
	         $(ECHO) Installing $$file to $(PS2SDK)/ee/include ; \
	         cp -f $$file $(PS2SDK)/ee/include ; \
	         chmod 644 $(PS2SDK)/ee/$$file ; \
	      fi \
	   done; \
	fi;
	

#
# If there is a smples directory.  Call makefile.
# Samples use their own release target based on the samples/Rules.sample
# makefile.
#

release-samples:
	@if test -f samples/Makefile ; then \
	   $(GNUMAKE) -C samples release ; \
	fi;


release: release-dirs release-lib release-bin release-include release-samples

release-clean:
	rm -f $(PS2SDK)/ee/include/*.*
	rm -f $(PS2SDK)/ee/lib/*.*
