File size: 1,103 Bytes
96c927a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#
# Makefile
# Jiayuan Mao, 2019-01-09 13:59
#

SRC_DIR = csrc
INC_DIR = csrc
OBJ_DIR = build/obj
TARGET = libpatchmatch.so

LIB_TARGET = $(TARGET)
INCLUDE_DIR = -I $(SRC_DIR) -I $(INC_DIR)

CXX = $(ENVIRONMENT_OPTIONS) g++
CXXFLAGS = -std=c++14
CXXFLAGS += -Ofast -ffast-math -w
# CXXFLAGS += -g
CXXFLAGS += $(shell pkg-config --cflags opencv.pc) -fPIC
CXXFLAGS += $(INCLUDE_DIR)
LDFLAGS = $(shell pkg-config --cflags --libs opencv.pc) -shared -fPIC


CXXSOURCES = $(shell find $(SRC_DIR)/ -name "*.cpp")
OBJS = $(addprefix $(OBJ_DIR)/,$(CXXSOURCES:.cpp=.o))
DEPFILES = $(OBJS:.o=.d)

.PHONY: all clean rebuild test

all: $(LIB_TARGET)

$(OBJ_DIR)/%.o: %.cpp
	@echo "[CC] $< ..."
	@$(CXX) -c $< $(CXXFLAGS) -o $@

$(OBJ_DIR)/%.d: %.cpp
	@mkdir -pv $(dir $@)
	@echo "[dep] $< ..."
	@$(CXX) $(INCLUDE_DIR) $(CXXFLAGS) -MM -MT "$(OBJ_DIR)/$(<:.cpp=.o) $(OBJ_DIR)/$(<:.cpp=.d)" "$<" > "$@"

sinclude $(DEPFILES)

$(LIB_TARGET): $(OBJS)
	@echo "[link] $(LIB_TARGET) ..."
	@$(CXX) $(OBJS) -o $@ $(CXXFLAGS) $(LDFLAGS)

clean:
	rm -rf $(OBJ_DIR) $(LIB_TARGET)

rebuild:
	+@make clean
	+@make

# vim:ft=make
#