diff options
Diffstat (limited to 'src/contrib/SDL-2.30.2/sdl2.m4')
-rw-r--r-- | src/contrib/SDL-2.30.2/sdl2.m4 | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/src/contrib/SDL-2.30.2/sdl2.m4 b/src/contrib/SDL-2.30.2/sdl2.m4 new file mode 100644 index 0000000..274753b --- /dev/null +++ b/src/contrib/SDL-2.30.2/sdl2.m4 | |||
@@ -0,0 +1,215 @@ | |||
1 | # Configure paths for SDL | ||
2 | # Sam Lantinga 9/21/99 | ||
3 | # stolen from Manish Singh | ||
4 | # stolen back from Frank Belew | ||
5 | # stolen from Manish Singh | ||
6 | # Shamelessly stolen from Owen Taylor | ||
7 | # | ||
8 | # Changelog: | ||
9 | # * also look for SDL2.framework under Mac OS X | ||
10 | # * removed HP/UX 9 support. | ||
11 | # * updated for newer autoconf. | ||
12 | # * (v3) use $PKG_CONFIG for pkg-config cross-compiling support | ||
13 | |||
14 | # serial 3 | ||
15 | |||
16 | dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
17 | dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS | ||
18 | dnl | ||
19 | AC_DEFUN([AM_PATH_SDL2], | ||
20 | [dnl | ||
21 | dnl Get the cflags and libraries from the sdl2-config script | ||
22 | dnl | ||
23 | AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], | ||
24 | sdl_prefix="$withval", sdl_prefix="") | ||
25 | AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], | ||
26 | sdl_exec_prefix="$withval", sdl_exec_prefix="") | ||
27 | AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], | ||
28 | , enable_sdltest=yes) | ||
29 | AC_ARG_ENABLE(sdlframework, [ --disable-sdlframework Do not search for SDL2.framework], | ||
30 | , search_sdl_framework=yes) | ||
31 | |||
32 | AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework]) | ||
33 | |||
34 | min_sdl_version=ifelse([$1], ,2.0.0,$1) | ||
35 | |||
36 | if test "x$sdl_prefix$sdl_exec_prefix" = x ; then | ||
37 | PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], | ||
38 | [sdl_pc=yes], | ||
39 | [sdl_pc=no]) | ||
40 | else | ||
41 | sdl_pc=no | ||
42 | if test x$sdl_exec_prefix != x ; then | ||
43 | sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" | ||
44 | if test x${SDL2_CONFIG+set} != xset ; then | ||
45 | SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config | ||
46 | fi | ||
47 | fi | ||
48 | if test x$sdl_prefix != x ; then | ||
49 | sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" | ||
50 | if test x${SDL2_CONFIG+set} != xset ; then | ||
51 | SDL2_CONFIG=$sdl_prefix/bin/sdl2-config | ||
52 | fi | ||
53 | fi | ||
54 | fi | ||
55 | |||
56 | if test "x$sdl_pc" = xyes ; then | ||
57 | no_sdl="" | ||
58 | SDL2_CONFIG="$PKG_CONFIG sdl2" | ||
59 | else | ||
60 | as_save_PATH="$PATH" | ||
61 | if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then | ||
62 | PATH="$prefix/bin:$prefix/usr/bin:$PATH" | ||
63 | fi | ||
64 | AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) | ||
65 | PATH="$as_save_PATH" | ||
66 | no_sdl="" | ||
67 | |||
68 | if test "$SDL2_CONFIG" = "no" -a "x$search_sdl_framework" = "xyes"; then | ||
69 | AC_MSG_CHECKING(for SDL2.framework) | ||
70 | if test "x$SDL2_FRAMEWORK" != x; then | ||
71 | sdl_framework=$SDL2_FRAMEWORK | ||
72 | else | ||
73 | for d in / ~/ /System/; do | ||
74 | if test -d "${d}Library/Frameworks/SDL2.framework"; then | ||
75 | sdl_framework="${d}Library/Frameworks/SDL2.framework" | ||
76 | fi | ||
77 | done | ||
78 | fi | ||
79 | |||
80 | if test x"$sdl_framework" != x && test -d "$sdl_framework"; then | ||
81 | AC_MSG_RESULT($sdl_framework) | ||
82 | sdl_framework_dir=`dirname $sdl_framework` | ||
83 | SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include" | ||
84 | SDL_LIBS="-F$sdl_framework_dir -Wl,-framework,SDL2" | ||
85 | else | ||
86 | no_sdl=yes | ||
87 | fi | ||
88 | fi | ||
89 | |||
90 | if test "$SDL2_CONFIG" != "no"; then | ||
91 | if test "x$sdl_pc" = "xno"; then | ||
92 | AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) | ||
93 | SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` | ||
94 | SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` | ||
95 | fi | ||
96 | |||
97 | sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ | ||
98 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | ||
99 | sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ | ||
100 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | ||
101 | sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ | ||
102 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | ||
103 | if test "x$enable_sdltest" = "xyes" ; then | ||
104 | ac_save_CFLAGS="$CFLAGS" | ||
105 | ac_save_CXXFLAGS="$CXXFLAGS" | ||
106 | ac_save_LIBS="$LIBS" | ||
107 | CFLAGS="$CFLAGS $SDL_CFLAGS" | ||
108 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" | ||
109 | LIBS="$LIBS $SDL_LIBS" | ||
110 | dnl | ||
111 | dnl Now check if the installed SDL is sufficiently new. (Also sanity | ||
112 | dnl checks the results of sdl2-config to some extent | ||
113 | dnl | ||
114 | rm -f conf.sdltest | ||
115 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ | ||
116 | #include <stdio.h> | ||
117 | #include <stdlib.h> | ||
118 | #include "SDL.h" | ||
119 | |||
120 | int main (int argc, char *argv[]) | ||
121 | { | ||
122 | int major, minor, micro; | ||
123 | FILE *fp = fopen("conf.sdltest", "w"); | ||
124 | |||
125 | if (fp) fclose(fp); | ||
126 | |||
127 | if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, µ) != 3) { | ||
128 | printf("%s, bad version string\n", "$min_sdl_version"); | ||
129 | exit(1); | ||
130 | } | ||
131 | |||
132 | if (($sdl_major_version > major) || | ||
133 | (($sdl_major_version == major) && ($sdl_minor_version > minor)) || | ||
134 | (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) | ||
135 | { | ||
136 | return 0; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); | ||
141 | printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); | ||
142 | printf("*** best to upgrade to the required version.\n"); | ||
143 | printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); | ||
144 | printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); | ||
145 | printf("*** config.cache before re-running configure\n"); | ||
146 | return 1; | ||
147 | } | ||
148 | } | ||
149 | |||
150 | ]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) | ||
151 | CFLAGS="$ac_save_CFLAGS" | ||
152 | CXXFLAGS="$ac_save_CXXFLAGS" | ||
153 | LIBS="$ac_save_LIBS" | ||
154 | |||
155 | fi | ||
156 | if test "x$sdl_pc" = "xno"; then | ||
157 | if test "x$no_sdl" = "xyes"; then | ||
158 | AC_MSG_RESULT(no) | ||
159 | else | ||
160 | AC_MSG_RESULT(yes) | ||
161 | fi | ||
162 | fi | ||
163 | fi | ||
164 | fi | ||
165 | if test "x$no_sdl" = x ; then | ||
166 | ifelse([$2], , :, [$2]) | ||
167 | else | ||
168 | if test "$SDL2_CONFIG" = "no" ; then | ||
169 | echo "*** The sdl2-config script installed by SDL could not be found" | ||
170 | echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" | ||
171 | echo "*** your path, or set the SDL2_CONFIG environment variable to the" | ||
172 | echo "*** full path to sdl2-config." | ||
173 | else | ||
174 | if test -f conf.sdltest ; then | ||
175 | : | ||
176 | else | ||
177 | echo "*** Could not run SDL test program, checking why..." | ||
178 | CFLAGS="$CFLAGS $SDL_CFLAGS" | ||
179 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" | ||
180 | LIBS="$LIBS $SDL_LIBS" | ||
181 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | ||
182 | #include <stdio.h> | ||
183 | #include "SDL.h" | ||
184 | |||
185 | int main(int argc, char *argv[]) | ||
186 | { return 0; } | ||
187 | #undef main | ||
188 | #define main K_and_R_C_main | ||
189 | ]], [[ return 0; ]])], | ||
190 | [ echo "*** The test program compiled, but did not run. This usually means" | ||
191 | echo "*** that the run-time linker is not finding SDL or finding the wrong" | ||
192 | echo "*** version of SDL. If it is not finding SDL, you'll need to set your" | ||
193 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" | ||
194 | echo "*** to the installed location Also, make sure you have run ldconfig if that" | ||
195 | echo "*** is required on your system" | ||
196 | echo "***" | ||
197 | echo "*** If you have an old version installed, it is best to remove it, although" | ||
198 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], | ||
199 | [ echo "*** The test program failed to compile or link. See the file config.log for the" | ||
200 | echo "*** exact error that occured. This usually means SDL was incorrectly installed" | ||
201 | echo "*** or that you have moved SDL since it was installed. In the latter case, you" | ||
202 | echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ]) | ||
203 | CFLAGS="$ac_save_CFLAGS" | ||
204 | CXXFLAGS="$ac_save_CXXFLAGS" | ||
205 | LIBS="$ac_save_LIBS" | ||
206 | fi | ||
207 | fi | ||
208 | SDL_CFLAGS="" | ||
209 | SDL_LIBS="" | ||
210 | ifelse([$3], , :, [$3]) | ||
211 | fi | ||
212 | AC_SUBST(SDL_CFLAGS) | ||
213 | AC_SUBST(SDL_LIBS) | ||
214 | rm -f conf.sdltest | ||
215 | ]) | ||