File size: 13,892 Bytes
d4035c1 |
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
# file: Makefile.mak
# author: Andrea Vedaldi
# author: Brian Fulkerson
# descrption: Microsoft NMake makefile
# --------------------------------------------------------------------
# Customization
# --------------------------------------------------------------------
#
# - MSVCR : the file name of msvcr__.dll for your compiler
# - MSVCRLOC : must point to the location of msvcr__.dll for your compiler
# - MATLABROOT : must point to MATLAB root directory (undef = no MEX support)
# - MATLABLIB : Location of the external libs, such as libmex and libmx.
ARCH = w32
VCROOT = C:\Program Files\Microsoft Visual Studio 9.0\VC
WINSDKROOT = C:\Program Files\Microsoft SDKs\Windows\v6.0A
MATLABROOT = C:\Program Files\MATLAB\R2008b
CC = "$(VCROOT)\bin\cl.exe"
LINK = "$(VCROOT)\bin\link.exe"
MSVCRLOC = $(VCROOT)\redist\x86\Microsoft.VC90.CRT
MSVCR = msvcr90.dll
MSVCP = msvcp90.dll
MSVCM = msvcm90.dll
MSMANIFEST = Microsoft.VC90.CRT.manifest
MATLABLIB = $(MATLABROOT)\extern\lib\win32\microsoft
MEX_SFX = mexw32
LFLAGS = /MACHINE:X86 \
/LIBPATH:"$(VCROOT)\lib" \
/LIBPATH:"$(WINSDKROOT)\lib"
!if "$(ARCH)" == "w64"
!message === COMPILING FOR 64-BIT ===
VCROOT = C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
WINSDKROOT = C:\Program Files\Microsoft SDKs\Windows\v6.0A
MATLABROOT = C:\Program Files\MATLAB\R2008b
CC = "$(VCROOT)\bin\amd64\cl.exe"
LINK = "$(VCROOT)\bin\amd64\link.exe"
MSVCRLOC = $(VCROOT)\redist\amd64\Microsoft.VC90.CRT
MSVCR = msvcr90.dll
MSVCP = msvcp90.dll
MSVCM = msvcm90.dll
MSMANIFEST = Microsoft.VC90.CRT.manifest
MATLABLIB = $(MATLABROOT)\extern\lib\win64\microsoft
MEX_SFX = mexw64
LFLAGS = /MACHINE:X64 \
/LIBPATH:"$(VCROOT)\lib\amd64" \
/LIBPATH:"$(WINSDKROOT)\lib\x64"
!endif
# Here is an example of how the variables might look with a different version
# of Visual Studio and an alternate location for Matlab
#MSVCR = msvcr80.dll
#MSVCP = msvcp80.dll
#MSVCM = msvcm80.dll
#MSMANIFEST = Microsoft.VC80.CRT.manifest
#MSVCRLOC = C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT
#MATLABROOT = C:\Program Files\MATLAB08a
#MATLABLIB = $(MATLABROOT)\extern\lib\$(ARCH)\microsoft
# --------------------------------------------------------------------
# Flags
# --------------------------------------------------------------------
# Debug info is embedded in .obj and .lib files (CodeView /Z7 option)
# but in .pdb files for .exe and .dll (since the linker does not
# produce CodeView output anymore).
#
# CFLAGS
# /nologo : CL does not display splash
# _CRT_NO_DEPRECATE : Do not deprecate `insecure' fscanf, snprintf, ...
# __LITTLE_ENDIAN__ : Signal little endian architecture
# /I. : Add VLROOT to include search path
# /Z7 : Embedded CodeView debug info in .obj
# /MT : Multi-thread run-time library
# /TC : Source code is C (not C++)
# /W3 : Usa all warnings
# /Zp8 : Align structures to 8 bytes
# /Ox : Turn on optimizations
#
# LFLAGS
# /NOLOGO : LINK does not display splash
# /INCREMENTAL:NO : No incremental linking
# /MANIFEST : See DLL HELL below
# /DEBUG : Generate debug info (.pdb files)
#
# MEX_RC : MEX .rc file location
#
# MEX_CFLAGS
# /D_WINDLL : Signal DLL code
# /DMATLAB_MEX_FILE : Signal MATLAB MEX code
# /Itoolbox : Add toolbox to inc
#
# MEX_LFLAGS
# /DLL : Produce a DLL
# /EXPORT:mexFunction : Export MEX file entry point
#
# ======================= ABOUT THE DLL HELL =========================
#
# This makefile compiles VLFeat to make use of the side-by-side
# deployment model. In other words, the C runtime library is
# re-distributed with the application and the appropriate manifest
# file is embedded in the binaries.
#
# References:
# http://www.codeguru.com/forum/showthread.php?t=408061
#
bindir = bin\$(ARCH)
mexdir = toolbox\$(MEX_SFX)
objdir = $(bindir)\objs
CFLAGS = /nologo /TC /MD \
/D"_CRT_SECURE_NO_DEPRECATE" \
/D"__LITTLE_ENDIAN__" \
/D"VL_SUPPORT_SSE2" \
/I. \
/W1 /Z7 /Zp8 /Ox
DLL_CFLAGS = /D"VL_BUILD_DLL"
LFLAGS = $(LFLAGS) /NOLOGO \
/INCREMENTAL:NO \
/MANIFEST \
/DEBUG
EXE_LFLAGS = $(LFLAGS) \
/LIBPATH:"$(bindir)" vl.lib
MEX_RC = "$(MATLABROOT)\extern\include\mexversion.rc"
MEX_CFLAGS = $(CFLAGS) \
/I"$(MATLABROOT)\extern\include" \
/Itoolbox \
/DMATLAB_MEX_FILE /D_WINDLL
MEX_LFLAGS = $(LFLAGS) \
/DLL \
/EXPORT:mexFunction \
/LIBPATH:"$(bindir)" vl.lib \
/LIBPATH:"$(MATLABLIB)" libmx.lib libmex.lib libmat.lib
libsrc = \
vl\aib.c \
vl\dsift.c \
vl\generic.c \
vl\getopt_long.c \
vl\hikmeans.c \
vl\host.c \
vl\ikmeans.c \
vl\imop.c \
vl\imopv.c \
vl\imopv_sse2.c \
vl\kdtree.c \
vl\mathop.c \
vl\mathop_sse2.c \
vl\mser.c \
vl\pgm.c \
vl\random.c \
vl\rodrigues.c \
vl\sift.c \
vl\quickshift.c \
vl\stringop.c
cmdsrc = \
src\aib.c \
src\mser.c \
src\sift.c \
src\test_getopt_long.c \
src\test_host.c \
src\test_imopv.c \
src\test_mathop.c \
src\test_nan.c \
src\test_rand.c \
src\test_stringop.c
mexsrc = \
toolbox\aib\vl_aib.c \
toolbox\aib\vl_aibhist.c \
toolbox\geometry\vl_irodr.c \
toolbox\geometry\vl_rodr.c \
toolbox\imop\vl_imintegral.c \
toolbox\imop\vl_imsmooth.c \
toolbox\imop\vl_imwbackwardmx.c \
toolbox\imop\vl_tpsumx.c \
toolbox\kmeans\vl_hikmeans.c \
toolbox\kmeans\vl_hikmeanspush.c \
toolbox\kmeans\vl_ikmeans.c \
toolbox\kmeans\vl_ikmeanspush.c \
toolbox\misc\vl_alldist.c \
toolbox\misc\vl_alldist2.c \
toolbox\misc\vl_binsearch.c \
toolbox\misc\vl_binsum.c \
toolbox\misc\vl_getpid.c \
toolbox\misc\vl_ihashfind.c \
toolbox\misc\vl_ihashsum.c \
toolbox\misc\vl_inthist.c \
toolbox\misc\vl_kdtreebuild.c \
toolbox\misc\vl_kdtreequery.c \
toolbox\misc\vl_localmax.c \
toolbox\misc\vl_samplinthist.c \
toolbox\misc\vl_simdctrl.c \
toolbox\misc\vl_twister.c \
toolbox\misc\vl_whistc.c \
toolbox\mser\vl_erfill.c \
toolbox\mser\vl_mser.c \
toolbox\quickshift\vl_quickshift.c \
toolbox\sift\vl_dsift.c \
toolbox\sift\vl_sift.c \
toolbox\sift\vl_siftdescriptor.c \
toolbox\sift\vl_ubcmatch.c
# horrible Make program, horrible code:
libobj = $(libsrc:vl\=bin\w32\objs\)
cmdexe = $(cmdsrc:src\=bin\w32\)
mexdll = $(mexsrc:.c=.mexw32)
mexdll = $(mexdll:toolbox\sift=toolbox\mexw32)
mexdll = $(mexdll:toolbox\mser=toolbox\mexw32)
mexdll = $(mexdll:toolbox\imop=toolbox\mexw32)
mexdll = $(mexdll:toolbox\geometry=toolbox\mexw32)
mexdll = $(mexdll:toolbox\kmeans=toolbox\mexw32)
mexdll = $(mexdll:toolbox\misc=toolbox\mexw32)
mexdll = $(mexdll:toolbox\aib=toolbox\mexw32)
mexdll = $(mexdll:toolbox\quickshift=toolbox\mexw32)
mexres = $(mexdll:.dll=.res)
mexpdb = $(mexdll:.dll=.pdb)
!if "$(ARCH)" == "w64"
libobj = $(libsrc:vl\=bin\w64\objs\)
cmdexe = $(cmdsrc:src\=bin\w64\)
mexdll = $(mexsrc:.c=.mexw64)
mexdll = $(mexdll:toolbox\sift=toolbox\mexw64)
mexdll = $(mexdll:toolbox\mser=toolbox\mexw64)
mexdll = $(mexdll:toolbox\imop=toolbox\mexw64)
mexdll = $(mexdll:toolbox\geometry=toolbox\mexw64)
mexdll = $(mexdll:toolbox\kmeans=toolbox\mexw64)
mexdll = $(mexdll:toolbox\misc=toolbox\mexw64)
mexdll = $(mexdll:toolbox\aib=toolbox\mexw64)
mexdll = $(mexdll:toolbox\quickshift=toolbox\mexw64)
mexres = $(mexdll:.mexw64=.res)
mexpdb = $(mexdll:.mexw64=.pdb)
!endif
libobj = $(libobj:.c=.obj)
cmdexe = $(cmdexe:.c=.exe)
cmdpdb = $(cmdexe:.exe=.pdb)
!IFDEF MATLABROOT
all: $(bindir) $(objdir) $(mexdir) $(bindir)\vl.lib $(bindir)\vl.dll $(mexdir)\vl.dll $(cmdexe) $(mexdll) $(mexdir)\$(MSMANIFEST) $(mexdir)\$(MSVCR) $(mexdir)\$(MSVCP) $(mexdir)\$(MSVCM) $(bindir)\$(MSMANIFEST) $(bindir)\$(MSVCR) $(bindir)\$(MSVCP) $(bindir)\$(MSVCM)
!ELSE
all: $(bindir) $(objdir) $(bindir)\vl.lib $(bindir)\vl.dll $(cmdexe) $(bindir)\$(MSMANIFEST) $(bindir)\$(MSVCR) $(bindir)\$(MSVCP) $(bindir)\$(MSVCM)
!ENDIF
BUILD_MEX=@echo .... CC [MEX] $(@R).dll && \
$(CC) $(MEX_CFLAGS) /c /Fo"$(@R).obj" "$(<)" && \
$(RC) /fo"$(@R).res" $(MEX_RC) && \
$(LINK) $(MEX_LFLAGS) "$(@R).res" "$(@R).obj" /OUT:$(@) && \
mt /nologo /outputresource:"$(@)";^#2 /manifest "$(@).manifest" && \
del "$(@R).obj" "$(@R).exp" "$(@R).lib" "$(@R).res" "$(@).manifest"
# --------------------------------------------------------------------
# Maintenance rules
# --------------------------------------------------------------------
clean:
del /f /Q $(libobj)
del /f /Q $(objdir)
del /f /Q $(cmdpdb)
del /f /Q $(mexpdb)
del /f /Q $(mexdir)\$(MSMANIFEST)
del /f /Q $(mexdir)\$(MSVCR)
del /f /Q $(mexdir)\$(MSVCP)
del /f /Q $(mexdir)\$(MSVCM)
del /f /Q $(mexdir)\vl.dll
del /f /Q $(bindir)\$(MSMANIFEST)
del /f /Q $(bindir)\$(MSVCR)
del /f /Q $(bindir)\$(MSVCP)
del /f /Q $(bindir)\$(MSVCM)
del /f /Q $(bindir)\vl.dll
distclean: clean
del /f /Q $(cmdexe)
del /f /Q $(mexdll)
info:
@echo $(mexx)
@echo ** bindir = $(bindir)
@echo ** mexdir = $(mexdir)
@echo ** objdir = $(objdir)
@echo ** libsrc = $(libsrc)
@echo ** libobj = $(libobj)
@echo ** cmdsrc = $(cmdsrc)
@echo ** cmdexe = $(cmdexe)
@echo ** mexsrc = $(mexsrc)
@echo ** mexdll = $(mexdll)
@echo ** CC = $(CC)
@echo ** CFLAGS = $(CFLAGS)
@echo ** DLL_CFLAGS = $(DLL_CFLAGS)
@echo ** MEX_CFLAGS = $(MEX_CFLAGS)
@echo ** BUILD_MEX = "$(BUILD_MEX)"
@echo ** MATLABROOT = $(MATLABROOT)
@echo ** MEX_LFLAGS = $(MEX_LFLAGS)
@echo ** MEX = $(MEX)
# --------------------------------------------------------------------
# Build rules
# --------------------------------------------------------------------
# create directory if missing
$(bindir) :
mkdir $(bindir)
$(objdir) :
mkdir $(objdir)
$(mexdir) :
mkdir $(mexdir)
# --------------------------------------------------------------------
# Rules to compile VLFeat DLL
# --------------------------------------------------------------------
# special sources with SSE2 support
$(objdir)\mathop_sse2.obj : vl\mathop_sse2.c
@echo .... CC [+SSE2] $(@)
@$(CC) $(CFLAGS) $(DLL_CFLAGS) /arch:SSE2 /D"__SSE2__" /c /Fo"$(@)" "vl\$(@B).c"
$(objdir)\imopv_sse2.obj : vl\imopv_sse2.c
@echo .... CC [+SSE2] $(@)
@$(CC) $(CFLAGS) $(DLL_CFLAGS) /arch:SSE2 /D"__SSE2__" /c /Fo"$(@)" "vl\$(@B).c"
# vl\*.c -> $objdir\*.obj
{vl}.c{$(objdir)}.obj:
@echo .... CC $(@)
@$(CC) $(CFLAGS) $(DLL_CFLAGS) /c /Fo"$(@)" "$(<)"
# Link VLFeat DLL
$(bindir)\vl.dll : $(libobj)
@echo .. LINK [DLL] $(@R).dll
@$(LINK) /DLL $(LFLAGS) $(**) /OUT:"$(@)"
@mt /nologo /outputresource:"$(@);#2" /manifest "$(@R).dll.manifest"
@-del "$(@R).dll.manifest"
# *.obj -> *.lib
$(bindir)\vl.lib : $(libobj)
@echo ... LIB $(@R).lib
@lib $(**) /OUT:"$(@)" /NOLOGO
# --------------------------------------------------------------------
# Rules to compile EXE
# --------------------------------------------------------------------
# src\*.c -> $bindir\*.exe
{src}.c{$(bindir)}.exe:
@echo .... CC [EXE] $(@)
@$(CC) $(CFLAGS) /Fe"$(@)" /Fo"$(@R).obj" "$(<)" /link $(EXE_LFLAGS)
@MT /nologo /outputresource:"$(@);#1" /manifest "$(@).manifest"
@-del "$(@).manifest"
@-del "$(@R).obj"
# --------------------------------------------------------------------
# Rules to compile MEX
# --------------------------------------------------------------------
# toolbox\*.c -> toolbox\*.dll
{toolbox\sift}.c{$(mexdir)}.$(MEX_SFX):
$(BUILD_MEX)
{toolbox\mser}.c{$(mexdir)}.$(MEX_SFX):
$(BUILD_MEX)
{toolbox\imop}.c{$(mexdir)}.$(MEX_SFX):
$(BUILD_MEX)
{toolbox\geometry}.c{$(mexdir)}.$(MEX_SFX):
$(BUILD_MEX)
{toolbox\kmeans}.c{$(mexdir)}.$(MEX_SFX):
$(BUILD_MEX)
{toolbox\aib}.c{$(mexdir)}.$(MEX_SFX):
$(BUILD_MEX)
{toolbox\quickshift}.c{$(mexdir)}.$(MEX_SFX):
$(BUILD_MEX)
{toolbox\misc}.c{$(mexdir)}.$(MEX_SFX):
$(BUILD_MEX)
# vl.dll => mexw{32,64}/vl.dll
$(mexdir)\vl.dll : $(bindir)\vl.dll
copy "$(**)" "$(@)"
# --------------------------------------------------------------------
# Rules to copy redistributable libraries
# --------------------------------------------------------------------
# msvcr__.dll => bin/win{32,64}/msvcr__.dll
$(bindir)\$(MSMANIFEST): "$(MSVCRLOC)\$(MSMANIFEST)"
copy $(**) "$(@)"
$(bindir)\$(MSVCR): "$(MSVCRLOC)\$(MSVCR)"
copy $(**) "$(@)"
$(bindir)\$(MSVCP): "$(MSVCRLOC)\$(MSVCP)"
copy $(**) "$(@)"
$(bindir)\$(MSVCM): "$(MSVCRLOC)\$(MSVCM)"
copy $(**) "$(@)"
# msvcr__.dll => toolbox/mexw32/msvcr__.dll
$(mexdir)\$(MSMANIFEST): "$(MSVCRLOC)\$(MSMANIFEST)"
copy $(**) "$(@)"
$(mexdir)\$(MSVCR): "$(MSVCRLOC)\$(MSVCR)"
copy $(**) "$(@)"
$(mexdir)\$(MSVCP): "$(MSVCRLOC)\$(MSVCP)"
copy $(**) "$(@)"
$(mexdir)\$(MSVCM): "$(MSVCRLOC)\$(MSVCM)"
copy $(**) "$(@)"
|