Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Started the process of improving configure support, and merging C types
and library support into a single header.
  • Loading branch information
slouken committed Feb 9, 2006
1 parent 60cb6dc commit 1af3eec
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 643 deletions.
90 changes: 65 additions & 25 deletions configure.in
@@ -1,6 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(README)
AC_CONFIG_HEADER(include/SDL_config.h)
AC_GNU_SOURCE

dnl Set various version strings - taken gratefully from the GTk sources
#
Expand Down Expand Up @@ -53,11 +54,8 @@ AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AC_PROG_MAKE_SET
AC_PROG_CC
AC_C_INLINE
AC_C_CONST
AC_PROG_CXX
AC_PROG_INSTALL
AC_FUNC_ALLOCA
ASFLAGS=""
AC_SUBST(ASFLAGS)
CCAS="$CC"
Expand Down Expand Up @@ -122,34 +120,76 @@ 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.
dnl Check for compiler characteristics
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE

dnl Check for header files
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h inttypes.h stdint.h ctype.h signal.h)

dnl Check for typedefs, structures, etc.
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)
if test x$ac_cv_header_inttypes_h = xyes -o x$ac_cv_header_stdint_h = xyes; then
AC_CHECK_TYPE(int64_t)
if test x$ac_cv_type_int64_t = xyes; then
AC_DEFINE(SDL_HAS_64BIT_TYPE)
fi
else
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)
if test x$ac_cv_sizeof_char = x1; then
AC_DEFINE(int8_t, signed char)
AC_DEFINE(uint8_t, unsigned char)
fi
if test x$ac_cv_sizeof_short = x2; then
AC_DEFINE(int16_t, signed short)
AC_DEFINE(uint16_t, unsigned short)
else
if test x$ac_cv_sizeof_int = x2; then
AC_DEFINE(int16_t, signed int)
AC_DEFINE(uint16_t, unsigned int)
fi
fi
if test x$ac_cv_sizeof_int = x4; then
AC_DEFINE(int32_t, signed int)
AC_DEFINE(uint32_t, unsigned int)
else
if test x$ac_cv_sizeof_long = x4; then
AC_DEFINE(int32_t, signed long)
AC_DEFINE(uint32_t, unsigned long)
fi
fi
if test x$ac_cv_sizeof_long = x8; then
AC_DEFINE(int64_t, signed long)
AC_DEFINE(uint64_t, unsigned long)
AC_DEFINE(SDL_HAS_64BIT_TYPE)
else
if test x$ac_cv_sizeof_long_long = x8; then
AC_DEFINE(int64_t, signed long long)
AC_DEFINE(uint64_t, unsigned long long)
AC_DEFINE(SDL_HAS_64BIT_TYPE)
fi
fi
AC_CHECK_TYPE(uintptr_t, unsigned long)
fi

dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(malloc calloc realloc free)
AC_CHECK_FUNCS(getenv putenv unsetenv 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 strtod atoi atof)
AC_CHECK_FUNCS(strcmp strncmp stricmp strcasecmp)
AC_CHECK_FUNCS(sscanf snprintf vsnprintf)
AC_FUNC_MEMCMP
if test x$ac_cv_func_memcmp_working = xyes; then
AC_DEFINE(HAVE_MEMCMP)
fi
AC_FUNC_STRTOD
if test x$ac_cv_func_strtod = xyes; then
AC_DEFINE(HAVE_STRTOD)
fi
AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strcpy strncpy strcat strncat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol _i64toa _ui64toa strtoll atoi atof strcmp strncmp stricmp strcasecmp sscanf snprintf vsnprint)


dnl Initialize the compiler and linker flags for SDL applications

Expand Down
6 changes: 2 additions & 4 deletions include/SDL.h
Expand Up @@ -25,10 +25,8 @@
#ifndef _SDL_H
#define _SDL_H

