PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Class_Segmentation/vlfeat/Makefile.mak

http://phd-workspace.googlecode.com/
Makefile | 454 lines | 298 code | 66 blank | 90 comment | 37 complexity | 3808c4196f8a721f275bd0ff944471e7 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. # file: Makefile.mak
  2. # authors: Andrea Vedaldi and Brian Fulkerson
  3. # descrption: Microsoft NMake makefile
  4. # --------------------------------------------------------------------
  5. # Customization
  6. # --------------------------------------------------------------------
  7. #
  8. # - MSVCR : the file name of msvcr__.dll for your compiler
  9. # - MSVCRLOC : must point to the location of msvcr__.dll for your compiler
  10. # - MATLABROOT : must point to MATLAB root directory (undef = no MEX support)
  11. VER = 0.9.7
  12. ARCH = w32
  13. VCROOT = C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
  14. WINSDKROOT = C:\Program Files\Microsoft SDKs\Windows\v6.0
  15. MATLABROOT = C:\Program Files\MATLAB\R2009b-32bit
  16. CC = "$(VCROOT)\bin\cl.exe"
  17. LINK = "$(VCROOT)\bin\link.exe"
  18. MSVCRLOC = $(VCROOT)\redist\x86\Microsoft.VC90.CRT
  19. MSVCR = msvcr90.dll
  20. MSVCP = msvcp90.dll
  21. MSVCM = msvcm90.dll
  22. MSMANIFEST = Microsoft.VC90.CRT.manifest
  23. MEX = "$(MATLABROOT)\bin\mex.bat"
  24. MEXEXT = mexw32
  25. GIT = git
  26. BRANCH = v$(VER)-$(ARCH)
  27. LFLAGS = /MACHINE:X86 \
  28. /LIBPATH:"$(VCROOT)\lib" \
  29. /LIBPATH:"$(WINSDKROOT)\lib"
  30. !if "$(ARCH)" == "w64"
  31. !message === COMPILING FOR 64-BIT ===
  32. VCROOT = C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
  33. WINSDKROOT = C:\Program Files\Microsoft SDKs\Windows\v6.0A
  34. MATLABROOT = C:\Program Files\MATLAB\R2009b
  35. CC = "$(VCROOT)\bin\amd64\cl.exe"
  36. LINK = "$(VCROOT)\bin\amd64\link.exe"
  37. MSVCRLOC = $(VCROOT)\redist\amd64\Microsoft.VC90.CRT
  38. MSVCR = msvcr90.dll
  39. MSVCP = msvcp90.dll
  40. MSVCM = msvcm90.dll
  41. MSMANIFEST = Microsoft.VC90.CRT.manifest
  42. MEX = "$(MATLABROOT)\bin\mex.bat"
  43. MEXEXT = mexw64
  44. LFLAGS = /MACHINE:X64 \
  45. /LIBPATH:"$(VCROOT)\lib\amd64" \
  46. /LIBPATH:"$(WINSDKROOT)\lib\x64"
  47. !endif
  48. # Here is an example of how the variables might look with a different version
  49. # of Visual Studio and an alternate location for Matlab
  50. #MSVCR = msvcr80.dll
  51. #MSVCP = msvcp80.dll
  52. #MSVCM = msvcm80.dll
  53. #MSMANIFEST = Microsoft.VC80.CRT.manifest
  54. #MSVCRLOC = C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT
  55. #MATLABROOT = C:\Program Files\MATLAB08a
  56. # --------------------------------------------------------------------
  57. # Flags
  58. # --------------------------------------------------------------------
  59. # Debug info is embedded in .obj and .lib files (CodeView /Z7 option)
  60. # but in .pdb files for .exe and .dll (since the linker does not
  61. # produce CodeView output anymore).
  62. #
  63. # CFLAGS
  64. # /nologo : CL does not display splash
  65. # _CRT_NO_DEPRECATE : Do not deprecate `insecure' fscanf, snprintf, ...
  66. # __LITTLE_ENDIAN__ : Signal little endian architecture
  67. # /I. : Add VLROOT to include search path
  68. # /Z7 : Embedded CodeView debug info in .obj
  69. # /MT : Multi-thread run-time library
  70. # /TC : Source code is C (not C++)
  71. # /W3 : Usa all warnings
  72. # /Zp8 : Align structures to 8 bytes
  73. # /Ox : Turn on optimizations
  74. #
  75. # LFLAGS
  76. # /NOLOGO : LINK does not display splash
  77. # /INCREMENTAL:NO : No incremental linking
  78. # /MANIFEST : See DLL HELL below
  79. # /DEBUG : Generate debug info (.pdb files)
  80. #
  81. # MEX_FLAGS
  82. # -I : Include VLFeat
  83. # -L : Add a library search path
  84. # -l : Link a dll
  85. #
  86. # ======================= ABOUT THE DLL HELL =========================
  87. #
  88. # This makefile compiles VLFeat to make use of the side-by-side
  89. # deployment model. In other words, the C runtime library is
  90. # re-distributed with the application and the appropriate manifest
  91. # file is embedded in the binaries.
  92. #
  93. # References:
  94. # http://www.codeguru.com/forum/showthread.php?t=408061
  95. #
  96. bindir = bin\$(ARCH)
  97. mexdir = toolbox\$(MEXEXT)
  98. objdir = $(bindir)\objs
  99. CFLAGS = /nologo /TC /MD \
  100. /D"_CRT_SECURE_NO_DEPRECATE" \
  101. /D"__LITTLE_ENDIAN__" \
  102. /D"VL_SUPPORT_SSE2" \
  103. /I. \
  104. /W1 /Z7 /Zp8 /Ox
  105. LFLAGS = $(LFLAGS) /NOLOGO \
  106. /INCREMENTAL:NO \
  107. /MANIFEST \
  108. /DEBUG
  109. DLL_CFLAGS = /D"VL_BUILD_DLL"
  110. EXE_LFLAGS = $(LFLAGS) /LIBPATH:"$(bindir)" vl.lib
  111. MEX_FLAGS = -I. -Itoolbox -L"$(bindir)" -lvl
  112. libsrc = \
  113. vl\aib.c \
  114. vl\dsift.c \
  115. vl\generic.c \
  116. vl\getopt_long.c \
  117. vl\heap.c \
  118. vl\hikmeans.c \
  119. vl\host.c \
  120. vl\ikmeans.c \
  121. vl\imop.c \
  122. vl\imopv.c \
  123. vl\imopv_sse2.c \
  124. vl\kdtree.c \
  125. vl\mathop.c \
  126. vl\mathop_sse2.c \
  127. vl\mser.c \
  128. vl\pgm.c \
  129. vl\quickshift.c \
  130. vl\random.c \
  131. vl\rodrigues.c \
  132. vl\sift.c \
  133. vl\stringop.c
  134. cmdsrc = \
  135. src\aib.c \
  136. src\mser.c \
  137. src\sift.c \
  138. src\test_getopt_long.c \
  139. src\test_heap-t.c \
  140. src\test_heap.c \
  141. src\test_host.c \
  142. src\test_imopv.c \
  143. src\test_mathop.c \
  144. src\test_mathop_abs.c \
  145. src\test_nan.c \
  146. src\test_rand.c \
  147. src\test_stringop.c \
  148. src\test_vec_comp.c
  149. mexsrc = \
  150. toolbox\aib\vl_aib.c \
  151. toolbox\aib\vl_aibhist.c \
  152. toolbox\geometry\vl_irodr.c \
  153. toolbox\geometry\vl_rodr.c \
  154. toolbox\imop\vl_imintegral.c \
  155. toolbox\imop\vl_imsmooth.c \
  156. toolbox\imop\vl_imwbackwardmx.c \
  157. toolbox\imop\vl_tpsumx.c \
  158. toolbox\kmeans\vl_hikmeans.c \
  159. toolbox\kmeans\vl_hikmeanspush.c \
  160. toolbox\kmeans\vl_ikmeans.c \
  161. toolbox\kmeans\vl_ikmeanspush.c \
  162. toolbox\misc\vl_alldist.c \
  163. toolbox\misc\vl_alldist2.c \
  164. toolbox\misc\vl_binsearch.c \
  165. toolbox\misc\vl_binsum.c \
  166. toolbox\misc\vl_getpid.c \
  167. toolbox\misc\vl_ihashfind.c \
  168. toolbox\misc\vl_ihashsum.c \
  169. toolbox\misc\vl_inthist.c \
  170. toolbox\misc\vl_kdtreebuild.c \
  171. toolbox\misc\vl_kdtreequery.c \
  172. toolbox\misc\vl_localmax.c \
  173. toolbox\misc\vl_samplinthist.c \
  174. toolbox\misc\vl_simdctrl.c \
  175. toolbox\misc\vl_twister.c \
  176. toolbox\misc\vl_version.c \
  177. toolbox\misc\vl_whistc.c \
  178. toolbox\mser\vl_erfill.c \
  179. toolbox\mser\vl_mser.c \
  180. toolbox\quickshift\vl_quickshift.c \
  181. toolbox\sift\vl_dsift.c \
  182. toolbox\sift\vl_sift.c \
  183. toolbox\sift\vl_siftdescriptor.c \
  184. toolbox\sift\vl_ubcmatch.c
  185. # horrible Make program, horrible code:
  186. libobj = $(libsrc:vl\=bin\w32\objs\)
  187. cmdexe = $(cmdsrc:src\=bin\w32\)
  188. mexdll = $(mexsrc:.c=.mexw32)
  189. mexdll = $(mexdll:toolbox\sift=toolbox\mexw32)
  190. mexdll = $(mexdll:toolbox\mser=toolbox\mexw32)
  191. mexdll = $(mexdll:toolbox\imop=toolbox\mexw32)
  192. mexdll = $(mexdll:toolbox\geometry=toolbox\mexw32)
  193. mexdll = $(mexdll:toolbox\kmeans=toolbox\mexw32)
  194. mexdll = $(mexdll:toolbox\misc=toolbox\mexw32)
  195. mexdll = $(mexdll:toolbox\aib=toolbox\mexw32)
  196. mexdll = $(mexdll:toolbox\quickshift=toolbox\mexw32)
  197. mexres = $(mexdll:.dll=.res)
  198. mexpdb = $(mexdll:.dll=.pdb)
  199. !if "$(ARCH)" == "w64"
  200. libobj = $(libsrc:vl\=bin\w64\objs\)
  201. cmdexe = $(cmdsrc:src\=bin\w64\)
  202. mexdll = $(mexsrc:.c=.mexw64)
  203. mexdll = $(mexdll:toolbox\sift=toolbox\mexw64)
  204. mexdll = $(mexdll:toolbox\mser=toolbox\mexw64)
  205. mexdll = $(mexdll:toolbox\imop=toolbox\mexw64)
  206. mexdll = $(mexdll:toolbox\geometry=toolbox\mexw64)
  207. mexdll = $(mexdll:toolbox\kmeans=toolbox\mexw64)
  208. mexdll = $(mexdll:toolbox\misc=toolbox\mexw64)
  209. mexdll = $(mexdll:toolbox\aib=toolbox\mexw64)
  210. mexdll = $(mexdll:toolbox\quickshift=toolbox\mexw64)
  211. mexres = $(mexdll:.mexw64=.res)
  212. mexpdb = $(mexdll:.mexw64=.pdb)
  213. !endif
  214. libobj = $(libobj:.c=.obj)
  215. cmdexe = $(cmdexe:.c=.exe)
  216. cmdpdb = $(cmdexe:.exe=.pdb)
  217. !IFDEF MATLABROOT
  218. 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)
  219. !ELSE
  220. all: $(bindir) $(objdir) $(bindir)\vl.lib $(bindir)\vl.dll $(cmdexe) $(bindir)\$(MSMANIFEST) $(bindir)\$(MSVCR) $(bindir)\$(MSVCP) $(bindir)\$(MSVCM)
  221. !ENDIF
  222. BUILD_MEX=@echo .... CC [MEX] $(@R).dll && \
  223. $(MEX) $(MEX_FLAGS) "$(<)" -output $(@)
  224. # --------------------------------------------------------------------
  225. # Maintenance rules
  226. # --------------------------------------------------------------------
  227. clean:
  228. del /f /Q $(libobj)
  229. del /f /Q $(objdir)
  230. del /f /Q $(cmdpdb)
  231. del /f /Q $(mexpdb)
  232. archclean:
  233. if exist bin\$(ARCH) rmdir /S /Q bin\$(ARCH)
  234. if exist toolbox\mex$(ARCH) rmdir /S /Q toolbox\mex$(ARCH)
  235. distclean:
  236. if exist bin\w32 rmdir /S /Q bin\w32
  237. if exist bin\w64 rmdir /S /Q bin\w64
  238. if exist toolbox\mexw32 rmdir /S /Q toolbox\mexw32
  239. if exist toolbox\mexw64 rmdir /S /Q toolbox\mexw64
  240. info:
  241. @echo $(mexx)
  242. @echo ** bindir = $(bindir)
  243. @echo ** mexdir = $(mexdir)
  244. @echo ** objdir = $(objdir)
  245. @echo ** libsrc = $(libsrc)
  246. @echo ** libobj = $(libobj)
  247. @echo ** cmdsrc = $(cmdsrc)
  248. @echo ** cmdexe = $(cmdexe)
  249. @echo ** mexsrc = $(mexsrc)
  250. @echo ** mexdll = $(mexdll)
  251. @echo ** CC = $(CC)
  252. @echo ** CFLAGS = $(CFLAGS)
  253. @echo ** DLL_CFLAGS = $(DLL_CFLAGS)
  254. @echo ** MEX_CFLAGS = $(MEX_CFLAGS)
  255. @echo ** BUILD_MEX = "$(BUILD_MEX)"
  256. @echo ** MATLABROOT = $(MATLABROOT)
  257. @echo ** MEX_LFLAGS = $(MEX_LFLAGS)
  258. @echo ** MEX = $(MEX)
  259. # --------------------------------------------------------------------
  260. # Build rules
  261. # --------------------------------------------------------------------
  262. # create directory if missing
  263. $(bindir) :
  264. mkdir $(bindir)
  265. $(objdir) :
  266. mkdir $(objdir)
  267. $(mexdir) :
  268. mkdir $(mexdir)
  269. # --------------------------------------------------------------------
  270. # Rules to compile VLFeat DLL
  271. # --------------------------------------------------------------------
  272. # special sources with SSE2 support
  273. $(objdir)\mathop_sse2.obj : vl\mathop_sse2.c
  274. @echo .... CC [+SSE2] $(@)
  275. @$(CC) $(CFLAGS) $(DLL_CFLAGS) /arch:SSE2 /D"__SSE2__" /c /Fo"$(@)" "vl\$(@B).c"
  276. $(objdir)\imopv_sse2.obj : vl\imopv_sse2.c
  277. @echo .... CC [+SSE2] $(@)
  278. @$(CC) $(CFLAGS) $(DLL_CFLAGS) /arch:SSE2 /D"__SSE2__" /c /Fo"$(@)" "vl\$(@B).c"
  279. # vl\*.c -> $objdir\*.obj
  280. {vl}.c{$(objdir)}.obj:
  281. @echo .... CC $(@)
  282. @$(CC) $(CFLAGS) $(DLL_CFLAGS) /c /Fo"$(@)" "$(<)"
  283. # Link VLFeat DLL
  284. $(bindir)\vl.dll : $(libobj)
  285. @echo .. LINK [DLL] $(@R).dll
  286. @$(LINK) /DLL $(LFLAGS) $(**) /OUT:"$(@)"
  287. @mt /nologo /outputresource:"$(@);#2" /manifest "$(@R).dll.manifest"
  288. @-del "$(@R).dll.manifest"
  289. # *.obj -> *.lib
  290. $(bindir)\vl.lib : $(libobj)
  291. @echo ... LIB $(@R).lib
  292. @lib $(**) /OUT:"$(@)" /NOLOGO
  293. # --------------------------------------------------------------------
  294. # Rules to compile EXE
  295. # --------------------------------------------------------------------
  296. # src\*.c -> $bindir\*.exe
  297. {src}.c{$(bindir)}.exe:
  298. @echo .... CC [EXE] $(@)
  299. @$(CC) $(CFLAGS) /Fe"$(@)" /Fo"$(@R).obj" "$(<)" /link $(EXE_LFLAGS)
  300. @MT /nologo /outputresource:"$(@);#1" /manifest "$(@).manifest"
  301. @-del "$(@).manifest"
  302. @-del "$(@R).obj"
  303. # --------------------------------------------------------------------
  304. # Rules to compile MEX
  305. # --------------------------------------------------------------------
  306. mexsetup:
  307. $(MEX) -setup
  308. # toolbox\*.c -> toolbox\*.dll
  309. {toolbox\sift}.c{$(mexdir)}.$(MEXEXT):
  310. $(BUILD_MEX)
  311. {toolbox\mser}.c{$(mexdir)}.$(MEXEXT):
  312. $(BUILD_MEX)
  313. {toolbox\imop}.c{$(mexdir)}.$(MEXEXT):
  314. $(BUILD_MEX)
  315. {toolbox\geometry}.c{$(mexdir)}.$(MEXEXT):
  316. $(BUILD_MEX)
  317. {toolbox\kmeans}.c{$(mexdir)}.$(MEXEXT):
  318. $(BUILD_MEX)
  319. {toolbox\aib}.c{$(mexdir)}.$(MEXEXT):
  320. $(BUILD_MEX)
  321. {toolbox\quickshift}.c{$(mexdir)}.$(MEXEXT):
  322. $(BUILD_MEX)
  323. {toolbox\misc}.c{$(mexdir)}.$(MEXEXT):
  324. $(BUILD_MEX)
  325. # vl.dll => mexw{32,64}/vl.dll
  326. $(mexdir)\vl.dll : $(bindir)\vl.dll
  327. copy "$(**)" "$(@)"
  328. # --------------------------------------------------------------------
  329. # Rules to copy redistributable libraries
  330. # --------------------------------------------------------------------
  331. # msvcr__.dll => bin/win{32,64}/msvcr__.dll
  332. $(bindir)\$(MSMANIFEST): "$(MSVCRLOC)\$(MSMANIFEST)"
  333. copy $(**) "$(@)"
  334. $(bindir)\$(MSVCR): "$(MSVCRLOC)\$(MSVCR)"
  335. copy $(**) "$(@)"
  336. $(bindir)\$(MSVCP): "$(MSVCRLOC)\$(MSVCP)"
  337. copy $(**) "$(@)"
  338. $(bindir)\$(MSVCM): "$(MSVCRLOC)\$(MSVCM)"
  339. copy $(**) "$(@)"
  340. # msvcr__.dll => toolbox/mexw32/msvcr__.dll
  341. $(mexdir)\$(MSMANIFEST): "$(MSVCRLOC)\$(MSMANIFEST)"
  342. copy $(**) "$(@)"
  343. $(mexdir)\$(MSVCR): "$(MSVCRLOC)\$(MSVCR)"
  344. copy $(**) "$(@)"
  345. $(mexdir)\$(MSVCP): "$(MSVCRLOC)\$(MSVCP)"
  346. copy $(**) "$(@)"
  347. $(mexdir)\$(MSVCM): "$(MSVCRLOC)\$(MSVCM)"
  348. copy $(**) "$(@)"
  349. # --------------------------------------------------------------------
  350. # Rules to post the binary files
  351. # --------------------------------------------------------------------
  352. bin-release:
  353. echo Fetching remote tags && \
  354. git fetch --tags && \
  355. echo Checking out v$(VER) && \
  356. $(GIT) checkout v$(VER)
  357. echo Rebuilding binaries for release
  358. if exist "bin\$(ARCH)" del /f /Q "bin\$(ARCH)"
  359. if exist "bin\mex$(ARCH)" del /f /Q "toolbox\mex$(ARCH)"
  360. nmake /f Makefile.mak ARCH=$(ARCH)
  361. bin-commit: bin-release
  362. @echo Fetching remote tags && \
  363. git fetch --tags
  364. @echo Crearing/resetting and checking out branch $(BRANCH) to v$(VER) && \
  365. $(GIT) branch -f $(BRANCH) v$(VER) && \
  366. $(GIT) checkout $(BRANCH)
  367. @echo Adding binaries && \
  368. $(GIT) add -f $(bindir)\vl.lib && \
  369. $(GIT) add -f $(bindir)\vl.dll && \
  370. $(GIT) add -f $(cmdexe) && \
  371. $(GIT) add -f $(bindir)\$(MSANIFEST) && \
  372. $(GIT) add -f $(bindir)\$(MSVCP) && \
  373. $(GIT) add -f $(bindir)\$(MSVCR) && \
  374. $(GIT) add -f $(bindir)\$(MSVCM)
  375. @echo Adding MEX files && \
  376. $(GIT) add -f $(mexdll) && \
  377. $(GIT) add -f $(mexdir)\$(MSANIFEST) && \
  378. $(GIT) add -f $(mexdir)\$(MSVCP) && \
  379. $(GIT) add -f $(mexdir)\$(MSVCR) && \
  380. $(GIT) add -f $(mexdir)\$(MSVCM) && \
  381. $(GIT) add -f $(mexdir)\$(MSVCP) && \
  382. $(GIT) add -f $(mexdir)\$(MSVCR)
  383. @echo Commiting changes && \
  384. $(GIT) commit -m "$(ARCH) binaries for version $(VER)"
  385. @echo Commiting and pushing to server the binaries && \
  386. $(GIT) push -v --force bin $(BRANCH):refs/heads/$(BRANCH) && \
  387. $(GIT) checkout v$(VER) && \
  388. $(GIT) branch -D $(BRANCH)