acinclude.m4
author Stephane Peter
Sat, 30 Oct 1999 22:57:49 +0000
changeset 11 3939a99bf422
parent 6 cb0e8db1f996
child 25 570c888ed4ce
permissions -rw-r--r--
Various bugfixes for music looping
slouken@0
     1
# Configure paths for SDL
slouken@0
     2
# Sam Lantinga 9/21/99
slouken@0
     3
# stolen from Manish Singh
slouken@0
     4
# stolen back from Frank Belew
slouken@0
     5
# stolen from Manish Singh
slouken@0
     6
# Shamelessly stolen from Owen Taylor
slouken@0
     7
slouken@0
     8
dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
slouken@0
     9
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
slouken@0
    10
dnl
slouken@0
    11
AC_DEFUN(AM_PATH_SDL,
slouken@0
    12
[dnl 
slouken@0
    13
dnl Get the cflags and libraries from the sdl-config script
slouken@0
    14
dnl
slouken@0
    15
AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
slouken@0
    16
            sdl_prefix="$withval", sdl_prefix="")
slouken@0
    17
AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
slouken@0
    18
            sdl_exec_prefix="$withval", sdl_exec_prefix="")
slouken@0
    19
AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
slouken@0
    20
		    , enable_sdltest=yes)
slouken@0
    21
slouken@0
    22
  if test x$sdl_exec_prefix != x ; then
slouken@0
    23
     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
slouken@0
    24
     if test x${SDL_CONFIG+set} != xset ; then
slouken@0
    25
        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
slouken@0
    26
     fi
slouken@0
    27
  fi
slouken@0
    28
  if test x$sdl_prefix != x ; then
slouken@0
    29
     sdl_args="$sdl_args --prefix=$sdl_prefix"
slouken@0
    30
     if test x${SDL_CONFIG+set} != xset ; then
slouken@0
    31
        SDL_CONFIG=$sdl_prefix/bin/sdl-config
slouken@0
    32
     fi
slouken@0
    33
  fi
slouken@0
    34
slouken@0
    35
  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
slouken@0
    36
  min_sdl_version=ifelse([$1], ,0.11.0,$1)
slouken@0
    37
  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
slouken@0
    38
  no_sdl=""
slouken@0
    39
  if test "$SDL_CONFIG" = "no" ; then
slouken@0
    40
    no_sdl=yes
slouken@0
    41
  else
slouken@0
    42
    SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
slouken@0
    43
    SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
slouken@0
    44
slouken@0
    45
    sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
slouken@0
    46
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
slouken@0
    47
    sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
slouken@0
    48
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
slouken@0
    49
    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
slouken@0
    50
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
slouken@0
    51
    if test "x$enable_sdltest" = "xyes" ; then
slouken@0
    52
      ac_save_CFLAGS="$CFLAGS"
slouken@0
    53
      ac_save_LIBS="$LIBS"
slouken@0
    54
      CFLAGS="$CFLAGS $SDL_CFLAGS"
slouken@0
    55
      LIBS="$LIBS $SDL_LIBS"
slouken@0
    56
dnl
slouken@0
    57
dnl Now check if the installed SDL is sufficiently new. (Also sanity
slouken@0
    58
dnl checks the results of sdl-config to some extent
slouken@0
    59
dnl
slouken@0
    60
      rm -f conf.sdltest
slouken@0
    61
      AC_TRY_RUN([
slouken@0
    62
#include <stdio.h>
slouken@0
    63
#include <stdlib.h>
slouken@0
    64
#include <string.h>
slouken@0
    65
#include <SDL/SDL.h>
slouken@0
    66
slouken@0
    67
char*
slouken@0
    68
my_strdup (char *str)
slouken@0
    69
{
slouken@0
    70
  char *new_str;
slouken@0
    71
  
slouken@0
    72
  if (str)
slouken@0
    73
    {
slouken@0
    74
      new_str = malloc ((strlen (str) + 1) * sizeof(char));
slouken@0
    75
      strcpy (new_str, str);
slouken@0
    76
    }
slouken@0
    77
  else
slouken@0
    78
    new_str = NULL;
slouken@0
    79
  
slouken@0
    80
  return new_str;
slouken@0
    81
}
slouken@0
    82
slouken@0
    83
int main ()
slouken@0
    84
{
slouken@0
    85
  int major, minor, micro;
slouken@0
    86
  char *tmp_version;
slouken@0
    87
slouken@0
    88
  system ("touch conf.sdltest");
slouken@0
    89
slouken@0
    90
  /* HP/UX 9 (%@#!) writes to sscanf strings */
slouken@0
    91
  tmp_version = my_strdup("$min_sdl_version");
slouken@0
    92
  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
slouken@0
    93
     printf("%s, bad version string\n", "$min_sdl_version");
slouken@0
    94
     exit(1);
slouken@0
    95
   }
slouken@0
    96
slouken@0
    97
   if (($sdl_major_version > major) ||
slouken@0
    98
      (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
slouken@0
    99
      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
slouken@0
   100
    {
slouken@0
   101
      return 0;
slouken@0
   102
    }
slouken@0
   103
  else
slouken@0
   104
    {
slouken@0
   105
      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
slouken@0
   106
      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
slouken@0
   107
      printf("*** best to upgrade to the required version.\n");
slouken@0
   108
      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
slouken@0
   109
      printf("*** to point to the correct copy of sdl-config, and remove the file\n");
slouken@0
   110
      printf("*** config.cache before re-running configure\n");
slouken@0
   111
      return 1;
slouken@0
   112
    }
slouken@0
   113
}
slouken@0
   114
slouken@0
   115
],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
slouken@0
   116
       CFLAGS="$ac_save_CFLAGS"
slouken@0
   117
       LIBS="$ac_save_LIBS"
slouken@0
   118
     fi
slouken@0
   119
  fi
slouken@0
   120
  if test "x$no_sdl" = x ; then
slouken@0
   121
     AC_MSG_RESULT(yes)
slouken@0
   122
     ifelse([$2], , :, [$2])     
slouken@0
   123
  else
slouken@0
   124
     AC_MSG_RESULT(no)
slouken@0
   125
     if test "$SDL_CONFIG" = "no" ; then
slouken@0
   126
       echo "*** The sdl-config script installed by SDL could not be found"
slouken@0
   127
       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
slouken@0
   128
       echo "*** your path, or set the SDL_CONFIG environment variable to the"
slouken@0
   129
       echo "*** full path to sdl-config."
slouken@0
   130
     else
slouken@0
   131
       if test -f conf.sdltest ; then
slouken@0
   132
        :
slouken@0
   133
       else
slouken@0
   134
          echo "*** Could not run SDL test program, checking why..."
slouken@0
   135
          CFLAGS="$CFLAGS $SDL_CFLAGS"
slouken@0
   136
          LIBS="$LIBS $SDL_LIBS"
slouken@0
   137
          AC_TRY_LINK([
slouken@0
   138
#include <stdio.h>
slouken@0
   139
#include <SDL/SDL.h>
slouken@0
   140
],      [ return 0; ],
slouken@0
   141
        [ echo "*** The test program compiled, but did not run. This usually means"
slouken@0
   142
          echo "*** that the run-time linker is not finding SDL or finding the wrong"
slouken@0
   143
          echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
slouken@0
   144
          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
slouken@0
   145
          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
slouken@0
   146
          echo "*** is required on your system"
slouken@0
   147
	  echo "***"
slouken@0
   148
          echo "*** If you have an old version installed, it is best to remove it, although"
slouken@0
   149
          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
slouken@0
   150
        [ echo "*** The test program failed to compile or link. See the file config.log for the"
slouken@0
   151
          echo "*** exact error that occured. This usually means SDL was incorrectly installed"
slouken@0
   152
          echo "*** or that you have moved SDL since it was installed. In the latter case, you"
slouken@0
   153
          echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
slouken@0
   154
          CFLAGS="$ac_save_CFLAGS"
slouken@0
   155
          LIBS="$ac_save_LIBS"
slouken@0
   156
       fi
slouken@0
   157
     fi
slouken@0
   158
     SDL_CFLAGS=""
slouken@0
   159
     SDL_LIBS=""
slouken@0
   160
     ifelse([$3], , :, [$3])
slouken@0
   161
  fi
slouken@0
   162
  AC_SUBST(SDL_CFLAGS)
slouken@0
   163
  AC_SUBST(SDL_LIBS)
slouken@0
   164
  rm -f conf.sdltest
slouken@0
   165
])
slouken@6
   166
## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
slouken@6
   167
## Copyright (C) 1996-1999 Free Software Foundation, Inc.
slouken@6
   168
## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
slouken@6
   169
##
slouken@6
   170
## This program is free software; you can redistribute it and/or modify
slouken@6
   171
## it under the terms of the GNU General Public License as published by
slouken@6
   172
## the Free Software Foundation; either version 2 of the License, or
slouken@6
   173
## (at your option) any later version.
slouken@6
   174
##
slouken@6
   175
## This program is distributed in the hope that it will be useful, but
slouken@6
   176
## WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@6
   177
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@6
   178
## General Public License for more details.
slouken@6
   179
##
slouken@6
   180
## You should have received a copy of the GNU General Public License
slouken@6
   181
## along with this program; if not, write to the Free Software
slouken@6
   182
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
slouken@6
   183
##
slouken@6
   184
## As a special exception to the GNU General Public License, if you
slouken@6
   185
## distribute this file as part of a program that contains a
slouken@6
   186
## configuration script generated by Autoconf, you may include it under
slouken@6
   187
## the same distribution terms that you use for the rest of that program.
slouken@6
   188
slouken@6
   189
# serial 41 AC_PROG_LIBTOOL
slouken@6
   190
AC_DEFUN(AC_PROG_LIBTOOL,
slouken@6
   191
[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
slouken@6
   192
slouken@6
   193
# Save cache, so that ltconfig can load it
slouken@6
   194
AC_CACHE_SAVE
slouken@6
   195
slouken@6
   196
# Actually configure libtool.  ac_aux_dir is where install-sh is found.
slouken@6
   197
CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
slouken@6
   198
LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
slouken@6
   199
LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
slouken@6
   200
DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
slouken@6
   201
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
slouken@6
   202
$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \
slouken@6
   203
|| AC_MSG_ERROR([libtool configure failed])
slouken@6
   204
slouken@6
   205
# Reload cache, that may have been modified by ltconfig
slouken@6
   206
AC_CACHE_LOAD
slouken@6
   207
slouken@6
   208
# This can be used to rebuild libtool when needed
slouken@6
   209
LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
slouken@6
   210
slouken@6
   211
# Always use our own libtool.
slouken@6
   212
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
slouken@6
   213
AC_SUBST(LIBTOOL)dnl
slouken@6
   214
slouken@6
   215
# Redirect the config.log output again, so that the ltconfig log is not
slouken@6
   216
# clobbered by the next message.
slouken@6
   217
exec 5>>./config.log
slouken@6
   218
])
slouken@6
   219
slouken@6
   220
AC_DEFUN(AC_LIBTOOL_SETUP,
slouken@6
   221
[AC_PREREQ(2.13)dnl
slouken@6
   222
AC_REQUIRE([AC_ENABLE_SHARED])dnl
slouken@6
   223
AC_REQUIRE([AC_ENABLE_STATIC])dnl
slouken@6
   224
AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
slouken@6
   225
AC_REQUIRE([AC_CANONICAL_HOST])dnl
slouken@6
   226
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
slouken@6
   227
AC_REQUIRE([AC_PROG_CC])dnl
slouken@6
   228
AC_REQUIRE([AC_PROG_LD])dnl
slouken@6
   229
AC_REQUIRE([AC_PROG_NM])dnl
slouken@6
   230
AC_REQUIRE([AC_PROG_LN_S])dnl
slouken@6
   231
dnl
slouken@6
   232
slouken@6
   233
AC_CHECK_TOOL(RANLIB, ranlib, :)
slouken@6
   234
slouken@6
   235
# Check for any special flags to pass to ltconfig.
slouken@6
   236
libtool_flags="--cache-file=$cache_file"
slouken@6
   237
test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
slouken@6
   238
test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
slouken@6
   239
test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
slouken@6
   240
test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
slouken@6
   241
test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
slouken@6
   242
ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
slouken@6
   243
[libtool_flags="$libtool_flags --enable-dlopen"])
slouken@6
   244
ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
slouken@6
   245
[libtool_flags="$libtool_flags --enable-win32-dll"])
slouken@6
   246
AC_ARG_ENABLE(libtool-lock,
slouken@6
   247
  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
slouken@6
   248
test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
slouken@6
   249
test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
slouken@6
   250
slouken@6
   251
AC_ARG_WITH(pic,
slouken@6
   252
  [  --with-pic              try to use only PIC/non-PIC objects [default=use both]],
slouken@6
   253
     pic_mode="$withval", pic_mode=default)
slouken@6
   254
test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic"
slouken@6
   255
test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
slouken@6
   256
slouken@6
   257
# Some flags need to be propagated to the compiler or linker for good
slouken@6
   258
# libtool support.
slouken@6
   259
case "$host" in
slouken@6
   260
*-*-irix6*)
slouken@6
   261
  # Find out which ABI we are using.
slouken@6
   262
  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
slouken@6
   263
  if AC_TRY_EVAL(ac_compile); then
slouken@6
   264
    case "`/usr/bin/file conftest.o`" in
slouken@6
   265
    *32-bit*)
slouken@6
   266
      LD="${LD-ld} -32"
slouken@6
   267
      ;;
slouken@6
   268
    *N32*)
slouken@6
   269
      LD="${LD-ld} -n32"
slouken@6
   270
      ;;
slouken@6
   271
    *64-bit*)
slouken@6
   272
      LD="${LD-ld} -64"
slouken@6
   273
      ;;
slouken@6
   274
    esac
slouken@6
   275
  fi
slouken@6
   276
  rm -rf conftest*
slouken@6
   277
  ;;
slouken@6
   278
slouken@6
   279
*-*-sco3.2v5*)
slouken@6
   280
  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
