#
# The following directory are FULLY generated under Linux:
#     abeans
#     acsabeans
#     acsexmpl
#     jcontexmpl
#
# The following directories have a recursive make:
#     ACS_docs
#
# PDF files are generated automatically if they are originated from MS word
#     documents in CVS:ACS/Documents.
#
# The following files need to be generated/copied by hand
#     Few PDF files in this directory
#     Vltsw   directory
#

TAG=HEAD
CURRDIR=$(shell pwd)

PLATFORM := $(shell uname)

.PHONY: checkEnv
checkEnv:
	@echo "====> Checking basic execution environment"
	@echo "   Path: $(PATH)"
	@echo "   Current directory: $(PWD)"
	@echo "   TAG: $(TAG)"

.PHONY: architecture
architecture:
	@echo "====> Updating architecture HTML and online UML model"
	@rm -rf ACSArchitecture ACSArchitecture.tmp
	@mkdir -p ACSArchitecture.tmp
	@cvs -Q export -r $(TAG) -d ACSArchitecture.tmp ACS/Documents/ACSArchitecture/Makefile \
                ACS/Documents/ACSArchitecture/Help \
                ACS/Documents/ACSArchitecture/Images \
                ACS/Documents/ACSArchitecture/Project \
                ACS/Documents/ACSArchitecture/UML
	@mv ACSArchitecture.tmp/ACS/Documents/ACSArchitecture ACSArchitecture
	@chmod -R ugo+r ACSArchitecture
	@rm -rf ACSArchitecture.tmp

.PHONY: abeans
abeans:
	@echo "====> Updating abeans tutorials"
	@rm -rf abeans/doc
	@mkdir -p abeans/doc
	@cd abeans; cvs export -r $(TAG) -d doc ACS/LGPL/CommonSoftware/abeans/doc
	@chmod -R ugo+r abeans

.PHONY: acsabeans
acsabeans:
	@echo "====> Updating acsabeans module"
	@rm -rf acsabeans
	@cvs export -r $(TAG)  -d acsabeans ACS/LGPL/CommonSoftware/acsabeans
	@acsBUILDCheckModuleTree.sh acsabeans
	@cd acsabeans/src; make man
	@chmod -R ugo+r acsabeans

.PHONY: ACSCommandCenter
ACSCommandCenter:
	@echo "====> Updating ACSCommandCenter module"
	@rm -rf ACSCommandCenter
	@cvs export -r $(TAG)  -d ACSCommandCenter ACS/Documents/ACSCommandCenter
	@chmod -R ugo+r ACSCommandCenter

.PHONY: WebStart
WebStart:
	@echo "====> Updating WebStart documentation module"
	@rm -rf WebStart
	@cvs export -r $(TAG)  -d WebStart ACS/Documents/WebStart
	@chmod -R ugo+r WebStart

.PHONY: acsexmpl
acsexmpl:
	@echo "====> Updating acsexmpl module"
	@rm -rf acsexmpl
	@cvs export -r $(TAG)  -d acsexmpl ACS/LGPL/CommonSoftware/acsexmpl
	@acsBUILDCheckModuleTree.sh acsexmpl
	@cd acsexmpl/ws/src; make man
	@chmod -R ugo+r acsexmpl

.PHONY: jcontexmpl
jcontexmpl:
	@echo "====> Updating jcontexmpl module"
	@rm -rf jcontexmpl
	@cvs export -r $(TAG)  -d jcontexmpl ACS/LGPL/CommonSoftware/jcontexmpl
	@acsBUILDCheckModuleTree.sh jcontexmpl
	@cd jcontexmpl/src; make man
	@chmod -R ugo+r jcontexmpl

.PHONY: ACS_docs
ACS_docs:
	@cd ACS_docs; make all

.PHONY: acscookbook
acscookbook:
	@echo "====> Updating cookbook"
	@rm -rf ACSCookbook
	@cvs -Q export -r $(TAG) -d ACSCookbook ACS/Documents/ACSCookbook
	@chmod -R ugo+r ACSCookbook
	@rm -rf ACSCookbook.tmp

#################################### Windows ###############
ifeq ($(PLATFORM),CYGWIN_NT-5.1)
  PLATFORM := Sun

all: firstLinux checkEnv wordDocs umlModel 


.PHONY: firstLinux
firstLinux:
	@echo "======> **** Did you remember to run this Makefile first of all on the Linux side?"

.PHONY: wordDocs
wordDocs:
	@echo "====> Updating PDF for MS Word documents"
	@echo "      Changing directory to ../../../../../Documents"
	@echo "      Running: $(MAKE) DESTDIR=$(CURRDIR) listDocs"
	@cd ../../../../../Documents; \
	   $(MAKE) DESTDIR=$(CURRDIR) all

.PHONY: umlModel
umlModel: 
	@echo "====> Updating online ACS Architecture UML Model "
	@echo "      Changing directory to ./ACSArchitecture"
	@cd ./ACSArchitecture; $(MAKE) model

test: checkEnv
	@echo "====> Testing remote Makefile on Windows "
	@echo "      "
	ls

#################################### NON Windows ###############
else

all: checkEnv architecture abeans acsabeans ACSCommandCenter WebStart \
     acsexmpl jcontexmpl ACS_docs acscookbook
	@echo "======> **** Remember to go on windows and run make all to update PDF files and UML model"
	@echo ... done.

clean: 
	@rm -rf architecture abeans acsabeans ACSCommandCenter WebStart \
                acsexmpl jcontexmpl ACSCookbook
	@cd ACS_docs; make clean

.PHONY: wordDocs
wordDocs:
	@echo "wordDocs: This Makefile must be run from Windows Cygwin!"

.PHONY: umlModel
umlModel:
	@echo "umlModel: This Makefile must be run from Windows Cygwin!"

endif
#################################### end ###############
