# ILE. . . . . d:/hak/hlt/src/hlt/fot/Makefile
# DIT BY . . . Hassan Ait-Kaci
# N MACHINE. . Hak-Laptop
# TARTED ON. . Sat Jul 14 07:23:50 2018

# Last modified on Sat Aug 18 10:10:21 2018 by hak

########################################################################

# NB: make does not understand /cygdrive/d - its needs D:
WIN_HOME	= D:/hak

HLT_HOME	= ${WIN_HOME}/hlt

HLT_CLASSES	= ${HLT_HOME}/classes
CLASSPATH	= .;${HLT_CLASSES}

#JDOM_CLASSES	= ${HLT_CLASSES}/jdom.jar# useful only if processing XML files
#CLASSPATH	= .;${HLT_CLASSES};${JDOM_CLASSES}#JDOM useful only if processing XML files

RESOURCES	= ${HLT_CLASSES}/resources

SOURCEROOT	= $(HLT_HOME)/src
SOURCES		= *.java
SYNTAX		= syntax
TEST		= test
TESTMAIN	= Test

DOCDIR		= ${HLT_HOME}/doc/hlt/code/fot/
#IMAGES		= ${DOCDIR}/images
APIDIR		= $(HLT_HOME)/doc/hlt/api/
#javadoc does not recognize @ tags as it used to because of doclint - need option:-Xdoclint:none"
DOCOPTIONS	= -Xdoclint:none \
                  -windowtitle "API documentation of hlt.fot package" \
                  -author -version -public $(TAGS) \
                  -header "Author: <a href=\"http://www.hassan-ait-kaci.net\">Hassan A&iuml;t-Kaci</a>" \
                  -footer "Contact: <a href=\"mailto:hak@acm.org?subject=hlt.fot.fuz\">hak@acm.org</a>"
SYSTEM		= hlt
PACKAGES	= $(SYSTEM).fot
SOURCES		= *.java

QUIET		= -quiet ${HUSH}
HUSH		= > /dev/null 2> /dev/null

TRASH	= ,*.java ,Makefile ${TEST}/,*.java */,.* */*~ */@*@ */.*~

JC		= @javac -classpath "$(CLASSPATH)" -O -d "$(HLT_CLASSES)" -Xlint:deprecation #-Xlint:unchecked
JCT		= @javac -classpath "$(CLASSPATH)" -O -Xlint:deprecation #-Xlint:unchecked
#JCT		= @javac -classpath "$(CLASSPATH)" -O -d "$(TEST)" -Xlint:deprecation #-Xlint:unchecked
JV		= @java -classpath "$(CLASSPATH)"

MK	= @make
ND	= @mkdir -p
CP	= @cp -f
CD	= @cd
LS	= @ls
MV	= @mv -f
RM	= @rm -rf

SAY	= @echo "***"

HL_OPS	= -! -c "${RESOURCES}/Hilite.Configuration"
HL	= @java -classpath "$(HLT_CLASSES)" hlt.language.tools.HiliteCommand \
	  -css $(HLT_CLASSES)/resources/Hilite.Style.css \
	  -con $(HLT_CLASSES)/resources/Hilite.Configuration.Jacc -s /

########################################################################

help:
	${SAY}
	${SAY} "This makefile manages the hlt.fot package."
	${SAY} "You can 'make ...' where '...' is one of:"
	${SAY}
	${SAY} "    all:      same as 'classes doc api'"
	${SAY} "    classes:  compiles the hlt.fot java package source files"
#	${SAY} "    syntax:   generates and compiles the hlt.fot/syntax/*.java source files"
	${SAY} "    doc:      generates its html source documentation in ~/hlt/doc/hlt/code/fot/"
	${SAY} "    api:      generates its API javadoc documentation in ~/hlt/doc/hlt/api/hlt/fot/"
#	${SAY} "    save:     saves the contents of this directory ($(shell pwd))"
	${SAY} "    save:     save the contents of this directory (~/hlt/src/hlt/fot/) as ~/save/hlt.fot.tar.gz"
	${SAY} "    tidy:     deletes trash"
	${SAY} "    clean:    erases regeneratable files (*.class, *.html)"
	${SAY} "    help:     prints this message"
	${SAY}

########################################################################

all:	classes doc api

########################################################################

classes: tidy
	${SAY} Removing existing hlt.fot class files
	${RM} ${HLT_CLASSES}/hlt/fot/*.class
	${SAY} Compiling hlt.fot package sources
	${JC} ${SOURCES}

########################################################################

test: tidy
	${SAY} Removing ${TEST}/*.class "file(s)"
	${RM} ${TEST}/*.class
	${SAY} Compiling ${TEST}/*.java "source(s)"
	${JCT} ${TEST}/*.java
	${SAY} Running ${TEST}/${TESTMAIN}
	${JV} ${TEST}/${TESTMAIN}

########################################################################

api: tidy
#	$(SAY) Regenerating the Javadoc API documentation for all the hlt.fot package
#	@make -C $(HLT_HOME)/src all
	$(SAY) Generating Javadoc API documentation for hlt.fot package
	@javadoc -J-Xmx128m -classpath "$(CLASSPATH)" -sourcepath "$(SOURCEROOT)"\
		 -d "$(APIDIR)" $(DOCOPTIONS) $(PACKAGES) $(QUIET)
	$(SAY) Wrote javadoc root file $(APIDIR)index.html

########################################################################

doc: tidy
	${SAY} Removing old ${DOCDIR} documentation
	${RM} ${DOCDIR}/*.*
	${SAY} Generating HTML docs for hlt.fot package source files
	${HL} -d ${DOCDIR} ${SOURCES}
	${MV} ${DOCDIR}/index.html ${DOCDIR}/000StartHere.html
	${SAY} See hilited HTML source code in ${DOCDIR}000StartHere.html

########################################################################

save: tidy
	${SAY} "Saving the java sources in current directory (~/hlt/src/hlt/fot/)"
	@tar cvf hlt.fot.tar Makefile *.java ${HUSH}
	@gzip hlt.fot.tar
	${MV} hlt.fot.tar.gz save/
	${SAY} Wrote ./save/hlt.fot.tar.gz

########################################################################

# Change the following to make the syntax/Makefile
# until then need to do under shell: cd syntax; make; cd ..
#
# syntax: tidy
# 	${SAY} Making the fot syntax parser
# 	make -f "syntax/Makefile" "DIRFIX = syntax/" basic
# 	${SAY} {$APP} parser generated and compiled

########################################################################

clean: tidy
	${SAY} "Deleting regeneratable class and html files"
	${RM} ${HLT_CLASSES}/hlt/fot/*.class
#	${RM} ${SYNTAX}/classes/*.class
#	${RM} ${HLT_HOME}/doc/hlt/code/fot/${SYNTAX}/*.html
#	${RM} ${HLT_HOME}/api/hlt/fot/${SYNTAX}/*.html

########################################################################

tidy:
	${SAY} "Tidying up trash"
	${RM} ${TRASH}

########################################################################
