Debian Codegraph @

acinclude.m4

raw
1 # Configure paths for SDL
2 # Modified for OpenCity by neoneurone on 9th november 2007
3 # Sam Lantinga 9/21/99
4 # stolen from Manish Singh
5 # stolen back from Frank Belew
6 # stolen from Manish Singh
7 # Shamelessly stolen from Owen Taylor
8
9 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
10 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
11 dnl
12 AC_DEFUN([AM_PATH_SDL],
13 [
14 dnl
15 dnl Get the cflags and libraries from the sdl-config script
16 dnl
17 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
18 sdl_prefix="$withval", sdl_prefix="")
19 AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
20 sdl_exec_prefix="$withval", sdl_exec_prefix="")
21 AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
22 , enable_sdltest=yes)
23
24 if test x$sdl_exec_prefix != x ; then
25 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
26 if test x${SDL_CONFIG+set} != xset ; then
27 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
28 fi
29 fi
30 if test x$sdl_prefix != x ; then
31 sdl_args="$sdl_args --prefix=$sdl_prefix"
32 if test x${SDL_CONFIG+set} != xset ; then
33 SDL_CONFIG=$sdl_prefix/bin/sdl-config
34 fi
35 fi
36
37 AC_REQUIRE([AC_CANONICAL_TARGET])
38 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
39 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
40 min_sdl_version=ifelse([$1], ,0.11.0,$1)
41 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
42 no_sdl=""
43 if test "$SDL_CONFIG" = "no" ; then
44 no_sdl=yes
45 else
46 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
47 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
48
49 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
50 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
51 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
52 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
53 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
54 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
55 if test "x$enable_sdltest" = "xyes" ; then
56 ac_save_CFLAGS="$CFLAGS"
57 ac_save_LIBS="$LIBS"
58 CFLAGS="$CFLAGS $SDL_CFLAGS"
59 LIBS="$LIBS $SDL_LIBS"
60 dnl
61 dnl Now check if the installed SDL is sufficiently new. (Also sanity
62 dnl checks the results of sdl-config to some extent
63 dnl
64 rm -f conf.sdltest
65 AC_TRY_RUN([
66 #include <stdio.h>
67 #include <stdlib.h>
68 #include <string.h>
69 #include "SDL.h"
70
71 char*
72 my_strdup (char *str)
73 {
74 char *new_str;
75
76 if (str)
77 {
78 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
79 strcpy (new_str, str);
80 }
81 else
82 new_str = NULL;
83
84 return new_str;
85 }
86
87 int main (int argc, char *argv[])
88 {
89 int major, minor, micro;
90 char *tmp_version;
91
92 /* This hangs on some systems (?)
93 system ("touch conf.sdltest");
94 */
95 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
96
97 /* HP/UX 9 (%@#!) writes to sscanf strings */
98 tmp_version = my_strdup("$min_sdl_version");
99 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
100 printf("%s, bad version string\n", "$min_sdl_version");
101 exit(1);
102 }
103
104 if (($sdl_major_version > major) ||
105 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
106 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
107 {
108 return 0;
109 }
110 else
111 {
112 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
113 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
114 printf("*** best to upgrade to the required version.\n");
115 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
116 printf("*** to point to the correct copy of sdl-config, and remove the file\n");
117 printf("*** config.cache before re-running configure\n");
118 return 1;
119 }
120 }
121
122 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
123 CFLAGS="$ac_save_CFLAGS"
124 LIBS="$ac_save_LIBS"
125 fi
126 fi
127 if test "x$no_sdl" = x ; then
128 AC_MSG_RESULT(yes)
129 ifelse([$2], , :, [$2])
130 else
131 AC_MSG_RESULT(no)
132 if test "$SDL_CONFIG" = "no" ; then
133 echo "*** The sdl-config script installed by SDL could not be found"
134 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
135 echo "*** your path, or set the SDL_CONFIG environment variable to the"
136 echo "*** full path to sdl-config."
137 else
138 if test -f conf.sdltest ; then
139 :
140 else
141 echo "*** Could not run SDL test program, checking why..."
142 CFLAGS="$CFLAGS $SDL_CFLAGS"
143 LIBS="$LIBS $SDL_LIBS"
144 AC_TRY_LINK([
145 #include <stdio.h>
146 #include "SDL.h"
147
148 int main(int argc, char *argv[])
149 { return 0; }
150 #undef main
151 #define main K_and_R_C_main
152 ], [ return 0; ],
153 [ echo "*** The test program compiled, but did not run. This usually means"
154 echo "*** that the run-time linker is not finding SDL or finding the wrong"
155 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
156 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
157 echo "*** to the installed location Also, make sure you have run ldconfig if that"
158 echo "*** is required on your system"
159 echo "***"
160 echo "*** If you have an old version installed, it is best to remove it, although"
161 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
162 [ echo "*** The test program failed to compile or link. See the file config.log for the"
163 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
164 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
165 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
166 CFLAGS="$ac_save_CFLAGS"
167 LIBS="$ac_save_LIBS"
168 fi
169 fi
170 SDL_CFLAGS=""
171 SDL_LIBS=""
172 ifelse([$3], , :, [$3])
173 fi
174 AC_SUBST(SDL_CFLAGS)
175 AC_SUBST(SDL_LIBS)
176 rm -f conf.sdltest
177 ])
178
179
180 # Check for binary relocation support.
181 # Written by Hongli Lai
182 # http://autopackage.org/
183
184 AC_DEFUN([AM_BINRELOC],
185 [
186 AC_ARG_ENABLE(binreloc,
187 [ --enable-binreloc compile with binary relocation support
188 (default=enable when available)],
189 enable_binreloc=$enableval,enable_binreloc=auto)
190
191 AC_ARG_ENABLE(binreloc-threads,
192 [ --enable-binreloc-threads compile binary relocation with threads support
193 (default=yes)],
194 enable_binreloc_threads=$enableval,enable_binreloc_threads=yes)
195
196 BINRELOC_CFLAGS=
197 BINRELOC_LIBS=
198 if test "x$enable_binreloc" = "xauto"; then
199 AC_CHECK_FILE([/proc/self/maps])
200 AC_CACHE_CHECK(
201 [whether everything is installed to the same prefix],
202 [br_cv_valid_prefixes],
203 [
204 if test "$bindir" = '${exec_prefix}/bin' -a "$sbindir" = '${exec_prefix}/sbin' -a \
205 "$datadir" = '${prefix}/share' -a "$libdir" = '${exec_prefix}/lib' -a \
206 "$libexecdir" = '${exec_prefix}/libexec' -a "$sysconfdir" = '${prefix}/etc'
207 then
208 br_cv_valid_prefixes=yes
209 else
210 br_cv_valid_prefixes=no
211 fi
212 ])
213 fi
214 AC_CACHE_CHECK(
215 [whether binary relocation support should be enabled],
216 [br_cv_binreloc],
217 [
218 if test "x$enable_binreloc" = "xyes"; then
219 br_cv_binreloc=yes
220 elif test "x$enable_binreloc" = "xauto"; then
221 if test "x$br_cv_valid_prefixes" = "xyes" -a \
222 "x$ac_cv_file__proc_self_maps" = "xyes"; then
223 br_cv_binreloc=yes
224 else
225 br_cv_binreloc=no
226 fi
227 else
228 br_cv_binreloc=no
229 fi
230 ])
231
232 if test "x$br_cv_binreloc" = "xyes"; then
233 BINRELOC_CFLAGS="-DENABLE_BINRELOC"
234 AC_DEFINE(ENABLE_BINRELOC, 1, [Use binary relocation?])
235 if test "x$enable_binreloc_threads" = "xyes"; then
236 AC_CHECK_LIB([pthread], [pthread_getspecific])
237 fi
238
239 AC_CACHE_CHECK(
240 [whether binary relocation should use threads],
241 [br_cv_binreloc_threads],
242 [
243 if test "x$enable_binreloc_threads" = "xyes"; then
244 if test "x$ac_cv_lib_pthread_pthread_getspecific" = "xyes"; then
245 br_cv_binreloc_threads=yes
246 else
247 br_cv_binreloc_threads=no
248 fi
249 else
250 br_cv_binreloc_threads=no
251 fi
252 ])
253
254 if test "x$br_cv_binreloc_threads" = "xyes"; then
255 BINRELOC_LIBS="-lpthread"
256 AC_DEFINE(BR_PTHREAD, 1, [Include pthread support for binary relocation?])
257 else
258 BINRELOC_CFLAGS="$BINRELOC_CFLAGS -DBR_PTHREADS=0"
259 AC_DEFINE(BR_PTHREAD, 0, [Include pthread support for binary relocation?])
260 fi
261 fi
262 AC_SUBST(BINRELOC_CFLAGS)
263 AC_SUBST(BINRELOC_LIBS)
264 ])