Commit b159f794 authored by Oliver Hitchcock Hill's avatar Oliver Hitchcock Hill
Browse files

Updating Makefile

parent e1f597b5
...@@ -20,16 +20,19 @@ ...@@ -20,16 +20,19 @@
####################### #######################
# TODO (begin) # # TODO (begin) #
####################### #######################
# Change IDENTIFIER to match the project identifier given in the project spec. # Change 'youruniqname' to match your UM uniqname (no quote marks).
IDENTIFIER = CD7E23DEB13C1B8840F765F9016C084FD5D3F130 UNIQNAME = youruniqname
# Change EXECUTABLE to match the command name given in the project spec. # Change the right hand side of the identifier to match the project identifier
EXECUTABLE = executable # given in the project or lab specification.
DEBUG = $(EXECUTABLE)_debug IDENTIFIER = CD7E23DEB13C1B8840F765F9016C084FD5D3F130
# The following line looks for a project's main() in a file named project*.cpp, # Change 'executable' to match the command name given in the project spec.
EXECUTABLE = lab1
# The following line looks for a project's main() in files named project*.cpp,
# executable.cpp (substituted from EXECUTABLE above), or main.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 # If main() is in another file delete line above, edit and uncomment below
#PROJECTFILE = mymainfile.cpp #PROJECTFILE = mymainfile.cpp
####################### #######################
...@@ -44,8 +47,8 @@ LD_RUN_PATH := /usr/um/gcc-6.2.0/lib64 ...@@ -44,8 +47,8 @@ LD_RUN_PATH := /usr/um/gcc-6.2.0/lib64
# This is the path from the CAEN home folder to where projects will be # This is the path from the CAEN home folder to where projects will be
# uploaded. (eg. /home/mmdarden/eecs281/project1) # uploaded. (eg. /home/mmdarden/eecs281/project1)
# Change this if you prefer a different path. # Change this if you prefer a different path.
# REMOTE_BASEDIR := w18/eecs281 # /home/mmdarden/w18/eecs281/project0 # REMOTE_PATH := eecs281_$(EXECUTABLE)_sync # /home/mmdarden/eecs281_proj0_sync
REMOTE_BASEDIR := eecs281 REMOTE_PATH := eecs281_$(EXECUTABLE)_sync
# designate which compiler to use # designate which compiler to use
CXX = g++ CXX = g++
...@@ -62,8 +65,9 @@ SOURCES := $(filter-out $(TESTSOURCES), $(SOURCES)) ...@@ -62,8 +65,9 @@ SOURCES := $(filter-out $(TESTSOURCES), $(SOURCES))
OBJECTS = $(SOURCES:%.cpp=%.o) OBJECTS = $(SOURCES:%.cpp=%.o)
# name of the tarball created for submission # name of the tarball created for submission
PARTIAL_SUBMITFILE = partialsubmit.tar.gz
FULL_SUBMITFILE = fullsubmit.tar.gz FULL_SUBMITFILE = fullsubmit.tar.gz
PARTIAL_SUBMITFILE = partialsubmit.tar.gz
UNGRADED_SUBMITFILE = ungraded.tar.gz
# name of the perf data file, only used by the clean target # name of the perf data file, only used by the clean target
PERF_FILE = perf.data* PERF_FILE = perf.data*
...@@ -76,15 +80,21 @@ CXXFLAGS = -std=c++1z -Wconversion -Wall -Werror -Wextra -pedantic ...@@ -76,15 +80,21 @@ CXXFLAGS = -std=c++1z -Wconversion -Wall -Werror -Wextra -pedantic
release: CXXFLAGS += -O3 -DNDEBUG release: CXXFLAGS += -O3 -DNDEBUG
release: $(EXECUTABLE) 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 # also defines DEBUG, so "#ifdef DEBUG /*...*/ #endif" works
debug: EXECUTABLE := $(DEBUG)
debug: CXXFLAGS += -g3 -DDEBUG 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 # make profile - will compile "all" with $(CXXFLAGS) and the -g3 and -O3 flags
profile: clean $(EXECUTABLE) profile: CXXFLAGS += -g3 -O3
profile:
$(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXECUTABLE)_profile
# make gprof - will compile "all" with $(CXXFLAGS) and the -pg (for gprof)
gprof: CXXFLAGS += -pg
gprof:
$(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXECUTABLE)_profile
# make static - will perform static analysis in the matter currently used # make static - will perform static analysis in the matter currently used
# on the autograder # on the autograder
...@@ -96,12 +106,15 @@ static: ...@@ -96,12 +106,15 @@ static:
# include the project identifier; skip subdirectories; # include the project identifier; skip subdirectories;
# also removes old submit tarballs, they are outdated # also removes old submit tarballs, they are outdated
identifier: 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 \
printf "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
# Build both release and debug executables # Build all executables
all: clean all: release debug profile
$(MAKE) -Rr release
$(MAKE) debug
$(EXECUTABLE): $(OBJECTS) $(EXECUTABLE): $(OBJECTS)
ifeq ($(EXECUTABLE), executable) ifeq ($(EXECUTABLE), executable)
...@@ -127,7 +140,7 @@ define make_tests ...@@ -127,7 +140,7 @@ define make_tests
endef endef
$(foreach test, $(TESTS), $(eval $(call make_tests, $(test)))) $(foreach test, $(TESTS), $(eval $(call make_tests, $(test))))
alltests: clean $(TESTS) alltests: $(TESTS)
# rule for creating objects # rule for creating objects
%.o: %.cpp %.o: %.cpp
...@@ -135,44 +148,65 @@ alltests: clean $(TESTS) ...@@ -135,44 +148,65 @@ alltests: clean $(TESTS)
# make clean - remove .o files, executables, tarball # make clean - remove .o files, executables, tarball
clean: clean:
rm -f $(OBJECTS) $(EXECUTABLE) $(DEBUG) $(TESTS) \ rm -f $(OBJECTS) $(EXECUTABLE) $(EXECUTABLE)_debug $(EXECUTABLE)_profile \
$(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(PERF_FILE) $(TESTS) $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(PERF_FILE) \
$(UNGRADED_SUBMITFILE)
rm -Rf *.dSYM rm -Rf *.dSYM
# make partialsubmit.tar.gz - cleans, creates tarball
# omitting test cases
PARTIAL_SUBMITFILES=$(filter-out $(TESTSOURCES), \
$(wildcard Makefile *.h *.hpp *.cpp))
$(PARTIAL_SUBMITFILE): $(PARTIAL_SUBMITFILES)
rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE)
COPYFILE_DISABLE=true tar -vczf $(PARTIAL_SUBMITFILE) \
$(PARTIAL_SUBMITFILES)
@echo !!! WARNING: No test cases included. Use 'make fullsubmit' to include test cases. !!!
# make fullsubmit.tar.gz - cleans, runs dos2unix, creates tarball # get a list of all files that might be included in a submit
# including test cases # different submit types can do additional filtering to remove unwanted files
FULL_SUBMITFILES=$(filter-out $(TESTSOURCES), \ FULL_SUBMITFILES=$(filter-out $(TESTSOURCES), \
$(wildcard Makefile *.h *.hpp *.cpp test*.txt)) $(wildcard Makefile *.h *.hpp *.cpp test*.txt))
# make fullsubmit.tar.gz - cleans, runs dos2unix, creates tarball
# including test files
$(FULL_SUBMITFILE): $(FULL_SUBMITFILES) $(FULL_SUBMITFILE): $(FULL_SUBMITFILES)
rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(UNGRADED_SUBMITFILE)
COPYFILE_DISABLE=true tar -vczf $(FULL_SUBMITFILE) $(FULL_SUBMITFILES) COPYFILE_DISABLE=true tar -vczf $(FULL_SUBMITFILE) $(FULL_SUBMITFILES)
@echo !!! Final submission prepared, test cases included... READY FOR GRADING !!! @echo !!! Final submission prepared, test files included... READY FOR GRADING !!!
# make partialsubmit.tar.gz - cleans, creates tarball
# omitting test files
PARTIAL_SUBMITFILES=$(filter-out $(wildcard test*.txt), $(FULL_SUBMITFILES))
$(PARTIAL_SUBMITFILE): $(PARTIAL_SUBMITFILES)
rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(UNGRADED_SUBMITFILE)
COPYFILE_DISABLE=true tar -vczf $(PARTIAL_SUBMITFILE) \
$(PARTIAL_SUBMITFILES)
@echo !!! WARNING: No test files included. Use 'make fullsubmit' to include test files. !!!
# make ungraded.tar.gz - cleans, creates tarball omitting test files, Makefile
UNGRADED_SUBMITFILES=$(filter-out Makefile, $(PARTIAL_SUBMITFILES))
$(UNGRADED_SUBMITFILE): $(UNGRADED_SUBMITFILES)
rm -f $(PARTIAL_SUBMITFILE) $(FULL_SUBMITFILE) $(UNGRADED_SUBMITFILE)
@touch __ungraded
COPYFILE_DISABLE=true tar -vczf $(UNGRADED_SUBMITFILE) \
$(UNGRADED_SUBMITFILES) __ungraded
@rm -f __ungraded
@echo !!! WARNING: This submission will not be graded. !!!
# shortcut for make submit tarballs # shortcut for make submit tarballs
partialsubmit: identifier $(PARTIAL_SUBMITFILE)
fullsubmit: identifier $(FULL_SUBMITFILE) fullsubmit: identifier $(FULL_SUBMITFILE)
partialsubmit: identifier $(PARTIAL_SUBMITFILE)
ungraded: identifier $(UNGRADED_SUBMITFILE)
sync2caen: REMOTE_PATH := ${REMOTE_BASEDIR}/$(notdir $(shell pwd)) # REMOTE_PATH has default definition above
sync2caen: sync2caen:
# Synchronize local files into target directory on CAEN # Synchronize local files into target directory on CAEN
rsync \ rsync \
-av \ -av \
--delete \ --delete \
--exclude '*.o' \
--exclude '$(EXECUTABLE)' \
--exclude '$(EXECUTABLE)_debug' \
--exclude '$(EXECUTABLE)_profile' \
--exclude '.git*' \ --exclude '.git*' \
--exclude '.vs*' \ --exclude '.vs*' \
--filter=":- .gitignore" \ --exclude '*.code-workspace' \
./ \ --filter=":- .gitignore" \
"login.engin.umich.edu:'${REMOTE_PATH}'/" "."/ \
"$(UNIQNAME)@login.engin.umich.edu:'$(REMOTE_PATH)/'"
echo "Files synced to CAEN at ~/$(REMOTE_PATH)/"
define MAKEFILE_HELP define MAKEFILE_HELP
EECS281 Advanced Makefile Help EECS281 Advanced Makefile Help
...@@ -196,7 +230,7 @@ EECS281 Advanced Makefile Help ...@@ -196,7 +230,7 @@ EECS281 Advanced Makefile Help
free submissions if the project does not build. free submissions if the project does not build.
$$ make partialsubmit $$ make partialsubmit
B) Build 'fullsubmit.tar.gz' a tarball complete with autograder test B) Build 'fullsubmit.tar.gz' a tarball complete with autograder test
cases. files.
*** ALWAYS USE THIS FOR FINAL GRADING! *** *** ALWAYS USE THIS FOR FINAL GRADING! ***
...@@ -255,7 +289,7 @@ help: ...@@ -255,7 +289,7 @@ help:
# #
# THE COMPILER CAN GENERATE DEPENDENCIES FROM SOURCE CODE # THE COMPILER CAN GENERATE DEPENDENCIES FROM SOURCE CODE
# #
# % g++ -MM *.cpp # % g++ -std=c++1z -MM *.cpp
# #
# ADD YOUR OWN DEPENDENCIES HERE # ADD YOUR OWN DEPENDENCIES HERE
...@@ -265,6 +299,6 @@ help: ...@@ -265,6 +299,6 @@ help:
# these targets do not create any files # these targets do not create any files
.PHONY: all release debug profile static clean alltests partialsubmit \ .PHONY: all release debug profile static clean alltests partialsubmit \
fullsubmit sync2caen help identifier fullsubmit ungraded sync2caen help identifier
# disable built-in rules # disable built-in rules
.SUFFIXES: .SUFFIXES:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment