diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 26fb99b14..46b89e9af 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.4: +- The unix build script is now able to detect SDL on Darwin (bug #358) - SvdB - Resource units given more obviously when ordering a probe to self-destruct (bug #586), from Nic. - Shipyard "Combat Energy" changed to reflect the recharge rate (bug #522). diff --git a/sc2/build/unix/build.docs b/sc2/build/unix/build.docs index 0e181f8c2..51a0739f3 100644 --- a/sc2/build/unix/build.docs +++ b/sc2/build/unix/build.docs @@ -124,6 +124,9 @@ Information about programs used should be supplied in the following form: 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 used to check for the program in the path. + This command may include a shell command that modifies any of the + variables PROG_${PROGRAM}_FILE, PROG_${PROGRAM}_ACTION, or + PROG_${PROGRAM}_VERSION. - PROG_${PROGRAM}_VERSION (optional) A string that evaluates to the version of the executable that is present, if it is present. @@ -150,10 +153,13 @@ Information about libraries used should be supplied in the following form: on the system, or 1 otherwise. If not supplied, 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 + variables PROG_${LIB}_FILE, PROG_${LIB}_ACTION, or + PROG_${LIB}_VERSION. - LIB_${LIB}_VERSION (optional) A string that evaluates to the version of the library that is present, if it is present. - - LIB_${PROGRAM}_PRESENT (set by the configuration program) + - LIB_${LIB}_PRESENT (set by the configuration program) 0 if the library has been verified to be present 1 if the library has been verified to be not present if the library hasn't been verified to be present diff --git a/sc2/build/unix/config_functions b/sc2/build/unix/config_functions index aab3b6f00..cebf273a4 100644 --- a/sc2/build/unix/config_functions +++ b/sc2/build/unix/config_functions @@ -107,14 +107,27 @@ lexlt() { # Description: check if a program is present in the path # Arguments: have_program() { - local TEMP_NAME TEMP_FILE TEMP_VERSION + local PROG TEMP_NAME TEMP_FILE TEMP_VERSION TEMP_DETECT - eval eval TEMP_NAME="\\\"\$PROG_${1}_NAME\\\"" + PROG="$1" + eval eval TEMP_NAME="\\\"\$PROG_${PROG}_NAME\\\"" if [ -z "$TEMP_NAME" ]; then - echo "Fatal: Program '$1' is not defined!" >&2 + echo "Fatal: Program '$PROG' is not defined!" >&2 exit 1 fi - eval eval TEMP_FILE="\\\"\$PROG_${1}_FILE\\\"" + + eval eval TEMP_DETECT="\\\"\$PROG_${PROG}_DETECT\\\"" + if [ -n "$TEMP_DETECT" ]; then + $TEMP_DETECT + # NB. TEMP_DETECT should make sure PROG_${PROG}_VERSION and + # PROG_${PROG}_FILE are set. + if [ $? -ne 0 ]; then + build_message "$TEMP_NAME not found." + return 1 + fi + fi + + eval eval TEMP_FILE="\\\"\$PROG_${PROG}_FILE\\\"" type "$TEMP_FILE" 2>&1 > /dev/null if [ $? -ne 0 ]; then @@ -124,7 +137,7 @@ have_program() { if [ $# -gt 1 ]; then # Minimum version supplied - eval eval TEMP_VERSION="\\\"\$PROG_${1}_VERSION\\\"" + eval eval TEMP_VERSION="\\\"\$PROG_${PROG}_VERSION\\\"" if [ -z "$TEMP_VERSION" ]; then echo "Fatal: Could not determine version of $TEMP_NAME" >&2 exit 1 @@ -152,7 +165,7 @@ but version $2 is required!" # 1 - if the library is not found have_library() { local LIB TEMP_NAME TEMP_PRESENT TEMP_LDFLAGS TEMP_CFLAGS \ - TEMP_VERSION + TEMP_VERSION TEMP_DETECT LIB="$1" eval eval TEMP_NAME="\\\"\$LIB_${1}_NAME\\\"" @@ -165,23 +178,31 @@ have_library() { if [ -n "$TEMP_PRESENT" ]; then return "$TEMP_PRESENT" fi + + eval eval TEMP_DETECT="\\\"\$LIB_${LIB}_DETECT\\\"" + if [ -n "$TEMP_DETECT" ]; then + $TEMP_DETECT + # NB. TEMP_DETECT should make sure PROG_$LIB_VERSION is set. + # return value of $TEMP_DETECT is used below. + else + eval eval TEMP_LDFLAGS="\\\"\$LIB_${LIB}_LDFLAGS\\\"" + eval eval TEMP_CFLAGS="\\\"\$LIB_${LIB}_CFLAGS\\\"" - eval eval TEMP_LDFLAGS="\\\"\$LIB_${LIB}_LDFLAGS\\\"" - eval eval TEMP_CFLAGS="\\\"\$LIB_${LIB}_CFLAGS\\\"" - - try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF + try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF int main(int argc, char *argv[]) { (void) argc; /* Get rid of unused variable warning */ (void) argv; /* Get rid of unused variable warning */ return 0; } EOF + fi # TEMP_DETECT not defined + if [ $? -ne 0 ]; then eval "LIB_${LIB}_PRESENT"=1 build_message "$TEMP_NAME not found." return 1 fi - + if [ $# -gt 1 ]; then # Minimum version supplied eval eval TEMP_VERSION="\\\"\$LIB_${LIB}_VERSION\\\"" diff --git a/sc2/build/unix/config_proginfo b/sc2/build/unix/config_proginfo index 92ac22788..5b1286e7c 100644 --- a/sc2/build/unix/config_proginfo +++ b/sc2/build/unix/config_proginfo @@ -76,6 +76,24 @@ case "$OSNAME" in FreeBSD) LIB_SDL_VERSION='$(sdl11-config --version)' ;; *) LIB_SDL_VERSION='$(sdl-config --version)' ;; esac +case "$OSNAME" in + Darwin) + LIB_SDL_DETECT="Darwin_SDL_detect" + Darwin_SDL_detect() { + eval TEMP_LDFLAGS="\"$LIB_SDL_LDFLAGS\"" + eval TEMP_CFLAGS="\"$LIB_SDL_CFLAGS\"" + try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF +#include "SDL.h" +int main(int argc, char *argv[]) { + (void) argc; /* Get rid of unused variable warning */ + (void) argv; /* Get rid of unused variable warning */ + return 0; +} +EOF + return $? + } + ;; +esac LIB_SDL_mixer_NAME="SDL_mixer" LIB_SDL_mixer_CFLAGS="$LIB_SDL_CFLAGS"