slouken@6
   281
  SAVE_CFLAGS="$CFLAGS"
slouken@6
   282
  CFLAGS="$CFLAGS -belf"
slouken@6
   283
  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
slouken@6
   284
    [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
slouken@6
   285
  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
slouken@6
   286
    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
slouken@6
   287
    CFLAGS="$SAVE_CFLAGS"
slouken@6
   288
  fi
slouken@6
   289
  ;;
slouken@6
   290
slouken@6
   291
ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
slouken@6
   292
[*-*-cygwin* | *-*-mingw*)
slouken@6
   293
  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
slouken@6
   294
  AC_CHECK_TOOL(AS, as, false)
slouken@6
   295
  AC_CHECK_TOOL(OBJDUMP, objdump, false)
slouken@6
   296
slouken@6
   297
  # recent cygwin and mingw systems supply a stub DllMain which the user
slouken@6
   298
  # can override, but on older systems we have to supply one
slouken@6
   299
  AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain,
slouken@6
   300
    [AC_TRY_LINK([DllMain (0, 0, 0);],
slouken@6
   301
      [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);],
slouken@6
   302
      [lt_cv_need_dllmain=yes],[lt_cv_need_dllmain=no])])
slouken@6
   303
slouken@6
   304
  case $host in
slouken@6
   305
  *-*-cygwin*)
