Configure dynamically generates SDL_config.h
authorSam Lantinga <slouken@libsdl.org>
Tue, 07 Feb 2006 12:11:33 +0000
changeset 1341 d02b552e5304
parent 1340 58b114ef50e7
child 1342 d73be99e9420
Configure dynamically generates SDL_config.h I'm still wrestling with autoheader, but this should work for now... Fixed lots of build problems with C library support disabled
autogen.sh
configure.in
include/Makefile.am
include/SDL_config.h
include/SDL_config.h.in
include/SDL_config.h.minimal
include/SDL_stdlib.h
include/SDL_string.h
src/audio/SDL_audio.c
src/audio/amigaos/SDL_ahiaudio.c
src/audio/disk/SDL_diskaudio.c
src/audio/dma/SDL_dmaaudio.c
src/audio/dsp/SDL_dspaudio.c
src/audio/mme/SDL_mmeaudio.h
src/cdrom/linux/SDL_syscdrom.c
src/stdlib/SDL_getenv.c
src/stdlib/SDL_string.c
src/video/SDL_video.c
src/video/SDL_yuv.c
src/video/fbcon/SDL_fbelo.c
src/video/fbcon/SDL_fbevents.c
src/video/fbcon/SDL_fbvideo.c
src/video/nanox/SDL_nxvideo.c
src/video/wincommon/SDL_sysevents.c
--- a/autogen.sh	Tue Feb 07 11:18:21 2006 +0000
+++ b/autogen.sh	Tue Feb 07 12:11:33 2006 +0000
@@ -6,6 +6,7 @@
 # Touch the timestamps on all the files since CVS messes them up
 directory=`dirname $0`
 touch $directory/configure.in
+touch $directory/include/SDL_config.h.in
 
 # Regenerate configuration files
 aclocal || exit 1
--- a/configure.in	Tue Feb 07 11:18:21 2006 +0000
+++ b/configure.in	Tue Feb 07 12:11:33 2006 +0000
@@ -1,5 +1,42 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT(README)
+AH_TOP([/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2006 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+#ifndef _SDL_config_h
+#define _SDL_config_h
+
+/* This is a set of defines to configure the SDL features */
+
+/* Comment this if you want to build without any libc requirements */
+#undef HAVE_LIBC
+#ifdef HAVE_LIBC
+])
+AC_CONFIG_HEADER(include/SDL_config.h)
+AH_BOTTOM([
+#endif /* HAVE_LIBC */
+
+#endif /* _SDL_config_h */
+])
 
 dnl Set various version strings - taken gratefully from the GTk sources
 #
@@ -113,6 +150,40 @@
     fi
 fi
 
