Skip to content

Instantly share code, notes, and snippets.

@guyhughes
Last active November 10, 2015 21:43
Show Gist options
  • Save guyhughes/0a5c7c383c0a70128d05 to your computer and use it in GitHub Desktop.
Save guyhughes/0a5c7c383c0a70128d05 to your computer and use it in GitHub Desktop.
makefile for java with run target; now with javadoc
RUN=NameSearchProgram
# ___ __ __ ____ ______ _ # < // // / / __ \ / ____/ (_)____ _ _ __ ____ _
# / // // /_ / / / //___ \ / // __ `/| | / // __ `/
# / //__ __// /_/ /____/ / / // /_/ / | |/ // /_/ /
# /_/ /_/ \____//_____/ __/ / \__,_/ |___/ \__,_/
# /___/
# __ ____ _ __
# ____ ___ ____ _ / /__ ___ / __/(_)/ /___
# / __ `__ \ / __ `// //_// _ \ / /_ / // // _ \
# / / / / / // /_/ // ,< / __// __// // // __/
# /_/ /_/ /_/ \__,_//_/|_| \___//_/ /_//_/ \___/
# by Guy Hughes
MK_CLASSPATH := ./.class
MK_SOURCEPATH := ./
MK_JAVADOCPATH := ./doc
COMPILER := javac
COMPILE_OPTIONS := -d $(MK_CLASSPATH) -classpath $(MK_CLASSPATH)
RUN :=
classfiles = $(patsubst $(MK_SOURCEPATH)/%.java,$(MK_CLASSPATH)/%.class,$(MK_SOURCEPATH)/*.java)
sourcefiles = $(MK_SOURCEPATH)/*.java
.PHONY: total all clean doc
total: clean all $(RUN)
all:
@mkdir -p $(MK_CLASSPATH)
$(COMPILER) $(COMPILE_OPTIONS) $(sourcefiles)
doc:
@mkdir -p $(MK_JAVADOCPATH)
javadoc $(sourcefiles) -d $(MK_JAVADOCPATH)
xdg-open $(MK_JAVADOCPATH)/index.html
$(MK_CLASSPATH)/%.class : $(MK_SOURCEPATH)/%.java
@mkdir -p $(MK_CLASSPATH)
$(COMPILER) $(COMPILE_OPTIONS) $?
%: $(MK_CLASSPATH)/%.class
java -classpath $(MK_CLASSPATH) $*
clean:
rm -f $(MK_CLASSPATH)/*.class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment