1######################################################### 2# Locate ImageMagick configuration program 3# ImageMagick has the config program: 4# bin/Wand-config 5# bin/MagickWand-config 6# 7# Sets 8# IM_WAND_BINARY 9# IM_IMAGEMAGICK_PREFIX 10# IM_IMAGEMAGICK_VERSION 11# IM_IMAGEMAGICK_VERSION_MASK 12# IM_USE_PKG_CONFIG 13# 14# Usage: 15# IM_FIND_IMAGEMAGICK (MINIMUM_VERSION, EXTRA_SEARCH_PREFIX) 16# 17# Note: 18# IM_PREFIX - the directory reported by `MagickWand-config --prefix` 19# IM_IMAGEMAGICK_PREFIX - the user specified location to use 20# 21######################################################### 22 23dnl 24dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD) 25dnl 26dnl Use this macro, if you need to add libraries and or library search 27dnl paths to the PHP build system which are only given in compiler 28dnl notation. 29dnl 30AC_DEFUN([IM_EVAL_LIBLINE_DEFER],[ 31 for ac_i in $1; do 32 case $ac_i in 33 -pthread[)] 34 if test "$ext_shared" = "yes"; then 35 $2="[$]$2 -pthread" 36 else 37 PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"]) 38 fi 39 ;; 40 -l*[)] 41 ac_ii=`echo $ac_i|cut -c 3-` 42 PHP_ADD_LIBRARY_DEFER($ac_ii,1,$2) 43 ;; 44 -L*[)] 45 ac_ii=`echo $ac_i|cut -c 3-` 46 PHP_ADD_LIBPATH_DEFER($ac_ii,$2) 47 ;; 48 esac 49 done 50]) 51 52AC_DEFUN([IM_FIND_IMAGEMAGICK],[ 53 54# 55# Variables passed in 56# 57 IM_MINIMUM_VERSION=$1 58 IM_EXTRA_SEARCH_PREFIX=$2 59 60 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 61 if test "x$PKG_CONFIG" = "xno"; then 62 AC_MSG_RESULT([pkg-config not found]) 63 AC_MSG_ERROR([Please reinstall the pkg-config distribution]) 64 fi 65 66 if test -z "$AWK"; then 67 AC_MSG_ERROR([awk not found]) 68 fi 69 70 AC_MSG_CHECKING(ImageMagick MagickWand API configuration program) 71 72 if test "$IM_EXTRA_SEARCH_PREFIX" != "yes"; then 73 for i in "$IM_EXTRA_SEARCH_PREFIX" /usr/local /usr /usr/sbin /opt /opt/local /opt/homebrew; 74 do 75 AC_MSG_CHECKING([Testing ${i}/bin/MagickWand-config]) 76 if test -r "${i}/bin/MagickWand-config"; then 77 IM_WAND_BINARY="${i}/bin/MagickWand-config" 78 IM_IMAGEMAGICK_PREFIX=$i 79 AC_MSG_RESULT([It exists]) 80 break 81 fi 82 AC_MSG_RESULT([Doesn't exist]) 83 84 AC_MSG_CHECKING([Testing ${i}/bin/Wand-config]) 85 if test -r "${i}/bin/Wand-config"; then 86 IM_WAND_BINARY="${i}/bin/Wand-config" 87 IM_IMAGEMAGICK_PREFIX=$i 88 AC_MSG_RESULT([It exists]) 89 break 90 fi 91 AC_MSG_RESULT([Doesn't exist]) 92 done 93 else 94 for i in /usr/local /usr /usr/sbin /opt /opt/local /opt/homebrew; 95 do 96 AC_MSG_CHECKING([Testing ${i}/bin/MagickWand-config]) 97 if test -r "${i}/bin/MagickWand-config"; then 98 IM_WAND_BINARY="${i}/bin/MagickWand-config" 99 IM_IMAGEMAGICK_PREFIX=$i 100 AC_MSG_RESULT([It exists]) 101 break 102 fi 103 104 if test -r "${i}/bin/Wand-config"; then 105 IM_WAND_BINARY="${i}/bin/Wand-config" 106 IM_IMAGEMAGICK_PREFIX=$i 107 AC_MSG_RESULT([It exists]) 108 break 109 fi 110 AC_MSG_RESULT([Doesn't exist]) 111 done 112 fi 113 114 IM_USE_PKG_CONFIG=0 115 if test "x" = "x$IM_WAND_BINARY"; then 116 if eval '$PKG_CONFIG --exists MagickWand'; then 117 IM_USE_PKG_CONFIG=1 118 IM_WAND_BINARY=$PKG_CONFIG 119 else 120 AC_MSG_ERROR(not found. Please provide a path to MagickWand-config or Wand-config program.) 121 fi 122 fi 123 AC_MSG_RESULT([found in $IM_WAND_BINARY]) 124 125# This is used later for cflags and libs 126 export PKG_CONFIG_PATH="${IM_IMAGEMAGICK_PREFIX}/${PHP_LIBDIR}/pkgconfig" 127 128# Check version 129# 130 if test "$IM_USE_PKG_CONFIG" = "1"; then 131 IM_IMAGEMAGICK_VERSION=`$IM_WAND_BINARY --modversion MagickWand` 132 else 133 IM_IMAGEMAGICK_VERSION=`$IM_WAND_BINARY --version` 134 fi 135 IM_IMAGEMAGICK_VERSION_MASK=`echo $IM_IMAGEMAGICK_VERSION | $AWK 'BEGIN { FS = "."; } { printf "%d", ($[1] * 1000 + $[2]) * 1000 + $[3];}'` 136 137 IM_MIMIMUM_VERSION_MASK=`echo $IM_MINIMUM_VERSION | $AWK 'BEGIN { FS = "."; } { printf "%d", ($[1] * 1000 + $[2]) * 1000 + $[3];}'` 138 139 AC_MSG_CHECKING(if ImageMagick version is at least $IM_MINIMUM_VERSION) 140 if test "$IM_IMAGEMAGICK_VERSION_MASK" -ge $IM_MIMIMUM_VERSION_MASK; then 141 AC_MSG_RESULT(found version $IM_IMAGEMAGICK_VERSION) 142 else 143 AC_MSG_ERROR(no. You need at least ImageMagick version $IM_MINIMUM_VERSION to use this extension.) 144 fi 145 146# Potential locations for the header 147# include/wand/magick-wand.h 148# include/ImageMagick/wand/MagickWand.h 149# include/ImageMagick-6/wand/MagickWand.h 150# include/ImageMagick-7/MagickWand/MagickWand.h 151 152 AC_MSG_CHECKING(for MagickWand.h or magick-wand.h header) 153 154 if test "$IM_USE_PKG_CONFIG" = "1"; then 155 IM_PREFIX=`$IM_WAND_BINARY --variable prefix MagickWand` 156 else 157 IM_PREFIX=`$IM_WAND_BINARY --prefix` 158 fi 159 IM_MAJOR_VERSION=`echo $IM_IMAGEMAGICK_VERSION | $AWK 'BEGIN { FS = "."; } {print $[1]}'` 160 161 # Try the header formats from newest to oldest 162 if test -r "${IM_IMAGEMAGICK_PREFIX}/include/ImageMagick-${IM_MAJOR_VERSION}/MagickWand/MagickWand.h"; then 163 164 IM_INCLUDE_FORMAT="MagickWand/MagickWand.h" 165 IM_HEADER_STYLE="SEVEN" 166 AC_DEFINE([IM_MAGICKWAND_HEADER_STYLE_SEVEN], [1], [ImageMagick 7.x style header]) 167 168 AC_MSG_RESULT([user location ${IM_IMAGEMAGICK_PREFIX}/include/ImageMagick-${IM_MAJOR_VERSION}/MagickWand/MagickWand.h]) 169 170 elif test -r "${IM_IMAGEMAGICK_PREFIX}/include/ImageMagick-${IM_MAJOR_VERSION}/wand/MagickWand.h"; then 171 172 IM_INCLUDE_FORMAT="wand/MagickWand.h" 173 IM_HEADER_STYLE="SIX" 174 AC_DEFINE([IM_MAGICKWAND_HEADER_STYLE_SIX], [1], [ImageMagick 6.x style header]) 175 176 AC_MSG_RESULT([user location ${IM_IMAGEMAGICK_PREFIX}/include/ImageMagick-${IM_MAJOR_VERSION}/wand/MagickWand.h]) 177 178 elif test -r "${IM_PREFIX}/include/ImageMagick-${IM_MAJOR_VERSION}/MagickWand/MagickWand.h"; then 179 180 IM_INCLUDE_FORMAT="MagickWand/MagickWand.h" 181 IM_HEADER_STYLE="SEVEN" 182 AC_DEFINE([IM_MAGICKWAND_HEADER_STYLE_SEVEN], [1], [ImageMagick 7.x style header]) 183 184 AC_MSG_RESULT([${IM_PREFIX}/include/ImageMagick-${IM_MAJOR_VERSION}/MagickWand/MagickWand.h]) 185 186 elif test -r "${IM_PREFIX}/include/ImageMagick-${IM_MAJOR_VERSION}/wand/MagickWand.h"; then 187 188 IM_INCLUDE_FORMAT="wand/MagickWand.h" 189 IM_HEADER_STYLE="SIX" 190 AC_DEFINE([IM_MAGICKWAND_HEADER_STYLE_SIX], [1], [ImageMagick 6.x style header]) 191 192 AC_MSG_RESULT([${IM_PREFIX}/include/ImageMagick-${IM_MAJOR_VERSION}/wand/MagickWand.h]) 193 194 elif test -r "${IM_PREFIX}/include/ImageMagick/wand/MagickWand.h"; then 195 196 IM_INCLUDE_FORMAT="wand/MagickWand.h" 197 IM_HEADER_STYLE="SIX" 198 AC_DEFINE([IM_MAGICKWAND_HEADER_STYLE_SIX], [1], [ImageMagick 6.x style header]) 199 200 AC_MSG_RESULT([${IM_PREFIX}/include/ImageMagick/wand/MagickWand.h]) 201 202 elif test -r "${IM_PREFIX}/include/ImageMagick/wand/magick-wand.h"; then 203 204 IM_INCLUDE_FORMAT="wand/magick-wand.h" 205 IM_HEADER_STYLE="OLD" 206 AC_DEFINE([IM_MAGICKWAND_HEADER_STYLE_OLD], [1], [ImageMagick old style header]) 207 208 AC_MSG_RESULT([${IM_PREFIX}/include/wand/magick-wand.h]) 209 210 else 211 AC_MSG_ERROR([Unable to find MagickWand.h or magick-wand.h header]) 212 fi 213 214# 215# The cflags and libs 216# 217 if test "$IM_USE_PKG_CONFIG" = "1"; then 218 IM_IMAGEMAGICK_LIBS=`$IM_WAND_BINARY --libs MagickWand` 219 IM_IMAGEMAGICK_CFLAGS=`$IM_WAND_BINARY --cflags MagickWand` 220 else 221 IM_IMAGEMAGICK_LIBS=`$IM_WAND_BINARY --libs` 222 IM_IMAGEMAGICK_CFLAGS=`$IM_WAND_BINARY --cflags` 223 fi 224 export IM_IMAGEMAGICK_PREFIX 225 export IM_WAND_BINARY 226 export IM_IMAGEMAGICK_VERSION 227 export IM_IMAGEMAGICK_VERSION_MASK 228 export IM_INCLUDE_FORMAT 229 export IM_HEADER_STYLE 230 export IM_USE_PKG_CONFIG 231 232 export IM_IMAGEMAGICK_LIBS 233 export IM_IMAGEMAGICK_CFLAGS 234]) 235 236