2023-05-07 19:51:43 +02:00

51 lines
1.1 KiB
Makefile

CC := g++ -m64 -std=c++17
OBJ_DIR := bin
$(shell mkdir -p $(OBJ_DIR))
SRC_DIR := .
#CFLAGS := -Og -g -Wall -Wextra -Wno-error=unused-function -pedantic -rdynamic
#CFLAGS := $(CFLAGS) -pg -ggdb3
#CFLAGS := $(CFLAGS) -D__DEBUG
CFLAGS := -O4 -Wall -Wextra -Wno-error=unused-function
EXEC := $(OBJ_DIR)/data
SRC := $(wildcard $(SRC_DIR)/*.cpp)
HEADER := $(wildcard $(SRC_DIR)/*.hpp)
OBJ_EXT := o
ifeq ($(OS), Windows_NT)
EXEC:=$(EXEC).exe
OBJ_EXT:=obj
endif
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.$(OBJ_EXT))
.PHONY: all start clean mrproper
all: $(EXEC)
$(OBJ_DIR)/%.$(OBJ_EXT): $(SRC_DIR)/%.cpp $(SRC_DIR)/%.hpp
@echo Compiling $<
@$(CC) $(CFLAGS) -c $< -o $@
$(EXEC): $(OBJ)
@echo Linking objects files to $@
@$(CC) $(CFLAGS) $^ -o $@
start: $(EXEC)
@./$(EXEC)
profile: start
@gprof $(EXEC) gmon.out | gprof2dot | dot -Tpng -o output.png
debug: $(EXEC)
@gdb -q -tui $(EXEC) -x copies
check: $(EXEC)
@valgrind -q -s --leak-check=full --show-leak-kinds=all $(EXEC)
r2: $(EXEC)
@r2 $(EXEC)
clean:
@rm $(EXEC) gmon.out output.png
mrproper:
@rm -r $(OBJ_DIR)