-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (37 loc) · 1.35 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
45
46
47
48
49
50
# Compiler to be used
CC = g++
# Compiler flags
CFLAGS = -Wall -std=c++17 -Ofast -s -march=native -ffast-math -fomit-frame-pointer -fexpensive-optimizations -fno-rtti -flto
CFLAGS_DEBUG = -Wall -Wextra -std=c++17 -O0 -g
# INCLUDES = -I ~/home/leon/models/lif_cpp/include
# LIBS = -I/home/leon/homebrew/Cellar/yaml-cpp/0.8.0/include -L/home/leon/homebrew/Cellar/yaml-cpp/0.8.0/lib -lyaml-cpp
LIBS = -lyaml-cpp
# LIBS = -L ~/mambaforge/lib -Wl,--disable-new-dtags,-rpath,~/mambaforge/lib -llapack -lblas -larmadillo -lyaml-cpp
# Source and build directories
SRCDIR = ./src
BUILDDIR = ./obj
TARGETDIR = ./bin
# Application name (target)
TARGET = LifNet
# Get all source files
SRCS := $(wildcard $(SRCDIR)/*.cpp)
# Object files are the same as sources but with .o extension
OBJS := $(SRCS:$(SRCDIR)/%.cpp=$(BUILDDIR)/%.o)
# Build both Release and Debug by default
all: $(TARGET)
debug: $(TARGET)
$(TARGET): $(OBJS)
$(CC) -o $(TARGETDIR)/$@ $^ $(CFLAGS) $(INCLUDES) $(LIBS)
# Create a special rule for the debug build
$(TARGET)_debug: $(OBJS)
$(CC) -o $(TARGETDIR)/$@ $^ $(CFLAGS_DEBUG) $(INCLUDES) $(LIBS)
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
ifndef DEBUG
$(CC) $(CFLAGS) $(INCLUDES) $(LIBS) -c $< -o $@
else
$(CC) $(CFLAGS_DEBUG) $(INCLUDES) $(LIBS) -c $< -o $@
endif
clean:
rm -rf $(BUILDDIR)/*.o $(TARGETDIR)/$(TARGET)
# Recompile if any headers change
.PHONY: clean debug