slouken@6
   306
    # cygwin systems need to pass --dll to the linker, and not link
slouken@6
   307
    # crt.o which will require a WinMain@16 definition.
slouken@6
   308
    lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;;
slouken@6
   309
  *-*-mingw*)
slouken@6
   310
    # old mingw systems require "-dll" to link a DLL, while more recent ones
slouken@6
   311
    # require "-mdll"
slouken@6
   312
    SAVE_CFLAGS="$CFLAGS"
slouken@6
   313
    CFLAGS="$CFLAGS -mdll"
slouken@6
   314
    AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch,
slouken@6
   315
      [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])])
slouken@6
   316
    CFLAGS="$SAVE_CFLAGS" ;;
slouken@6
   317
  esac
slouken@6
   318
  ;;
slouken@6
   319
  ])
slouken@6
   320
esac
slouken@6
   321
])
slouken@6
   322
slouken@6
   323
# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
slouken@6
   324
AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
slouken@6
   325
slouken@6
   326
# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
slouken@6
   327
AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
slouken@6
   328
slouken@6
   329
# AC_ENABLE_SHARED - implement the --enable-shared flag
slouken@6
   330
# Usage: AC_ENABLE_SHARED[(DEFAULT)]
slouken@6
   331
#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
slouken@6
   332
