configure.in
author Sam Lantinga <slouken@libsdl.org>
Sat, 26 Sep 2009 08:42:09 +0000
changeset 203 b3d13895fd59
parent 197 9645d3416002
child 206 4dcd1d3c3636
permissions -rw-r--r--
Christian Walther 2008-01-13 07:59:42 PST

I'm trying to build a set of static SDL_* libraries in my Mingw
cross-compilation setup on Mac OS X. I have only static (no dynamic) versions
of libpng and libtiff installed and configure SDL_image using

cross-configure.sh --prefix=/usr/local/cross-tools/i386-mingw32
--disable-shared --disable-jpg-shared --disable-png-shared --disable-tif-shared

In this invocation, the checks for libpng and libtiff fail (even though the
libraries are there, and are found) because of missing symbols from zlib. I can
fix this using the attached patch. I assume this shouldn't interfere in the
case that dynamic png/tiff libraries are around, but I'm reluctant to try it,
and I'm not very familiar with autoconf in general. Perhaps someone who is can
advise if this is the right thing to do...
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@181
    16
MICRO_VERSION=7
slouken@181
    17
INTERFACE_AGE=6
slouken@181
    18
BINARY_AGE=7
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@0
    29
LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
slouken@0
    30
LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
slouken@0
    31
LT_REVISION=$INTERFACE_AGE
slouken@0
    32
LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
slouken@0
    33
slouken@0
    34
AC_SUBST(LT_RELEASE)
slouken@0
    35
AC_SUBST(LT_CURRENT)
slouken@0
    36
AC_SUBST(LT_REVISION)
slouken@0
    37
AC_SUBST(LT_AGE)
slouken@0
    38
slouken@122
    39
dnl Detect the canonical build and host environments
slouken@122
    40
AC_CANONICAL_HOST
slouken@2
    41
slouken@40
    42
dnl Setup for automake
slouken@40
    43
AM_INIT_AUTOMAKE(SDL_image, $VERSION)
slouken@40
    44
slouken@0
    45
dnl Check for tools
slouken@0
    46
slouken@2
    47
AC_LIBTOOL_WIN32_DLL
slouken@2
    48
AM_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@0
    78
esac
slouken@164
    79
AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue)
slouken@0
    80
slouken@0
    81
dnl Check for SDL
slouken@144
    82
SDL_VERSION=1.2.10
slouken@196
    83
AC_SUBST(SDL_VERSION)
slouken@0
    84
AM_PATH_SDL($SDL_VERSION,
slouken@0
    85
            :,
slouken@137
    86
           AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
slouken@0
    87
)
slouken@191
    88
CFLAGS="$CFLAGS -DSDL_IMAGE_USE_COMMON_BACKEND $SDL_CFLAGS"
slouken@75
    89
LIBS="$LIBS $SDL_LIBS"
slouken@137
    90
saved_LIBS="$LIBS"
slouken@0
    91
slouken@0
    92
dnl Check command-line options
couriersud@189
    93
AC_ARG_ENABLE([bmp], [AC_HELP_STRING([--enable-bmp], [support loading BMP/ICO/CUR images [default=yes]])],
slouken@137
    94
 [], [enable_bmp=yes])
slouken@137
    95
AC_ARG_ENABLE([gif], [AC_HELP_STRING([--enable-gif], [support loading GIF images [default=yes]])],
slouken@137
    96
 [], [enable_gif=yes])
slouken@137
    97
AC_ARG_ENABLE([jpg], [AC_HELP_STRING([--enable-jpg], [support loading JPG images [default=yes]])],
slouken@137
    98
 [], [enable_jpg=yes])
slouken@143
    99
AC_ARG_ENABLE([jpg-shared], AC_HELP_STRING([--enable-jpg-shared], [dynamically load JPG support [[default=yes]]]),
slouken@143
   100
 [], [enable_jpg_shared=yes])
slouken@137
   101
AC_ARG_ENABLE([lbm], [AC_HELP_STRING([--enable-lbm], [support loading LBM images [default=yes]])],
slouken@137
   102
 [], [enable_lbm=yes])
