-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (28 loc) · 849 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
ODIR = ./objects
SDIR = ./src
IDIR = ./include
MAIN = generator.cpp
EXECUTABLE = $(patsubst %.cpp,%, $(MAIN))
MAKEFLAGS = -j$(shell nproc)
FLAGS := $(shell root-config --cflags)
FLAGS += -I. -I$(IDIR)
OPTFLAG = $(FLAGS) -Wall -Wextra -O3
LIBS := $(shell root-config --libs)
LIBS += -lrt
OBJS = $(patsubst %.cpp,%.o,$(addprefix $(ODIR)/,$(wildcard *.cpp)))
OBJS += $(patsubst $(SDIR)/%.cpp,$(ODIR)/%.o,$(wildcard $(SDIR)/*.cpp))
.PHONY: clean
all: $(EXECUTABLE)
debug:OPTFLAG = $(FLAGS) -Wall -Wextra -O0 -g
debug:$(EXECUTABLE)
$(OBJS): | $(ODIR)
$(ODIR):
mkdir -p $(ODIR)
$(ODIR)/$(MAIN:.cpp=.o): $(MAIN)
$(CXX) $(OPTFLAG) -c -o $@ $<
$(ODIR)/%.o:$(SDIR)/%.cpp $(IDIR)/%.hpp
$(CXX) $(OPTFLAG) -c -o $@ $<
$(EXECUTABLE): $(OBJS)
$(CXX) -o $@ $^ $(LIBS)
clean:
rm -f $(ODIR)/*.o $(SDIR)/*~ $(IDIR)/*~ $(EXECUTABLE) *.txt *.root *~