#include "SDL_config.h"
#include "SDL_stdinc.h"
#include "SDL_main.h"
#include "SDL_types.h"
#include "SDL_getenv.h"
#include "SDL_error.h"
#include "SDL_rwops.h"
#include "SDL_timer.h"
Expand All @@ -37,9 +35,9 @@
#include "SDL_joystick.h"
#include "SDL_events.h"
#include "SDL_video.h"
#include "SDL_loadso.h"
#include "SDL_byteorder.h"
#include "SDL_version.h"
#include "SDL_loadso.h"

#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
Expand Down
4 changes: 4 additions & 0 deletions include/SDL_active.h
Expand Up @@ -25,6 +25,9 @@
#ifndef _SDL_active_h
#define _SDL_active_h

#include "SDL_stdinc.h"

#ifndef DISABLE_EVENTS
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Expand All @@ -51,5 +54,6 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
}
#endif
#include "close_code.h"
#endif /* !DISABLE_EVENTS */

#endif /* _SDL_active_h */
4 changes: 3 additions & 1 deletion include/SDL_audio.h
Expand Up @@ -25,12 +25,13 @@
#ifndef _SDL_audio_h
#define _SDL_audio_h

#include "SDL_stdinc.h"
#include "SDL_main.h"
#include "SDL_types.h"
#include "SDL_error.h"
#include "SDL_rwops.h"
#include "SDL_byteorder.h"

#ifndef DISABLE_AUDIO
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Expand Down Expand Up @@ -248,5 +249,6 @@ extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
}
#endif
#include "close_code.h"
#endif /* !DISABLE_AUDIO */

#endif /* _SDL_audio_h */
26 changes: 6 additions & 20 deletions include/SDL_byteorder.h
Expand Up @@ -25,38 +25,24 @@
#ifndef _SDL_byteorder_h
#define _SDL_byteorder_h

#include "SDL_config.h"

/* The two types of endianness */
#define SDL_LIL_ENDIAN 1234
#define SDL_BIG_ENDIAN 4321

#ifdef __linux__
# include <endian.h>
# if BYTE_ORDER == LITTLE_ENDIAN
# define SDL_BYTEORDER SDL_LIL_ENDIAN
# else
# define SDL_BYTEORDER SDL_BIG_ENDIAN
# endif

#else

/* Pardon the mess, I'm trying to determine the endianness of this host.
I'm doing it by preprocessor defines rather than some sort of configure
script so that application code can use this too. The "right" way would
be to dynamically generate this file on install, but that's a lot of work.
*/
#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
#if (defined(__i386__) || defined(__i386)) || \
defined(__ia64__) || defined(WIN32) || \
defined(__ia64__) || defined(__x86_64__) || \
(defined(__alpha__) || defined(__alpha)) || \
(defined(__arm__) || defined(__thumb__)) || \
(defined(__sh__) || defined(__sh64__)) || \
(defined(__mips__) && defined(__MIPSEL__)) || \
defined(__SYMBIAN32__) || defined(__x86_64__) || \
defined(__OS2__) || defined(__LITTLE_ENDIAN__)
defined(__SYMBIAN32__) || defined(__OS2__)
#define SDL_BYTEORDER SDL_LIL_ENDIAN
#else
#define SDL_BYTEORDER SDL_BIG_ENDIAN
#endif

#endif /* __linux__ */
#endif /* !SDL_BYTEORDER */

#endif /* _SDL_byteorder_h */
4 changes: 3 additions & 1 deletion include/SDL_cdrom.h
Expand Up @@ -25,8 +25,9 @@
#ifndef _SDL_cdrom_h
#define _SDL_cdrom_h

#include "SDL_types.h"
#include "SDL_stdinc.h"

#ifndef DISABLE_CDROM
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Expand Down Expand Up @@ -166,5 +167,6 @@ extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom);
}
#endif
#include "close_code.h"
#endif /* !DISABLE_CDROM */

#endif /* _SDL_video_h */
11 changes: 10 additions & 1 deletion include/SDL_config.h
Expand Up @@ -25,6 +25,15 @@

