Nuke '^M' from includes
[attac-man.git] / aclocal.m4
blob57c2a7765e3ad3a5a4185a6e4d9a075091cbe2fb
1 # aclocal.m4 generated automatically by aclocal 1.5
3 # Copyright 1996, 1997, 1998, 1999, 2000, 2001
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
14 # $Id: acinclude.m4,v 1.1 2003/11/17 20:13:23 nsubtil Exp $
16 # Configure paths for SDL
17 # Sam Lantinga 9/21/99
18 # stolen from Manish Singh
19 # stolen back from Frank Belew
20 # stolen from Manish Singh
21 # Shamelessly stolen from Owen Taylor
23 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
24 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
25 dnl
26 AC_DEFUN(AM_PATH_SDL,
27 [dnl 
28 dnl Get the cflags and libraries from the sdl-config script
29 dnl
30 AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
31             sdl_prefix="$withval", sdl_prefix="")
32 AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
33             sdl_exec_prefix="$withval", sdl_exec_prefix="")
34 AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
35                     , enable_sdltest=yes)
37   if test x$sdl_exec_prefix != x ; then
38      sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
39      if test x${SDL_CONFIG+set} != xset ; then
40         SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
41      fi
42   fi
43   if test x$sdl_prefix != x ; then
44      sdl_args="$sdl_args --prefix=$sdl_prefix"
45      if test x${SDL_CONFIG+set} != xset ; then
46         SDL_CONFIG=$sdl_prefix/bin/sdl-config
47      fi
48   fi
50   AC_REQUIRE([AC_CANONICAL_TARGET])
51   PATH="$prefix/bin:$prefix/usr/bin:$PATH"
52   AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
53   min_sdl_version=ifelse([$1], ,0.11.0,$1)
54   AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
55   no_sdl=""
56   if test "$SDL_CONFIG" = "no" ; then
57     no_sdl=yes
58   else
59     SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
60     SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
62     sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
63            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
64     sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
65            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
66     sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
67            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
68     if test "x$enable_sdltest" = "xyes" ; then
69       ac_save_CFLAGS="$CFLAGS"
70       ac_save_LIBS="$LIBS"
71       CFLAGS="$CFLAGS $SDL_CFLAGS"
72       LIBS="$LIBS $SDL_LIBS"
73 dnl
74 dnl Now check if the installed SDL is sufficiently new. (Also sanity
75 dnl checks the results of sdl-config to some extent
76 dnl
77       rm -f conf.sdltest
78       AC_TRY_RUN([
79 #include <stdio.h>
80 #include <stdlib.h>
81 #include <string.h>
82 #include "SDL.h"
84 char*
85 my_strdup (char *str)
87   char *new_str;
88   
89   if (str)
90     {
91       new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
92       strcpy (new_str, str);
93     }
94   else
95     new_str = NULL;
96   
97   return new_str;
100 int main (int argc, char *argv[])
102   int major, minor, micro;
103   char *tmp_version;
105   /* This hangs on some systems (?)
106   system ("touch conf.sdltest");
107   */
108   { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
110   /* HP/UX 9 (%@#!) writes to sscanf strings */
111   tmp_version = my_strdup("$min_sdl_version");
112   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
113      printf("%s, bad version string\n", "$min_sdl_version");
114      exit(1);
115    }
117    if (($sdl_major_version > major) ||
118       (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
119       (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
120     {
121       return 0;
122     }
123   else
124     {
125       printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
126       printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
127       printf("*** best to upgrade to the required version.\n");
128       printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
129       printf("*** to point to the correct copy of sdl-config, and remove the file\n");
130       printf("*** config.cache before re-running configure\n");
131       return 1;
132     }
135 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
136        CFLAGS="$ac_save_CFLAGS"
137        LIBS="$ac_save_LIBS"
138      fi
139   fi
140   if test "x$no_sdl" = x ; then
141      AC_MSG_RESULT(yes)
142      ifelse([$2], , :, [$2])     
143   else
144      AC_MSG_RESULT(no)
145      if test "$SDL_CONFIG" = "no" ; then
146        echo "*** The sdl-config script installed by SDL could not be found"
147        echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
148        echo "*** your path, or set the SDL_CONFIG environment variable to the"
149        echo "*** full path to sdl-config."
150      else
151        if test -f conf.sdltest ; then
152         :
153        else
154           echo "*** Could not run SDL test program, checking why..."
155           CFLAGS="$CFLAGS $SDL_CFLAGS"
156           LIBS="$LIBS $SDL_LIBS"
157           AC_TRY_LINK([
158 #include <stdio.h>
159 #include "SDL.h"
161 int main(int argc, char *argv[])
162 { return 0; }
163 #undef  main
164 #define main K_and_R_C_main
165 ],      [ return 0; ],
166         [ echo "*** The test program compiled, but did not run. This usually means"
167           echo "*** that the run-time linker is not finding SDL or finding the wrong"
168           echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
169           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
170           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
171           echo "*** is required on your system"
172           echo "***"
173           echo "*** If you have an old version installed, it is best to remove it, although"
174           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
175         [ echo "*** The test program failed to compile or link. See the file config.log for the"
176           echo "*** exact error that occured. This usually means SDL was incorrectly installed"
177           echo "*** or that you have moved SDL since it was installed. In the latter case, you"
178           echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
179           CFLAGS="$ac_save_CFLAGS"
180           LIBS="$ac_save_LIBS"
181        fi
182      fi
183      SDL_CFLAGS=""
184      SDL_LIBS=""
185      ifelse([$3], , :, [$3])
186   fi
187   AC_SUBST(SDL_CFLAGS)
188   AC_SUBST(SDL_LIBS)
189   rm -f conf.sdltest