From a423bbc224ebe389c6b7e08f22d54e55f414e35b Mon Sep 17 00:00:00 2001 From: "Marcus M. Darden" <mmdarden@umich.edu> Date: Mon, 11 Mar 2019 23:42:15 -0400 Subject: [PATCH] Add Project Identifier variable and target * A variable (IDENTIFIER) was added to allow the 'identifier' target to search source code and header files for a matching hash parametrically. * The phony 'identifier' target greps for the IDENTIFIER pattern in each file and fails if any source/header doesn't contain the pattern. * The identifier target is added as a dependency to fullsubmit and partialsubmit. * Editing IDENTIFIER is now part of the first student TODO in the Makefile. --- Makefile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index aeda718..8750382 100644 --- a/Makefile +++ b/Makefile @@ -20,12 +20,16 @@ ####################### # TODO (begin) # ####################### +# Change IDENTIFIER to match the project identifier given in the project spec. +IDENTIFIER = EEC50281EEC50281EEC50281EEC50281EEC50281 + # Change EXECUTABLE to match the command name given in the project spec. EXECUTABLE = executable DEBUG = $(EXECUTABLE)_debug -# If main() is in a file named project*.cpp, use the following line -PROJECTFILE = $(or $(wildcard project*.cpp), $(EXECUTABLE).cpp) +# The following line looks for a project's main() in a file named project*.cpp, +# executable.cpp (substituted from EXECUTABLE above), or main.cpp +PROJECTFILE = $(or $(wildcard project*.cpp), $(wildcard $(EXECUTABLE).cpp), main.cpp) # If main() is in another file delete line above, edit and uncomment below #PROJECTFILE = mymainfile.cpp ####################### @@ -88,6 +92,11 @@ static: cppcheck --enable=all --suppress=missingIncludeSystem \ $(SOURCES) *.h *.hpp +# make identifier - will ensure that all source code and header files include +# the project identifier +identifier: + @if [ $$(grep --include=*.{h,hpp,c,cpp} -L $(IDENTIFIER) * | wc -l) -ne 0 ]; then echo "Missing project identifier"; exit 1; fi + # Build both release and debug executables all: clean $(MAKE) -Rr release @@ -151,8 +160,8 @@ $(FULL_SUBMITFILE): $(FULL_SUBMITFILES) @echo !!! Final submission prepared, test cases included... READY FOR GRADING !!! # shortcut for make submit tarballs -partialsubmit: $(PARTIAL_SUBMITFILE) -fullsubmit: $(FULL_SUBMITFILE) +partialsubmit: identifier $(PARTIAL_SUBMITFILE) +fullsubmit: identifier $(FULL_SUBMITFILE) sync2caen: REMOTE_PATH := ${REMOTE_BASEDIR}/$(notdir $(shell pwd)) sync2caen: @@ -257,6 +266,6 @@ help: # these targets do not create any files .PHONY: all release debug profile static clean alltests partialsubmit \ - fullsubmit sync2caen help + fullsubmit sync2caen help identifier # disable built-in rules .SUFFIXES: -- GitLab