# FILE. . . . . d:/hak/hlt/src/hlt/fot/fuz/syntax/Makefile
# EDIT BY . . . Hassan Ait-Kaci
# ON MACHINE. . Hak-Laptop
# STARTED ON. . Sun Jul 15 08:02:18 2018

# Last modified on Wed Aug 21 13:45:44 2019 by hak

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

APPLICATION	= FuzzyFOTLattice

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

HOME		= D:/hak
# WIN_HOME is defined as an environment var in .profile as /cygdrive/d
WIN_HOME	= ${HOME}
HLT_HOME	= ${WIN_HOME}/hlt

HLT_CLASSES	= ${HLT_HOME}/classes
#JDOM_CLASSES	= ${HLT_HOME}/classes/jdom-1.1.3/jdom-1.1.3.jar
JDOM_CLASSES	= ${HLT_HOME}/classes/jdom-2.0.6/jdom-2.0.6.jar

SHARED_CLASSES	= ${HLT_CLASSES};${JDOM_CLASSES}

RESOURCES	= ${HLT_CLASSES}/resources
LOCAL_CLASSES	= ./classes
SOURCES		= ./sources
DOCS		= ./docs
EXAMPLES	= ./examples
CLASSPATH	= ${LOCAL_CLASSES};${SHARED_CLASSES}

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

TRASH	= ,* ,.* *~ @*@ .*~ */,* */,.* */*~ */@*@ */.*~

JC	= @javac -O -d "${LOCAL_CLASSES}" -classpath "${CLASSPATH}" -Xlint:deprecation #-Xlint:unchecked
JV	= @java -classpath "${CLASSPATH}"
JACC	= ${JV} hlt.language.syntax.Jacc
# LOG	= ${JACC} -n -v4
DOC	= ${JACC} -doc

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

HL_OPS	= -! -con "${RESOURCES}/Hilite.Configuration" # -p jacc.${APPLICATION}
HL	= @hl ${HL_OPS}

DOCDIR  = ${DOCS}/${APPLICATION}Doc
IMAGES	= ${DOCDIR}/images

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

help: tidy
	@echo
	@echo "This is: ~/hlt/src/hlt/fot/fuz/syntax/Makefile"
	@echo
	@echo "Use it to manage the ${APPLICATION} Jacc application"
	@echo
	@echo "Doing 'make ?' where ? is:"
	@echo
	@echo "    gen      generates the ${APPLICATION} JACC parser"
	@echo "    classes  compiles the ${APPLICATION} java source files"
	@echo "    basic    is the same as doing 'make gen classes'"
	@echo "    run      runs the compiled ${APPLICATION} application"
	@echo "    all      is the same as doing 'make basic run'"
	@echo "    doc      generates the ${APPLICATION} JACC application's html documentation:"
	@echo "             files from javadoc and sources highlighted with hlt.language.tools.Hilite"
	@echo "    full     is the same as doing 'make basic doc'"
#	@echo "    log      generates a symbol/rule/state grammar analysis log file"
#	@echo "    tidy     erases all temp files (no need: done automatically)"
	@echo "    clean    erases all regeneratable files (done automatically when doing 'make save')"
	@echo "    save     saves a gzipped tarball of the ${APPLICATION} JACC grammar source files"
	@echo "    help     prints this message (same as: 'make')"
	@echo
	@echo

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

all:	basic run
basic:	gen classes
full:	basic doc

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

gen: tidy ${SOURCES}/${APPLICATION}.grm
	${SAY} Make gen:
	${SAY} Generating the ${APPLICATION} parser...
	${JACC} -base ${SOURCES} \
                -dest ${SOURCES} \
                -p ${APPLICATION}Parser \
                ${SOURCES}/${APPLICATION}.grm

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

classes: tidy
	${SAY} Make classes:
	${SAY} Compiling java files...
	${JC} ${SOURCES}/*.java
	${SAY} Wrote class files in ${LOCAL_CLASSES}/

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

run:
	${CD} ${LOCAL_CLASSES}
#	${SAY} Welcome to FFF!
	${JV} ${APPLICATION}Main
	${CD} ..

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

save: clean
	${SAY} "Saving the ${APPLICATION} JACC grammar source files"
	@tar cvf hlt.fot.fuz.syntax.tar Makefile *.html *.fff sources/*.grm sources/*.java ${HUSH}
	@gzip hlt.fot.fuz.syntax.tar
	${MV} hlt.fot.fuz.syntax.tar.gz save/
	${SAY} Wrote ./save/hlt.fot.fuz.syntax.tar.gz

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

doc: rmdoc hyper hl

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

rmdoc:
	${SAY} Make rmdoc:
	${SAY} Removing old ${DOCDIR} documentation ...
	${RM} ${DOCDIR}

########################################################################
# generating the javadoc files
hyper: rmdoc tidy
	${SAY} Make hyper:
	${SAY} Generating the ${APPLICATION} grammar javadoc hyperdocumentation ...
	${JACC} -doc -base ${SOURCES} ${SOURCES}/${APPLICATION}.grm
	${MV} ${APPLICATION}Doc ${DOCS}/
	${MK} images
	${MV} ${DOCDIR}/index.html ${DOCDIR}/000StartHere.html
	${SAY} Visit ${DOCDIR}/000StartHere.html to navigate the grammar documentation

########################################################################
# highlighting the Java and Jacc grammar sources
hl: tidy
	${SAY} Make hl:
	${SAY} Hiliting HTML for Java and Jacc sources files ...
	${HL} -d ${DOCDIR} ${SOURCES}/*.grm ${SOURCES}/*.java
	${SAY} See hilited HTML source code in ${DOCDIR}/index.html.

########################################################################
# used to create the documentation image file directories and files
images:
	${SAY} Make images:
	${SAY} Copying image files ...
	${ND} ${IMAGES}
	${ND} ${IMAGES}/hlt
	${ND} ${IMAGES}/arrows
	${ND} ${IMAGES}/arrows/misc/
	${CP} ${RESOURCES}/images/hlt/*.gif ${IMAGES}/hlt/
	${CP} ${RESOURCES}/images/arrows/misc/*.gif ${IMAGES}/arrows/misc/

########################################################################
# # generates a Jacc grammar LARL(1) rule analysis log file
# log: tidy
# 	${SAY} Make log:
# 	${SAY} Generating complete analysis log for ${SOURCES}/${APPLICATION}.grm...
# 	${JACC} -v 4 -n -o ${APPLICATION}.log \
#                 -base ${SOURCES} ${SOURCES}/${APPLICATION}
# 	${MV} ${APPLICATION}.log ${SOURCES}/${APPLICATION}.log
# 	${SAY} See grammar log in file ${SOURCES}/${APPLICATION}.log

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

clean: tidy
	${SAY} Make clean:
	${SAY} Cleaning ${APPLICATION} application
	${SAY} Removing the existing parser Java sources...
	${RM} ${SOURCES}/${APPLICATION}Parser.java
#	${SAY} Removing the old grammar analysis log...
#	${RM} ${SOURCES}/${APPLICATION}.log
	${SAY} Removing the old documentation
	${RM} ${DOCDIR}
	${SAY} Cleaned ${APPLICATION} application

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

tidy:
#	${SAY} Make tidy:
#	${SAY} "Tidying up trash (if any) ..."
#	${LS} ${TRASH} 2> /dev/null ; true
	${RM} ${TRASH}

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