-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
43 lines (29 loc) · 696 Bytes
/
Makefile
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
42
43
CC := g++
# Final target
EXE := main
# Source and build output directories
SRC_DIR := src
OBJ_DIR := obj
# Source files
SRC := $(wildcard $(SRC_DIR)/*.cpp)
# Object files
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
# Preprocessor flags
CPPFLAGS := -Iinclude
# Compiler flags
CFLAGS := -std=c++14 -Wall -g -fopenmp -w -O3
# Linker flags
LDFLAGS := -Llib -fopenmp
# Third party libraries to link against
LDLIBS := -lm
.PHONY: all clean
all: $(EXE)
# Prerequisites for building executable
$(EXE): $(OBJ)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJ_DIR):
mkdir $@
clean:
rm -f $(OBJ) $(EXE)