# Define the compiler and the linker. The linker must be defined since # the implicit rule for linking uses CC as the linker. g++ can be # changed to clang++. CXX = g++ CC = $(CXX) # Define preprocessor, compiler, and linker flags. Uncomment the # lines # if you use clang++ and wish to use libc++ instead of GNU's libstdc++. # -g is for debugging. CPPFLAGS = -std=c++11 -I. CXXFLAGS = -O0 -Wall -Wextra -pedantic-errors -Wold-style-cast CXXFLAGS += -std=c++11 CXXFLAGS += -g LDFLAGS = -g # CPPFLAGS += -stdlib=libc++ # CXXFLAGS += -stdlib=libc++ # LDFLAGS += -stdlib=libc++ PROGS=ub leak bounds bounds-heap dangling sum ALL: $(PROGS) leak: leak.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< dangling: dangling.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< bounds: bounds.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< ub: ub.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< sum: sum.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< .PHONY: all clean test clean: -rm -f $(PROGS) -rm -rf $(addsuffix .dSYM, $(PROGS)) test: $(PROGS) @echo "Running tests with Valgrind..." @for prog in $(PROGS); do \ echo "Testing $$prog with Valgrind:"; \ valgrind ./$$prog; \ echo ""; \ done