#   `yes'.
slouken@6
   333
AC_DEFUN(AC_ENABLE_SHARED, [dnl
slouken@6
   334
define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
slouken@6
   335
AC_ARG_ENABLE(shared,
slouken@6
   336
changequote(<<, >>)dnl
slouken@6
   337
<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
slouken@6
   338
changequote([, ])dnl
slouken@6
   339
[p=${PACKAGE-default}
slouken@6
   340
case "$enableval" in
slouken@6
   341
yes) enable_shared=yes ;;
slouken@6
   342
no) enable_shared=no ;;
slouken@6
   343
*)
slouken@6
   344
  enable_shared=no
slouken@6
   345
  # Look at the argument we got.  We use all the common list separators.
slouken@6
   346
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
slouken@6
   347
  for pkg in $enableval; do
slouken@6
   348
    if test "X$pkg" = "X$p"; then
slouken@6
   349
      enable_shared=yes
slouken@6
   350
    fi
slouken@6
   351
  done
slouken@6
   352
  IFS="$ac_save_ifs"
slouken@6
   353
  ;;
slouken@6
   354
esac],
slouken@6
   355
enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
slouken@6
   356
])
slouken@6
   357
slouken@6
   358
# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
slouken@6
   359
AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
slouken@6
   360
AC_ENABLE_SHARED(no)])
slouken@6
   361
slouken@6
   362
# AC_ENABLE_STATIC - implement the --enable-static flag
slouken@6
   363
# Usage: AC_ENABLE_STATIC[(DEFAULT)]
slouken@6
   364
#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
slouken@6
   365
#   `yes'.
slouken@6
   366
AC_DEFUN(AC_ENABLE_STATIC, [dnl
slouken@6
   367
define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
slouken@6
   368
AC_ARG_ENABLE(static,
slouken@6
   369
changequote(<<, >>)dnl
slouken@6
   370
<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
slouken@6
   371
changequote([, ])dnl
slouken@6
   372
[p=${PACKAGE-default}
slouken@6
   373
case "$enableval" in
slouken@6
   374
yes) enable_static=yes ;;
slouken@6
   375
no) enable_static=no ;;
slouken@6
   376
*)
slouken@6
   377
  enable_static=no
slouken@6
   378
  # Look at the argument we got.  We use all the common list separators.
slouken@6
   379
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
slouken@6
   380
  for pkg in $enableval; do
slouken@6
   381
    if test "X$pkg" = "X$p"; then
slouken@6
   382
      enable_static=yes
slouken@6
   383
    fi
slouken@6
   384
  done
slouken@6
   385
  IFS="$ac_save_ifs"
slouken@6
   386
  ;;
slouken@6
   387
esac],
slouken@6
   388
enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
slouken@6
   389
])
slouken@6
   390
slouken@6
   391
# AC_DISABLE_STATIC - set the default static flag to --disable-static
slouken@6
   392
AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
slouken@6
   393
AC_ENABLE_STATIC(no)])
slouken@6
   394
slouken@6
   395
slouken@6
   396
# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
slouken@6
   397
# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
slouken@6
   398
#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
slouken@6
   399
#   `yes'.
slouken@6
   400
AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
slouken@6
   401
define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
slouken@6
   402
AC_ARG_ENABLE(fast-install,
slouken@6
   403
changequote(<<, >>)dnl
slouken@6
   404
<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
slouken@6
   405
changequote([, ])dnl
slouken@6
   406
[p=${PACKAGE-default}
slouken@6
   407
case "$enableval" in
slouken@6
   408
yes) enable_fast_install=yes ;;
slouken@6
   409
no) enable_fast_install=no ;;
slouken@6
   410
*)
slouken@6
   411
  enable_fast_install=no
slouken@6
   412
  # Look at the argument we got.  We use all the common list separators.
slouken@6
   413
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
slouken@6
   414
  for pkg in $enableval; do
slouken@6
   415
    if test "X$pkg" = "X$p"; then
slouken@6
   416
      enable_fast_install=yes
slouken@6
   417
    fi
slouken@6
   418
  done
slouken@6
   419
  IFS="$ac_save_ifs"
slouken@6
   420
  ;;
slouken@6
   421
esac],
slouken@6
   422
enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
slouken@6
   423
])
slouken@6
   424
slouken@6
   425
# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
slouken@6
   426
AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
slouken@6
   427
AC_ENABLE_FAST_INSTALL(no)])
slouken@6
   428
slouken@6
   429
# AC_PROG_LD - find the path to the GNU or non-GNU linker
slouken@6
   430
AC_DEFUN(AC_PROG_LD,
slouken@6
   431
[AC_ARG_WITH(gnu-ld,
slouken@6
   432
[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
slouken@6
   433
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
slouken@6
   434
AC_REQUIRE([AC_PROG_CC])dnl
slouken@6
   435
AC_REQUIRE([AC_CANONICAL_HOST])dnl
slouken@6
   436
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
slouken@6
   437
ac_prog=ld
slouken@6
   438
if test "$ac_cv_prog_gcc" = yes; then
slouken@6
   439
  # Check if gcc -print-prog-name=ld gives a path.
slouken@6
   440
  AC_MSG_CHECKING([for ld used by GCC])
slouken@6
   441
  case $host in
slouken@6
   442
  *-*-mingw*)
slouken@6
   443
    # gcc leaves a trailing carriage return which upsets mingw
slouken@6
   444
    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
slouken@6
   445
  *)
slouken@6
   446
    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
slouken@6
   447
  esac
slouken@6
   448
  case "$ac_prog" in
slouken@6
   449
    # Accept absolute paths.
slouken@6
   450
changequote(,)dnl
slouken@6
   451
    [\\/]* | [A-Za-z]:[\\/]*)
slouken@6
   452
      re_direlt='/[^/][^/]*/\.\./'
slouken@6
   453
changequote([,])dnl
slouken@6
   454
      # Canonicalize the path of ld
slouken@6
   455
      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
slouken@6
   456
      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
slouken@6
   457
	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
slouken@6
   458
      done
slouken@6
   459
      test -z "$LD" && LD="$ac_prog"
slouken@6
   460
      ;;
slouken@6
   461
  "")
slouken@6
   462
    # If it fails, then pretend we aren't using GCC.
slouken@6
   463
    ac_prog=ld
slouken@6
   464
    ;;
slouken@6
   465
  *)
