configure.in 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_INIT(README.txt)
  3. dnl Set various version strings - taken gratefully from the GTk sources
  4. # Making releases:
  5. # MICRO_VERSION += 1;
  6. # INTERFACE_AGE += 1;
  7. # BINARY_AGE += 1;
  8. # if any functions have been added, set INTERFACE_AGE to 0.
  9. # if backwards compatibility has been broken,
  10. # set BINARY_AGE and INTERFACE_AGE to 0.
  11. MAJOR_VERSION=2
  12. MINOR_VERSION=0
  13. MICRO_VERSION=0
  14. INTERFACE_AGE=0
  15. BINARY_AGE=0
  16. VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
  17. AC_SUBST(MAJOR_VERSION)
  18. AC_SUBST(MINOR_VERSION)
  19. AC_SUBST(MICRO_VERSION)
  20. AC_SUBST(INTERFACE_AGE)
  21. AC_SUBST(BINARY_AGE)
  22. AC_SUBST(VERSION)
  23. # libtool versioning
  24. LT_INIT([win32-dll])
  25. LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
  26. LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
  27. LT_REVISION=$INTERFACE_AGE
  28. LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
  29. AC_SUBST(LT_RELEASE)
  30. AC_SUBST(LT_CURRENT)
  31. AC_SUBST(LT_REVISION)
  32. AC_SUBST(LT_AGE)
  33. dnl Detect the canonical build and host environments
  34. AC_CANONICAL_HOST
  35. dnl Setup for automake
  36. AM_INIT_AUTOMAKE(SDL2_image, $VERSION)
  37. dnl Check for tools
  38. AC_PROG_LIBTOOL
  39. AC_PROG_CC
  40. AC_PROG_OBJC
  41. AC_C_INLINE
  42. AC_PROG_INSTALL
  43. AC_PROG_MAKE_SET
  44. if test -z "$host_alias"; then
  45. hostaliaswindres=
  46. else
  47. hostaliaswindres="$host_alias-windres"
  48. fi
  49. AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres])
  50. case "$host" in
  51. *-*-beos*)
  52. ac_default_prefix=/boot/develop/tools/gnupro
  53. ;;
  54. *-*-cygwin* | *-*-mingw32*)
  55. if test "$build" != "$host"; then # cross-compiling
  56. # Default cross-compile location
  57. ac_default_prefix=/usr/local/cross-tools/i386-mingw32
  58. else
  59. # Look for the location of the tools and install there
  60. if test "$BUILD_PREFIX" != ""; then
  61. ac_default_prefix=$BUILD_PREFIX
  62. fi
  63. fi
  64. if test x$WINDRES != x; then
  65. use_version_rc=true
  66. fi
  67. ;;
  68. *-*-darwin*)
  69. AC_ARG_ENABLE([imageio], [AC_HELP_STRING([--enable-imageio], [use native Mac OS X frameworks for loading images [default=yes]])],
  70. [], [enable_imageio=yes])
  71. if test x$enable_imageio = xyes; then
  72. IMG_LIBS="-Wl,-framework,ApplicationServices $IMG_LIBS"
  73. else
  74. CFLAGS="$CFLAGS -DSDL_IMAGE_USE_COMMON_BACKEND"
  75. fi
  76. ;;
  77. esac
  78. AM_CONDITIONAL(USE_IMAGEIO, test x$enable_imageio = xyes)
  79. AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue)
  80. dnl set this to use on systems that use lib64 instead of lib
  81. base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
  82. dnl Function to find a library in the compiler search path
  83. find_lib()
  84. {
  85. gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
  86. gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
  87. env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
  88. if test "$cross_compiling" = yes; then
  89. host_lib_path=""
  90. else
  91. host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
  92. fi
  93. for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
  94. lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
  95. if test x$lib != x; then
  96. echo $lib
  97. return
  98. fi
  99. done
  100. }
  101. dnl Check for SDL
  102. SDL_VERSION=2.0.0
  103. AC_SUBST(SDL_VERSION)
  104. AM_PATH_SDL2($SDL_VERSION,
  105. :,
  106. AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
  107. )
  108. CFLAGS="$CFLAGS $SDL_CFLAGS"
  109. LIBS="$LIBS $SDL_LIBS"
  110. saved_LIBS="$LIBS"
  111. dnl Check command-line options
  112. AC_ARG_ENABLE([bmp], [AC_HELP_STRING([--enable-bmp], [support loading BMP/ICO/CUR images [default=yes]])],
  113. [], [enable_bmp=yes])
  114. AC_ARG_ENABLE([gif], [AC_HELP_STRING([--enable-gif], [support loading GIF images [default=yes]])],
  115. [], [enable_gif=yes])
  116. AC_ARG_ENABLE([jpg], [AC_HELP_STRING([--enable-jpg], [support loading JPG images [default=yes]])],
  117. [], [enable_jpg=yes])
  118. AC_ARG_ENABLE([jpg-shared], AC_HELP_STRING([--enable-jpg-shared], [dynamically load JPG support [[default=yes]]]),
  119. [], [enable_jpg_shared=yes])
  120. AC_ARG_ENABLE([lbm], [AC_HELP_STRING([--enable-lbm], [support loading LBM images [default=yes]])],
  121. [], [enable_lbm=yes])
  122. AC_ARG_ENABLE([pcx], [AC_HELP_STRING([--enable-pcx], [support loading PCX images [default=yes]])],
  123. [], [enable_pcx=yes])
  124. AC_ARG_ENABLE([png], [AC_HELP_STRING([--enable-png], [support loading PNG images [default=yes]])],
  125. [], [enable_png=yes])
  126. AC_ARG_ENABLE([png-shared], AC_HELP_STRING([--enable-png-shared], [dynamically load PNG support [[default=yes]]]),
  127. [], [enable_png_shared=yes])
  128. AC_ARG_ENABLE([pnm], [AC_HELP_STRING([--enable-pnm], [support loading PNM images [default=yes]])],
  129. [], [enable_pnm=yes])
  130. AC_ARG_ENABLE([tga], [AC_HELP_STRING([--enable-tga], [support loading TGA images [default=yes]])],
  131. [], [enable_tga=yes])
  132. AC_ARG_ENABLE([tif], [AC_HELP_STRING([--enable-tif], [support loading TIFF images [default=yes]])],
  133. [], [enable_tif=yes])
  134. AC_ARG_ENABLE([tif-shared], AC_HELP_STRING([--enable-tif-shared], [dynamically load TIFF support [[default=yes]]]),
  135. [], [enable_tif_shared=yes])
  136. AC_ARG_ENABLE([xcf], [AC_HELP_STRING([--enable-xcf], [support loading XCF images [default=yes]])],
  137. [], [enable_xcf=yes])
  138. AC_ARG_ENABLE([xpm], [AC_HELP_STRING([--enable-xpm], [support loading XPM images [default=yes]])],
  139. [], [enable_xpm=yes])
  140. AC_ARG_ENABLE([xv], [AC_HELP_STRING([--enable-xv], [support loading XV images [default=yes]])],
  141. [], [enable_xv=yes])
  142. AC_ARG_ENABLE([webp], [AC_HELP_STRING([--enable-webp], [support loading WEBP images [default=yes]])],
  143. [], [enable_webp=yes])
  144. AC_ARG_ENABLE([webp-shared], AC_HELP_STRING([--enable-webp-shared], [dynamically load WEBP support [[default=yes]]]),
  145. [], [enable_webp_shared=yes])
  146. dnl Show a message when we use ImageIO support so it's not a surprise
  147. AC_MSG_CHECKING([for ImageIO support])
  148. AC_MSG_RESULT($enable_imageio)
  149. if (test x$enable_jpg = xyes || test x$enable_tif = xyes) && test x$enable_imageio != xyes; then
  150. AC_CHECK_HEADER([jpeglib.h], [have_jpg_hdr=yes])
  151. AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], [have_jpg_lib=yes])
  152. if test x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
  153. if test x$enable_jpg = xyes; then
  154. AC_DEFINE([LOAD_JPG])
  155. fi
  156. LIBS="-ljpeg $LIBS"
  157. case "$host" in
  158. *-*-darwin*)
  159. jpg_lib=[`find_lib libjpeg.dylib`]
  160. ;;
  161. *-*-cygwin* | *-*-mingw32*)
  162. jpg_lib=[`find_lib "libjpeg*.dll"`]
  163. ;;
  164. *)
  165. jpg_lib=[`find_lib "libjpeg[0-9]*.so.*"`]
  166. if test x$jpg_lib = x; then
  167. jpg_lib=[`find_lib "libjpeg.so.*"`]
  168. fi
  169. ;;
  170. esac
  171. elif test x$enable_jpg = xyes; then
  172. AC_MSG_WARN([*** Unable to find JPEG library (http://www.ijg.org/)])
  173. AC_MSG_WARN([JPG image loading disabled])
  174. fi
  175. fi
  176. if test x$enable_png = xyes -a x$enable_imageio != xyes; then
  177. PKG_CHECK_MODULES([LIBPNG], [libpng], [dnl
  178. have_png_hdr=yes
  179. CFLAGS="$LIBPNG_CFLAGS $CFLAGS"
  180. have_png_lib=yes
  181. ], [dnl
  182. AC_CHECK_HEADER([png.h], [have_png_hdr=yes])
  183. AC_CHECK_LIB([png], [png_create_read_struct], [have_png_lib=yes], [], [-lz])
  184. ])
  185. if test x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
  186. AC_DEFINE([LOAD_PNG])
  187. case "$host" in
  188. *-*-darwin*)
  189. png_lib=[`find_lib libpng.dylib`]
  190. ;;
  191. *-*-cygwin* | *-*-mingw32*)
  192. png_lib=[`find_lib "libpng*.dll"`]
  193. ;;
  194. *)
  195. png_lib=[`find_lib "libpng[0-9]*.so.*"`]
  196. if test x$png_lib = x; then
  197. png_lib=[`find_lib "libpng.so.*"`]
  198. fi
  199. ;;
  200. esac
  201. else
  202. AC_MSG_WARN([*** Unable to find PNG library (http://www.libpng.org/pub/png/libpng.html)])
  203. AC_MSG_WARN([PNG image loading disabled])
  204. fi
  205. fi
  206. if test x$enable_tif = xyes -a x$enable_imageio != xyes; then
  207. AC_CHECK_HEADER([tiffio.h], [have_tif_hdr=yes])
  208. AC_CHECK_LIB([tiff], [TIFFClientOpen], [have_tif_lib=yes], [], [-lz])
  209. if test x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
  210. AC_DEFINE([LOAD_TIF])
  211. case "$host" in
  212. *-*-darwin*)
  213. tif_lib=[`find_lib libtiff.dylib`]
  214. ;;
  215. *-*-cygwin* | *-*-mingw32*)
  216. tif_lib=[`find_lib "libtiff-*.dll"`]
  217. ;;
  218. *)
  219. tif_lib=[`find_lib "libtiff[0-9]*.so.*"`]
  220. if test x$tif_lib = x; then
  221. tif_lib=[`find_lib "libtiff.so.*"`]
  222. fi
  223. ;;
  224. esac
  225. else
  226. AC_MSG_WARN([*** Unable to find Tiff library (http://www.remotesensing.org/libtiff/)])
  227. AC_MSG_WARN([TIF image loading disabled])
  228. fi
  229. fi
  230. if test x$enable_webp = xyes; then
  231. PKG_CHECK_MODULES([LIBWEBP], [libwebp], [dnl
  232. have_webp_hdr=yes
  233. CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
  234. have_webp_lib=yes
  235. ], [dnl
  236. AC_CHECK_HEADER([webp/decode.h], [have_webp_hdr=yes])
  237. AC_CHECK_LIB([webp], [WebPGetDecoderVersion], [have_webp_lib=yes], [], [-lm])
  238. ])
  239. if test x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
  240. AC_DEFINE([LOAD_WEBP])
  241. case "$host" in
  242. *-*-darwin*)
  243. webp_lib=[`find_lib libwebp.dylib`]
  244. ;;
  245. *-*-cygwin* | *-*-mingw32*)
  246. webp_lib=[`find_lib "libwebp*.dll"`]
  247. ;;
  248. *)
  249. webp_lib=[`find_lib "libwebp[0-9]*.so.*"`]
  250. if test x$webp_lib = x; then
  251. webp_lib=[`find_lib "libwebp.so.*"`]
  252. fi
  253. ;;
  254. esac
  255. else
  256. AC_MSG_WARN([*** Unable to find WEBP library (http://code.google.com/intl/en-US/speed/webp/index.html)])
  257. AC_MSG_WARN([WEBP Pimage loading disabled])
  258. fi
  259. fi
  260. if test x$enable_bmp = xyes; then
  261. AC_DEFINE([LOAD_BMP])
  262. fi
  263. if test x$enable_gif = xyes; then
  264. AC_DEFINE([LOAD_GIF])
  265. fi
  266. if test x$enable_lbm = xyes; then
  267. AC_DEFINE([LOAD_LBM])
  268. fi
  269. if test x$enable_pcx = xyes; then
  270. AC_DEFINE([LOAD_PCX])
  271. fi
  272. if test x$enable_pnm = xyes; then
  273. AC_DEFINE([LOAD_PNM])
  274. fi
  275. if test x$enable_tga = xyes; then
  276. AC_DEFINE([LOAD_TGA])
  277. fi
  278. if test x$enable_xcf = xyes; then
  279. AC_DEFINE([LOAD_XCF])
  280. fi
  281. if test x$enable_xpm = xyes; then
  282. AC_DEFINE([LOAD_XPM])
  283. fi
  284. if test x$enable_xv = xyes; then
  285. AC_DEFINE([LOAD_XV])
  286. fi
  287. if test x$enable_webp = xyes -a x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
  288. if test x$enable_webp_shared = xyes && test x$webp_lib != x; then
  289. echo "-- dynamic libwebp -> $webp_lib"
  290. AC_DEFINE_UNQUOTED(LOAD_WEBP_DYNAMIC, "$webp_lib")
  291. else
  292. IMG_LIBS="-lwebp $IMG_LIBS"
  293. fi
  294. fi
  295. if test x$enable_tif = xyes -a x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
  296. if test x$enable_tif_shared = xyes && test x$tif_lib != x; then
  297. echo "-- dynamic libtiff -> $tif_lib"
  298. AC_DEFINE_UNQUOTED(LOAD_TIF_DYNAMIC, "$tif_lib")
  299. else
  300. if test x$have_libjpeg = xyes; then
  301. # Disable dynamic jpeg since we're linking it explicitly
  302. jpg_lib=''
  303. fi
  304. IMG_LIBS="-ltiff -lz $IMG_LIBS"
  305. fi
  306. fi
  307. if test x$enable_jpg = xyes -a x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
  308. if test x$enable_jpg_shared = xyes && test x$jpg_lib != x; then
  309. echo "-- dynamic libjpeg -> $jpg_lib"
  310. AC_DEFINE_UNQUOTED(LOAD_JPG_DYNAMIC, "$jpg_lib")
  311. else
  312. IMG_LIBS="-ljpeg $IMG_LIBS"
  313. fi
  314. fi
  315. if test x$enable_png = xyes -a x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
  316. if test x$enable_png_shared = xyes && test x$png_lib != x; then
  317. echo "-- dynamic libpng -> $png_lib"
  318. AC_DEFINE_UNQUOTED(LOAD_PNG_DYNAMIC, "$png_lib")
  319. else
  320. IMG_LIBS="-lpng -lz $IMG_LIBS"
  321. fi
  322. fi
  323. LIBS="$saved_LIBS"
  324. AC_SUBST([WINDRES])
  325. AC_SUBST([IMG_LIBS])
  326. OBJCFLAGS=$CFLAGS
  327. # Finally create all the generated files
  328. AC_OUTPUT([
  329. Makefile
  330. SDL2_image.spec
  331. SDL2_image.pc
  332. ])