+dnl See whether we are allowed to use the system C library
+AC_ARG_ENABLE(libc,
+[  --enable-libc           Use the system C library [default=yes]],
+              , AC_DEFINE(HAVE_LIBC))
+
+dnl Checks for header files.
+AC_CHECK_HEADERS(alloca.h stdint.h stdlib.h stdarg.h malloc.h)
+AC_CHECK_HEADERS(ctype.h)
+AC_CHECK_HEADERS(string.h)
+AC_CHECK_HEADERS(stdio.h)
+AC_CHECK_HEADERS(signal.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_C_INLINE
+AC_TYPE_SIZE_T
+AC_CHECK_SIZEOF(char, 1)
+AC_CHECK_SIZEOF(short, 2)
+AC_CHECK_SIZEOF(int, 4)
+AC_CHECK_SIZEOF(long, 4)
+AC_CHECK_SIZEOF(long long, 8)
+
+dnl Checks for library functions.
+AC_FUNC_ALLOCA
+AC_CHECK_FUNCS(malloc calloc realloc free)
+AC_CHECK_FUNCS(getenv putenv qsort abs)
+AC_CHECK_FUNCS(memset memcpy memmove memcmp)
+AC_CHECK_FUNCS(strlen strcpy strncpy strcat strncat strdup)
+AC_CHECK_FUNCS(_strrev _strupr _strlwr)
+AC_CHECK_FUNCS(strchr strrchr strstr)
+AC_CHECK_FUNCS(itoa _ltoa _uitoa _ultoa strtol _i64toa _ui64toa strtoll atoi atof)
+AC_CHECK_FUNCS(strcmp strncmp stricmp strcasecmp)
+AC_CHECK_FUNCS(sscanf snprintf vsnprintf)
+
 dnl Initialize the compiler and linker flags for SDL applications
 
 SDL_CFLAGS=""
--- a/include/Makefile.am	Tue Feb 07 11:18:21 2006 +0000
+++ b/include/Makefile.am	Tue Feb 07 12:11:33 2006 +0000
@@ -41,3 +41,7 @@
 	SDL_windows.h		\
 	begin_code.h		\
 	close_code.h
+
+EXTRA_DIST =			\
+	SDL_config.h.in		\
+	SDL_config.h.minimal
--- a/include/SDL_config.h	Tue Feb 07 11:18:21 2006 +0000
+++ b/include/SDL_config.h	Tue Feb 07 12:11:33 2006 +0000
@@ -23,81 +23,8 @@
 #ifndef _SDL_config_h
 #define _SDL_config_h
 
-/* This is a set of defines to configure the SDL features */
-
-#define HAVE_STDARG_H
-
-/* Comment this if you want to build without any libc requirements */
-#define HAVE_LIBC
-#ifdef HAVE_LIBC
-
-/* Various C library headers */
-#ifndef HAVE_CTYPE_H
-#define HAVE_CTYPE_H
-#endif
-#ifndef HAVE_STDIO_H
-#define HAVE_STDIO_H
-#endif
-#ifndef HAVE_STDLIB_H
-#define HAVE_STDLIB_H
-#endif
-#ifndef HAVE_MALLOC_H
-#define HAVE_MALLOC_H
-#endif
-#ifndef HAVE_STRING_H
-#define HAVE_STRING_H
-#endif
-#if !defined(_WIN32_WCE)
-#ifndef HAVE_SIGNAL_H
-#define HAVE_SIGNAL_H
-#endif
-#endif /* !_WIN32_WCE */
+/* This is the minimal configuration that can be used to build SDL */
 
-/* Features provided by SDL_stdlib.h */
-#define HAVE_MALLOC
-#define HAVE_REALLOC
-#define HAVE_FREE
-#ifndef HAVE_ALLOCA
-#define HAVE_ALLOCA
-#endif
-#if !defined(_WIN32) /* Don't use C runtime versions of these on Windows */
-#define HAVE_GETENV
-#define HAVE_PUTENV
-#endif
-/*#define HAVE_QSORT*/
-
-/* Features provided by SDL_string.h */
-#define HAVE_MEMSET
-#define HAVE_MEMCPY
-#define HAVE_MEMMOVE
-#define HAVE_MEMCMP
-#define HAVE_STRLEN
-#define HAVE_STRCPY
-#define HAVE_STRNCPY
-#define HAVE_STRCAT
-#define HAVE_STRNCAT
-/*#define HAVE__STRREV*/
-/*#define HAVE__STRUPR*/
-/*#define HAVE__STRLWR*/
-#define HAVE_STRCHR
-#define HAVE_STRRCHR
-#define HAVE_STRSTR
-/*#define HAVE_ITOA*/
-/*#define HAVE__LTOA*/
-/*#define HAVE__UITOA*/
-/*#define HAVE__ULTOA*/
-/*#define HAVE_STRTOL*/
-/*#define HAVE__I64TOA*/
-/*#define HAVE__UI64TOA*/
-/*#define HAVE_STRTOLL*/
-#define HAVE_STRCMP
-#define HAVE_STRNCMP
-/*#define HAVE_STRICMP*/
-/*#define HAVE_STRCASECMP*/
-#define HAVE_SSCANF
-/*#define HAVE_SNPRINTF*/
-/*#define HAVE_VSNPRINTF*/
-
-#endif /* HAVE_LIBC */
+#define HAVE_STDARG_H 1
 
 #endif /* _SDL_config_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_config.h.in	Tue Feb 07 12:11:33 2006 +0000
@@ -0,0 +1,289 @@
+/* include/SDL_config.h.in.  Generated from configure.in by autoheader.  */
+
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2006 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+#ifndef _SDL_config_h
+#define _SDL_config_h
+
+/* This is a set of defines to configure the SDL features */
+
+/* Comment this if you want to build without any libc requirements */
+#undef HAVE_LIBC
+#ifdef HAVE_LIBC
+
+
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to 1 if you have the `abs' function. */
+#undef HAVE_ABS
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+#undef HAVE_ALLOCA_H
+
+/* Define to 1 if you have the `atof' function. */
+#undef HAVE_ATOF
+
+/* Define to 1 if you have the `atoi' function. */
+#undef HAVE_ATOI
+
+/* Define to 1 if you have the `calloc' function. */
+#undef HAVE_CALLOC
+
+/* Define to 1 if you have the <ctype.h> header file. */
+#undef HAVE_CTYPE_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the `free' function. */
+#undef HAVE_FREE
+
+/* Define to 1 if you have the `getenv' function. */
+#undef HAVE_GETENV
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `itoa' function. */
+#undef HAVE_ITOA
+
+/* Define to 1 if you have the `asound' library (-lasound). */
+#undef HAVE_LIBASOUND
+
+/* Define to 1 if you have the `malloc' function. */
+#undef HAVE_MALLOC
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define to 1 if you have the `memcmp' function. */
+#undef HAVE_MEMCMP
+
+/* Define to 1 if you have the `memcpy' function. */
+#undef HAVE_MEMCPY
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `putenv' function. */
+#undef HAVE_PUTENV
+
+/* Define to 1 if you have the `qsort' function. */
+#undef HAVE_QSORT
+
+/* Define to 1 if you have the `realloc' function. */
+#undef HAVE_REALLOC
+
+/* Define to 1 if you have the <signal.h> header file. */
+#undef HAVE_SIGNAL_H
+
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_SNPRINTF
+
+/* Define to 1 if you have the `sscanf' function. */
+#undef HAVE_SSCANF
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#undef HAVE_STDARG_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strcat' function. */
+#undef HAVE_STRCAT
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the `strcmp' function. */
+#undef HAVE_STRCMP
+
+/* Define to 1 if you have the `strcpy' function. */
+#undef HAVE_STRCPY
+
+/* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define to 1 if you have the `stricmp' function. */
+#undef HAVE_STRICMP
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strlen' function. */
+#undef HAVE_STRLEN
+
+/* Define to 1 if you have the `strncat' function. */
+#undef HAVE_STRNCAT
+
+/* Define to 1 if you have the `strncmp' function. */
+#undef HAVE_STRNCMP
+
+/* Define to 1 if you have the `strncpy' function. */
+#undef HAVE_STRNCPY
+
+/* Define to 1 if you have the `strrchr' function. */
+#undef HAVE_STRRCHR
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* Define to 1 if you have the `strtol' function. */
+#undef HAVE_STRTOL
+
+/* Define to 1 if you have the `strtoll' function. */
+#undef HAVE_STRTOLL
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#undef HAVE_VSNPRINTF
+
+/* Define to 1 if you have the `_i64toa' function. */
+#undef HAVE__I64TOA
+
+/* Define to 1 if you have the `_ltoa' function. */
+#undef HAVE__LTOA
+
+/* Define to 1 if you have the `_strlwr' function. */
+#undef HAVE__STRLWR
+
+/* Define to 1 if you have the `_strrev' function. */
+#undef HAVE__STRREV
+
+/* Define to 1 if you have the `_strupr' function. */
+#undef HAVE__STRUPR
+
+/* Define to 1 if you have the `_ui64toa' function. */
+#undef HAVE__UI64TOA
+
+/* Define to 1 if you have the `_uitoa' function. */
+#undef HAVE__UITOA
+
+/* Define to 1 if you have the `_ultoa' function. */
+#undef HAVE__ULTOA
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of a `char', as computed by sizeof. */
+#undef SIZEOF_CHAR
+
+/* The size of a `int', as computed by sizeof. */
+#undef SIZEOF_INT
+
+/* The size of a `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
+/* The size of a `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
+/* The size of a `short', as computed by sizeof. */
+#undef SIZEOF_SHORT
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at run-time.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to 1 if the X Window System is missing or not being used. */
+#undef X_DISPLAY_MISSING
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+#undef size_t
+
+
+
+#endif /* HAVE_LIBC */
+
+#endif /* _SDL_config_h */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_config.h.minimal	Tue Feb 07 12:11:33 2006 +0000
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2006 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+#ifndef _SDL_config_h
+#define _SDL_config_h
+
+/* This is the minimal configuration that can be used to build SDL */
+
+#define HAVE_STDARG_H 1
+
+#endif /* _SDL_config_h */
--- a/include/SDL_stdlib.h	Tue Feb 07 11:18:21 2006 +0000
+++ b/include/SDL_stdlib.h	Tue Feb 07 12:11:33 2006 +0000
@@ -62,6 +62,12 @@
 extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
 #endif
 
+#ifdef HAVE_CALLOC
+#define SDL_calloc	calloc
+#else
+extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size);
+#endif
+
 #ifdef HAVE_REALLOC
 #define SDL_realloc	realloc
 #else
