-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile.macos
69 lines (54 loc) · 1.54 KB
/
Makefile.macos
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
# Makefiel for SRCNN git cloned mod.
# by Raphael Kim
CPP = llvm-gcc
CXX = llvm-g++
AR = ar
# sense macOS kernel type
KERNEL = $(shell uname -s)
KRNL_ARCH = $(shell uname -m)
KRNL_VER = $(shell uname -r | cut -d . -f1)
KERNELID = $(KERNEL)
MACHINEID = universal
# remind, macOS brew don't provides universal binary -
OPENCV_INCS = $(shell pkg-config opencv4 --cflags)
OPENCV_LIBS = $(shell pkg-config opencv4 --libs)
USE_STATIC_OPENCV = 0
SRC_PATH = src
OBJ_PATH = obj
BIN_PATH = bin
TARGET = srcnn
SRCS = $(wildcard $(SRC_PATH)/*.cpp)
OBJS = $(SRCS:$(SRC_PATH)/%.cpp=$(OBJ_PATH)/%.o)
CFLAGS += -std=c++11
CFLAGS += -I$(SRC_PATH)
CFLAGS += $(OPENCV_INCS)
CFLAGS += -DNO_OMP
# Static build may require static-configured openCV.
LFLAGS =
LFLAGS += $(OPENCV_LIBS)
LFLAGS += -ffast-math -O3
# architecture flag setting.
# Darwin, kernel 20 (big sur) automatically using universal binary.
ifeq ($(USE_STATIC_OPENCV),1)
ifeq ($(KERNEL),Darwin)
ifeq ($(shell test $(KRNL_VER) -gt 19; echo $$?),0)
CFLAGS += -arch x86_64 -arch arm64
CFLAGS += -mmacosx-version-min=11.0
LFLAGS += -arch x86_64 -arch arm64
endif
endif
endif
.PHONY: prepare clean all
all: prepare $(BIN_PATH)/$(TARGET)
prepare:
@mkdir -p $(OBJ_PATH)
@mkdir -p $(BIN_PATH)
clean:
@rm -rf $(OBJ_PATH)/*.o
@rm -rf $(BIN_PATH)/$(TARGET)
$(OBJS): $(OBJ_PATH)/%.o: $(SRC_PATH)/%.cpp
@echo "Compiling $< ..."
@$(CXX) $(CFLAGS) -c $< -o $@
$(BIN_PATH)/$(TARGET): $(OBJS)
@echo "Linking $@ ..."
@$(CXX) $^ $(CFLAGS) $(LFLAGS) -o $@