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