Last active
December 21, 2015 13:49
-
-
Save ellotheth/6315832 to your computer and use it in GitHub Desktop.
Linux makefiles for Coursera's 'Algorithms I' class, derived from https://class.coursera.org/algs4partI-003/forum/thread?thread_id=63#post-432
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stick this one at the top of your Algorithms class directory; it | |
# will be sourced from all the individual code directories. | |
SUFFIXES: | |
.PHONY: build run checkstyle findbugs deliver clean cleanall | |
# My java binaries, classpath and class binary path are all already | |
# sourced in my ~/.bashrc, so I don't need to specify them here: | |
# JAVAC = "$(JAVA_HOME)/bin/javac" | |
# JAVA = "$(JAVA_HOME)/bin/java" | |
# JAR = "$(JAVA_HOME)/bin/jar" | |
# CP = .:$(ALGO)/stdlib.jar:$(ALGO)/algs4.jar | |
# ALGOBIN = $(ALGO)/bin | |
JAVAC = javac | |
JAVA = java | |
JAR = jar | |
# Change this to your algo class directory: | |
ALGO = $(HOME)/coursera/algo_i | |
# Optional | |
ALGODATA = $(ALGO)/data | |
ALGOSRC = $(ALGO)/src | |
PROG ?= $(word 1,$(CLASSES)) | |
CLASSFILES = $(patsubst %,%.class,$(CLASSES)) | |
TESTCLASSES = $(patsubst %,Test%,$(CLASSES)) | |
TESTFILES = $(patsubst %,%.class,$(TESTCLASSES)) | |
JAVAFILES = $(patsubst %,%.java,$(CLASSES)) | |
%.class: %.java | |
# $(JAVAC) -cp $(CP) $< | |
$(JAVAC) $< | |
build: $(CLASSFILES) | |
run: build | |
$(JAVA) $(PROG) $(CMDLINE) | |
checkstyle: $(JAVAFILES) | |
checkstyle $^ | |
findbugs: $(CLASSFILES) | |
findbugs $^ | |
test: build $(TESTFILES) | |
$(JAVA) org.junit.runner.JUnitCore $(TESTCLASSES) | |
# By default, 'deliver' runs your unit tests. If you're not unit | |
# testing, you can replace 'test' with 'build': | |
# deliver: build checkstyle findbugs | |
deliver: test checkstyle findbugs | |
$(JAR) cfMv $(PROG).zip $(JAVAFILES) | |
clean: | |
rm -f *.class | |
cleanall: clean | |
rm -f *.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make one of these per source directory, assumed to be a child of | |
# the common.mk directory. | |
# List the classes to be compiled here | |
CLASSES = HelloAlgo | |
# Anything you want to throw on the command line for `make run` | |
CMDLINE = 1024 100 | |
MAKEFILE_DIRECTORY := $(dir $(word 1,$(MAKEFILE_LIST))) | |
include $(MAKEFILE_DIRECTORY)/../common.mk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment