-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
50 lines (37 loc) · 967 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
44
45
46
47
48
49
50
CC = g++
CFLAGS = -O2 -Wall -fopenmp
LDFLAGS = -lgomp -lpthread `pkg-config --cflags --libs opencv` -lstdc++fs
TARGET = haar
SRCDIR = src
OBJDIR = obj
IMGDIR = output_img
IMGDIRSEQ = output_img_seq
FSTATS = stats.txt
SOURCES = $(shell find $(SRCDIR) -type f -name *.cpp)
SRCDIRS = $(shell find . -name '*.cpp' -exec dirname {} \; | uniq)
OBJ = $(patsubst %.cpp,$(OBJDIR)/%.o,$(SOURCES))
HEADER = $(shell find $(SRCDIR) -type f -name *.h)
all: directories $(TARGET)
directories:
@mkdir -p $(OBJDIR)
@mkdir -p $(IMGDIR)
@mkdir -p $(IMGDIRSEQ)
$(OBJDIR)/$(SRCDIR)/%.o: $(SRCDIR)/%.cpp
$(CC) $(CFLAGS) -o $@ -c $<
$(TARGET): buildrepo $(OBJ)
$(CC) $(CFLAGS) $(OBJ) -o $(TARGET) $(LDFLAGS)
$(OBJ): $(HEADER)
buildrepo:
@$(call make-repo)
define make-repo
for dir in $(SRCDIRS); \
do \
mkdir -p $(OBJDIR)/$$dir; \
done
endef
clean:
rm -rf $(OBJDIR)
cleanall:
rm -rf $(TARGET) $(OBJDIR) $(IMGDIR) $(IMGDIRSEQ) $(FSTATS)
.PHONY:
all clean cleanall