-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
121 lines (96 loc) · 3.81 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
EXECUTABLE := OpenSURF
CCFILES := clutils.cpp cvutils.cpp eventlist.cpp fasthessian.cpp \
main.cpp nearestNeighbor.cpp responselayer.cpp surf.cpp \
utils.cpp
C_DEPS := clutils.h cvutils.h eventlist.h fasthessian.h \
kmeans.h nearestNeighbor.h prf_util.h responselayer.h \
surf.h utils.h
# Comment the following to disable building
BUILD_AMD = 1
#BUILD_NVIDIA = 1
# TODO: Replace with AMDAPPSDKROOT
AMD_OPENCL_INSTALL_PATH := $(ATISTREAMSDKROOT)
NVIDIA_OPENCL_INSTALL_PATH := /usr/local/cuda
OPENCV_INC := /usr/include/opencv
OPENCV_LIB := /usr/lib64
USE_OPENCV_VERSION := 2.1
#USE_OPENCV_VERSION := 2.3
#OPENCV_LIB := /usr/local/lib
#OPENCV_INC := /usr/local/include/opencv
OPENCV_LIB_NAMES := -lopencv_imgproc -lopencv_legacy -lopencv_highgui -lopencv_video -lopencv_core
ifeq ($(USE_OPENCV_VERSION),2.1)
OPENCV_LIB_NAMES := -lcxcore -lcv -lcvaux -lhighgui -lml
endif
# Basic directory setup
SRCDIR = src
AMD_BINDIR = bin/amd
NVIDIA_BINDIR = bin/nvidia
AMD_OBJDIR = obj/amd
NVIDIA_OBJDIR = obj/nvidia
# Compilers
CXX = g++ -g
CC = gcc -g
LINK = g++ -g
# Includes
COMMON_INCLUDES += -I$(OPENCV_INC)
AMD_INCLUDES += -I$(AMD_OPENCL_INSTALL_PATH)/include $(COMMON_INCLUDES)
NVIDIA_INCLUDES += -I$(NVIDIA_OPENCL_INSTALL_PATH)/include $(COMMON_INCLUDES)
# Libs
# NVIDIA installs their OpenCL library in /usr/lib64
COMMON_LIBS := -L$(OPENCV_LIB) $(OPENCV_LIB_NAMES)
AMD_LIB := -L$(AMD_OPENCL_INSTALL_PATH)/lib/x86_64 -lOpenCL
NVIDIA_LIB := -L/usr/lib64 -lOpenCL
# Warning flags
CXXWARN_FLAGS := -W -Wall -Wno-write-strings
CWARN_FLAGS := $(CXXWARN_FLAGS) -W -Wall -Wno-write-strings
# Compiler-specific flags
CXXFLAGS := $(CXXWARN_FLAGS)
CFLAGS := $(CWARN_FLAGS)
# Common flags
COMMONFLAGS = -DUNIX -O3
# Build executable commands
ifeq ($(BUILD_AMD),1)
AMD_TARGET := $(AMD_BINDIR)/$(EXECUTABLE)
endif
ifeq ($(BUILD_NVIDIA),1)
NVIDIA_TARGET := $(NVIDIA_BINDIR)/$(EXECUTABLE)
endif
AMD_LINKLINE = $(LINK) -o $(AMD_TARGET) $(AMD_OBJS) $(AMD_LIB) \
$(COMMON_LIBS)
NVIDIA_LINKLINE = $(LINK) -o $(NVIDIA_TARGET) $(NVIDIA_OBJS) $(NVIDIA_LIB) \
$(COMMON_LIBS)
################################################################################
# Check for input flags and set compiler flags appropriately
################################################################################
CXXFLAGS += $(COMMONFLAGS)
CFLAGS += $(COMMONFLAGS)
################################################################################
# Set up object files
################################################################################
AMD_OBJS := $(patsubst %.cpp,$(AMD_OBJDIR)/%.cpp_o,$(notdir $(CCFILES)))
NVIDIA_OBJS := $(patsubst %.cpp,$(NVIDIA_OBJDIR)/%.cpp_o,$(notdir $(CCFILES)))
AMD_OBJS += $(patsubst %.c,$(AMD_OBJDIR)/%.c_o,$(notdir $(CFILES)))
NVIDIA_OBJS += $(patsubst %.c,$(NVIDIA_OBJDIR)/%.c_o,$(notdir $(CFILES)))
################################################################################
# Rules
################################################################################
$(AMD_OBJDIR)/%.c_o : $(SRCDIR)%.c
$(VERBOSE)$(CC) $(AMD_INCLUDES) $(CFLAGS) -o $@ -c $<
$(NVIDIA_OBJDIR)/%.c_o : $(SRCDIR)%.c
$(VERBOSE)$(CC) $(NVIDIA_INCLUDES) $(CFLAGS) -o $@ -c $<
$(AMD_OBJDIR)/%.cpp_o : $(SRCDIR)/%.cpp
$(VERBOSE)$(CXX) $(AMD_INCLUDES) $(CXXFLAGS) -o $@ -c $<
$(NVIDIA_OBJDIR)/%.cpp_o : $(SRCDIR)/%.cpp
$(VERBOSE)$(CXX) $(NVIDIA_INCLUDES) $(CXXFLAGS) -o $@ -c $<
all: $(AMD_TARGET) $(NVIDIA_TARGET)
$(AMD_TARGET): makedirectories $(AMD_OBJS)
$(VERBOSE)$(AMD_LINKLINE)
$(NVIDIA_TARGET): makedirectories $(NVIDIA_OBJS)
$(VERBOSE)$(NVIDIA_LINKLINE)
makedirectories:
@mkdir -p $(AMD_OBJDIR)
@mkdir -p $(NVIDIA_OBJDIR)
@mkdir -p $(AMD_BINDIR)
@mkdir -p $(NVIDIA_BINDIR)
clean:
$(VERBOSE)rm -rf obj