-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
41 lines (31 loc) · 1.25 KB
/
makefile
File metadata and controls
41 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
BUILD_DIR := ./build
OBJS_DIR := ./build/objs
INCS_DIR := ./src/header
SRCS_DIR := ./src
# find the source files and header files
SRCS=$(shell find $(SRCS_DIR) -name '*.cpp')
INCS=$(shell find $(INCS_DIR) -name '*.hpp')
# generate obj and header object file strings
OBJS=$(patsubst $(SRCS_DIR)/%.cpp,$(OBJS_DIR)/%.o,$(SRCS))
INC_OBJS=$(patsubst $(INCS_DIR)/%.hpp,$(OBJS_DIR)/%.o,$(INCS))
# generate the target strings with a filter on the header strings (might break if gets more complex)
TARGETS=$(patsubst $(OBJS_DIR)/%.o,$(BUILD_DIR)/%.out,$(filter-out $(INC_OBJS),$(OBJS)))
#add prefix to ind dir for includes
INC_FLAGS := $(addprefix -I,$(INCS_DIR))
# for now all we need is this?
CPPFLAGS := $(INC_FLAGS)
# using c++23 might change this for other versions too later on, change warnings?
CXXFLAGS := -std=c++26 -O3 -mavx2 -mf16c -Wall -Wextra -Wpedantic -Werror
.PHONY: all OBJECT_FILES PROGRAMS clean
all: OBJECT_FILES PROGRAMS
OBJECT_FILES: $(OBJS)
PROGRAMS: $(TARGETS)
$(OBJS_DIR)/%.o: $(SRCS_DIR)/%.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(BUILD_DIR)/%.out: $(OBJS_DIR)/%.o
$(CXX) $^ $(INC_OBJS) -o $@
# TODO move this part to be prebuild instead of after cleaning
clean:
rm -r $(BUILD_DIR)
mkdir -p $(OBJS_DIR)
mkdir -p $(BUILD_DIR)/data