#
# For RedHat/CentOS5 on My X60
# - To setup tcdemo/* use this makefile for a while
#
# 20071119 Seiji Munetoh
#

usage:
	@echo " TC DEMO Setup for X60/CentOS5"
	@echo " ------------------------------------- client"
	@echo " make setup_tpm12"
	@echo " make setup_rm"
	@echo " make clean"
	@echo " ------------------------------------- Server"
	@echo " make start_tcsd"
	@echo " make start_tomcat5"
	@echo " make start_postgresql"
	@echo " make server_status"
	@echo "---------------------------------------------"

clean: clean_manifest
	rm -f *measurements
	rm -f dmidecode
	rm -f pcrs
	rm -f quote.properties
	rm -f grub
	rm -f grub2
	rm -f knoppix_ir.xml
	rm -f knoppix_vr.xml

###############################################
# Client Setup
###############################################

UUID=00000000000000000000000000000078
NONCE=83c5cacb20a590e5b48980598cc69f18068495de

setup_tpm:
	tpm_takeownership
	tpm_createkey -u $(UUID)
	@echo "make setup_tpm11"
	@echo "make setup_tpm12"

setup_tpm11:
	#cd /opt/OpenPlatformTrustServices; ./bin/getiml.sh tcdemo tpm11
	/opt/OpenPlatformTrustServices/bin/getiml.sh $(PWD) tpm11
setup_tpm12:
	#cd /opt/OpenPlatformTrustServices; ./bin/getiml.sh tcdemo tpm12
	/opt/OpenPlatformTrustServices/bin/getiml.sh $(PWD) tpm12

reset_tpm:
	tpm_clear
	@echo "reboot"

grub:
	ln -s /boot/grub grub

grub2:
	ln -s /usr/share/grub/i386-redhat grub2
	
###############################################
# Create Reference Manifest
###############################################
RUNTIME_TYPE=runtime
RUNTIME_PROP=runtime_model.properties

TCDEMO_PROP=$(PWD)/tcdemo.properties

platform_rm.xml:
	@echo "Create Platform Reference Manifest"
	openpts manifest --create --platform --model platfotm_model.properties --prop $(TCDEMO_PROP)
	@echo "Create Platform Reference Manifest - done"
	ls -l $@

runtime_rm.xml:
	@echo "Create Runtime Reference Manifest"
	openpts manifest --create --$(RUNTIME_TYPE) --model runtime_model.properties --prop $(TCDEMO_PROP)
	ls -l $@

setup_rm: grub grub2 platform_rm.xml runtime_rm.xml

clean_manifest:
	rm -f platform_rm.xml
	rm -f runtime_rm.xml

start_client_user:
	/opt/OpenPlatformTrustServices/bin/ptsclientuser

###############################################
# Server
###############################################
JWS_DST=/var/lib/tomcat5/webapps/axis/Server.jws 

server_status:
	service tcsd status
	service postgresql status
	service tomcat5 status

start_tomcat5:
	service tomcat5 start
	@echo "http://localhost:8080"
	
	
	
# EOF