diff --git a/Makefile b/Makefile index bb48e51a502d50642a55940030bf40e3acd291ca..166c892773ea592423842111c59e1d98bacf1a36 100644 --- a/Makefile +++ b/Makefile @@ -21,15 +21,14 @@ # TODO (begin) # ####################### # Change IDENTIFIER to match the project identifier given in the project spec. -IDENTIFIER = EEC50281EEC50281EEC50281EEC50281EEC50281 +IDENTIFIER = EEC50281EEC50281EEC50281EEC50281EEC50281 # Change EXECUTABLE to match the command name given in the project spec. EXECUTABLE = executable -DEBUG = $(EXECUTABLE)_debug -# The following line looks for a project's main() in a file named project*.cpp, +# The following line looks for a project's main() in files named project*.cpp, # executable.cpp (substituted from EXECUTABLE above), or main.cpp -PROJECTFILE = $(or $(wildcard project*.cpp), $(wildcard $(EXECUTABLE).cpp), main.cpp) +PROJECTFILE = $(or $(wildcard project*.cpp $(EXECUTABLE).cpp), main.cpp) # If main() is in another file delete line above, edit and uncomment below #PROJECTFILE = mymainfile.cpp ####################### @@ -76,15 +75,16 @@ CXXFLAGS = -std=c++1z -Wconversion -Wall -Werror -Wextra -pedantic release: CXXFLAGS += -O3 -DNDEBUG release: $(EXECUTABLE) -# make debug - will compile "all" with $(CXXFLAGS) and the -g flag +# make debug - will compile sources with $(CXXFLAGS) and the -g3 flag # also defines DEBUG, so "#ifdef DEBUG /*...*/ #endif" works -debug: EXECUTABLE := $(DEBUG) debug: CXXFLAGS += -g3 -DDEBUG -debug: clean $(EXECUTABLE) +debug: + $(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXECUTABLE)_debug # make profile - will compile "all" with $(CXXFLAGS) and the -pg flag profile: CXXFLAGS += -pg -profile: clean $(EXECUTABLE) +profile: + $(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXECUTABLE)_profile # make static - will perform static analysis in the matter currently used # on the autograder @@ -96,12 +96,18 @@ static: # include the project identifier; skip subdirectories; # also removes old submit tarballs, they are outdated identifier: - @if [ $$(grep --include=*.{h,hpp,c,cpp} --exclude=xcode_redirect.hpp --directories=skip -L $(IDENTIFIER) * | wc -l) -ne 0 ]; then echo -n "Missing project identifier in file(s): ";echo `grep --include=*.{h,hpp,c,cpp} --directories=skip -L $(IDENTIFIER) *`;rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE); exit 1; fi + @if [ $$(grep --include=*.{h,hpp,c,cpp} --exclude=xcode_redirect.hpp --directories=skip -L $(IDENTIFIER) * | wc -l) -ne 0 ]; then \ + echo "Missing project identifier in file(s): \c"; \ + echo `grep --include=*.{h,hpp,c,cpp} --directories=skip -L $(IDENTIFIER) *`; \ + rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE); \ + exit 1; \ + fi # Build both release and debug executables -all: clean +all: $(MAKE) -Rr release $(MAKE) debug + $(MAKE) profile $(EXECUTABLE): $(OBJECTS) ifeq ($(EXECUTABLE), executable) @@ -127,7 +133,7 @@ define make_tests endef $(foreach test, $(TESTS), $(eval $(call make_tests, $(test)))) -alltests: clean $(TESTS) +alltests: $(TESTS) # rule for creating objects %.o: %.cpp @@ -135,8 +141,8 @@ alltests: clean $(TESTS) # make clean - remove .o files, executables, tarball clean: - rm -f $(OBJECTS) $(EXECUTABLE) $(DEBUG) $(TESTS) \ - $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(PERF_FILE) + rm -f $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE)_debug $(EXECUTABLE)_profile \ + $(TESTS) $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(PERF_FILE) rm -Rf *.dSYM # make partialsubmit.tar.gz - cleans, creates tarball