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