#
# Establishes properties file and wad file to be able to automatically
# license firmware.
#
default: install

# to be consistent with rest of P2P makefiles
REVOLUTION_P2P_ROOT?=../..

IOS_VERS     = 34.4.16

HEX_TITLE_ID = 0000000100000022
PRODUCTNAME  = RVL-OS34
APP_TYPE     = RVL_SYS
FULLBIN_ROOT = .
PASS         = mypass

#  pass1 does not seem to be compatible with the firmware on lab4.
#

include ../../etc/properties.template.mk

.PHONY: install all properties

ifndef RVL_64
FW_WAD = firmware.128.$(IOS_VERS).wad
PLATFORM=RVL_128
else
FW_WAD = firmware.64.$(IOS_VERS).wad
PLATFORM=RVL_64
endif

#  server is NG build server 'iose-3'
SERVER     = iose-3
SRC_DIR    = build/latest/$(PLATFORM)/usr/bin/rvl

.PHONY: $(FW_WAD)
$(FW_WAD) :
	@rm -f $(FW_WAD)
	rsync -t --progress guest@$(SERVER)::$(SRC_DIR)/$@ ./

INSTALL_DIR  = $(REVOLUTION_P2P_ROOT)/RVL/boot/fw

install: properties $(FW_WAD)
	@if [ -z '$(REVOLUTION_P2P_ROOT)' ]; then\
		echo "You must establish environment variable REVOLUTION_P2P_ROOT before proceeding."; \
		exit 1; \
	fi
	@if [ ! -w '$(INSTALL_DIR)' -o ! -d '$(INSTALL_DIR)' ]; then\
	    	mkdir -p '$(INSTALL_DIR)'; \
	fi
	cp $(FW_WAD) $(INSTALL_DIR)/
	cp $(PROPERTIES_FILE) $(INSTALL_DIR)/

clean:
	rm -f *.wad *.properties
