Skip to content

Commit

Permalink
Merge pull request #255 from OnePageCRM/master
Browse files Browse the repository at this point in the history
Support for ImageMagick 6.9+
  • Loading branch information
vassilevsky committed Aug 9, 2016
2 parents d343a9d + 55a2b2e commit 8643ab5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
57 changes: 44 additions & 13 deletions ext/RMagick/extconf.rb
Expand Up @@ -21,6 +21,7 @@ def initialize
def configured_compile_options
{
:magick_config => $magick_config,
:with_magick_wand => $with_magick_wand,
:pkg_config => $pkg_config,
:magick_version => $magick_version,
:local_libs => $LOCAL_LIBS,
Expand Down Expand Up @@ -57,6 +58,7 @@ def configure_compile_options
end

# ugly way to handle which config tool we're going to use...
$with_magick_wand = false
$magick_config = false
$pkg_config = false

Expand Down Expand Up @@ -84,21 +86,50 @@ def configure_compile_options
end
end

# either set flags using Magick-config or pkg-config (new Debian default)
if $magick_config
# Save flags
$CFLAGS = ENV['CFLAGS'].to_s + ' ' + `Magick-config --cflags`.chomp
$CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `Magick-config --cppflags`.chomp
$LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `Magick-config --ldflags`.chomp
$LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `Magick-config --libs`.chomp
# From ImageMagick 6.9 binaries are split to two and we have to use
# MagickWand instead of MagickCore
checking_for("presence of MagickWand API (ImageMagick version >= #{Magick::MIN_WAND_VERSION})") do
$with_magick_wand = Gem::Version.new($magick_version) >= Gem::Version.new(Magick::MIN_WAND_VERSION)
if $with_magick_wand
Logging.message('Detected 6.9+ version, using MagickWand API')
else
Logging.message('Older version detected, using MagickCore API')
end
end

if $pkg_config
# Save flags
$CFLAGS = ENV['CFLAGS'].to_s + ' ' + `pkg-config --cflags MagickCore`.chomp
$CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `pkg-config --cflags MagickCore`.chomp
$LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `pkg-config --libs MagickCore`.chomp
$LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `pkg-config --libs MagickCore`.chomp
# either set flags using Magick-config, MagickWand-config or pkg-config (new Debian default)
if $with_magick_wand
if $magick_config
# Save flags
$CFLAGS = ENV['CFLAGS'].to_s + ' ' + `MagickWand-config --cflags`.chomp
$CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `MagickWand-config --cppflags`.chomp
$LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `MagickWand-config --ldflags`.chomp
$LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `MagickWand-config --libs`.chomp
end

if $pkg_config
# Save flags
$CFLAGS = ENV['CFLAGS'].to_s + ' ' + `pkg-config --cflags MagickWand`.chomp
$CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `pkg-config --cflags MagickWand`.chomp
$LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `pkg-config --libs MagickWand`.chomp
$LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `pkg-config --libs MagickWand`.chomp
end
else
if $magick_config
# Save flags
$CFLAGS = ENV['CFLAGS'].to_s + ' ' + `Magick-config --cflags`.chomp
$CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `Magick-config --cppflags`.chomp
$LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `Magick-config --ldflags`.chomp
$LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `Magick-config --libs`.chomp
end

if $pkg_config
# Save flags
$CFLAGS = ENV['CFLAGS'].to_s + ' ' + `pkg-config --cflags MagickCore`.chomp
$CPPFLAGS = ENV['CPPFLAGS'].to_s + ' ' + `pkg-config --cflags MagickCore`.chomp
$LDFLAGS = ENV['LDFLAGS'].to_s + ' ' + `pkg-config --libs MagickCore`.chomp
$LOCAL_LIBS = ENV['LIBS'].to_s + ' ' + `pkg-config --libs MagickCore`.chomp
end
end

if RUBY_PLATFORM =~ /darwin/ # osx
Expand Down
1 change: 1 addition & 0 deletions lib/rmagick/version.rb
Expand Up @@ -2,4 +2,5 @@ module Magick
VERSION = '2.15.4'
MIN_RUBY_VERSION = '1.8.5'
MIN_IM_VERSION = '6.4.9'
MIN_WAND_VERSION = '6.9.0'
end

0 comments on commit 8643ab5

Please sign in to comment.