2008-08-19 14:55:46 -04:00
|
|
|
#!/usr/bin/env ruby
|
2008-08-19 11:01:28 -04:00
|
|
|
#/usr/local/bin/ruby
|
|
|
|
=begin
|
|
|
|
create Makefile script for Ruby/OpenCV
|
|
|
|
|
|
|
|
usage : ruby extconf.rb
|
|
|
|
make && make install
|
|
|
|
|
|
|
|
VC : ruby extconf.rb
|
|
|
|
nmake
|
|
|
|
=end
|
|
|
|
require "mkmf"
|
|
|
|
|
|
|
|
# option "opencv"
|
|
|
|
# extconf.rb --with-opencv-lib=/path/to/opencv/lib
|
|
|
|
# extconf.rb --with-opencv-include=/path/to/opencv/include
|
|
|
|
|
2010-12-29 14:32:34 -05:00
|
|
|
dir_config("opencv", "/usr/local/include/opencv2", "/usr/local/lib")
|
2008-08-19 15:30:09 -04:00
|
|
|
if CONFIG["arch"].include?("darwin")
|
2010-12-29 14:32:34 -05:00
|
|
|
dir_config("ffcall", "/opt/local/include", "/opt/local/lib")
|
2008-08-19 15:30:09 -04:00
|
|
|
else
|
2010-12-29 14:32:34 -05:00
|
|
|
dir_config("ffcall", "/usr/local/include", "/usr/local/lib")
|
2008-08-19 15:30:09 -04:00
|
|
|
end
|
2010-12-29 14:32:34 -05:00
|
|
|
dir_config("libxml2", "/usr/include", "/usr/lib")
|
|
|
|
|
|
|
|
opencv_headers = ["core/core_c.h", "core/core.hpp", "imgproc/imgproc_c.h",
|
|
|
|
"imgproc/imgproc.hpp", "video/tracking.hpp", "features2d/features2d.hpp",
|
|
|
|
"flann/flann.hpp", "calib3d/calib3d.hpp", "objdetect/objdetect.hpp",
|
|
|
|
"legacy/compat.hpp", "legacy/legacy.hpp", "highgui/highgui_c.h",
|
|
|
|
"highgui/highgui.hpp"]
|
|
|
|
|
|
|
|
opencv_libraries = ["opencv_calib3d", "opencv_contrib", "opencv_core", "opencv_features2d",
|
|
|
|
"opencv_flann", "opencv_gpu", "opencv_highgui", "opencv_imgproc",
|
|
|
|
"opencv_legacy", "opencv_ml", "opencv_objdetect", "opencv_video"]
|
2008-08-19 11:01:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
puts ">> check require libraries..."
|
|
|
|
case CONFIG["arch"]
|
|
|
|
when /mswin32/
|
|
|
|
have_library("msvcrt", nil)
|
|
|
|
opencv_libraries.each{|lib|
|
|
|
|
have_library(lib)
|
|
|
|
}
|
|
|
|
else
|
|
|
|
opencv_libraries.each{|lib|
|
|
|
|
raise "lib#{lib} not found." unless have_library(lib)
|
|
|
|
}
|
|
|
|
#have_library("ml")
|
|
|
|
have_library("stdc++")
|
|
|
|
end
|
|
|
|
|
|
|
|
# check require headers
|
|
|
|
puts ">> check require headers..."
|
2010-12-29 14:32:34 -05:00
|
|
|
opencv_headers.each{|header|
|
2008-08-19 11:01:28 -04:00
|
|
|
raise "#{header} not found." unless have_header(header)
|
|
|
|
}
|
|
|
|
#have_header("ml.h")
|
|
|
|
have_header("stdarg.h")
|
|
|
|
|
|
|
|
# check require functions.
|
|
|
|
# todo
|
|
|
|
|
|
|
|
# optional libraies check.
|
|
|
|
puts ">> ----- optional -----"
|
|
|
|
puts ">> check ffcall..."
|
|
|
|
# check ffcall
|
|
|
|
if have_library("callback") && have_header("callback.h")
|
|
|
|
puts ">> support OpenCV::GUI"
|
|
|
|
else
|
|
|
|
puts ">> ! unsupport OpenCV::GUI (if need it. install ffcall)"
|
|
|
|
puts "http://www.haible.de/bruno/packages-ffcall.html"
|
|
|
|
end
|
|
|
|
|
2011-05-03 12:32:48 -04:00
|
|
|
# Quick fix for 1.8.7
|
2011-05-04 15:24:21 -04:00
|
|
|
$CFLAGS << " -I#{File.dirname(__FILE__)}/ext/opencv"
|
2011-05-03 12:32:48 -04:00
|
|
|
|
2008-08-19 11:01:28 -04:00
|
|
|
# step-final. create Makefile
|
2011-05-03 04:12:47 -04:00
|
|
|
create_makefile("opencv", "./ext/opencv")
|
2011-05-03 12:32:48 -04:00
|
|
|
|