
SRC=		srv/src/context.js			\
			srv/src/room.js				\
			srv/src/message.js			\
			srv/src/chatter.js			\
			srv/src/multichatManager.js	\
			\
			cli/lang/core.js			\
			cli/lang/fr.js				\
			cli/lang/en.js				\
			\
			cli/msgFormatter/msgFormatter.js	\
			\
			cli/confirmDialog.js		\
			cli/resources.js			\
			cli/ui.js					\
			cli/uiSettings.js			\
			cli/osmTile.js				\
			cli/dom.js					\
			cli/emojiBar.js				\
			cli/data.js					\
			cli/contextBackground.js	\
			cli/workflow.js				\
			cli/uiMessage.js			\
			cli/utils.js				\
			cli/config.js				\
			\
			cli/commands/core.js		\
			cli/commands/sherlock.js

EXTERNS=	--externs cli/externs/hljs.js

OUTPUT=		srv/public/slack.min.js

SRC_EMOJIONE_2.3=	cli/emoji/emojione_v2.3/data.js		\
					cli/emoji/emojione_v2.3/emojione.js

OUTPUT_EMOJIONE_2.3= srv/public/emojione_v2.3.sprites.js

SRC_EMOJIONE_3=	cli/emoji/emojione_v3/data.js		\
					cli/emoji/emojione_v3/emojione.js

OUTPUT_EMOJIONE_3= srv/public/emojione_v3.sprites.js

SRC_CGU=	cli/lang/core.js		\
			cli/cgu/fr.js			\
			cli/cgu/en.js			\
			\
			cli/cgu/main.js

OUTPUT_CGU=	srv/public/cgu.min.js

SRC_ERR=	cli/lang/core.js		\
			cli/err/fr.js			\
			cli/err/en.js			\
			\
			cli/err/main.js

OUTPUT_ERR=	srv/public/err.min.js

CLOSURE=	cli/closure-compiler-v20170521.jar

JSHINT=		jshint

all:	core emojione2.3 emojione3 cgu

core:
	echo "\"use strict\";(function(){" > ${OUTPUT}
	java -jar ${CLOSURE} --compilation_level ADVANCED --language_in=ECMASCRIPT5_STRICT --warning_level=VERBOSE ${EXTERNS} ${SRC} >> ${OUTPUT}
	echo "})();" >> ${OUTPUT}

core-debug:
	java -jar ${CLOSURE} --compilation_level WHITESPACE_ONLY --language_in=ECMASCRIPT5_STRICT --js_output_file ${OUTPUT} ${EXTERNS} ${SRC}

core-clean:
	$(RM) $(OUTPUT)

$OUTPUT: all

cli/emoji/emojione_v2.3/data.js:
	node cli/emoji/emojione_v2.3/_makeemojiData.js > cli/emoji/emojione_v2.3/data.js

emojione2.3: cli/emoji/emojione_v2.3/data.js
	echo "\"use strict\";(function(){" > ${OUTPUT_EMOJIONE_2.3}
	java -jar ${CLOSURE} --compilation_level ADVANCED --language_in=ECMASCRIPT5_STRICT --warning_level=VERBOSE ${SRC_EMOJIONE_2.3} >> ${OUTPUT_EMOJIONE_2.3}
	echo "})();" >> ${OUTPUT_EMOJIONE_2.3}

emojione2.3-debug: cli/emoji/emojione_v2.3/data.js
	java -jar ${CLOSURE} --compilation_level WHITESPACE_ONLY --language_in=ECMASCRIPT5_STRICT ${SRC_EMOJIONE_2.3} > ${OUTPUT_EMOJIONE_2.3}

emojione_2.3-clean:
	$(RM) $(OUTPUT_EMOJIONE_2.3) cli/emoji/emojione_v2.3/data.js

cli/emoji/emojione_v3/data.js:
	node cli/emoji/emojione_v3/_makeemojiData.js > cli/emoji/emojione_v3/data.js

emojione3: cli/emoji/emojione_v3/data.js
	echo "\"use strict\";(function(){" > ${OUTPUT_EMOJIONE_3}
	java -jar ${CLOSURE} --compilation_level ADVANCED --language_in=ECMASCRIPT5_STRICT --warning_level=VERBOSE ${SRC_EMOJIONE_3} >> ${OUTPUT_EMOJIONE_3}
	echo "})();" >> ${OUTPUT_EMOJIONE_3}

emojione3-debug: cli/emoji/emojione_v3/data.js
	java -jar ${CLOSURE} --compilation_level WHITESPACE_ONLY --language_in=ECMASCRIPT5_STRICT ${SRC_EMOJIONE_3} > ${OUTPUT_EMOJIONE_3}

emojione_3-clean:
	$(RM) $(OUTPUT_EMOJIONE_3) cli/emoji/emojione_v3/data.js

cgu:
	echo "\"use strict\";(function(){" > ${OUTPUT_CGU}
	java -jar ${CLOSURE} --compilation_level ADVANCED --language_in=ECMASCRIPT5_STRICT --warning_level=VERBOSE ${SRC_CGU} >> ${OUTPUT_CGU}
	echo "})();" >> ${OUTPUT_CGU}

cgu-clean:
	$(RM) $(OUTPUT_CGU)

err:
	echo "\"use strict\";(function(){" > ${OUTPUT_ERR}
	java -jar ${CLOSURE} --compilation_level ADVANCED --language_in=ECMASCRIPT5_STRICT --warning_level=VERBOSE ${SRC_ERR} >> ${OUTPUT_ERR}
	echo "})();" >> ${OUTPUT_ERR}

err-clean:
	$(RM) $(OUTPUT_ERR)

clean:	core-clean emojione_2.3-clean emojione_3-clean cgu-clean

re:	clean all

jshint:
	$(JSHINT) cli srv/*.js srv/src

.PHONY: all clean re core core-debug core-clean emojione2.3 emojione2.3-debug emojione2.3-clean jshint

