This commit is contained in:
Imbus 2024-05-27 06:24:26 +02:00
parent 2b329b4031
commit 61812932ac
4 changed files with 83 additions and 5 deletions

View file

@ -1,24 +1,25 @@
BIN := graphs
# Compiler
CC := gcc
# CC := gcc
CC := g++
GITHASH := $(shell git rev-parse --short HEAD)
# Compiler flags
CFLAGS := -Wall -Wextra -Wpedantic -std=c2x
CFLAGS := -Wall -Wextra -Wpedantic -std=c++23
# Directories
SRC_DIR := src
BUILD_DIR := build
# Source files
SRCS := $(wildcard $(SRC_DIR)/*.c)
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
# Header files (used for formatting)
HEADERS := $(wildcard $(SRC_DIR)/*.h)
# Object files
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS))
# Target executable
TARGET := $(BUILD_DIR)/$(BIN)
@ -31,7 +32,7 @@ $(TARGET): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@
# Rule to build object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@