Download Makefile source code

EXE=hello_w

all: $(EXE) $(EXE)_asan $(EXE)_msan $(EXE)_tsan $(EXE)_ubsan

$(EXE): hello_w.c
	cc -g -Wall -Wextra hello_w.c -o $(EXE) -pthread

$(EXE)_asan: hello_w.c
	clang -g -Wall -Wextra -fsanitize=address hello_w.c -o $(EXE)_asan -pthread

$(EXE)_msan: hello_w.c
	clang -g -Wall -Wextra -fsanitize=memory hello_w.c -o $(EXE)_msan -pthread

$(EXE)_tsan: hello_w.c
	clang -g -Wall -Wextra -fsanitize=thread hello_w.c -o $(EXE)_tsan -pthread

$(EXE)_ubsan: hello_w.c
	clang -g -Wall -Wextra -fsanitize=undefined hello_w.c -o $(EXE)_ubsan -pthread

.PHONY: memcheck
memcheck:
	valgrind ./$(EXE)

.PHONY: helgrind
helgrind:
	valgrind --tool=helgrind --quiet ./$(EXE)

.PHONY: rebuild
rebuild: clean $(EXE)

.PHONY: lint
lint:
	cpplint --filter=-readability/casting hello_w.c

.PHONY: gitignore
gitignore:
	echo $(EXE) $(EXE)_asan $(EXE)_msan $(EXE)_tsan $(EXE)_ubsan | tr " " "\n" > .gitignore

.PHONY: clean
clean:
	rm -rf $(EXE) $(EXE)_asan $(EXE)_msan $(EXE)_tsan $(EXE)_ubsan