# define some macros
all: version help

version:
	@echo "LinuxFocus Editors' Makefile v0.7.1 (2001-07-31) - to Make live easier"

help: version
	@echo "Options:"
	@echo "   make help       -> show this help"
	@echo "   make version    -> show the version information"
	@echo "   make backup     -> make a backup op the current Nederlands dir"
	@echo "   make upload     -> upload the patch"
	@echo "   make mainindex  -> make a mainindex patch"
	@echo "   make monthindex -> make MonthYYYY/index.html from new DB"
	@echo "   make themes     -> make new theme pages"
	@echo "   make clean      -> remove the current patch"
	@echo "   make sync       -> synchronize local version"
	@echo "   make changed    -> show recently changed files"
	@echo "   make index      -> update the Nederlands/index.html page"
	@echo "   make patch      -> make a patch of all changed files"
	@echo
	@echo "   make lock       -> make clear that other should not interfere"
	@echo "   make unlock"
	@echo "   make islocked   -> check if LF is locked"    

sync:
	@echo "Syncing local version..."
	@echo "  *** Nederlands directory..."
	@rsync -rLtz -vv main.linuxfocus.org::lf/Nederlands . | grep -v uptodate
	@echo "  *** common directory..."
	@rsync -rLtz -vv main.linuxfocus.org::lf/common . | grep -v uptodate

esync:
	@echo "Syncing local version..."
	@echo "  *** English directory..."
	@rsync -rLtz -vv main.linuxfocus.org::lf/English . | grep -v uptodate
	@echo "  *** WorkSpace directory..." 
	@rsync -rLtz -vv main.linuxfocus.org::lf/WorkSpace . | grep -v uptodate
	@echo "  *** Spanish directory..."
	@rsync -rLtz -vv main.linuxfocus.org::lf/Castellano . | grep -v uptodate
	@echo "  *** Frensh directory..."
	@rsync -rLtz -vv main.linuxfocus.org::lf/Francais . | grep -v uptodate
	@echo "  *** German directory..."
	@rsync -rLtz -vv main.linuxfocus.org::lf/Deutsch . | grep -v uptodate

upload: 
	@echo "Uploading patch..."
	@Nederlands/WorkSpace/bin/lfsendpatch-0.6 -p nllf_007 -u egon.w patch_ew_`date +%d_%m`.tar.gz

update: medewerkers xml

xml: index
	@echo "Updating all LF DB XML based pages..."
	@cd Nederlands/xml; \
	  make

medewerkers:
	@echo "Updating medewerkers.html"
	@cd Nederlands/WorkSpace/bin/; \
	  genmedewerkers > ../../medewerkers.html

news:
	@echo "Generating updated news..."
	@cd Nederlands/WorkSpace/News ; \
	  ./gen_nl_news.pl

clean:
	@echo "Removing patch..."
	@find . -name 'patch*.tar*' -exec ${RM} {} \;
	@find . -name '*~' -exec $(RM) {} \;
	@find . -name '*bak' -exec $(RM) {} \;

daychanged:
	@echo "The following files have changed..."
	@find Nederlands -mmin -600 -type f
	@find common -mmin -600 -type f

changed:
	@echo "The following files have changed..."
	@find Nederlands -mmin -120 -type f
	@find common -mmin -120 -type f

ws_sync:
	@echo "Syncing local version..."
	@echo "  *** WorkSpace directory..."
	@rsync -rLtz -vv www.linuxfocus.org::lf/WorkSpace . | grep -v uptodate

ws_clean:
	@echo "Cleaning WorkSpace..."
	@find WorkSpace -name '*' -exec ${RM} {} \; 

themes_patch: clean
	@echo "Making mainindex/themes patch..."
	@tar cvf patch_ew_`date +%d_%m`.tar Nederlands/mainindex.txt Nederlands/vertaald.html Nederlands/mainindex.html Nederlands/data/opkomst.txt Nederlands/data/mainindex.def.nl.txt Nederlands/Themes/*.html
	@gzip patch_ew_`date +%d_%m`.tar

index_patch: clean
	@echo "Making index patch..."
	@tar cvf patch_ew_`date +%d_%m`.tar Nederlands/index.html Nederlands/WorkSpace/Index/*.html
	@gzip patch_ew_`date +%d_%m`.tar

hourpatch: clean
	@echo "Making new patch..."
	@tar cvf patch_ew_`date +%d_%m`.tar `find Nederlands -mmin -60 -type f`
	@gzip patch_ew_`date +%d_%m`.tar

daypatch: clean
	@echo "Making new patch..."
	@tar cvf patch_ew_`date +%d_%m`.tar `find Nederlands -mmin -600 -type f`
	@gzip patch_ew_`date +%d_%m`.tar

patch: clean
	@echo "Making new patch..."
	@tar cvf patch_ew_`date +%d_%m`.tar `find Nederlands -mmin -1200 -type f`
	@gzip patch_ew_`date +%d_%m`.tar

newindex:
	@echo "Making new patch of Concept Index..."
	@tar cvf patch_ew_`date +%d_%m`.tar `find Nederlands/Temp -mmin -120 -type f`
	@gzip patch_ew_`date +%d_%m`.tar

lock: .who
	@echo "LOCKED!"
	@echo "`cat .who`: locked at `date`" > Nederlands/lock
	@tar cf patch_ew_`date +%d_%m`.tar Nederlands/lock
	@gzip -f patch_ew_`date +%d_%m`.tar
	@echo "y" | make upload > /dev/null

unlock:
	@echo "UNLOCKED!"
	@echo "unlocked" > Nederlands/lock
	@tar cf patch_ew_`date +%d_%m`.tar Nederlands/lock
	@gzip -f patch_ew_`date +%d_%m`.tar
	@echo "y" | make upload > /dev/null

islocked:
	@rsync -rLtz -vv main.linuxfocus.org::lf/Nederlands/lock . | grep -v uptodate > /dev/null
	@find . -name ".lock" -exec $(RM) {} \;
	@cat Nederlands/lock

broken:
	@echo "Broken links are save to broken.txt..."
	@blnkcheck `find Nederlands/ -name "*html" | grep -v "WorkSpace" | grep -v "Nederlands/data" | grep -v "Nederlands/Temp" | grep -v Archives` | sort > broken.txt

backup:
	@echo "Making an backup of the current Nederlands dir..."
	@tar cvf backup`date +%d_%m`.tar Nederlands/*
	@echo "y" | gzip backup`date +%d_%m`.tar

index:
	@echo "Making new index.shtml..."
	@sabcmd Nederlands/xml/stylesheets/recently_translated_light.xslt Nederlands/xml/db/lfdb.nl.xml > Nederlands/box09.html
	@Nederlands/WorkSpace/bin/lfpagecomposer Nederlands/skel.html > Nederlands/index.shtml

