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