Fix SDL detection.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1671 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2005-04-23 23:23:16 +00:00
parent a9080b7a49
commit cad8f6f54d
17 changed files with 104 additions and 47 deletions
+6 -4
View File
@@ -122,7 +122,8 @@ Information about programs used should be supplied in the following form:
done configuring. done configuring.
- PROG_${PROGRAM}_DETECT (optional) - PROG_${PROGRAM}_DETECT (optional)
A command to be executed which should return 0 if the program is present A command to be executed which should return 0 if the program is present
on the system, or 1 otherwise. If not supplied, 'type' is on the system, 1 if it is not present, or 2 to fallback to the default
detection. If no detect function was set, or it returned 2, 'type' is
used to check for the program in the path. used to check for the program in the path.
This command may include a shell command that modifies any of the This command may include a shell command that modifies any of the
variables PROG_${PROGRAM}_FILE, PROG_${PROGRAM}_ACTION, or variables PROG_${PROGRAM}_FILE, PROG_${PROGRAM}_ACTION, or
@@ -156,9 +157,10 @@ Information about libraries used should be supplied in the following form:
is used. is used.
- PROG_${LIB}_DETECT (optional) - PROG_${LIB}_DETECT (optional)
A command to be executed which should return 0 if the library is present A command to be executed which should return 0 if the library is present
on the system, or 1 otherwise. If not supplied, an attempt is on the system, 1 if it is not present, or 2 to fallback to the default
made to compile and link an empty C program with the flags as in detection. If no detect function was set, or it returned 2,
LIB_${LIB}_CFLAGS and LIB_${LIB}_LDFLAGS. an attempt is made to compile and link an empty C program with
the flags as in LIB_${LIB}_CFLAGS and LIB_${LIB}_LDFLAGS.
This command may include a shell command that modifies any of the This command may include a shell command that modifies any of the
variables PROG_${LIB}_CFLAGS, PROG_${LIB}_LDFLAGS, or variables PROG_${LIB}_CFLAGS, PROG_${LIB}_LDFLAGS, or
PROG_${LIB}_VERSION. PROG_${LIB}_VERSION.
+48 -16
View File
@@ -194,17 +194,30 @@ have_program() {
$TEMP_DETECT $TEMP_DETECT
# NB. TEMP_DETECT should make sure PROG_${PROG}_VERSION and # NB. TEMP_DETECT should make sure PROG_${PROG}_VERSION and
# PROG_${PROG}_FILE are set. # PROG_${PROG}_FILE are set.
if [ $? -ne 0 ]; then case $? in
eval "PROG_${PROG}_PRESENT"=1 0) # Program found
build_message "$TEMP_NAME not found." eval "PROG_${PROG}_PRESENT"=0
return 1 ;;
fi 1) # Lib not found
eval "PROG_${PROG}_PRESENT"=1
;;
2) # Use default detection
;;
esac
fi fi
TEMP_FILE=`evalVar PROG_${PROG}_FILE` eval TEMP_PRESENT="\$PROG_${PROG}_PRESENT"
if [ -z "$TEMP_PRESENT" ]; then
type "${TEMP_FILE%% *}" > /dev/null 2>&1 TEMP_FILE=`evalVar PROG_${PROG}_FILE`
if [ $? -ne 0 ]; then type "${TEMP_FILE%% *}" > /dev/null 2>&1
if [ $? -eq 0 ]; then
# Program found
eval "PROG_${PROG}_PRESENT"=0
fi
fi
eval TEMP_PRESENT="\$PROG_${PROG}_PRESENT"
if [ -z "$TEMP_PRESENT" ]; then
eval "PROG_${PROG}_PRESENT"=1 eval "PROG_${PROG}_PRESENT"=1
build_message "$TEMP_NAME not found." build_message "$TEMP_NAME not found."
return 1 return 1
@@ -262,14 +275,27 @@ have_library() {
TEMP_DETECT=`evalVar LIB_${LIB}_DETECT` TEMP_DETECT=`evalVar LIB_${LIB}_DETECT`
if [ -n "$TEMP_DETECT" ]; then if [ -n "$TEMP_DETECT" ]; then
$TEMP_DETECT
TEMP_DEPEND_PROG=`evalVar LIB_${LIB}_DEPEND_DETECT_PROG` TEMP_DEPEND_PROG=`evalVar LIB_${LIB}_DEPEND_DETECT_PROG`
TEMP_DEPEND_LIB=`evalVar LIB_${LIB}_DEPEND_DETECT_LIB` TEMP_DEPEND_LIB=`evalVar LIB_${LIB}_DEPEND_DETECT_LIB`
detect_dependencies_program "$TEMP_DEPEND_PROG" detect_dependencies_program "$TEMP_DEPEND_PROG"
detect_dependencies_library "$TEMP_DEPEND_LIB" detect_dependencies_library "$TEMP_DEPEND_LIB"
$TEMP_DETECT
# NB. TEMP_DETECT should make sure PROG_$LIB_VERSION is set. # NB. TEMP_DETECT should make sure PROG_$LIB_VERSION is set.
# return value of $TEMP_DETECT is used below. # return value of $TEMP_DETECT is used below.
else case $? in
0) # Lib found
eval "LIB_${LIB}_PRESENT"=0
;;
1) # Lib not found
eval "LIB_${LIB}_PRESENT"=1
;;
2) # Use default detection
;;
esac
fi
eval TEMP_PRESENT="\$LIB_${LIB}_PRESENT"
if [ -z "$TEMP_PRESENT" ]; then
TEMP_CFLAGS=`evalVar LIB_${LIB}_CFLAGS` TEMP_CFLAGS=`evalVar LIB_${LIB}_CFLAGS`
TEMP_LDFLAGS=`evalVar LIB_${LIB}_LDFLAGS` TEMP_LDFLAGS=`evalVar LIB_${LIB}_LDFLAGS`
@@ -280,9 +306,14 @@ int main(int argc, char *argv[]) {
return 0; return 0;
} }
EOF EOF
fi # TEMP_DETECT not defined if [ $? -eq 0 ]; then
# Build successful
eval "LIB_${LIB}_PRESENT"=0
fi
fi
if [ $? -ne 0 ]; then eval TEMP_PRESENT="\$LIB_${LIB}_PRESENT"
if [ -z "$TEMP_PRESENT" ]; then
eval "LIB_${LIB}_PRESENT"=1 eval "LIB_${LIB}_PRESENT"=1
build_message "$TEMP_NAME not found." build_message "$TEMP_NAME not found."
return 1 return 1
@@ -548,7 +579,7 @@ try_pkgconfig_prog() {
eval PROG_${PROG}_VERSION=\$TEMP_VERSION eval PROG_${PROG}_VERSION=\$TEMP_VERSION
return 0 return 0
else else
return 1 return 2
fi fi
} }
@@ -582,9 +613,10 @@ try_pkgconfig_lib() {
eval LIB_${LIB}_VERSION=\$TEMP_VERSION eval LIB_${LIB}_VERSION=\$TEMP_VERSION
eval LIB_${LIB}_CFLAGS=\$TEMP_CFLAGS eval LIB_${LIB}_CFLAGS=\$TEMP_CFLAGS
eval LIB_${LIB}_LDFLAGS=\$TEMP_LDFLAGS eval LIB_${LIB}_LDFLAGS=\$TEMP_LDFLAGS
return 0 return 2 # Force testing using the new CFLAGS and LDFLAGS
#return 0
else else
return 1 return 2
fi fi
} }
+7 -3
View File
@@ -132,7 +132,7 @@ case "$OSNAME" in
LIB_SDL_VERSION='$(sdl11-config --version)' LIB_SDL_VERSION='$(sdl11-config --version)'
;; ;;
Darwin) Darwin)
LIB_SDL_CFLAGS='-I/System/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/SDL.framework/Headers -I$HOME/Library/Frameworks/SDL.framework/Headers' LIB_SDL_CFLAGS=''
LIB_SDL_LDFLAGS='-framework SDL -framework Cocoa -lobjc' LIB_SDL_LDFLAGS='-framework SDL -framework Cocoa -lobjc'
LIB_SDL_VERSION=$(echo \ LIB_SDL_VERSION=$(echo \
"SDL_MAJOR_VERSION.SDL_MINOR_VERSION.SDL_PATCHLEVEL" | \ "SDL_MAJOR_VERSION.SDL_MINOR_VERSION.SDL_PATCHLEVEL" | \
@@ -158,7 +158,7 @@ LIB_SDL_mixer_VERSION=""
LIB_SDL_image_NAME="SDL_image" LIB_SDL_image_NAME="SDL_image"
case "$OSNAME" in case "$OSNAME" in
Darwin) Darwin)
LIB_SDL_image_CFLAGS='-I/System/Library/Frameworks/SDL_image.framework/Headers -I/Library/Frameworks/SDL_image.framework/Headers -I$HOME/Library/Frameworks/SDL_image.framework/Headers' LIB_SDL_image_CFLAGS=''
LIB_SDL_image_LDFLAGS="-framework SDL_image" LIB_SDL_image_LDFLAGS="-framework SDL_image"
;; ;;
*) *)
@@ -176,9 +176,13 @@ case "$OSNAME" in
FreeBSD|OpenBSD) FreeBSD|OpenBSD)
LIB_openal_LDFLAGS="-L/usr/local/lib -pthread -lopenal" LIB_openal_LDFLAGS="-L/usr/local/lib -pthread -lopenal"
;; ;;
MINGW32*) MINGW32*)
LIB_openal_LDFLAGS="-lopenal32" LIB_openal_LDFLAGS="-lopenal32"
;; ;;
Darwin)
LIB_openal_CFLAGS=''
LIB_openal_LDFLAGS="-framework OpenAL"
;;
*) *)
LIB_openal_LDFLAGS="-lopenal" LIB_openal_LDFLAGS="-lopenal"
;; ;;
+14
View File
@@ -137,6 +137,20 @@ iswgraph(wint_t wc)
} }
#endif #endif
// Use SDL_INCLUDE to portably include the SDL files from the right
// location. TODO: Where SDL_H is located could be detected from the build
// script.
#ifdef APPLE
# define HAVE_SDL_SDL_H
#else
# define HAVE_SDL_H
#endif
#ifdef HAVE_SDL_H
# define SDL_INCLUDE(file) <file>
#elif defined(HAVE_SDL_SDL_H)
# define SDL_INCLUDE(file) <SDL/file>
#endif
#endif /* _PORT_H */ #endif /* _PORT_H */
+2 -1
View File
@@ -1,4 +1,5 @@
#include "SDL.h" #include "port.h"
#include SDL_INCLUDE(SDL.h)
#include "bbox.h" #include "bbox.h"
TFB_BoundingBox TFB_BBox; TFB_BoundingBox TFB_BBox;
+2 -1
View File
@@ -1,4 +1,5 @@
#include "SDL.h" #include "port.h"
#include SDL_INCLUDE(SDL.h)
#include "sdl_common.h" #include "sdl_common.h"
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#include "libs/graphics/sdl/primitives.h" #include "libs/graphics/sdl/primitives.h"
+2 -1
View File
@@ -18,7 +18,8 @@
#define M_PI 3.141592654 #define M_PI 3.141592654
#endif #endif
#include "SDL.h" #include "port.h"
#include SDL_INCLUDE(SDL.h)
/* ---- Defines */ /* ---- Defines */
@@ -19,9 +19,10 @@
#ifndef SDL_COMMON_H #ifndef SDL_COMMON_H
#define SDL_COMMON_H #define SDL_COMMON_H
#include "SDL.h" #include "port.h"
#include "SDL_image.h" #include SDL_INCLUDE(SDL.h)
#include "SDL_byteorder.h" #include SDL_INCLUDE(SDL_image.h)
#include SDL_INCLUDE(SDL_byteorder.h)
#include "libs/graphics/gfxintrn.h" #include "libs/graphics/gfxintrn.h"
#include "libs/graphics/tfb_draw.h" #include "libs/graphics/tfb_draw.h"
+4 -4
View File
@@ -2,10 +2,10 @@
#include "port.h" #include "port.h"
#include "libs/uio.h" #include "libs/uio.h"
#include "SDL.h" #include SDL_INCLUDE(SDL.h)
#include "SDL_image.h" #include SDL_INCLUDE(SDL_image.h)
#include "SDL_error.h" #include SDL_INCLUDE(SDL_error.h)
#include "SDL_rwops.h" #include SDL_INCLUDE(SDL_rwops.h)
#include "libs/misc.h" #include "libs/misc.h"
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
+2 -2
View File
@@ -3,8 +3,8 @@
#include "port.h" #include "port.h"
#include "libs/uio.h" #include "libs/uio.h"
#include "SDL.h" #include SDL_INCLUDE(SDL.h)
#include "SDL_rwops.h" #include SDL_INCLUDE(SDL_rwops.h)
SDL_Surface *sdluio_loadImage (uio_DirHandle *dir, const char *fileName); SDL_Surface *sdluio_loadImage (uio_DirHandle *dir, const char *fileName);
int sdluio_seek (SDL_RWops *context, int offset, int whence); int sdluio_seek (SDL_RWops *context, int offset, int whence);
+2 -2
View File
@@ -1,7 +1,7 @@
#include <SDL.h> #include "port.h"
#include SDL_INCLUDE(SDL.h)
#include <string.h> #include <string.h>
#include "keynames.h" #include "keynames.h"
#include "port.h"
/* This code is adapted from the code in SDL_keysym.h. Though this /* This code is adapted from the code in SDL_keysym.h. Though this
* would almost certainly be fast if we were to use a direct char * * would almost certainly be fast if we were to use a direct char *
+2 -2
View File
@@ -1,11 +1,11 @@
#include <SDL.h> #include "port.h"
#include SDL_INCLUDE(SDL.h)
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "vcontrol.h" #include "vcontrol.h"
#include "vcontrol_malloc.h" #include "vcontrol_malloc.h"
#include "keynames.h" #include "keynames.h"
#include "port.h"
/* How many binding slots are allocated at once. */ /* How many binding slots are allocated at once. */
#define POOL_CHUNK_SIZE 64 #define POOL_CHUNK_SIZE 64
+1 -2
View File
@@ -1,10 +1,9 @@
#include <SDL.h>
#ifndef _VCONTROL_H_ #ifndef _VCONTROL_H_
#define _VCONTROL_H_ #define _VCONTROL_H_
#include "port.h" #include "port.h"
#include "libs/uio.h" #include "libs/uio.h"
#include SDL_INCLUDE(SDL.h)
/* Initialization routines */ /* Initialization routines */
void VControl_Init (void); void VControl_Init (void);
@@ -20,10 +20,10 @@
#ifndef _AUDIODRV_SDL_H #ifndef _AUDIODRV_SDL_H
#define _AUDIODRV_SDL_H #define _AUDIODRV_SDL_H
#include "config.h" #include "port.h"
#include "libs/sound/sound.h" #include "libs/sound/sound.h"
#include "libs/sound/mixer/mixer.h" #include "libs/sound/mixer/mixer.h"
#include <SDL.h> #include SDL_INCLUDE(SDL.h)
/* General */ /* General */
sint32 mixSDL_Init (audio_Driver *driver, sint32 flags); sint32 mixSDL_Init (audio_Driver *driver, sint32 flags);
@@ -20,8 +20,9 @@
#ifndef _SDLTHREAD_H #ifndef _SDLTHREAD_H
#define _SDLTHREAD_H #define _SDLTHREAD_H
#include "SDL.h" #include "port.h"
#include "SDL_thread.h" #include SDL_INCLUDE(SDL.h)
#include SDL_INCLUDE(SDL_thread.h)
#include "libs/threadlib.h" #include "libs/threadlib.h"
#include "libs/timelib.h" #include "libs/timelib.h"
+2 -1
View File
@@ -20,7 +20,8 @@
#ifndef _SDLTIME_H #ifndef _SDLTIME_H
#define _SDLTIME_H #define _SDLTIME_H
#include "SDL.h" #include "port.h"
#include SDL_INCLUDE(SDL.h)
#include "../timecommon.h" #include "../timecommon.h"
#define NativeInitTimeSystem() #define NativeInitTimeSystem()
+1 -1
View File
@@ -43,7 +43,7 @@
#if defined(GFXMODULE_SDL) #if defined(GFXMODULE_SDL)
# include <SDL.h> # include SDL_INCLUDE(SDL.h)
// Including this is actually necessary on OSX. // Including this is actually necessary on OSX.
#endif #endif