configure.in
author Sam Lantinga <slouken@libsdl.org>
Tue, 26 Feb 2013 16:52:53 -0800
changeset 354 a32397bbb608
parent 330 1230766039be
child 357 56243a3eb8ea
permissions -rw-r--r--
Updated library version to 2.0 for consistency with SDL 2.0
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README)
     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=0
    17 INTERFACE_AGE=0
    18 BINARY_AGE=0
    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/i386-mingw32
    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 $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 $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
   107         lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
   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.0
   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([tga], [AC_HELP_STRING([--enable-tga], [support loading TGA images [default=yes]])],
   146  [], [enable_tga=yes])
   147 AC_ARG_ENABLE([tif], [AC_HELP_STRING([--enable-tif], [support loading TIFF images [default=yes]])],
   148  [], [enable_tif=yes])
   149 AC_ARG_ENABLE([tif-shared], AC_HELP_STRING([--enable-tif-shared], [dynamically load TIFF support [[default=yes]]]),
   150  [], [enable_tif_shared=yes])
   151 AC_ARG_ENABLE([xcf], [AC_HELP_STRING([--enable-xcf], [support loading XCF images [default=yes]])],
   152  [], [enable_xcf=yes])
   153 AC_ARG_ENABLE([xpm], [AC_HELP_STRING([--enable-xpm], [support loading XPM images [default=yes]])],
   154  [], [enable_xpm=yes])
   155 AC_ARG_ENABLE([xv], [AC_HELP_STRING([--enable-xv], [support loading XV images [default=yes]])],
   156  [], [enable_xv=yes])
   157 AC_ARG_ENABLE([webp], [AC_HELP_STRING([--enable-webp], [support loading WEBP images [default=yes]])],
   158  [], [enable_webp=yes])
   159 AC_ARG_ENABLE([webp-shared], AC_HELP_STRING([--enable-webp-shared], [dynamically load WEBP support [[default=yes]]]),
   160  [], [enable_webp_shared=yes])
   161 
   162 if test x$enable_jpg = xyes || test x$enable_tif = xyes; then
   163     AC_CHECK_HEADER([jpeglib.h], [have_jpg_hdr=yes])
   164     AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], [have_jpg_lib=yes])
   165     if test x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
   166         if test x$enable_jpg = xyes; then
   167             AC_DEFINE([LOAD_JPG])
   168         fi
   169         LIBS="-ljpeg $LIBS"
   170 
   171         case "$host" in
   172             *-*-darwin*)
   173                 jpg_lib=[`find_lib libjpeg.dylib`]
   174                 ;;
   175             *-*-cygwin* | *-*-mingw32*)
   176                 jpg_lib=[`find_lib "libjpeg*.dll"`]
   177                 ;;
   178             *)
   179                 jpg_lib=[`find_lib "libjpeg.so.[0-9]"`]
   180                 if test x$jpg_lib = x; then
   181                     jpg_lib=[`find_lib "libjpeg.so.[0-9][0-9]"`]
   182                 fi
   183                 if test x$jpg_lib = x; then
   184                     jpg_lib=[`find_lib "libjpeg.so.[0-9]*"`]
   185                 fi
   186                 ;;
   187         esac
   188     elif test x$enable_jpg = xyes; then
   189         AC_MSG_WARN([*** Unable to find JPEG library (http://www.ijg.org/)])
   190         AC_MSG_WARN([JPG image loading disabled])
   191     fi
   192 fi
   193 
   194 if test "x$enable_png" = xyes; then
   195     PKG_CHECK_MODULES([LIBPNG], [libpng], [dnl
   196         have_png_hdr=yes
   197         CFLAGS="$LIBPNG_CFLAGS $CFLAGS"
   198         have_png_lib=yes
   199       ], [dnl
   200         AC_CHECK_HEADER([png.h], [have_png_hdr=yes])
   201         AC_CHECK_LIB([png], [png_create_read_struct], [have_png_lib=yes], [], [-lz])
   202       ])
   203     if test x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
   204         AC_DEFINE([LOAD_PNG])
   205 
   206         case "$host" in
   207             *-*-darwin*)
   208                 png_lib=[`find_lib libpng.dylib`]
   209                 ;;
   210             *-*-cygwin* | *-*-mingw32*)
   211                 png_lib=[`find_lib "libpng*.dll"`]
   212                 ;;
   213             *)
   214                 png_lib=[`find_lib "libpng.so.[0-9]"`]
   215                 if test x$png_lib = x; then
   216                     png_lib=[`find_lib "libpng.so.[0-9]*"`]
   217                 fi
   218                 if test x$png_lib = x; then
   219                     png_lib=[`find_lib "libpng*.so.[0-9]"`]
   220                 fi
   221                 if test x$png_lib = x; then
   222                     png_lib=[`find_lib "libpng*.so.[0-9]*"`]
   223                 fi
   224                 ;;
   225         esac
   226     else
   227         AC_MSG_WARN([*** Unable to find PNG library (http://www.libpng.org/pub/png/libpng.html)])
   228         AC_MSG_WARN([PNG image loading disabled])
   229     fi
   230 fi
   231 
   232 if test x$enable_tif = xyes; then
   233     AC_CHECK_HEADER([tiffio.h], [have_tif_hdr=yes])
   234     AC_CHECK_LIB([tiff], [TIFFClientOpen], [have_tif_lib=yes], [], [-lz])
   235     if test x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
   236         AC_DEFINE([LOAD_TIF])
   237 
   238         case "$host" in
   239             *-*-darwin*)
   240                 tif_lib=[`find_lib libtiff.dylib`]
   241                 ;;
   242             *-*-cygwin* | *-*-mingw32*)
   243                 tif_lib=[`find_lib "libtiff-*.dll"`]
   244                 ;;
   245             *)
   246                 tif_lib=[`find_lib "libtiff.so.[0-9]"`]
   247                 if test x$tif_lib = x; then
   248                     tif_lib=[`find_lib "libtiff.so.[0-9]*"`]
   249                 fi
   250                 ;;
   251         esac
   252     else
   253         AC_MSG_WARN([*** Unable to find Tiff library (http://www.remotesensing.org/libtiff/)])
   254         AC_MSG_WARN([TIF image loading disabled])
   255     fi
   256 fi
   257 
   258 if test x$enable_webp = xyes; then
   259     PKG_CHECK_MODULES([LIBWEBP], [libwebp], [dnl
   260         have_webp_hdr=yes
   261         CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
   262         have_webp_lib=yes
   263       ], [dnl
   264         AC_CHECK_HEADER([webp/decode.h], [have_webp_hdr=yes])
   265         AC_CHECK_LIB([webp], [WebPGetDecoderVersion], [have_webp_lib=yes], [], [-lm])
   266       ])
   267     if test x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
   268         AC_DEFINE([LOAD_WEBP])
   269 
   270         case "$host" in
   271             *-*-darwin*)
   272                 webp_lib=[`find_lib libwebp.dylib`]
   273                 ;;
   274             *-*-cygwin* | *-*-mingw32*)
   275                 webp_lib=[`find_lib "libwebp*.dll"`]
   276                 ;;
   277             *)
   278                 webp_lib=[`find_lib "libwebp.so.[0-9]"`]
   279                 if test x$webp_lib = x; then
   280                     webp_lib=[`find_lib "libwebp.so.[0-9]*"`]
   281                 fi
   282                 if test x$webp_lib = x; then
   283                     webp_lib=[`find_lib "libwebp*.so.[0-9]"`]
   284                 fi
   285                 if test x$webp_lib = x; then
   286                     webp_lib=[`find_lib "libwebp*.so.[0-9]*"`]
   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
   294 fi
   295 
   296 if test x$enable_bmp = xyes; then
   297     AC_DEFINE([LOAD_BMP])
   298 fi
   299 
   300 if test x$enable_gif = xyes; then
   301     AC_DEFINE([LOAD_GIF])
   302 fi
   303 
   304 if test x$enable_lbm = xyes; then
   305     AC_DEFINE([LOAD_LBM])
   306 fi
   307 
   308 if test x$enable_pcx = xyes; then
   309     AC_DEFINE([LOAD_PCX])
   310 fi
   311 
   312 if test x$enable_pnm = xyes; then
   313     AC_DEFINE([LOAD_PNM])
   314 fi
   315 
   316 if test x$enable_tga = xyes; then
   317     AC_DEFINE([LOAD_TGA])
   318 fi
   319 
   320 if test x$enable_xcf = xyes; then
   321     AC_DEFINE([LOAD_XCF])
   322 fi
   323 
   324 if test x$enable_xpm = xyes; then
   325     AC_DEFINE([LOAD_XPM])
   326 fi
   327 
   328 if test x$enable_xv = xyes; then
   329     AC_DEFINE([LOAD_XV])
   330 fi
   331 
   332 if test x$enable_webp = xyes -a x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
   333     if test x$enable_webp_shared = xyes && test x$webp_lib != x; then
   334         echo "-- dynamic libwebp -> $webp_lib"
   335         AC_DEFINE_UNQUOTED(LOAD_WEBP_DYNAMIC, "$webp_lib")
   336     else
   337         IMG_LIBS="-lwebp $IMG_LIBS"
   338     fi
   339 fi
   340 
   341 if test x$enable_tif = xyes -a x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
   342     if test x$enable_tif_shared = xyes && test x$tif_lib != x; then
   343         echo "-- dynamic libtiff -> $tif_lib"
   344         AC_DEFINE_UNQUOTED(LOAD_TIF_DYNAMIC, "$tif_lib")
   345     else
   346         if test x$have_libjpeg = xyes; then
   347             # Disable dynamic jpeg since we're linking it explicitly
   348             jpg_lib=''
   349         fi
   350         IMG_LIBS="-ltiff -lz $IMG_LIBS"
   351     fi
   352 fi
   353 if test x$enable_jpg = xyes -a x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
   354     if test x$enable_jpg_shared = xyes && test x$jpg_lib != x; then
   355         echo "-- dynamic libjpeg -> $jpg_lib"
   356         AC_DEFINE_UNQUOTED(LOAD_JPG_DYNAMIC, "$jpg_lib")
   357     else
   358         IMG_LIBS="-ljpeg $IMG_LIBS"
   359     fi
   360 fi
   361 if test x$enable_png = xyes -a x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
   362     if test x$enable_png_shared = xyes && test x$png_lib != x; then
   363         echo "-- dynamic libpng -> $png_lib"
   364         AC_DEFINE_UNQUOTED(LOAD_PNG_DYNAMIC, "$png_lib")
   365     else
   366         IMG_LIBS="-lpng -lz $IMG_LIBS"
   367     fi
   368 fi
   369 
   370 LIBS="$saved_LIBS"
   371 
   372 AC_SUBST([WINDRES])
   373 AC_SUBST([IMG_LIBS])
   374 
   375 OBJCFLAGS=$CFLAGS
   376 
   377 # Finally create all the generated files
   378 AC_OUTPUT([
   379 Makefile
   380 SDL2_image.spec
   381 SDL2_image.pc
   382 ])