Skip to content

Instantly share code, notes, and snippets.

@theKidOfArcrania
Last active September 10, 2018 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theKidOfArcrania/bacccc18122e50817073eaf5c3f96e4c to your computer and use it in GitHub Desktop.
Save theKidOfArcrania/bacccc18122e50817073eaf5c3f96e4c to your computer and use it in GitHub Desktop.
Makefile for any CS3345.HON (Data structures) project
JFLAGS=
JCFLAGS=
include config.mk
# Some private variables
MAINCLASS=$(join $(NAMEPREF), $(PROJ))
DATAFILE=$(join $(PROJ), data)
.PHONY: all test clean
all: $(MAINCLASS:%=%.class)
config.mk:
@set -eu; read -p "Hello, what's your full name (First and last only, please): " NAME; \
read -p "Hello, $$NAME! Which project number is this for? (ex. 1): " PROJ; \
NAMEPREF=$$(echo $$NAME | gawk '{print toupper(substr($$1, 0, 2) substr($$2, 0, 2)) }'); \
PROJ=P$$PROJ; echo "You should have a file named: $$NAMEPREF$$PROJ.java"; \
echo "NAMEPREF=$$NAMEPREF\nPROJ=$$PROJ" > config.mk
@echo "*** config.mk generated! ***"
realclean: clean
rm -f config.mk
clean:
rm -f *.class
test: all $(DATAFILE:%=%.txt) $(DATAFILE:%=%.out)
@echo "Comparing run output to actual output..." && bash -c \
"diff -u <(java $(JFLAGS) $(MAINCLASS)) $(DATAFILE:%=%.out)"
@echo "Success! They match!"
%.class: %.java
javac $(JCFLAGS) $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment