Makefile now checks for dependencies
This commit is contained in:
parent
674c5da3cc
commit
0da832aa8b
52
Makefile
52
Makefile
@ -1,11 +1,9 @@
|
|||||||
CC := g++ -m64 -std=c++17
|
CC := g++ -m64 -std=c++17
|
||||||
OBJ_DIR := bin
|
OBJ_DIR := bin
|
||||||
$(shell mkdir -p $(OBJ_DIR))
|
|
||||||
SRC_DIR := .
|
SRC_DIR := .
|
||||||
#CFLAGS := -Og -g -Wall -Wextra -Wno-error=unused-function -pedantic -rdynamic
|
#CFLAGS := -Og -g -rdynamic -pg -ggdb3 -D__DEBUG
|
||||||
#CFLAGS := $(CFLAGS) -pg -ggdb3
|
CFLAGS := -O2
|
||||||
#CFLAGS := $(CFLAGS) -D__DEBUG
|
CFLAGS := $(CFLAGS) -Wall -Wextra -Wno-error=unused-function -pedantic
|
||||||
CFLAGS := -O4 -Wall -Wextra -Wno-error=unused-function
|
|
||||||
EXEC := $(OBJ_DIR)/data
|
EXEC := $(OBJ_DIR)/data
|
||||||
SRC := $(wildcard $(SRC_DIR)/*.cpp)
|
SRC := $(wildcard $(SRC_DIR)/*.cpp)
|
||||||
HEADER := $(wildcard $(SRC_DIR)/*.hpp)
|
HEADER := $(wildcard $(SRC_DIR)/*.hpp)
|
||||||
@ -16,11 +14,14 @@ ifeq ($(OS), Windows_NT)
|
|||||||
endif
|
endif
|
||||||
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.$(OBJ_EXT))
|
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.$(OBJ_EXT))
|
||||||
|
|
||||||
.PHONY: all start clean mrproper
|
.PHONY: all start profile debug check r2 clean mrproper
|
||||||
|
|
||||||
all: $(EXEC)
|
all: $(EXEC)
|
||||||
|
|
||||||
$(OBJ_DIR)/%.$(OBJ_EXT): $(SRC_DIR)/%.cpp $(SRC_DIR)/%.hpp
|
$(OBJ_DIR):
|
||||||
|
@mkdir -v $@
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.$(OBJ_EXT): $(SRC_DIR)/%.cpp $(SRC_DIR)/%.hpp | $(OBJ_DIR)
|
||||||
@echo Compiling $<
|
@echo Compiling $<
|
||||||
@$(CC) $(CFLAGS) -c $< -o $@
|
@$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
@ -31,20 +32,43 @@ $(EXEC): $(OBJ)
|
|||||||
start: $(EXEC)
|
start: $(EXEC)
|
||||||
@./$(EXEC)
|
@./$(EXEC)
|
||||||
|
|
||||||
profile: start
|
profile: start | check-gprof-works check-gprof2dot-works
|
||||||
@gprof $(EXEC) gmon.out | gprof2dot | dot -Tpng -o output.png
|
@gprof $(EXEC) gmon.out | gprof2dot | dot -Tpng -o output.png
|
||||||
|
|
||||||
debug: $(EXEC)
|
debug: $(EXEC) | check-gdb-works
|
||||||
@gdb -q -tui $(EXEC) -x copies
|
@gdb -q -tui $(EXEC) -x copies
|
||||||
|
|
||||||
check: $(EXEC)
|
check: $(EXEC) | check-valgrind-works
|
||||||
@valgrind -q -s --leak-check=full --show-leak-kinds=all $(EXEC)
|
@valgrind -q -s --leak-check=full --show-leak-kinds=all $(EXEC)
|
||||||
|
|
||||||
r2: $(EXEC)
|
r2: $(EXEC) | check-r2-works
|
||||||
@r2 $(EXEC)
|
@r2 $(EXEC)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm $(EXEC) gmon.out output.png
|
@rm -fv $(EXEC) gmon.out output.png
|
||||||
|
|
||||||
mrproper:
|
mrproper: clean
|
||||||
@rm -r $(OBJ_DIR)
|
@rm -rv $(OBJ_DIR)
|
||||||
|
|
||||||
|
.PHONY: check-env
|
||||||
|
check-env: check-gprof2dot-works check-gprof-works check-gdb-works check-valgrind-works check-r2-works
|
||||||
|
|
||||||
|
.PHONY: check-gprof2dot-works
|
||||||
|
check-gprof2dot-works:
|
||||||
|
@gprof2dot --help >/dev/null 2>&1 || (echo 'Please install gprof2dot.' && exit 1)
|
||||||
|
|
||||||
|
.PHONY: check-gprof-works
|
||||||
|
check-gprof-works:
|
||||||
|
@gprof --version >/dev/null 2>&1 || (echo 'Please install gprof.' && exit 1)
|
||||||
|
|
||||||
|
.PHONY: check-gdb-works
|
||||||
|
check-gdb-works:
|
||||||
|
@gdb --version >/dev/null 2>&1 || (echo 'Please install gdb.' && exit 1)
|
||||||
|
|
||||||
|
.PHONY: check-valgrind-works
|
||||||
|
check-valgrind-works:
|
||||||
|
@valgrind --version >/dev/null 2>&1 || (echo 'Please install valgrind.' && exit 1)
|
||||||
|
|
||||||
|
.PHONY: check-r2-works
|
||||||
|
check-r2-works:
|
||||||
|
@r2 -v >/dev/null 2>&1 || (echo 'Please install r2.' && exit 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user