| 1 |
dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
| 2 |
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS |
| 3 |
dnl |
| 4 |
AC_DEFUN([AM_PATH_SDL], |
| 5 |
[dnl |
| 6 |
dnl Get the cflags and libraries from the sdl-config script |
| 7 |
dnl |
| 8 |
AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], |
| 9 |
sdl_prefix="$withval", sdl_prefix="") |
| 10 |
AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], |
| 11 |
sdl_exec_prefix="$withval", sdl_exec_prefix="") |
| 12 |
AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], |
| 13 |
, enable_sdltest=yes) |
| 14 |
|
| 15 |
if test x$sdl_exec_prefix != x ; then |
| 16 |
sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" |
| 17 |
if test x${SDL_CONFIG+set} != xset ; then |
| 18 |
SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config |
| 19 |
fi |
| 20 |
fi |
| 21 |
if test x$sdl_prefix != x ; then |
| 22 |
sdl_args="$sdl_args --prefix=$sdl_prefix" |
| 23 |
if test x${SDL_CONFIG+set} != xset ; then |
| 24 |
SDL_CONFIG=$sdl_prefix/bin/sdl-config |
| 25 |
fi |
| 26 |
fi |
| 27 |
|
| 28 |
AC_PATH_PROG(SDL_CONFIG, sdl-config, no) |
| 29 |
min_sdl_version=ifelse([$1], ,0.11.0,$1) |
| 30 |
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) |
| 31 |
no_sdl="" |
| 32 |
if test "$SDL_CONFIG" = "no" ; then |
| 33 |
no_sdl=yes |
| 34 |
else |
| 35 |
SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` |
| 36 |
SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` |
| 37 |
|
| 38 |
sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ |
| 39 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
| 40 |
sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ |
| 41 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
| 42 |
sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ |
| 43 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
| 44 |
if test "x$enable_sdltest" = "xyes" ; then |
| 45 |
ac_save_CFLAGS="$CFLAGS" |
| 46 |
ac_save_LIBS="$LIBS" |
| 47 |
CFLAGS="$CFLAGS $SDL_CFLAGS" |
| 48 |
LIBS="$LIBS $SDL_LIBS" |
| 49 |
dnl |
| 50 |
dnl Now check if the installed SDL is sufficiently new. (Also sanity |
| 51 |
dnl checks the results of sdl-config to some extent |
| 52 |
dnl |
| 53 |
rm -f conf.sdltest |
| 54 |
AC_TRY_RUN([ |
| 55 |
#include <stdio.h> |
| 56 |
#include <stdlib.h> |
| 57 |
#include <string.h> |
| 58 |
#include "SDL.h" |
| 59 |
|
| 60 |
char* |
| 61 |
my_strdup (char *str) |
| 62 |
{ |
| 63 |
char *new_str; |
| 64 |
|
| 65 |
if (str) |
| 66 |
{ |
| 67 |
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); |
| 68 |
strcpy (new_str, str); |
| 69 |
} |
| 70 |
else |
| 71 |
new_str = NULL; |
| 72 |
|
| 73 |
return new_str; |
| 74 |
} |
| 75 |
|
| 76 |
int main (int argc, char *argv[]) |
| 77 |
{ |
| 78 |
int major, minor, micro; |
| 79 |
char *tmp_version; |
| 80 |
|
| 81 |
/* This hangs on some systems (?) |
| 82 |
system ("touch conf.sdltest"); |
| 83 |
*/ |
| 84 |
{ FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } |
| 85 |
|
| 86 |
/* HP/UX 9 (%@#!) writes to sscanf strings */ |
| 87 |
tmp_version = my_strdup("$min_sdl_version"); |
| 88 |
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { |
| 89 |
printf("%s, bad version string\n", "$min_sdl_version"); |
| 90 |
exit(1); |
| 91 |
} |
| 92 |
|
| 93 |
if (($sdl_major_version > major) || |
| 94 |
(($sdl_major_version == major) && ($sdl_minor_version > minor)) || |
| 95 |
(($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) |
| 96 |
{ |
| 97 |
return 0; |
| 98 |
} |
| 99 |
else |
| 100 |
{ |
| 101 |
printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); |
| 102 |
printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); |
| 103 |
printf("*** best to upgrade to the required version.\n"); |
| 104 |
printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); |
| 105 |
printf("*** to point to the correct copy of sdl-config, and remove the file\n"); |
| 106 |
printf("*** config.cache before re-running configure\n"); |
| 107 |
return 1; |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
| 112 |
CFLAGS="$ac_save_CFLAGS" |
| 113 |
LIBS="$ac_save_LIBS" |
| 114 |
fi |
| 115 |
fi |
| 116 |
if test "x$no_sdl" = x ; then |
| 117 |
AC_MSG_RESULT(yes) |
| 118 |
ifelse([$2], , :, [$2]) |
| 119 |
else |
| 120 |
AC_MSG_RESULT(no) |
| 121 |
if test "$SDL_CONFIG" = "no" ; then |
| 122 |
echo "*** The sdl-config script installed by SDL could not be found" |
| 123 |
echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" |
| 124 |
echo "*** your path, or set the SDL_CONFIG environment variable to the" |
| 125 |
echo "*** full path to sdl-config." |
| 126 |
else |
| 127 |
if test -f conf.sdltest ; then |
| 128 |
: |
| 129 |
else |
| 130 |
echo "*** Could not run SDL test program, checking why..." |
| 131 |
CFLAGS="$CFLAGS $SDL_CFLAGS" |
| 132 |
LIBS="$LIBS $SDL_LIBS" |
| 133 |
AC_TRY_LINK([ |
| 134 |
#include <stdio.h> |
| 135 |
#include "SDL.h" |
| 136 |
], [ return 0; ], |
| 137 |
[ echo "*** The test program compiled, but did not run. This usually means" |
| 138 |
echo "*** that the run-time linker is not finding SDL or finding the wrong" |
| 139 |
echo "*** version of SDL. If it is not finding SDL, you'll need to set your" |
| 140 |
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
| 141 |
echo "*** to the installed location Also, make sure you have run ldconfig if that" |
| 142 |
echo "*** is required on your system" |
| 143 |
echo "***" |
| 144 |
echo "*** If you have an old version installed, it is best to remove it, although" |
| 145 |
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], |
| 146 |
[ echo "*** The test program failed to compile or link. See the file config.log for the" |
| 147 |
echo "*** exact error that occured. This usually means SDL was incorrectly installed" |
| 148 |
echo "*** or that you have moved SDL since it was installed. In the latter case, you" |
| 149 |
echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) |
| 150 |
CFLAGS="$ac_save_CFLAGS" |
| 151 |
LIBS="$ac_save_LIBS" |
| 152 |
fi |
| 153 |
fi |
| 154 |
SDL_CFLAGS="" |
| 155 |
SDL_LIBS="" |
| 156 |
ifelse([$3], , :, [$3]) |
| 157 |
fi |
| 158 |
AC_SUBST(SDL_CFLAGS) |
| 159 |
AC_SUBST(SDL_LIBS) |
| 160 |
rm -f conf.sdltest |
| 161 |
]) |
| 162 |
|
| 163 |
dnl Configure Paths for Alsa |
| 164 |
dnl Some modifications by Richard Boulton <[email protected]> |
| 165 |
dnl Christopher Lansdown <[email protected]> |
| 166 |
dnl Jaroslav Kysela <[email protected]> |
| 167 |
dnl Last modification: alsa.m4,v 1.22 2002/05/27 11:14:20 tiwai Exp |
| 168 |
dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
| 169 |
dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate. |
| 170 |
dnl enables arguments --with-alsa-prefix= |
| 171 |
dnl --with-alsa-enc-prefix= |
| 172 |
dnl --disable-alsatest (this has no effect, as yet) |
| 173 |
dnl |
| 174 |
dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified, |
| 175 |
dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result. |
| 176 |
dnl |
| 177 |
AC_DEFUN([AM_PATH_ALSA], |
| 178 |
[dnl Save the original CFLAGS, LDFLAGS, and LIBS |
| 179 |
alsa_save_CFLAGS="$CFLAGS" |
| 180 |
alsa_save_LDFLAGS="$LDFLAGS" |
| 181 |
alsa_save_LIBS="$LIBS" |
| 182 |
alsa_found=yes |
| 183 |
|
| 184 |
dnl |
| 185 |
dnl Get the cflags and libraries for alsa |
| 186 |
dnl |
| 187 |
AC_ARG_WITH(alsa-prefix, |
| 188 |
[ --with-alsa-prefix=PFX Prefix where Alsa library is installed(optional)], |
| 189 |
[alsa_prefix="$withval"], [alsa_prefix=""]) |
| 190 |
|
| 191 |
AC_ARG_WITH(alsa-inc-prefix, |
| 192 |
[ --with-alsa-inc-prefix=PFX Prefix where include libraries are (optional)], |
| 193 |
[alsa_inc_prefix="$withval"], [alsa_inc_prefix=""]) |
| 194 |
|
| 195 |
dnl FIXME: this is not yet implemented |
| 196 |
AC_ARG_ENABLE(alsatest, |
| 197 |
[ --disable-alsatest Do not try to compile and run a test Alsa program], |
| 198 |
[enable_alsatest=no], |
| 199 |
[enable_alsatest=yes]) |
| 200 |
|
| 201 |
dnl Add any special include directories |
| 202 |
AC_MSG_CHECKING(for ALSA CFLAGS) |
| 203 |
if test "$alsa_inc_prefix" != "" ; then |
| 204 |
ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix" |
| 205 |
CFLAGS="$CFLAGS -I$alsa_inc_prefix" |
| 206 |
fi |
| 207 |
AC_MSG_RESULT($ALSA_CFLAGS) |
| 208 |
|
| 209 |
dnl add any special lib dirs |
| 210 |
AC_MSG_CHECKING(for ALSA LDFLAGS) |
| 211 |
if test "$alsa_prefix" != "" ; then |
| 212 |
ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix" |
| 213 |
LDFLAGS="$LDFLAGS $ALSA_LIBS" |
| 214 |
fi |
| 215 |
|
| 216 |
dnl add the alsa library |
| 217 |
ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl -lpthread" |
| 218 |
LIBS=`echo $LIBS | sed 's/-lm//'` |
| 219 |
LIBS=`echo $LIBS | sed 's/-ldl//'` |
| 220 |
LIBS=`echo $LIBS | sed 's/-lpthread//'` |
| 221 |
LIBS=`echo $LIBS | sed 's/ //'` |
| 222 |
LIBS="$ALSA_LIBS $LIBS" |
| 223 |
AC_MSG_RESULT($ALSA_LIBS) |
| 224 |
|
| 225 |
dnl Check for a working version of libasound that is of the right version. |
| 226 |
min_alsa_version=ifelse([$1], ,0.1.1,$1) |
| 227 |
AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version) |
| 228 |
no_alsa="" |
| 229 |
alsa_min_major_version=`echo $min_alsa_version | \ |
| 230 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
| 231 |
alsa_min_minor_version=`echo $min_alsa_version | \ |
| 232 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
| 233 |
alsa_min_micro_version=`echo $min_alsa_version | \ |
| 234 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
| 235 |
|
| 236 |
AC_LANG_SAVE |
| 237 |
AC_LANG_C |
| 238 |
AC_TRY_COMPILE([ |
| 239 |
#include <alsa/asoundlib.h> |
| 240 |
], [ |
| 241 |
/* ensure backward compatibility */ |
| 242 |
#if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR) |
| 243 |
#define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR |
| 244 |
#endif |
| 245 |
#if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR) |
| 246 |
#define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR |
| 247 |
#endif |
| 248 |
#if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR) |
| 249 |
#define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR |
| 250 |
#endif |
| 251 |
|
| 252 |
# if(SND_LIB_MAJOR > $alsa_min_major_version) |
| 253 |
exit(0); |
| 254 |
# else |
| 255 |
# if(SND_LIB_MAJOR < $alsa_min_major_version) |
| 256 |
# error not present |
| 257 |
# endif |
| 258 |
|
| 259 |
# if(SND_LIB_MINOR > $alsa_min_minor_version) |
| 260 |
exit(0); |
| 261 |
# else |
| 262 |
# if(SND_LIB_MINOR < $alsa_min_minor_version) |
| 263 |
# error not present |
| 264 |
# endif |
| 265 |
|
| 266 |
# if(SND_LIB_SUBMINOR < $alsa_min_micro_version) |
| 267 |
# error not present |
| 268 |
# endif |
| 269 |
# endif |
| 270 |
# endif |
| 271 |
exit(0); |
| 272 |
], |
| 273 |
[AC_MSG_RESULT(found.)], |
| 274 |
[AC_MSG_RESULT(not present.) |
| 275 |
ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)]) |
| 276 |
alsa_found=no] |
| 277 |
) |
| 278 |
AC_LANG_RESTORE |
| 279 |
|
| 280 |
dnl Now that we know that we have the right version, let's see if we have the library and not just the headers. |
| 281 |
AC_CHECK_LIB([asound], [snd_ctl_open],, |
| 282 |
[ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)]) |
| 283 |
alsa_found=no] |
| 284 |
) |
| 285 |
|
| 286 |
if test "x$alsa_found" = "xyes" ; then |
| 287 |
ifelse([$2], , :, [$2]) |
| 288 |
LIBS=`echo $LIBS | sed 's/-lasound//g'` |
| 289 |
LIBS=`echo $LIBS | sed 's/ //'` |
| 290 |
LIBS="-lasound $LIBS" |
| 291 |
fi |
| 292 |
if test "x$alsa_found" = "xno" ; then |
| 293 |
ifelse([$3], , :, [$3]) |
| 294 |
CFLAGS="$alsa_save_CFLAGS" |
| 295 |
LDFLAGS="$alsa_save_LDFLAGS" |
| 296 |
LIBS="$alsa_save_LIBS" |
| 297 |
ALSA_CFLAGS="" |
| 298 |
ALSA_LIBS="" |
| 299 |
fi |
| 300 |
|
| 301 |
dnl That should be it. Now just export out symbols: |
| 302 |
AC_SUBST(ALSA_CFLAGS) |
| 303 |
AC_SUBST(ALSA_LIBS) |
| 304 |
]) |
| 305 |
|
| 306 |
AH_TOP([ |
| 307 |
/* |
| 308 |
* Copyright (C) 2002-2010 The DOSBox Team |
| 309 |
* |
| 310 |
* This program is free software; you can redistribute it and/or modify |
| 311 |
* it under the terms of the GNU General Public License as published by |
| 312 |
* the Free Software Foundation; either version 2 of the License, or |
| 313 |
* (at your option) any later version. |
| 314 |
* |
| 315 |
* This program is distributed in the hope that it will be useful, |
| 316 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 317 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 318 |
* GNU Library General Public License for more details. |
| 319 |
* |
| 320 |
* You should have received a copy of the GNU General Public License |
| 321 |
* along with this program; if not, write to the Free Software |
| 322 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 323 |
*/ |
| 324 |
]) |
| 325 |
|
| 326 |
AH_BOTTOM([#if C_ATTRIBUTE_ALWAYS_INLINE |
| 327 |
#define INLINE inline __attribute__((always_inline)) |
| 328 |
#else |
| 329 |
#define INLINE inline |
| 330 |
#endif]) |
| 331 |
|
| 332 |
AH_BOTTOM([#if C_ATTRIBUTE_FASTCALL |
| 333 |
#define DB_FASTCALL __attribute__((fastcall)) |
| 334 |
#else |
| 335 |
#define DB_FASTCALL |
| 336 |
#endif]) |
| 337 |
|
| 338 |
|
| 339 |
AH_BOTTOM([#if C_HAS_ATTRIBUTE |
| 340 |
#define GCC_ATTRIBUTE(x) __attribute__ ((x)) |
| 341 |
#else |
| 342 |
#define GCC_ATTRIBUTE(x) /* attribute not supported */ |
| 343 |
#endif]) |
| 344 |
|
| 345 |
AH_BOTTOM([#if C_HAS_BUILTIN_EXPECT |
| 346 |
#define GCC_UNLIKELY(x) __builtin_expect((x),0) |
| 347 |
#define GCC_LIKELY(x) __builtin_expect((x),1) |
| 348 |
#else |
| 349 |
#define GCC_UNLIKELY(x) (x) |
| 350 |
#define GCC_LIKELY(x) (x) |
| 351 |
#endif]) |
| 352 |
|
| 353 |
AH_BOTTOM([ |
| 354 |
typedef double Real64; |
| 355 |
|
| 356 |
#if SIZEOF_UNSIGNED_CHAR != 1 |
| 357 |
# error "sizeof (unsigned char) != 1" |
| 358 |
#else |
| 359 |
typedef unsigned char Bit8u; |
| 360 |
typedef signed char Bit8s; |
| 361 |
#endif |
| 362 |
|
| 363 |
#if SIZEOF_UNSIGNED_SHORT != 2 |
| 364 |
# error "sizeof (unsigned short) != 2" |
| 365 |
#else |
| 366 |
typedef unsigned short Bit16u; |
| 367 |
typedef signed short Bit16s; |
| 368 |
#endif |
| 369 |
|
| 370 |
#if SIZEOF_UNSIGNED_INT == 4 |
| 371 |
typedef unsigned int Bit32u; |
| 372 |
typedef signed int Bit32s; |
| 373 |
#elif SIZEOF_UNSIGNED_LONG == 4 |
| 374 |
typedef unsigned long Bit32u; |
| 375 |
typedef signed long Bit32s; |
| 376 |
#else |
| 377 |
# error "can't find sizeof(type) of 4 bytes!" |
| 378 |
#endif |
| 379 |
|
| 380 |
#if SIZEOF_UNSIGNED_LONG == 8 |
| 381 |
typedef unsigned long Bit64u; |
| 382 |
typedef signed long Bit64s; |
| 383 |
#elif SIZEOF_UNSIGNED_LONG_LONG == 8 |
| 384 |
typedef unsigned long long Bit64u; |
| 385 |
typedef signed long long Bit64s; |
| 386 |
#else |
| 387 |
# error "can't find data type of 8 bytes" |
| 388 |
#endif |
| 389 |
|
| 390 |
#if SIZEOF_INT_P == 4 |
| 391 |
typedef Bit32u Bitu; |
| 392 |
typedef Bit32s Bits; |
| 393 |
#else |
| 394 |
typedef Bit64u Bitu; |
| 395 |
typedef Bit64s Bits; |
| 396 |
#endif |
| 397 |
|
| 398 |
]) |