@@ -101,6 +107,12 @@
            int (*compare)(const void *, const void *));
 #endif
 
+#ifdef HAVE_ABS
+#define SDL_abs		abs
+#else
+#define SDL_abs(X)	((X) < 0 ? -(X) : (X))
+#endif
+
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
 }
--- a/include/SDL_string.h	Tue Feb 07 11:18:21 2006 +0000
+++ b/include/SDL_string.h	Tue Feb 07 12:11:33 2006 +0000
@@ -201,6 +201,12 @@
 #define SDL_strncat(dst, src, n) (SDL_strncpy(dst+SDL_strlen(dst), src, n), dst)
 #endif
 
+#ifdef HAVE_STRDUP
+#define SDL_strdup     strdup
+#else
+extern DECLSPEC char * SDLCALL SDL_strdup(const char *string);
+#endif
+
 #ifdef HAVE__STRREV
 #define SDL_strrev      _strrev
 #else
@@ -289,6 +295,24 @@
 
 #endif /* SDL_HAS_64BIT_TYPE */
 
+#ifdef HAVE_STRTOD
+#define SDL_strtod      strtod
+#else
+extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
+#endif
+
+#ifdef HAVE_ATOI
+#define SDL_atoi        atoi
+#else
+#define SDL_atoi(X)     SDL_strtol(X, NULL, 0)
+#endif
+
+#ifdef HAVE_ATOF
+#define SDL_atof        atof
+#else
+#define SDL_atof(X)     SDL_strtod(X, NULL)
+#endif
+
 #ifdef HAVE_STRCMP
 #define SDL_strcmp      strcmp
 #else
