Last active
September 10, 2018 20:05
-
-
Save theKidOfArcrania/bacccc18122e50817073eaf5c3f96e4c to your computer and use it in GitHub Desktop.
Makefile for any CS3345.HON (Data structures) project
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
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