slouken@6
   466
    # If it is relative, then search for the first ld in PATH.
slouken@6
   467
    with_gnu_ld=unknown
slouken@6
   468
    ;;
slouken@6
   469
  esac
slouken@6
   470
elif test "$with_gnu_ld" = yes; then
slouken@6
   471
  AC_MSG_CHECKING([for GNU ld])
slouken@6
   472
else
slouken@6
   473
  AC_MSG_CHECKING([for non-GNU ld])
slouken@6
   474
fi
slouken@6
   475
AC_CACHE_VAL(ac_cv_path_LD,
slouken@6
   476
[if test -z "$LD"; then
slouken@6
   477
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
slouken@6
   478
  for ac_dir in $PATH; do
slouken@6
   479
    test -z "$ac_dir" && ac_dir=.
slouken@6
   480
    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
slouken@6
   481
      ac_cv_path_LD="$ac_dir/$ac_prog"
slouken@6
   482
      # Check to see if the program is GNU ld.  I'd rather use --version,
slouken@6
   483
      # but apparently some GNU ld's only accept -v.
slouken@6
   484
      # Break only if it was the GNU/non-GNU ld that we prefer.
slouken@6
   485
      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
slouken@6
   486
	test "$with_gnu_ld" != no && break
slouken@6
   487
      else
slouken@6
   488
	test "$with_gnu_ld" != yes && break
slouken@6
   489
      fi
slouken@6
   490
    fi
slouken@6
   491
  done
slouken@6
   492
  IFS="$ac_save_ifs"
slouken@6
   493
else
slouken@6
   494
  ac_cv_path_LD="$LD" # Let the user override the test with a path.
slouken@6
   495
fi])
slouken@6
   496
LD="$ac_cv_path_LD"
slouken@6
   497
if test -n "$LD"; then
slouken@6
   498
  AC_MSG_RESULT($LD)
slouken@6
   499
else
slouken@6
   500
  AC_MSG_RESULT(no)
slouken@6
   501
fi
slouken@6
   502
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
slouken@6
   503
AC_SUBST(LD)
slouken@6
   504
AC_PROG_LD_GNU
slouken@6
   505
])
slouken@6
   506
slouken@6
   507
AC_DEFUN(AC_PROG_LD_GNU,
slouken@6
   508
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
slouken@6
   509
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
slouken@6
   510
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
slouken@6
   511
  ac_cv_prog_gnu_ld=yes
slouken@6
   512
else
slouken@6
   513
  ac_cv_prog_gnu_ld=no
slouken@6
   514
fi])
slouken@6
   515
])
slouken@6
   516
slouken@6
   517
# AC_PROG_NM - find the path to a BSD-compatible name lister
slouken@6
   518
AC_DEFUN(AC_PROG_NM,
slouken@6
   519
[AC_MSG_CHECKING([for BSD-compatible nm])
slouken@6
   520
AC_CACHE_VAL(ac_cv_path_NM,
slouken@6
   521
[if test -n "$NM"; then
slouken@6
   522
  # Let the user override the test.
slouken@6
   523
  ac_cv_path_NM="$NM"
slouken@6
   524
else
slouken@6
   525
  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
slouken@6
   526
  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
slouken@6
   527
    test -z "$ac_dir" && ac_dir=.
slouken@6
   528
    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
slouken@6
   529
      # Check to see if the nm accepts a BSD-compat flag.
slouken@6
   530
      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
slouken@6
   531
      #   nm: unknown option "B" ignored
slouken@6
   532
      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
slouken@6
   533
	ac_cv_path_NM="$ac_dir/nm -B"
slouken@6
   534
	break
slouken@6
   535
      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
slouken@6
   536
	ac_cv_path_NM="$ac_dir/nm -p"
slouken@6
   537
	break
slouken@6
   538
      else
slouken@6
   539
	ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
slouken@6
   540
	continue # so that we can try to find one that supports BSD flags
slouken@6
   541
      fi
slouken@6
   542
    fi
slouken@6
   543
  done
slouken@6
   544
  IFS="$ac_save_ifs"
slouken@6
   545
  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
slouken@6
   546
fi])
slouken@6
   547
NM="$ac_cv_path_NM"
slouken@6
   548
AC_MSG_RESULT([$NM])
slouken@6
   549
AC_SUBST(NM)
slouken@6
   550
])
slouken@6
   551