slouken@137
   103
AC_ARG_ENABLE([pcx], [AC_HELP_STRING([--enable-pcx], [support loading PCX images [default=yes]])],
slouken@137
   104
 [], [enable_pcx=yes])
slouken@143
   105
AC_ARG_ENABLE([png], [AC_HELP_STRING([--enable-png], [support loading PNG images [default=yes]])],
slouken@137
   106
 [], [enable_png=yes])
slouken@143
   107
AC_ARG_ENABLE([png-shared], AC_HELP_STRING([--enable-png-shared], [dynamically load PNG support [[default=yes]]]),
slouken@143
   108
 [], [enable_png_shared=yes])
slouken@137
   109
AC_ARG_ENABLE([pnm], [AC_HELP_STRING([--enable-pnm], [support loading PNM images [default=yes]])],
slouken@137
   110
 [], [enable_pnm=yes])
slouken@137
   111
AC_ARG_ENABLE([tga], [AC_HELP_STRING([--enable-tga], [support loading TGA images [default=yes]])],
slouken@137
   112
 [], [enable_tga=yes])
slouken@143
   113
AC_ARG_ENABLE([tif], [AC_HELP_STRING([--enable-tif], [support loading TIFF images [default=yes]])],
slouken@143
   114
 [], [enable_tif=yes])
slouken@143
   115
AC_ARG_ENABLE([tif-shared], AC_HELP_STRING([--enable-tif-shared], [dynamically load TIFF support [[default=yes]]]),
slouken@143
   116
 [], [enable_tif_shared=yes])
slouken@137
   117
AC_ARG_ENABLE([xcf], [AC_HELP_STRING([--enable-xcf], [support loading XCF images [default=yes]])],
slouken@137
   118
 [], [enable_xcf=yes])
slouken@137
   119
AC_ARG_ENABLE([xpm], [AC_HELP_STRING([--enable-xpm], [support loading XPM images [default=yes]])],
slouken@137
   120
 [], [enable_xpm=yes])
slouken@137
   121
AC_ARG_ENABLE([xv], [AC_HELP_STRING([--enable-xv], [support loading XV images [default=yes]])],
slouken@137
   122
 [], [enable_xv=yes])
slouken@137
   123
slouken@168
   124
