Mac OS X fat build works! :)
authorSam Lantinga <slouken@libsdl.org>
Sat, 22 Apr 2006 19:17:14 +0000
changeset 16489f59d4c5aaea
parent 1647 2af911d41a08
child 1649 9705d5d69691
Mac OS X fat build works! :)
build-scripts/fatbuild.sh
configure.in
src/loadso/macosx/SDL_sysloadso.c
src/video/quartz/SDL_QuartzVideo.h
src/video/quartz/SDL_QuartzYUV.m
src/video/x11/SDL_x11dyn.c
     1.1 --- a/build-scripts/fatbuild.sh	Thu Apr 20 16:33:51 2006 +0000
     1.2 +++ b/build-scripts/fatbuild.sh	Sat Apr 22 19:17:14 2006 +0000
     1.3 @@ -3,24 +3,28 @@
     1.4  # Build a fat binary on Mac OS X, thanks Ryan!
     1.5  
     1.6  # PowerPC compiler flags (10.2 runtime compatibility)
     1.7 -CFLAGS_PPC="-arch ppc \
     1.8 +CC_PPC="gcc-3.3"
     1.9 +CFLAGS_PPC="-arch ppc"
    1.10 +CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
    1.11 +-nostdinc \
    1.12  -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
    1.13 --I/Developer/SDKs/MacOSX10.2.8.sdk/Developer/Headers/FlatCarbon \
    1.14 --DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
    1.15  -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
    1.16 --I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++ \
    1.17 --I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin \
    1.18  -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
    1.19  
    1.20  # PowerPC linker flags 
    1.21 -LFLAGS_PPC="-arch ppc -mmacosx-version-min=10.2 \
    1.22 +LFLAGS_PPC="-arch ppc \
    1.23  -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
    1.24  -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
    1.25  -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
    1.26  
    1.27  # Intel compiler flags (10.4 runtime compatibility)
    1.28 -CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
    1.29 --DMAC_OS_X_VERSION_MIN_REQUIRED=1040 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
    1.30 +CC_X86="gcc-4.0"
    1.31 +CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4"
    1.32 +CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
    1.33 +-nostdinc \
    1.34 +-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
    1.35 +-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
    1.36 +-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
    1.37  
    1.38  # Intel linker flags
    1.39  LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
    1.40 @@ -30,7 +34,9 @@
    1.41  #
    1.42  # Find the configure script
    1.43  #
    1.44 -cd `dirname $0`/..
    1.45 +srcdir=`dirname $0`/..
    1.46 +auxdir=$srcdir/build-scripts
    1.47 +cd $srcdir
    1.48  
    1.49  #
    1.50  # Figure out which phase to build:
    1.51 @@ -76,7 +82,42 @@
    1.52          merge="yes"
    1.53          ;;
    1.54      install)
    1.55 -        make_x86="yes"
    1.56 +        install_bin="yes"
    1.57 +        install_hdrs="yes"
    1.58 +        install_lib="yes"
    1.59 +        install_data="yes"
    1.60 +        install_man="yes"
    1.61 +        ;;
    1.62 +    install-bin)
    1.63 +        install_bin="yes"
    1.64 +        ;;
    1.65 +    install-hdrs)
    1.66 +        install_hdrs="yes"
    1.67 +        ;;
    1.68 +    install-lib)
    1.69 +        install_lib="yes"
    1.70 +        ;;
    1.71 +    install-data)
    1.72 +        install_data="yes"
    1.73 +        ;;
    1.74 +    install-man)
    1.75 +        install_man="yes"
    1.76 +        ;;
    1.77 +    *)
    1.78 +        echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge]"
    1.79 +        exit 1
    1.80 +        ;;
    1.81 +esac
    1.82 +case `uname -p` in
    1.83 +    powerpc)
    1.84 +        native_path=ppc
    1.85 +        ;;
    1.86 +    *86)
    1.87 +        native_path=x86
    1.88 +        ;;
    1.89 +    *)
    1.90 +        echo "Couldn't figure out native architecture path"
    1.91 +        exit 1
    1.92          ;;
    1.93  esac
    1.94  
    1.95 @@ -96,7 +137,7 @@
    1.96  #
    1.97  if test x$configure_ppc = xyes; then
    1.98      (cd build/ppc && \
    1.99 -     sh ../../configure CFLAGS="$CFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
   1.100 +     sh ../../configure --build=`uname -p`-apple-darwin --host=powerpc-apple-darwin CC="$CC_PPC" CFLAGS="$CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
   1.101  fi
   1.102  if test x$make_ppc = xyes; then
   1.103      (cd build/ppc && make) || exit 3
   1.104 @@ -107,7 +148,7 @@
   1.105  #
   1.106  if test x$configure_x86 = xyes; then
   1.107      (cd build/x86 && \
   1.108 -     sh ../../configure CFLAGS="$CFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
   1.109 +     sh ../../configure --build=`uname -p`-apple-darwin --host=i686-apple-darwin CC="$CC_X86" CFLAGS="$CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
   1.110  fi
   1.111  if test x$make_x86 = xyes; then
   1.112      (cd build/x86 && make) || exit 3
   1.113 @@ -116,22 +157,79 @@
   1.114  #
   1.115  # Combine into fat binary
   1.116  #
   1.117 -target=`find x86 -type f -name '*.dylib' | sed 's|.*/||'`
   1.118  if test x$merge = xyes; then
   1.119 -    (cd build && \
   1.120 -     lipo -create -o $target `find ppc x86 -type f -name "*.dylib"` &&
   1.121 -     ln -s $target libSDL-1.2.0.dylib
   1.122 -     ln -s $target libSDL.dylib
   1.123 -     lipo -create -o SDLMain.o */build/SDLMain.o &&
   1.124 -     ar cru libSDLmain.a SDLMain.o && ranlib libSDLmain.a &&
   1.125 +    output=.libs
   1.126 +    sh $auxdir/mkinstalldirs build/$output
   1.127 +    cd build
   1.128 +    target=`find . -mindepth 3 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
   1.129 +    (lipo -create -o $output/$target `find . -mindepth 3 -type f -name "*.dylib"` &&
   1.130 +     ln -sf $target $output/libSDL-1.2.0.dylib &&
   1.131 +     ln -sf $target $output/libSDL.dylib &&
   1.132 +     lipo -create -o $output/libSDL.a */build/.libs/libSDL.a &&
   1.133 +     cp $native_path/build/.libs/libSDL.la $output &&
   1.134 +     cp $native_path/build/.libs/libSDL.lai $output &&
   1.135 +     cp $native_path/build/libSDL.la . &&
   1.136 +     lipo -create -o libSDLmain.a */build/libSDLmain.a &&
   1.137       echo "Build complete!" &&
   1.138       echo "Files can be found in the build directory.") || exit 4
   1.139 +    cd ..
   1.140  fi
   1.141  
   1.142  #
   1.143  # Install
   1.144  #
   1.145 -if test x$install = xyes; then
   1.146 -    echo "Install not implemented"
   1.147 -    exit 1
   1.148 +do_install()
   1.149 +{
   1.150 +    echo $*
   1.151 +    $* || exit 5
   1.152 +}
   1.153 +if test x$prefix = x; then
   1.154 +    prefix=/usr/local
   1.155  fi
   1.156 +if test x$exec_prefix = x; then
   1.157 +    exec_prefix=$prefix
   1.158 +fi
   1.159 +if test x$bindir = x; then
   1.160 +    bindir=$exec_prefix/bin
   1.161 +fi
   1.162 +if test x$libdir = x; then
   1.163 +    libdir=$exec_prefix/lib
   1.164 +fi
   1.165 +if test x$includedir = x; then
   1.166 +    includedir=$prefix/include
   1.167 +fi
   1.168 +if test x$datadir = x; then
   1.169 +    datadir=$prefix/share
   1.170 +fi
   1.171 +if test x$mandir = x; then
   1.172 +    mandir=$prefix/man
   1.173 +fi
   1.174 +if test x$install_bin = xyes; then
   1.175 +    do_install sh $auxdir/mkinstalldirs $bindir
   1.176 +    do_install /usr/bin/install -c -m 755 build/$native_path/sdl-config $bindir/sdl-config
   1.177 +fi
   1.178 +if test x$install_hdrs = xyes; then
   1.179 +    do_install sh $auxdir/mkinstalldirs $includedir/SDL
   1.180 +    for src in $srcdir/include/*.h; do \
   1.181 +        file=`echo $src | sed -e 's|^.*/||'`; \
   1.182 +        do_install /usr/bin/install -c -m 644 $src $includedir/SDL/$file; \
   1.183 +    done
   1.184 +    do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL/SDL_config.h
   1.185 +fi
   1.186 +if test x$install_lib = xyes; then
   1.187 +    do_install sh $auxdir/mkinstalldirs $libdir
   1.188 +    do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c  build/libSDL.la $libdir/libSDL.la
   1.189 +    do_install /usr/bin/install -c -m 644 build/libSDLmain.a $libdir/libSDLmain.a
   1.190 +    do_install ranlib $libdir/libSDLmain.a
   1.191 +fi
   1.192 +if test x$install_data = xyes; then
   1.193 +    do_install sh $auxdir/mkinstalldirs $datadir/aclocal
   1.194 +    do_install /usr/bin/install -c -m 644 $srcdir/sdl.m4 $datadir/aclocal/sdl.m4
   1.195 +fi
   1.196 +if test x$install_man = xyes; then
   1.197 +    do_install sh $auxdir/mkinstalldirs $mandir/man3
   1.198 +    for src in $srcdir/docs/man3/*.3; do \
   1.199 +        file=`echo $src | sed -e 's|^.*/||'`; \
   1.200 +        do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
   1.201 +    done
   1.202 +fi
     2.1 --- a/configure.in	Thu Apr 20 16:33:51 2006 +0000
     2.2 +++ b/configure.in	Sat Apr 22 19:17:14 2006 +0000
     2.3 @@ -65,7 +65,7 @@
     2.4          BASE_LDFLAGS=""
     2.5          ;;
     2.6  esac
     2.7 -BUILD_CFLAGS="$CFLAGS"
     2.8 +BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
     2.9  EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
    2.10  BUILD_LDFLAGS="$LDFLAGS"
    2.11  EXTRA_LDFLAGS="$BASE_LDFLAGS"
    2.12 @@ -2336,6 +2336,15 @@
    2.13          CheckDiskAudio
    2.14          CheckDummyAudio
    2.15          CheckDLOPEN
    2.16 +
    2.17 +        # Set up files for the shared object loading library
    2.18 +        # (this needs to be done before the dynamic X11 check)
    2.19 +        if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
    2.20 +            AC_DEFINE(SDL_LOADSO_DLCOMPAT)
    2.21 +            SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
    2.22 +            have_loadso=yes
    2.23 +        fi
    2.24 +
    2.25          CheckCOCOA
    2.26          CheckCARBON
    2.27          CheckX11
    2.28 @@ -2374,12 +2383,6 @@
    2.29              SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
    2.30              have_timers=yes
    2.31          fi
    2.32 -        # Set up files for the shared object loading library
    2.33 -        if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
    2.34 -            AC_DEFINE(SDL_LOADSO_DLCOMPAT)
    2.35 -            SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
    2.36 -            have_loadso=yes
    2.37 -        fi
    2.38          # The Mac OS X platform requires special setup.
    2.39          SDLMAIN_SOURCES="$srcdir/src/main/macosx/*.m"
    2.40          EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
     3.1 --- a/src/loadso/macosx/SDL_sysloadso.c	Thu Apr 20 16:33:51 2006 +0000
     3.2 +++ b/src/loadso/macosx/SDL_sysloadso.c	Sat Apr 22 19:17:14 2006 +0000
     3.3 @@ -109,7 +109,7 @@
     3.4  #endif /* ! _POSIX_SOURCE */
     3.5  
     3.6  static int SDL_OSX_dlclose(void * handle);
     3.7 -static char * SDL_OSX_dlerror(void);
     3.8 +static const char * SDL_OSX_dlerror(void);
     3.9  static void * SDL_OSX_dlopen(const char *path, int mode);
    3.10  static void * SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict symbol);
    3.11  
    3.12 @@ -249,7 +249,7 @@
    3.13  static void resetdlerror(void);
    3.14  static const struct mach_header *my_find_image(const char *name);
    3.15  static const struct mach_header *image_for_address(const void *address);
    3.16 -static inline const char *dyld_error_str(void);
    3.17 +static inline char *dyld_error_str(void);
    3.18  
    3.19  #if FINK_BUILD
    3.20  /* Two Global Functions */
    3.21 @@ -623,7 +623,7 @@
    3.22  }
    3.23  
    3.24  /* Up to the caller to SDL_free() returned string */
    3.25 -static inline const char *dyld_error_str()
    3.26 +static inline char *dyld_error_str()
    3.27  {
    3.28  	NSLinkEditErrors dylder;
    3.29  	int dylderno;
    3.30 @@ -647,7 +647,7 @@
    3.31  	void *caller = NULL;
    3.32  #endif
    3.33  	const struct mach_header *caller_mh = 0;
    3.34 -	char* savedErrorStr = NULL;
    3.35 +	char *savedErrorStr = NULL;
    3.36  	resetdlerror();
    3.37  #ifndef RTLD_SELF
    3.38  #define	RTLD_SELF		((void *) -3)
    3.39 @@ -1168,7 +1168,7 @@
    3.40  	return 1;
    3.41  }
    3.42  
    3.43 -static char *SDL_OSX_dlerror(void)
    3.44 +static const char *SDL_OSX_dlerror(void)
    3.45  {
    3.46  	struct dlthread  *tss;
    3.47  	const char * err_str = NULL;
    3.48 @@ -1378,7 +1378,7 @@
    3.49  void *SDL_LoadObject(const char *sofile)
    3.50  {
    3.51  	void *handle = SDL_OSX_dlopen(sofile, RTLD_NOW);
    3.52 -	const char *loaderror = (char *)SDL_OSX_dlerror();
    3.53 +	const char *loaderror = SDL_OSX_dlerror();
    3.54  	if ( handle == NULL ) {
    3.55  		SDL_SetError("Failed loading %s: %s", sofile, loaderror);
    3.56  	}
    3.57 @@ -1389,7 +1389,7 @@
    3.58  {
    3.59  	void *symbol = SDL_OSX_dlsym(handle, name);
    3.60  	if ( symbol == NULL ) {
    3.61 -		SDL_SetError("Failed loading %s: %s", name, (const char *)SDL_OSX_dlerror());
    3.62 +		SDL_SetError("Failed loading %s: %s", name, SDL_OSX_dlerror());
    3.63  	}
    3.64  	return(symbol);
    3.65  }
     4.1 --- a/src/video/quartz/SDL_QuartzVideo.h	Thu Apr 20 16:33:51 2006 +0000
     4.2 +++ b/src/video/quartz/SDL_QuartzVideo.h	Sat Apr 22 19:17:14 2006 +0000
     4.3 @@ -54,7 +54,8 @@
     4.4  #include <Cocoa/Cocoa.h>
     4.5  #include <Carbon/Carbon.h>
     4.6  #include <QuickTime/QuickTime.h>
     4.7 -#include <IOKit/IOKitLib.h> /* For powersave handling */
     4.8 +#include <OpenGL/CGLTypes.h>	/* For CGLContextObj */
     4.9 +#include <IOKit/IOKitLib.h>	/* For powersave handling */
    4.10  #include <pthread.h>
    4.11  
    4.12  #include "SDL_thread.h"
     5.1 --- a/src/video/quartz/SDL_QuartzYUV.m	Thu Apr 20 16:33:51 2006 +0000
     5.2 +++ b/src/video/quartz/SDL_QuartzYUV.m	Sat Apr 22 19:17:14 2006 +0000
     5.3 @@ -47,31 +47,31 @@
     5.4      ;
     5.5  }
     5.6  
     5.7 -static int QZ_DisplayYUV (_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) {
     5.8 +static int QZ_DisplayYUV (_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst) {
     5.9  
    5.10      OSErr err;
    5.11      CodecFlags flags;
    5.12  
    5.13 -    if (dstrect->x != 0 || dstrect->y != 0) {
    5.14 +    if (dst->x != 0 || dst->y != 0) {
    5.15  
    5.16 -        SDL_SetError ("Need a dstrect at (0,0)");
    5.17 +        SDL_SetError ("Need a dst at (0,0)");
    5.18          return -1;
    5.19      }
    5.20  
    5.21 -    if (dstrect->w != yuv_width || dstrect->h != yuv_height) {
    5.22 +    if (dst->w != yuv_width || dst->h != yuv_height) {
    5.23  
    5.24          Fixed scale_x, scale_y;
    5.25  
    5.26 -        scale_x = FixDiv ( Long2Fix (dstrect->w), Long2Fix (overlay->w) );
    5.27 -        scale_y = FixDiv ( Long2Fix (dstrect->h), Long2Fix (overlay->h) );
    5.28 +        scale_x = FixDiv ( Long2Fix (dst->w), Long2Fix (overlay->w) );
    5.29 +        scale_y = FixDiv ( Long2Fix (dst->h), Long2Fix (overlay->h) );
    5.30  
    5.31          SetIdentityMatrix (yuv_matrix);
    5.32          ScaleMatrix (yuv_matrix, scale_x, scale_y, Long2Fix (0), Long2Fix (0));
    5.33  
    5.34          SetDSequenceMatrix (yuv_seq, yuv_matrix);
    5.35  
    5.36 -        yuv_width = dstrect->w;
    5.37 -        yuv_height = dstrect->h;
    5.38 +        yuv_width = dst->w;
    5.39 +        yuv_height = dst->h;
    5.40      }
    5.41  
    5.42      if( ( err = DecompressSequenceFrameS(
     6.1 --- a/src/video/x11/SDL_x11dyn.c	Thu Apr 20 16:33:51 2006 +0000
     6.2 +++ b/src/video/x11/SDL_x11dyn.c	Sat Apr 22 19:17:14 2006 +0000
     6.3 @@ -31,7 +31,6 @@
     6.4  
     6.5  #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
     6.6  
     6.7 -#include <dlfcn.h>
     6.8  #include "SDL_name.h"
     6.9  #include "SDL_loadso.h"
    6.10