slouken@6
   552
# AC_CHECK_LIBM - check for math library
slouken@6
   553
AC_DEFUN(AC_CHECK_LIBM,
slouken@6
   554
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
slouken@6
   555
LIBM=
slouken@6
   556
case "$host" in
slouken@6
   557
*-*-beos* | *-*-cygwin*)
slouken@6
   558
  # These system don't have libm
slouken@6
   559
  ;;
slouken@6
   560
*-ncr-sysv4.3*)
slouken@6
   561
  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
slouken@6
   562
  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
slouken@6
   563
  ;;
slouken@6
   564
*)
slouken@6
   565
  AC_CHECK_LIB(m, main, LIBM="-lm")
slouken@6
   566
  ;;
slouken@6
   567
esac
slouken@6
   568
])
slouken@6
   569
slouken@6
   570
# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
slouken@6
   571
# the libltdl convenience library, adds --enable-ltdl-convenience to
slouken@6
   572
# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
slouken@6
   573
# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
slouken@6
   574
# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
slouken@6
   575
# '${top_builddir}/' (note the single quotes!) if your package is not
slouken@6
   576
# flat, and, if you're not using automake, define top_builddir as
slouken@6
   577
# appropriate in the Makefiles.
slouken@6
   578
AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
slouken@6
   579
  case "$enable_ltdl_convenience" in
slouken@6
   580
  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
slouken@6
   581
  "") enable_ltdl_convenience=yes
slouken@6
   582
      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
slouken@6
   583
  esac
slouken@6
   584
  LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
slouken@6
   585
  INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
slouken@6
   586
])
slouken@6
   587
slouken@6
   588
# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
slouken@6
   589
# the libltdl installable library, and adds --enable-ltdl-install to
slouken@6
   590
# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
slouken@6
   591
# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
slouken@6
   592
# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
slouken@6
   593
# '${top_builddir}/' (note the single quotes!) if your package is not
slouken@6
   594
# flat, and, if you're not using automake, define top_builddir as
slouken@6
   595
# appropriate in the Makefiles.
slouken@6
   596
# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
slouken@6
   597
AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
slouken@6
   598
  AC_CHECK_LIB(ltdl, main,
slouken@6
   599
  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
slouken@6
   600
  [if test x"$enable_ltdl_install" = xno; then
slouken@6
   601
     AC_MSG_WARN([libltdl not installed, but installation disabled])
slouken@6
   602
   else
slouken@6
   603
     enable_ltdl_install=yes
slouken@6
   604
   fi
slouken@6
   605
  ])
slouken@6
   606
  if test x"$enable_ltdl_install" = x"yes"; then
slouken@6
   607
    ac_configure_args="$ac_configure_args --enable-ltdl-install"
slouken@6
   608
    LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
slouken@6
   609
    INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
slouken@6
   610
  else
slouken@6
   611
    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
slouken@6
   612
    LIBLTDL="-lltdl"
slouken@6
   613
    INCLTDL=
slouken@6
   614
  fi
slouken@6
   615
])
slouken@6
   616
slouken@6
   617
dnl old names
slouken@6
   618
AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
slouken@6
   619
AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
slouken@6
   620
AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
slouken@6
   621
AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
slouken@6
   622
AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
slouken@6
   623
AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
slouken@6
   624
AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
slouken@6
   625
slouken@6
   626
dnl This is just to silence aclocal about the macro not being used
slouken@6
   627
ifelse([AC_DISABLE_FAST_INSTALL])dnl