find_lib()
slouken@168
   125
{
slouken@173
   126
    gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
slouken@173
   127
    gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
slouken@168
   128
    env_lib_path=[`echo $LIBS $LDFLAGS | sed 's/-L[ ]*//g'`]
slouken@173
   129
    for path in $gcc_bin_path $gcc_lib_path $env_lib_path /usr/lib /usr/local/lib; do
slouken@168
   130
        lib=[`ls -- $path/$1 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
slouken@168
   131
        if test x$lib != x; then
slouken@168
   132
            echo $lib
slouken@168
   133
            return
slouken@168
   134
        fi
slouken@168
   135
    done
slouken@168
   136
}
slouken@168
   137
slouken@143
   138
if test x$enable_jpg = xyes || test x$enable_tif = xyes; then
slouken@168
   139
    AC_CHECK_HEADER([jpeglib.h], [have_jpg_hdr=yes])
slouken@168
   140
    AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], [have_jpg_lib=yes])
slouken@168
   141
    if test x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
slouken@137
   142
        if test x$enable_jpg = xyes; then
slouken@168
   143
            AC_DEFINE([LOAD_JPG])
slouken@137
   144
        fi
slouken@137
   145
        LIBS="-ljpeg $LIBS"
slouken@143
   146
slouken@143
   147
        case "$host" in
slouken@168
   148
            *-*-darwin*)
slouken@169
   149
                jpg_lib=[`find_lib libjpeg*.dylib`]
slouken@143
   150
                ;;
slouken@143
   151
            *-*-cygwin* | *-*-mingw32*)
slouken@173
   152
                jpg_lib=[`find_lib "jpeg.dll"`]
slouken@143
   153
                ;;
slouken@143
   154
            *)
slouken@170
   155
                jpg_lib=[`find_lib "libjpeg.so.[0-9]"`]
slouken@170
   156
                if test x$jpg_lib = x; then
slouken@177
   157
                    jpg_lib=[`find_lib "libjpeg.so.[0-9][0-9]"`]
slouken@177
   158
                fi
slouken@177
   159
                if test x$jpg_lib = x; then
slouken@170
   160
                    jpg_lib=[`find_lib "libjpeg.so.[0-9]*"`]
slouken@170
   161
                fi
slouken@143
   162
                ;;
slouken@143
   163
        esac
slouken@137
   164
    elif test x$enable_jpg = xyes; then
slouken@137
   165
        AC_MSG_WARN([*** Unable to find JPEG library (http://www.ijg.org/)])
slouken@0
   166
        AC_MSG_WARN([JPG image loading disabled])
slouken@0
   167
    fi
slouken@0
   168
fi
slouken@137
   169
slouken@0
   170
if test x$enable_png = xyes; then
slouken@168
   171
    AC_CHECK_HEADER([png.h], [have_png_hdr=yes])
slouken@203
   172
    AC_CHECK_LIB([png], [png_create_read_struct], [have_png_lib=yes], [], [-lz])
slouken@168
   173
    if test x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
slouken@137
   174
        AC_DEFINE([LOAD_PNG])
slouken@143
   175
slouken@143
   176
        case "$host" in
slouken@168
   177
            *-*-darwin*)
slouken@169
   178
                png_lib=[`find_lib libpng*.dylib`]
slouken@143
   179
                ;;
slouken@143
   180
            *-*-cygwin* | *-*-mingw32*)
slouken@173
   181
                png_lib=[`find_lib "libpng*.dll"`]
slouken@143
   182
                ;;
slouken@143
   183
            *)
slouken@170
   184
                png_lib=[`find_lib "libpng.so.[0-9]"`]
slouken@170
   185
                if test x$png_lib = x; then
slouken@170
   186
                    png_lib=[`find_lib "libpng.so.[0-9]*"`]
slouken@170
   187
                fi
slouken@143
   188
                ;;
slouken@143
   189
        esac
slouken@0
   190
    else
slouken@137
   191
        AC_MSG_WARN([*** Unable to find PNG library (http://www.libpng.org/pub/png/libpng.html)])
slouken@0
   192
        AC_MSG_WARN([PNG image loading disabled])
slouken@0
   193
    fi
slouken@0
   194
fi
slouken@137
   195
slouken@0
   196
if test x$enable_tif = xyes; then
slouken@168
   197
    AC_CHECK_HEADER([tiffio.h], [have_tif_hdr=yes])
slouken@203
   198
    AC_CHECK_LIB([tiff], [TIFFClientOpen], [have_tif_lib=yes], [], [-lz])
slouken@168
   199
    if test x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
slouken@137
   200
        AC_DEFINE([LOAD_TIF])
slouken@143
   201
slouken@143
   202
        case "$host" in
slouken@168
   203
            *-*-darwin*)
slouken@169
   204
                tif_lib=[`find_lib libtiff*.dylib`]
slouken@143
   205
                ;;
slouken@143
   206
            *-*-cygwin* | *-*-mingw32*)
slouken@173
   207
                tif_lib=[`find_lib "libtiff-*.dll"`]
slouken@143
   208
                ;;
slouken@143
   209
            *)
slouken@170
   210
                tif_lib=[`find_lib "libtiff.so.[0-9]"`]
slouken@170
   211
                if test x$tif_lib = x; then
slouken@170
   212
                    tif_lib=[`find_lib "libtiff.so.[0-9]*"`]
slouken@170
   213
                fi
slouken@143
   214
                ;;
slouken@143
   215
        esac
slouken@0
   216
    else
slouken@143
   217
        AC_MSG_WARN([*** Unable to find Tiff library (http://www.remotesensing.org/libtiff/)])
slouken@0
   218
        AC_MSG_WARN([TIF image loading disabled])
slouken@0
   219
    fi
slouken@0
   220
fi
slouken@137
   221
slouken@137
   222
if test x$enable_bmp = xyes; then
slouken@137
   223
    AC_DEFINE([LOAD_BMP])
slouken@137
   224
fi
slouken@137
   225
slouken@137
   226
if test x$enable_gif = xyes; then
slouken@137
   227
    AC_DEFINE([LOAD_GIF])
slouken@137
   228
fi
slouken@137
   229
slouken@137
   230
if test x$enable_lbm = xyes; then
slouken@137
   231
    AC_DEFINE([LOAD_LBM])
slouken@137
   232
fi
slouken@137
   233
slouken@137
   234
if test x$enable_pcx = xyes; then
slouken@137
   235
    AC_DEFINE([LOAD_PCX])
slouken@137
   236
fi
slouken@137
   237
slouken@137
   238
if test x$enable_pnm = xyes; then
slouken@137
   239
    AC_DEFINE([LOAD_PNM])
slouken@137
   240
fi
slouken@137
   241
slouken@137
   242
if test x$enable_tga = xyes; then
slouken@137
   243
    AC_DEFINE([LOAD_TGA])
slouken@137
   244
fi
slouken@137
   245
slouken@26
   246
if test x$enable_xcf = xyes; then
slouken@137
   247
    AC_DEFINE([LOAD_XCF])
slouken@26
   248
fi
slouken@137
   249
slouken@7
   250
if test x$enable_xpm = xyes; then
slouken@137
   251
    AC_DEFINE([LOAD_XPM])
slouken@7
   252
fi
slouken@137
   253
slouken@119
   254
if test x$enable_xv = xyes; then
slouken@137
   255
    AC_DEFINE([LOAD_XV])
slouken@119
   256
fi
slouken@137
   257
slouken@168
   258
if test x$enable_tif = xyes -a x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
slouken@143
   259
    if test x$enable_tif_shared = xyes && test x$tif_lib != x; then
slouken@143
   260
        echo "-- dynamic libtiff -> $tif_lib"
slouken@143
   261
        AC_DEFINE_UNQUOTED(LOAD_TIF_DYNAMIC, "$tif_lib")
slouken@143
   262
    else
slouken@143
   263
        if test x$have_libjpeg = xyes; then
slouken@143
   264
            # Disable dynamic jpeg since we're linking it explicitly
slouken@143
   265
            jpg_lib=''
slouken@143
   266
        fi
slouken@156
   267
        IMG_LIBS="-ltiff -lz $IMG_LIBS"
slouken@143
   268
    fi
slouken@143
   269
fi
slouken@168
   270
if test x$enable_jpg = xyes -a x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
slouken@143
   271
    if test x$enable_jpg_shared = xyes && test x$jpg_lib != x; then
slouken@143
   272
        echo "-- dynamic libjpeg -> $jpg_lib"
slouken@143
   273
        AC_DEFINE_UNQUOTED(LOAD_JPG_DYNAMIC, "$jpg_lib")
slouken@143
   274
    else
slouken@143
   275
        IMG_LIBS="-ljpeg $IMG_LIBS"
slouken@143
   276
    fi
slouken@143
   277
fi
slouken@168
   278
if test x$enable_png = xyes -a x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
slouken@143
   279
    if test x$enable_png_shared = xyes && test x$png_lib != x; then
slouken@143
   280
        echo "-- dynamic libpng -> $png_lib"
slouken@143
   281
        AC_DEFINE_UNQUOTED(LOAD_PNG_DYNAMIC, "$png_lib")
slouken@143
   282
    else
slouken@143
   283
        IMG_LIBS="-lpng -lz $IMG_LIBS"
slouken@143
   284
    fi
slouken@143
   285
fi
slouken@143
   286
slouken@137
   287
LIBS="$saved_LIBS"
slouken@137
   288
slouken@168
   289
AC_SUBST([WINDRES])
slouken@168
   290
AC_SUBST([IMG_LIBS])
slouken@0
   291
slouken@0
   292
# Finally create all the generated files
slouken@0
   293
AC_OUTPUT([
slouken@0
   294
Makefile
slouken@0
   295
SDL_image.spec
slouken@197
   296
SDL_image.pc
slouken@0
   297
])