configure.in
author Sam Lantinga <slouken@libsdl.org>
Sat, 31 Dec 2011 09:41:39 -0500
changeset 280 ec4ae96c100c
parent 279 e2fa9ff13b5d
child 287 9cd057e88c99
permissions -rw-r--r--
Happy New Year!
     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=1
    15 MINOR_VERSION=2
    16 MICRO_VERSION=11
    17 INTERFACE_AGE=3
    18 BINARY_AGE=11
    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(SDL_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_VERSION_RC, test x$use_version_rc = xtrue)
    90 
    91 dnl set this to use on systems that use lib64 instead of lib
    92 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
    93 
    94 dnl Function to find a library in the compiler search path
    95 find_lib()
    96 {
    97     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
    98     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
    99     env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
   100     if test "$cross_compiling" = yes; then
   101         host_lib_path=""
   102     else
   103         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
   104     fi
   105     for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
   106         lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
   107         if test x$lib != x; then
   108             echo $lib
   109             return
   110         fi
   111     done
   112 }
   113 
   114 dnl Check for SDL
   115 SDL_VERSION=1.2.10
   116 AC_SUBST(SDL_VERSION)
   117 AM_PATH_SDL($SDL_VERSION,
   118             :,
   119            AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
   120 )
   121 CFLAGS="$CFLAGS $SDL_CFLAGS"
   122 LIBS="$LIBS $SDL_LIBS"
   123 saved_LIBS="$LIBS"
   124 
   125 dnl Check command-line options
   126 AC_ARG_ENABLE([bmp], [AC_HELP_STRING([--enable-bmp], [support loading BMP/ICO/CUR images [default=yes]])],
   127  [], [enable_bmp=yes])
   128 AC_ARG_ENABLE([gif], [AC_HELP_STRING([--enable-gif], [support loading GIF images [default=yes]])],
   129  [], [enable_gif=yes])
   130 AC_ARG_ENABLE([jpg], [AC_HELP_STRING([--enable-jpg], [support loading JPG images [default=yes]])],
   131  [], [enable_jpg=yes])
   132 AC_ARG_ENABLE([jpg-shared], AC_HELP_STRING([--enable-jpg-shared], [dynamically load JPG support [[default=yes]]]),
   133  [], [enable_jpg_shared=yes])
   134 AC_ARG_ENABLE([lbm], [AC_HELP_STRING([--enable-lbm], [support loading LBM images [default=yes]])],
   135  [], [enable_lbm=yes])
   136 AC_ARG_ENABLE([pcx], [AC_HELP_STRING([--enable-pcx], [support loading PCX images [default=yes]])],
   137  [], [enable_pcx=yes])
   138 AC_ARG_ENABLE([png], [AC_HELP_STRING([--enable-png], [support loading PNG images [default=yes]])],
   139  [], [enable_png=yes])
   140 AC_ARG_ENABLE([png-shared], AC_HELP_STRING([--enable-png-shared], [dynamically load PNG support [[default=yes]]]),
   141  [], [enable_png_shared=yes])
   142 AC_ARG_ENABLE([pnm], [AC_HELP_STRING([--enable-pnm], [support loading PNM images [default=yes]])],
   143  [], [enable_pnm=yes])
   144 AC_ARG_ENABLE([tga], [AC_HELP_STRING([--enable-tga], [support loading TGA images [default=yes]])],
   145  [], [enable_tga=yes])
   146 AC_ARG_ENABLE([tif], [AC_HELP_STRING([--enable-tif], [support loading TIFF images [default=yes]])],
   147  [], [enable_tif=yes])
   148 AC_ARG_ENABLE([tif-shared], AC_HELP_STRING([--enable-tif-shared], [dynamically load TIFF support [[default=yes]]]),
   149  [], [enable_tif_shared=yes])
   150 AC_ARG_ENABLE([xcf], [AC_HELP_STRING([--enable-xcf], [support loading XCF images [default=yes]])],
   151  [], [enable_xcf=yes])
   152 AC_ARG_ENABLE([xpm], [AC_HELP_STRING([--enable-xpm], [support loading XPM images [default=yes]])],
   153  [], [enable_xpm=yes])
   154 AC_ARG_ENABLE([xv], [AC_HELP_STRING([--enable-xv], [support loading XV images [default=yes]])],
   155  [], [enable_xv=yes])
   156 AC_ARG_ENABLE([webp], [AC_HELP_STRING([--enable-webp], [support loading WEBP images [default=yes]])],
   157  [], [enable_webp=yes])
   158 AC_ARG_ENABLE([webp-shared], AC_HELP_STRING([--enable-webp-shared], [dynamically load WEBP support [[default=yes]]]),
   159  [], [enable_webp_shared=yes])
   160 
   161 if test x$enable_jpg = xyes || test x$enable_tif = xyes; then
   162     AC_CHECK_HEADER([jpeglib.h], [have_jpg_hdr=yes])
   163     AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], [have_jpg_lib=yes])
   164     if test x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
   165         if test x$enable_jpg = xyes; then
   166             AC_DEFINE([LOAD_JPG])
   167         fi
   168         LIBS="-ljpeg $LIBS"
   169 
   170         case "$host" in
   171             *-*-darwin*)
   172                 jpg_lib=[`find_lib libjpeg.dylib`]
   173                 ;;
   174             *-*-cygwin* | *-*-mingw32*)
   175                 jpg_lib=[`find_lib "jpeg.dll"`]
   176                 ;;
   177             *)
   178                 jpg_lib=[`find_lib "libjpeg.so.[0-9]"`]
   179                 if test x$jpg_lib = x; then
   180                     jpg_lib=[`find_lib "libjpeg.so.[0-9][0-9]"`]
   181                 fi
   182                 if test x$jpg_lib = x; then
   183                     jpg_lib=[`find_lib "libjpeg.so.[0-9]*"`]
   184                 fi
   185                 ;;
   186         esac
   187     elif test x$enable_jpg = xyes; then
   188         AC_MSG_WARN([*** Unable to find JPEG library (http://www.ijg.org/)])
   189         AC_MSG_WARN([JPG image loading disabled])
   190     fi
   191 fi
   192 
   193 if test "x$enable_png" = xyes; then
   194     PKG_CHECK_MODULES([LIBPNG], [libpng], [dnl
   195         have_png_hdr=yes
   196         CFLAGS="$LIBPNG_CFLAGS $CFLAGS"
   197         have_png_lib=yes
   198       ], [dnl
   199         AC_CHECK_HEADER([png.h], [have_png_hdr=yes])
   200         AC_CHECK_LIB([png], [png_create_read_struct], [have_png_lib=yes], [], [-lz])
   201       ])
   202     if test x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
   203         AC_DEFINE([LOAD_PNG])
   204 
   205         case "$host" in
   206             *-*-darwin*)
   207                 png_lib=[`find_lib libpng.dylib`]
   208                 ;;
   209             *-*-cygwin* | *-*-mingw32*)
   210                 png_lib=[`find_lib "libpng*.dll"`]
   211                 ;;
   212             *)
   213                 png_lib=[`find_lib "libpng.so.[0-9]"`]
   214                 if test x$png_lib = x; then
   215                     png_lib=[`find_lib "libpng.so.[0-9]*"`]
   216                 fi
   217                 if test x$png_lib = x; then
   218                     png_lib=[`find_lib "libpng*.so.[0-9]"`]
   219                 fi
   220                 if test x$png_lib = x; then
   221                     png_lib=[`find_lib "libpng*.so.[0-9]*"`]
   222                 fi
   223                 ;;
   224         esac
   225     else
   226         AC_MSG_WARN([*** Unable to find PNG library (http://www.libpng.org/pub/png/libpng.html)])
   227         AC_MSG_WARN([PNG image loading disabled])
   228     fi
   229 fi
   230 
   231 if test x$enable_tif = xyes; then
   232     AC_CHECK_HEADER([tiffio.h], [have_tif_hdr=yes])
   233     AC_CHECK_LIB([tiff], [TIFFClientOpen], [have_tif_lib=yes], [], [-lz])
   234     if test x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
   235         AC_DEFINE([LOAD_TIF])
   236 
   237         case "$host" in
   238             *-*-darwin*)
   239                 tif_lib=[`find_lib libtiff.dylib`]
   240                 ;;
   241             *-*-cygwin* | *-*-mingw32*)
   242                 tif_lib=[`find_lib "libtiff-*.dll"`]
   243                 ;;
   244             *)
   245                 tif_lib=[`find_lib "libtiff.so.[0-9]"`]
   246                 if test x$tif_lib = x; then
   247                     tif_lib=[`find_lib "libtiff.so.[0-9]*"`]
   248                 fi
   249                 ;;
   250         esac
   251     else
   252         AC_MSG_WARN([*** Unable to find Tiff library (http://www.remotesensing.org/libtiff/)])
   253         AC_MSG_WARN([TIF image loading disabled])
   254     fi
   255 fi
   256 
   257 if test x$enable_webp = xyes; then
   258     PKG_CHECK_MODULES([LIBWEBP], [libwebp], [dnl
   259         have_webp_hdr=yes
   260         CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
   261         have_webp_lib=yes
   262       ], [dnl
   263         AC_CHECK_HEADER([webp/decode.h], [have_webp_hdr=yes])
   264         AC_CHECK_LIB([webp], [WebPGetDecoderVersion], [have_webp_lib=yes], [], [-lm])
   265       ])
   266     if test x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
   267         AC_DEFINE([LOAD_WEBP])
   268 
   269         case "$host" in
   270             *-*-darwin*)
   271                 webp_lib=[`find_lib libwebp.dylib`]
   272                 ;;
   273             *-*-cygwin* | *-*-mingw32*)
   274                 webp_lib=[`find_lib "libwebp*.dll"`]
   275                 ;;
   276             *)
   277                 webp_lib=[`find_lib "libwebp.so.[0-9]"`]
   278                 if test x$webp_lib = x; then
   279                     webp_lib=[`find_lib "libwebp.so.[0-9]*"`]
   280                 fi
   281                 if test x$webp_lib = x; then
   282                     webp_lib=[`find_lib "libwebp*.so.[0-9]"`]
   283                 fi
   284                 if test x$webp_lib = x; then
   285                     webp_lib=[`find_lib "libwebp*.so.[0-9]*"`]
   286                 fi
   287                 ;;
   288         esac
   289     else
   290         AC_MSG_WARN([*** Unable to find WEBP library (http://code.google.com/intl/en-US/speed/webp/index.html)])
   291         AC_MSG_WARN([WEBP Pimage loading disabled])
   292     fi
   293 fi
   294 
   295 if test x$enable_bmp = xyes; then
   296     AC_DEFINE([LOAD_BMP])
   297 fi
   298 
   299 if test x$enable_gif = xyes; then
   300     AC_DEFINE([LOAD_GIF])
   301 fi
   302 
   303 if test x$enable_lbm = xyes; then
   304     AC_DEFINE([LOAD_LBM])
   305 fi
   306 
   307 if test x$enable_pcx = xyes; then
   308     AC_DEFINE([LOAD_PCX])
   309 fi
   310 
   311 if test x$enable_pnm = xyes; then
   312     AC_DEFINE([LOAD_PNM])
   313 fi
   314 
   315 if test x$enable_tga = xyes; then
   316     AC_DEFINE([LOAD_TGA])
   317 fi
   318 
   319 if test x$enable_xcf = xyes; then
   320     AC_DEFINE([LOAD_XCF])
   321 fi
   322 
   323 if test x$enable_xpm = xyes; then
   324     AC_DEFINE([LOAD_XPM])
   325 fi
   326 
   327 if test x$enable_xv = xyes; then
   328     AC_DEFINE([LOAD_XV])
   329 fi
   330 
   331 if test x$enable_webp = xyes -a x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
   332     if test x$enable_webp_shared = xyes && test x$webp_lib != x; then
   333         echo "-- dynamic libwebp -> $webp_lib"
   334         AC_DEFINE_UNQUOTED(LOAD_WEBP_DYNAMIC, "$webp_lib")
   335     else
   336         IMG_LIBS="-lwebp $IMG_LIBS"
   337     fi
   338 fi
   339 
   340 if test x$enable_tif = xyes -a x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
   341     if test x$enable_tif_shared = xyes && test x$tif_lib != x; then
   342         echo "-- dynamic libtiff -> $tif_lib"
   343         AC_DEFINE_UNQUOTED(LOAD_TIF_DYNAMIC, "$tif_lib")
   344     else
   345         if test x$have_libjpeg = xyes; then
   346             # Disable dynamic jpeg since we're linking it explicitly
   347             jpg_lib=''
   348         fi
   349         IMG_LIBS="-ltiff -lz $IMG_LIBS"
   350     fi
   351 fi
   352 if test x$enable_jpg = xyes -a x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
   353     if test x$enable_jpg_shared = xyes && test x$jpg_lib != x; then
   354         echo "-- dynamic libjpeg -> $jpg_lib"
   355         AC_DEFINE_UNQUOTED(LOAD_JPG_DYNAMIC, "$jpg_lib")
   356     else
   357         IMG_LIBS="-ljpeg $IMG_LIBS"
   358     fi
   359 fi
   360 if test x$enable_png = xyes -a x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
   361     if test x$enable_png_shared = xyes && test x$png_lib != x; then
   362         echo "-- dynamic libpng -> $png_lib"
   363         AC_DEFINE_UNQUOTED(LOAD_PNG_DYNAMIC, "$png_lib")
   364     else
   365         IMG_LIBS="-lpng -lz $IMG_LIBS"
   366     fi
   367 fi
   368 
   369 LIBS="$saved_LIBS"
   370 
   371 AC_SUBST([WINDRES])
   372 AC_SUBST([IMG_LIBS])
   373 
   374 OBJCFLAGS=$CFLAGS
   375 
   376 # Finally create all the generated files
   377 AC_OUTPUT([
   378 Makefile
   379 SDL_image.spec
   380 SDL_image.pc
   381 ])