--- a/src/audio/SDL_audio.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/audio/SDL_audio.c	Tue Feb 07 12:11:33 2006 +0000
@@ -306,18 +306,20 @@
 		 */
 		for ( i=0; bootstrap[i]; ++i ) {
 			if ( SDL_strcmp(bootstrap[i]->name, "esd") == 0 ) {
+#ifdef HAVE_PUTENV
 				const char *esd_no_spawn;
 
 				/* Don't start ESD if it's not running */
-				esd_no_spawn = SDL_getenv("ESD_NO_SPAWN");
+				esd_no_spawn = getenv("ESD_NO_SPAWN");
 				if ( esd_no_spawn == NULL ) {
 					putenv("ESD_NO_SPAWN=1");
 				}
+#endif
 				if ( bootstrap[i]->available() ) {
 					audio = bootstrap[i]->create(0);
 					break;
 				}
-#ifdef linux	/* No unsetenv() on most platforms */
+#ifdef HAVE_UNSETENV
 				if ( esd_no_spawn == NULL ) {
 					unsetenv("ESD_NO_SPAWN");
 				}
--- a/src/audio/amigaos/SDL_ahiaudio.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/audio/amigaos/SDL_ahiaudio.c	Tue Feb 07 12:11:33 2006 +0000
@@ -22,6 +22,8 @@
 
 /* Allow access to a raw mixing buffer (for AmigaOS) */
 
+#include "SDL_stdlib.h"
+#include "SDL_string.h"
 #include "SDL_endian.h"
 #include "SDL_audio.h"
 #include "SDL_audiomem.h"
--- a/src/audio/disk/SDL_diskaudio.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/audio/disk/SDL_diskaudio.c	Tue Feb 07 12:11:33 2006 +0000
@@ -26,6 +26,7 @@
 /* Output raw audio data to a file. */
 
 #include <stdio.h>
+#include <string.h>	/* For strerror() */
 #include <errno.h>
 #include <unistd.h>
 #include <sys/stat.h>
@@ -130,7 +131,7 @@
 	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
 
     envr = SDL_getenv(DISKENVR_WRITEDELAY);
-    this->hidden->write_delay = (envr) ? atoi(envr) : DISKDEFAULT_WRITEDELAY;
+    this->hidden->write_delay = (envr) ? SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY;
 
 	/* Set the function pointers */
 	this->OpenAudio = DISKAUD_OpenAudio;
--- a/src/audio/dma/SDL_dmaaudio.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/audio/dma/SDL_dmaaudio.c	Tue Feb 07 12:11:33 2006 +0000
@@ -23,6 +23,7 @@
 /* Allow access to a raw mixing buffer */
 
 #include <stdio.h>
+#include <string.h>	/* For strerror() */
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
--- a/src/audio/dsp/SDL_dspaudio.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/audio/dsp/SDL_dspaudio.c	Tue Feb 07 12:11:33 2006 +0000
@@ -25,7 +25,8 @@
 
 /* Allow access to a raw mixing buffer */
 
-#include <stdio.h>	/* For perror() ... should we really do this? */
+#include <stdio.h>	/* For perror() */
+#include <string.h>	/* For strerror() */
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
--- a/src/audio/mme/SDL_mmeaudio.h	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/audio/mme/SDL_mmeaudio.h	Tue Feb 07 12:11:33 2006 +0000
@@ -24,6 +24,8 @@
 
 #include <mme_api.h>
 
+#include "SDL_stdlib.h"
+#include "SDL_string.h"
 #include "SDL_audio.h"
 #include "SDL_mutex.h"
 #include "SDL_timer.h"
--- a/src/cdrom/linux/SDL_syscdrom.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/cdrom/linux/SDL_syscdrom.c	Tue Feb 07 12:11:33 2006 +0000
@@ -22,6 +22,7 @@
 
 /* Functions for system-level CD-ROM audio control */
 
+#include <string.h>	/* For strerror() */
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
@@ -215,7 +216,7 @@
 				tmp = SDL_strstr(mntent->mnt_opts, "fs=");
 				if ( tmp ) {
 					SDL_free(mnt_type);
-					mnt_type = strdup(tmp + SDL_strlen("fs="));
+					mnt_type = SDL_strdup(tmp + SDL_strlen("fs="));
 					if ( mnt_type ) {
 						tmp = SDL_strchr(mnt_type, ',');
 						if ( tmp ) {
@@ -226,7 +227,7 @@
 				tmp = SDL_strstr(mntent->mnt_opts, "dev=");
 				if ( tmp ) {
 					SDL_free(mnt_dev);
-					mnt_dev = strdup(tmp + SDL_strlen("dev="));
+					mnt_dev = SDL_strdup(tmp + SDL_strlen("dev="));
 					if ( mnt_dev ) {
 						tmp = SDL_strchr(mnt_dev, ',');
 						if ( tmp ) {
--- a/src/stdlib/SDL_getenv.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/stdlib/SDL_getenv.c	Tue Feb 07 12:11:33 2006 +0000
@@ -113,11 +113,11 @@
 	}
 
 	/* Allocate memory for the variable */
-	new_variable = (char *)malloc(strlen(variable)+1);
+	new_variable = (char *)SDL_malloc(SDL_strlen(variable)+1);
 	if ( ! new_variable ) {
 		return(-1);
 	}
-	strcpy(new_variable, variable);
+	SDL_strcpy(new_variable, variable);
 
 	/* Actually put it into the environment */
 	added = 0;
@@ -126,13 +126,13 @@
 		/* Check to see if it's already there... */
 		len = (value - name);
 		for ( ; SDL_env[i]; ++i ) {
-			if ( strncmp(SDL_env[i], name, len) == 0 ) {
+			if ( SDL_strncmp(SDL_env[i], name, len) == 0 ) {
 				break;
 			}
 		}
 		/* If we found it, just replace the entry */
 		if ( SDL_env[i] ) {
-			free(SDL_env[i]);
+			SDL_free(SDL_env[i]);
 			SDL_env[i] = new_variable;
 			added = 1;
 		}
@@ -147,7 +147,7 @@
 			SDL_env[i++] = (char *)0;
 			added = 1;
 		} else {
-			free(new_variable);
+			SDL_free(new_variable);
 		}
 	}
 	return (added ? 0 : -1);
@@ -161,9 +161,9 @@
 
 	value = (char *)0;
 	if ( SDL_env ) {
-		len = strlen(name);
+		len = SDL_strlen(name);
 		for ( i=0; SDL_env[i] && !value; ++i ) {
-			if ( (strncmp(SDL_env[i], name, len) == 0) &&
+			if ( (SDL_strncmp(SDL_env[i], name, len) == 0) &&
 			     (SDL_env[i][len] == '=') ) {
 				value = &SDL_env[i][len+1];
 			}
@@ -185,59 +185,59 @@
 
 	printf("Checking for non-existent variable... ");
 	fflush(stdout);
-	if ( ! getenv("EXISTS") ) {
+	if ( ! SDL_getenv("EXISTS") ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Setting FIRST=VALUE1 in the environment... ");
 	fflush(stdout);
-	if ( putenv("FIRST=VALUE1") == 0 ) {
+	if ( SDL_putenv("FIRST=VALUE1") == 0 ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Getting FIRST from the environment... ");
 	fflush(stdout);
-	value = getenv("FIRST");
-	if ( value && (strcmp(value, "VALUE1") == 0) ) {
+	value = SDL_getenv("FIRST");
+	if ( value && (SDL_strcmp(value, "VALUE1") == 0) ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Setting SECOND=VALUE2 in the environment... ");
 	fflush(stdout);
-	if ( putenv("SECOND=VALUE2") == 0 ) {
+	if ( SDL_putenv("SECOND=VALUE2") == 0 ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Getting SECOND from the environment... ");
 	fflush(stdout);
-	value = getenv("SECOND");
-	if ( value && (strcmp(value, "VALUE2") == 0) ) {
+	value = SDL_getenv("SECOND");
+	if ( value && (SDL_strcmp(value, "VALUE2") == 0) ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Setting FIRST=NOVALUE in the environment... ");
 	fflush(stdout);
-	if ( putenv("FIRST=NOVALUE") == 0 ) {
+	if ( SDL_putenv("FIRST=NOVALUE") == 0 ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Getting FIRST from the environment... ");
 	fflush(stdout);
-	value = getenv("FIRST");
-	if ( value && (strcmp(value, "NOVALUE") == 0) ) {
+	value = SDL_getenv("FIRST");
+	if ( value && (SDL_strcmp(value, "NOVALUE") == 0) ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
 	}
 	printf("Checking for non-existent variable... ");
 	fflush(stdout);
-	if ( ! getenv("EXISTS") ) {
+	if ( ! SDL_getenv("EXISTS") ) {
 		printf("okay\n");
 	} else {
 		printf("failed\n");
--- a/src/stdlib/SDL_string.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/stdlib/SDL_string.c	Tue Feb 07 12:11:33 2006 +0000
@@ -25,6 +25,7 @@
 
 #include "SDL_types.h"
 #include "SDL_ctype.h"
+#include "SDL_stdlib.h"
 #include "SDL_string.h"
 
 
@@ -175,7 +176,7 @@
 #endif
 #endif /* SDL_HAS_64BIT_TYPE */
 
-#ifndef HAVE_SSCANF
+#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD)
 static size_t SDL_ScanFloat(const char *text, double *valuep)
 {
     const char *textstart = text;
@@ -322,6 +323,18 @@
 }
 #endif
 
+#ifndef HAVE_STRDUP
+char *SDL_strdup(const char *string)
+{
+    size_t len = SDL_strlen(string);
+    char *newstr = SDL_malloc(len+1);
+    if ( newstr ) {
+        SDL_strcpy(newstr, string);
+    }
+    return newstr;
+}
+#endif
+
 #ifndef HAVE__STRREV
 char *SDL_strrev(char *string)
 {
@@ -549,6 +562,20 @@
 
 #endif /* SDL_HAS_64BIT_TYPE */
 
+#ifndef HAVE_STRTOD
+double SDL_strtod(const char *string, char **endp)
+{
+    size_t len;
+    double value;
+
+    len = SDL_ScanFloat(string, &value);
+    if ( endp ) {
+        *endp = (char *)string + len;
+    }
+    return value;
+}
+#endif
+
 #ifndef HAVE_STRCMP
 int SDL_strcmp(const char *str1, const char *str2)
 {
--- a/src/video/SDL_video.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/video/SDL_video.c	Tue Feb 07 12:11:33 2006 +0000
@@ -798,7 +798,7 @@
 		 */
 		if ( (bpp == 16) &&
 		     (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
-		     (atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f))
+		     (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f))
 		   ) {
 			video->is_32bit = 0;
 			SDL_VideoSurface = SDL_CreateRGBSurface(
--- a/src/video/SDL_yuv.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/video/SDL_yuv.c	Tue Feb 07 12:11:33 2006 +0000
@@ -23,6 +23,7 @@
 /* This is the implementation of the YUV video surface support */
 
 #include "SDL_stdlib.h"
+#include "SDL_string.h"
 #include "SDL_video.h"
 #include "SDL_error.h"
 #include "SDL_sysvideo.h"
@@ -54,7 +55,7 @@
 	overlay = NULL;
         yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL");
 	if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) &&
-	     (!yuv_hwaccel || (*yuv_hwaccel != '0')) ) {
+	     (!yuv_hwaccel || (SDL_atoi(yuv_hwaccel) > 0)) ) {
 		overlay = video->CreateYUVOverlay(this, w, h, format, display);
 	}
 	/* If hardware YUV overlay failed ... */
--- a/src/video/fbcon/SDL_fbelo.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/video/fbcon/SDL_fbelo.c	Tue Feb 07 12:11:33 2006 +0000
@@ -92,7 +92,7 @@
 	x = ((mousebuf[4] << 8) | mousebuf[3]);
 	y = ((mousebuf[6] << 8) | mousebuf[5]);
 
-	if((abs(x - last_x) > ELO_SNAP_SIZE) || (abs(y - last_y) > ELO_SNAP_SIZE)) {
+	if((SDL_abs(x - last_x) > ELO_SNAP_SIZE) || (SDL_abs(y - last_y) > ELO_SNAP_SIZE)) {
 		*dx = ((mousebuf[4] << 8) | mousebuf[3]);
 		*dy = ((mousebuf[6] << 8) | mousebuf[5]);
 	}
@@ -335,19 +335,19 @@
 	/* try to read the calibration values */
 	buffer = SDL_getenv("SDL_ELO_MIN_X");
 	if(buffer) {
-		ELO_MIN_X = atoi(buffer);
+		ELO_MIN_X = SDL_atoi(buffer);
 	}
 	buffer = SDL_getenv("SDL_ELO_MAX_X");
 	if(buffer) {
-		ELO_MAX_X = atoi(buffer);
+		ELO_MAX_X = SDL_atoi(buffer);
 	}
 	buffer = SDL_getenv("SDL_ELO_MIN_Y");
 	if(buffer) {
-		ELO_MIN_Y = atoi(buffer);
+		ELO_MIN_Y = SDL_atoi(buffer);
 	}
 	buffer = SDL_getenv("SDL_ELO_MAX_Y");
 	if(buffer) {
-		ELO_MAX_Y = atoi(buffer);
+		ELO_MAX_Y = SDL_atoi(buffer);
 	}
 
 #ifdef DEBUG_MOUSE
--- a/src/video/fbcon/SDL_fbevents.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/video/fbcon/SDL_fbevents.c	Tue Feb 07 12:11:33 2006 +0000
@@ -351,7 +351,7 @@
 				name[0] = '\0';
 				fscanf(status, "Name: %s", name);
 				if ( SDL_strcmp(name, wanted_name) == 0 ) {
-					pid = atoi(entry->d_name);
+					pid = SDL_atoi(entry->d_name);
 				}
 				fclose(status);
 			}
--- a/src/video/fbcon/SDL_fbvideo.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/video/fbcon/SDL_fbvideo.c	Tue Feb 07 12:11:33 2006 +0000
@@ -523,7 +523,7 @@
 	{ const char *fb_accel;
 		fb_accel = SDL_getenv("SDL_FBACCEL");
 		if ( fb_accel ) {
-			finfo.accel = atoi(fb_accel);
+			finfo.accel = SDL_atoi(fb_accel);
 		}
 	}
 
--- a/src/video/nanox/SDL_nxvideo.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/video/nanox/SDL_nxvideo.c	Tue Feb 07 12:11:33 2006 +0000
@@ -68,9 +68,9 @@
     Dprintf ("enter NX_DeleteDevice\n") ;
 
     if (device) {
-        if (device -> hidden) free (device -> hidden) ;
-        if (device -> gl_data) free (device -> gl_data) ;
-            free (device) ;
+        if (device -> hidden) SDL_free (device -> hidden) ;
+        if (device -> gl_data) SDL_free (device -> gl_data) ;
+            SDL_free (device) ;
     }
 
     Dprintf ("leave NX_DeleteDevice\n") ;
@@ -256,9 +256,9 @@
         GrDestroyWindow (FSwindow) ;
     }
     NX_FreeVideoModes (this) ;
-    free (GammaRamp_R) ;
-    free (GammaRamp_G) ;
-    free (GammaRamp_B) ;
+    SDL_free (GammaRamp_R) ;
+    SDL_free (GammaRamp_G) ;
+    SDL_free (GammaRamp_B) ;
 
 #ifdef ENABLE_NANOX_DIRECT_FB
     if (Clientfb)
@@ -306,7 +306,7 @@
 
     // See if we have been given a window id
     if (SDL_windowid) {
-        SDL_Window = strtol (SDL_windowid, NULL, 0) ;
+        SDL_Window = SDL_strtol (SDL_windowid, NULL, 0) ;
     } else {
         SDL_Window = 0 ;
     }
--- a/src/video/wincommon/SDL_sysevents.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/video/wincommon/SDL_sysevents.c	Tue Feb 07 12:11:33 2006 +0000
@@ -798,7 +798,7 @@
 	int	cp = GetACP();
 
 	if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) {
-		cp = SDL_strtol(buff, NULL, 0);
+		cp = SDL_atoi(buff);
 	}
 	return cp;
 }