SHELL = /bin/bash
DESTDIR=/var/www/html/freedocs

numCores=$(shell nproc --all)

EXECUTABLES = javac mvn rsync convert \
java ffmpeg

K := $(foreach exec,$(EXECUTABLES),\
        $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH)))

REVEALHOME=/usr/share/reveal.js
K := $(if $(shell ls ${REVEALHOME}),some string,$(error "No ${REVEALHOME} found, please execute git clone https://github.com/hakimel/reveal.js)))

doc:
	cd Doc;$(MAKE) -j ${numCores} all

all:doc
#	mvn -T ${numCores} --fail-at-end install || echo
	mvn --fail-at-end install javadoc:javadoc || exit 0
	find P -type f \( -name \*.css -o -name \*.html -o -name \*.js \) -print | tar --files-from=- -c| tar -x -C Doc/target/webhelp

clean:
	cd Doc;$(MAKE) -j ${numCores} clean
	mvn -T ${numCores} clean

check-install:
ifndef DESTDIR
        $(error DESTDIR is undefined)
endif

install: check-install
	rsync -av --exclude \*.jar --exclude \*.war --exclude \*VAADIN\* --exclude \*.class --exclude=__figurelink\* --delete P Doc/target/webhelp/ \
          freedocs@prog.mi.hdm-stuttgart.de:${DESTDIR}
	rsync -av --exclude \*.jar --exclude \*.war --exclude \*VAADIN\* --exclude \*.class --exclude=__figurelink\* --delete P Doc/target/webhelp/ \
          ubuntu@freedocs.hdm-stuttgart.cloud:/data/var/www/html
	
#end