-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
195 lines (152 loc) · 6.39 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/make -f
# ============================================================================
# xyTrackerMakefile
# ============================================================================
#
# The following configuration parameters are recognized:
#
# MATLABDIR MATLAB root directory.
# FLYCAPINCLUDEDIR Include dir for the FlyCaptureSDK
# MEXOPENCVDIR Path to the MEXOPENCV directory
#
# The above settings can be defined as shell environment variables and/or
# specified on the command line as arguments to make:
#
# export VAR=value
# make VAR=value
#
# Note that the Makefile uses pkg-config to locate OpenCV and glibmm-2.4, so you need to have
# the opencv.pc and glibmm-2.4.pc file accessible from the PKG_CONFIG_PATH environment variable.
#
# Required OpenCV version: 3.0
#
# If no FLyCaptureSDK is available the MEX enhanced version cannot be build. Then use
#
# make helper
#
# to compile only the helper files
#
#
# ============================================================================
# programs
MATLABDIR ?= /opt/MATLAB/R2019a
MATLAB = $(MATLABDIR)/bin/matlab
MEXOPENCVDIR ?= /home/malte/work/progs/toolboxes/mexopencv
SRCDIR = src
TARGETDIR = .
#flycapture paths
FLYCAPINCLUDEDIR ?= /usr/include/flycapture
# search whether .h can be found
ifeq ($(wildcard $(FLYCAPINCLUDEDIR)/FlyCapture2.h),)
FLYCAPFLAG =
$(warning "Cannot find FlyCapture2.h. Compiling without ptGrey grabbing feature.")
FLYCAPINCLUDES = -I$(SRCDIR)
FLYCAPLIBS = -lstdc++
ALLTARGET = nograb
else
FLYCAPFLAG = -DFLYCAPTURE
FLYCAPINCLUDES = -I$(SRCDIR) $(shell pkg-config --cflags glibmm-2.4) -I$(FLYCAPINCLUDEDIR)
FLYCAPLIBS = $(shell pkg-config --libs glibmm-2.4) -lstdc++ -lncurses -lflycapture
ALLTARGET = everything
endif
# mexopencv directories
INCLUDEDIR = $(MEXOPENCVDIR)/include
LIBDIR = $(MEXOPENCVDIR)/lib
ifeq ($(wildcard $(INCLUDEDIR)/mexopencv.hpp),)
ALLTARGET = helper
$(warning "Cannot find mexopencv.hpp. OpenCV/Mex-versions disabled. Compiling only helper function.")
endif
# file extensions
OBJEXT = o
LIBEXT = a
ifneq ($(wildcard $(MATLABDIR)/bin/mexext.bat),)
MEXEXT = $(shell $(MATLABDIR)/bin/mexext.bat)
MEX = $(MATLABDIR)/bin/mex.bat
else
MEX = $(MATLABDIR)/bin/mex
MEXEXT = $(shell $(MATLABDIR)/bin/mexext)
endif
ifeq ($(MEXEXT),)
$(error "MEX extension not set")
endif
#aux dirs
HELPERDIR = +xy/+helper
CAPTUREDIR = +xy/+core/@VideoCapture/private
HANDLERDIR = +xy/+core/@VideoHandlerMex/private
BTRACEDIR = +xy/+core/@DAGraph/private
GTTDIR = +xy/@Tracker/private
# savevideo
ifneq ($(FLYCAPFLAG),)
SAVEVIDEOSRC = $(SRCDIR)/SaveVideoClass.cpp
SAVEVIDEOOBJ = $(TARGETDIR)/$(HANDLERDIR)/SaveVideoClass.$(OBJEXT)
endif
SAVEVIDEOSRCBASE = $(SRCDIR)/SaveVideoClassBase.cpp
SAVEVIDEOOBJBASE = $(TARGETDIR)/$(HANDLERDIR)/SaveVideoClassBase.$(OBJEXT)
# struc
SAR = $(SRCDIR)/strucarr2strucmat.c
SARTARGET = $(TARGETDIR)/$(HELPERDIR)/strucarr2strucmat.$(MEXEXT)
# pdist
PDIST = $(SRCDIR)/pdist2Euclidean.c
PDISTTARGET = $(TARGETDIR)/$(HELPERDIR)/pdist2Euclidean.$(MEXEXT)
# pdist
BTRACE = $(SRCDIR)/backtrace_.c
BTRACETARGET = $(TARGETDIR)/$(BTRACEDIR)/backtrace_.$(MEXEXT)
# current tracks
GTT = $(SRCDIR)/getCurrentTracks_.c
GTTTARGET = $(TARGETDIR)/$(GTTDIR)/getCurrentTracks_.$(MEXEXT)
# pcenterlinedist
PCLDIST = $(SRCDIR)/pdist2CenterLine.c
PCLDISTTARGET = $(TARGETDIR)/$(HELPERDIR)/pdist2CenterLine.$(MEXEXT)
# munkres
MUNKRES = $(SRCDIR)/assignDetectionsToTracks.cpp
MUNKRESTARGET = $(TARGETDIR)/$(HELPERDIR)/assignDetectionsToTracks.$(MEXEXT)
ifneq ($(ALLTARGET),helper)
# mexopencv files and targets
HEADERS := $(wildcard $(INCLUDEDIR)/*.hpp)
SRCS1 := $(SRCDIR)/xyVideoCapture_.cpp
TARGETS1 := $(TARGETDIR)/$(CAPTUREDIR)/xyVideoCapture_.$(MEXEXT)
SRCS2 := $(SRCDIR)/VideoHandler.cpp
OBJECTS := $(TARGETDIR)/$(HANDLERDIR)/VideoHandler.$(OBJEXT)
SRCS3 := $(SRCDIR)/xyVideoHandler_.cpp
TARGETS2 := $(TARGETDIR)/$(HANDLERDIR)/xyVideoHandler_.$(MEXEXT)
# OpenCV flags
ifneq ($(shell pkg-config --exists --atleast-version=3 opencv; echo $$?), 0)
$(error "OpenCV 3.0 package was not found in the pkg-config search path")
endif
CV_CFLAGS := $(shell pkg-config --cflags opencv)
CV_LDFLAGS := $(shell pkg-config --libs opencv)
endif
# compiler/linker flags
override CFLAGS += -v COMPFLAGS='$COMPFLAGS -std=c++11' CXXFLAGS='-std=c++11 -fPIC' -I$(INCLUDEDIR) $(FLYCAPINCLUDES) $(FLYCAPFLAG) $(CV_CFLAGS)
override LDFLAGS += -L$(LIBDIR) -lMxArray $(CV_LDFLAGS) $ $(FLYCAPLIBS)
# targets
all: $(ALLTARGET)
helper: $(SARTARGET) $(PDISTTARGET) $(PCLDISTTARGET) $(MUNKRESTARGET) $(BTRACETARGET) $(GTTTARGET)
everything: $(SAVEVIDEOOBJBASE) $(SAVEVIDEOOBJ) $(OBJECTS) $(TARGETS1) $(TARGETS2) helper
nograb: $(SAVEVIDEOOBJBASE) $(OBJECTS) $(TARGETS1) $(TARGETS2) helper
$(SAVEVIDEOOBJBASE): $(SAVEVIDEOSRCBASE)
$(MEX) -c -cxx -largeArrayDims $(CFLAGS) -outdir $(TARGETDIR)/$(HANDLERDIR)/ $<
$(SAVEVIDEOOBJ): $(SAVEVIDEOSRC)
$(MEX) -c -cxx -largeArrayDims $(CFLAGS) -outdir $(TARGETDIR)/$(HANDLERDIR)/ $<
# objects
$(OBJECTS): $(SRCS2)
$(MEX) -c -cxx -largeArrayDims $(CFLAGS) $(SAVEVIDEOOBJBASE) $(SAVEVIDEOOBJ) -outdir $(TARGETDIR)/$(HANDLERDIR)/ $<
# MEX-files
$(TARGETS1): $(SRCS1)
$(MEX) -cxx -largeArrayDims $(CFLAGS) -output $(TARGETS1) -outdir $(TARGETDIR)/$(CAPTUREDIR) $< $(LDFLAGS)
$(TARGETS2): $(SRCS3)
$(MEX) -cxx -largeArrayDims $(CFLAGS) $(SAVEVIDEOOBJBASE) $(SAVEVIDEOOBJ) $(OBJECTS) -output $(TARGETS2) -outdir $(TARGETDIR)/$(HANDLERDIR) $< $(LDFLAGS)
$(SARTARGET): $(SAR)
$(MEX) -largeArrayDims -outdir $(TARGETDIR)/$(HELPERDIR) -output $(SARTARGET) $<
$(PDISTTARGET): $(PDIST)
$(MEX) -largeArrayDims -outdir $(TARGETDIR)/$(HELPERDIR) -output $(PDISTTARGET) $<
$(PCLDISTTARGET): $(PCLDIST)
$(MEX) -largeArrayDims -outdir $(TARGETDIR)/$(HELPERDIR) -output $(PCLDISTTARGET) $<
$(BTRACETARGET): $(BTRACE)
$(MEX) -largeArrayDims -outdir $(TARGETDIR)/$(BTRACEDIR) -output $(BTRACETARGET) $<
$(GTTTARGET): $(GTT)
$(MEX) -largeArrayDims -outdir $(TARGETDIR)/$(GTTDIR) -output $(GTTTARGET) $<
$(MUNKRESTARGET): $(MUNKRES)
$(MEX) -largeArrayDims -cxx CXXFLAGS='$$CXXFLAGS -std=c++11 -lstdc++' -I$(SRCDIR) -outdir $(TARGETDIR)/$(HELPERDIR) -output $(MUNKRESTARGET) $<
clean:
rm $(TARGETS1) $(TARGETS2) $(OBJECTS) $(SAVEVIDEOOBJ) $(SAVEVIDEOOBJBASE) $(SARTARGET) $(PDISTTARGET) $(PCLDISTTARGET) $(MUNKRESTARGET) $(BTRACETARGET) $(GTTTARGET)