-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
44 lines (32 loc) · 1.17 KB
/
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
44
# Description: Makefile for the project
# Compiler and flags
CXX := g++
CC := gcc
CXXFLAGS := -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 -Wcast-align -Wconversion -Wsign-conversion -Wnull-dereference -g3 -Ofast -std=c++11
CFLAGS := -Wall -Wextra -pedantic -Ofast -std=c11
# Libraries and paths
HDF5_DIR := /opt/homebrew/Cellar/hdf5/1.14.3
EIGEN_DIR := /opt/homebrew/Cellar/eigen/3.4.0_1
LIBS := -lm -L$(HDF5_DIR)/lib -lhdf5_cpp -lhdf5
INCLUDES := -I$(EIGEN_DIR)/include/ -I$(HDF5_DIR)/include
# Folders
SRC := src
INCLUDE := include
BIN := bin
# Executable name
TARGET := main
# Sources and objects
SOURCES := $(wildcard $(SRC)/*.c) $(wildcard $(SRC)/*.cpp)
OBJECTS := $(patsubst $(SRC)/%.cpp, $(BIN)/%.o, $(filter %.cpp, $(SOURCES))) $(patsubst $(SRC)/%.c, $(BIN)/%.o, $(filter %.c, $(SOURCES)))
# Headers
HEADERS := $(wildcard $(INCLUDE)/*.h) $(wildcard $(INCLUDE)/*.hpp)
.PHONY: all clean
all: $(BIN)/$(TARGET)
$(BIN)/$(TARGET): $(OBJECTS)
@$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
$(BIN)/%.o: $(SRC)/%.cpp $(HEADERS)
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(BIN)/%.o: $(SRC)/%.c $(HEADERS)
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
@rm -f $(BIN)/*.o $(BIN)/$(TARGET)