Commit b538bc61 authored by Marcus M. Darden's avatar Marcus M. Darden
Browse files

Reimplement 'make all'

% make all
This now builds executable, executable_debug, and executable_profile.
This will allow for easy implementation of the autograder building and
testing student solutions. When a SIG occurs, the AG can then run
valgrind with a debug build, to give improved feedback to students.

Build objects (.o files) are now only created for release builds.
Therefore, any .o file found in the directory will be compiled with -O3
and -DNDEBUG. The other two build targets (debug and profile) are
compiled directly from source to executable. This should prevent any
unfortunate hybrid builds.

Some minor documentation and formatting updates were also made.
parent b08db67b
......@@ -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,15 @@ 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
$(MAKE) -Rr release
$(MAKE) debug
# Build all executables
all: release debug profile
$(EXECUTABLE): $(OBJECTS)
ifeq ($(EXECUTABLE), executable)
......@@ -127,7 +130,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 +138,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
......
Markdown is supported
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