-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
71 lines (53 loc) · 1.21 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
OPENCV=1
OPENMP=1
DEBUG=0
OBJ=classifier.o feature.o image.o load_image.o utils.o model.o list.o data.o postprocess.o
EXOBJ=main.o
VPATH=./src/:./
#SLIB=haarcascade.so
#ALIB=haarcascade.a
EXEC=haarcascade
OBJDIR=./obj/
CC=g++
LD=ld
AR=ar
ARFLAGS=rcs
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON= -Ih/ -Isrc/
CFLAGS=-Wall -Wno-unknown-pragmas -Wfatal-errors -fPIC -std=c++11
ifeq ($(OPENMP), 1)
CFLAGS+= -Xpreprocessor -fopenmp
LDFLAGS+= -lomp
endif
ifeq ($(DEBUG), 1)
OPTS=-O0 -g
COMMON= -Ih/ -Isrc/
else
CFLAGS+= -flto
endif
CFLAGS+=$(OPTS)
ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV -I/usr/local/include/opencv4
LDFLAGS+= `pkg-config --libs opencv4`
COMMON+= `pkg-config --cflags opencv4`
endif
EXOBJS = $(addprefix $(OBJDIR), $(EXOBJ))
OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(wildcard h/*.h) makefile
all: obj $(SLIB) $(ALIB) $(EXEC)
#all: obj $(EXEC)
$(EXEC): $(EXOBJS) $(OBJS)
$(CC) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS)
$(ALIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
$(SLIB): $(OBJS)
$(CC) $(CFLAGS) -shared $^ -o $@ $(LDFLAGS)
$(OBJDIR)%.o: %.c $(DEPS)
$(CC) $(COMMON) $(CFLAGS) -c $< -o $@
obj:
mkdir -p obj
.PHONY: clean
clean:
rm -rf $(OBJS) $(SLIB) $(ALIB) $(EXEC) $(EXOBJS) $(OBJDIR)/*