/* This is the minimal configuration that can be used to build SDL */

#define HAVE_STDARG_H 1
#include <stdarg.h>

typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned int size_t;
typedef unsigned long uintptr_t;

#endif /* _SDL_config_h */
51 changes: 43 additions & 8 deletions include/SDL_config.h.in
Expand Up @@ -25,23 +25,44 @@

/* This is a set of defines to configure the SDL features */

#undef HAVE_STDARG_H
/* C language features */
#undef const
#undef inline
#undef volatile

/* C datatypes */
#undef size_t
#undef int8_t
#undef uint8_t
#undef int16_t
#undef uint16_t
#undef int32_t
#undef uint32_t
#undef SDL_HAS_64BIT_TYPE
#undef int64_t
#undef uint64_t
#undef uintptr_t

/* Comment this if you want to build without any libc requirements */
/* Comment this if you want to build without any C library requirements */
#undef HAVE_LIBC
#ifdef HAVE_LIBC

/* Various C library headers */
/* Useful headers */
#undef HAVE_SYS_TYPES_H
#undef HAVE_STDIO_H
#undef STDC_HEADERS
#undef HAVE_STDLIB_H
#undef HAVE_STDARG_H
#undef HAVE_MALLOC_H
#undef HAVE_MEMORY_H
#undef HAVE_STRING_H
#undef HAVE_STRINGS_H
#undef HAVE_INTTYPES_H
#undef HAVE_STDINT_H
#undef HAVE_CTYPE_H
#ifndef _WIN32_WCE
#undef HAVE_SIGNAL_H
#endif /* !_WIN32_WCE */

/* Features provided by SDL_stdlib.h */
/* C library functions */
#undef HAVE_MALLOC
#undef HAVE_CALLOC
#undef HAVE_REALLOC
Expand All @@ -54,8 +75,7 @@
#endif
#undef HAVE_QSORT
#undef HAVE_ABS

/* Features provided by SDL_string.h */
#undef HAVE_BCOPY
#undef HAVE_MEMSET
#undef HAVE_MEMCPY
#undef HAVE_MEMMOVE
Expand All @@ -69,6 +89,8 @@
#undef HAVE__STRREV
#undef HAVE__STRUPR
#undef HAVE__STRLWR
#undef HAVE_INDEX
#undef HAVE_RINDEX
#undef HAVE_STRCHR
#undef HAVE_STRRCHR
#undef HAVE_STRSTR
Expand All @@ -93,4 +115,17 @@

#endif /* HAVE_LIBC */


/* Allow disabling of core subsystems */
#undef DISABLE_AUDIO
#undef DISABLE_VIDEO
#undef DISABLE_EVENTS
#undef DISABLE_JOYSTICK
#undef DISABLE_CDROM
#undef DISABLE_THREADS
#undef DISABLE_TIMERS
#undef DISABLE_ENDIAN
#undef DISABLE_FILE
#undef DISABLE_CPUINFO

#endif /* _SDL_config_h */
11 changes: 10 additions & 1 deletion include/SDL_config.h.minimal
Expand Up @@ -25,6 +25,15 @@

/* This is the minimal configuration that can be used to build SDL */

#define HAVE_STDARG_H 1
#include <stdarg.h>

typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned int size_t;
typedef unsigned long uintptr_t;

#endif /* _SDL_config_h */
4 changes: 4 additions & 0 deletions include/SDL_cpuinfo.h
Expand Up @@ -23,9 +23,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* CPU feature detection for SDL */

#include "SDL_stdinc.h"

#ifndef _SDL_cpuinfo_h
#define _SDL_cpuinfo_h

#ifndef DISABLE_CPUINFO
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Expand Down Expand Up @@ -69,5 +72,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec();
}
#endif
#include "close_code.h"
#endif /* !DISABLE_CPUINFO */

#endif /* _SDL_cpuinfo_h */

0 comments on commit 1af3eec

Please sign in to comment.