Mac OS X fat build works! :)
authorSam Lantinga <slouken@libsdl.org>
Sat, 22 Apr 2006 19:17:14 +0000
changeset 1648 9f59d4c5aaea
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
--- a/build-scripts/fatbuild.sh	Thu Apr 20 16:33:51 2006 +0000
+++ b/build-scripts/fatbuild.sh	Sat Apr 22 19:17:14 2006 +0000
@@ -3,24 +3,28 @@
 # Build a fat binary on Mac OS X, thanks Ryan!
 
 # PowerPC compiler flags (10.2 runtime compatibility)
-CFLAGS_PPC="-arch ppc \
+CC_PPC="gcc-3.3"
+CFLAGS_PPC="-arch ppc"
+CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
+-nostdinc \
 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
--I/Developer/SDKs/MacOSX10.2.8.sdk/Developer/Headers/FlatCarbon \
--DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
 -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
--I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++ \
--I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin \
 -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
 
 # PowerPC linker flags 
-LFLAGS_PPC="-arch ppc -mmacosx-version-min=10.2 \
+LFLAGS_PPC="-arch ppc \
 -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
 -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
 
 # Intel compiler flags (10.4 runtime compatibility)
-CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
--DMAC_OS_X_VERSION_MIN_REQUIRED=1040 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
+CC_X86="gcc-4.0"
+CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4"
+CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
+-nostdinc \
+-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
+-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
+-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
 
 # Intel linker flags
 LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
@@ -30,7 +34,9 @@
 #
 # Find the configure script
 #
-cd `dirname $0`/..
+srcdir=`dirname $0`/..
+auxdir=$srcdir/build-scripts
+cd $srcdir
 
 #
 # Figure out which phase to build:
@@ -76,7 +82,42 @@
         merge="yes"
         ;;
     install)
-        make_x86="yes"
+        install_bin="yes"
+        install_hdrs="yes"
+        install_lib="yes"
+        install_data="yes"
+        install_man="yes"
+        ;;
+    install-bin)
+        install_bin="yes"
+        ;;
+    install-hdrs)
+        install_hdrs="yes"
+        ;;
+    install-lib)
+        install_lib="yes"
+        ;;
+    install-data)
+        install_data="yes"
+        ;;
+    install-man)
+        install_man="yes"
+        ;;
+    *)
+        echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge]"
+        exit 1
+        ;;
+esac
+case `uname -p` in
+    powerpc)
+        native_path=ppc
+        ;;
+    *86)
+        native_path=x86
+        ;;
+    *)
+        echo "Couldn't figure out native architecture path"
+        exit 1
         ;;
 esac
 
@@ -96,7 +137,7 @@
 #
 if test x$configure_ppc = xyes; then
     (cd build/ppc && \
-     sh ../../configure CFLAGS="$CFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
+     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
 fi
 if test x$make_ppc = xyes; then
     (cd build/ppc && make) || exit 3
@@ -107,7 +148,7 @@
 #
 if test x$configure_x86 = xyes; then
     (cd build/x86 && \
-     sh ../../configure CFLAGS="$CFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
+     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
 fi
 if test x$make_x86 = xyes; then
     (cd build/x86 && make) || exit 3
@@ -116,22 +157,79 @@
 #
 # Combine into fat binary
 #
-target=`find x86 -type f -name '*.dylib' | sed 's|.*/||'`
 if test x$merge = xyes; then
-    (cd build && \
-     lipo -create -o $target `find ppc x86 -type f -name "*.dylib"` &&
-     ln -s $target libSDL-1.2.0.dylib
-     ln -s $target libSDL.dylib
-     lipo -create -o SDLMain.o */build/SDLMain.o &&
-     ar cru libSDLmain.a SDLMain.o && ranlib libSDLmain.a &&
+    output=.libs
+    sh $auxdir/mkinstalldirs build/$output
+    cd build
+    target=`find . -mindepth 3 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
+    (lipo -create -o $output/$target `find . -mindepth 3 -type f -name "*.dylib"` &&
+     ln -sf $target $output/libSDL-1.2.0.dylib &&
+     ln -sf $target $output/libSDL.dylib &&
+     lipo -create -o $output/libSDL.a */build/.libs/libSDL.a &&
+     cp $native_path/build/.libs/libSDL.la $output &&
+     cp $native_path/build/.libs/libSDL.lai $output &&
+     cp $native_path/build/libSDL.la . &&
+     lipo -create -o libSDLmain.a */build/libSDLmain.a &&
      echo "Build complete!" &&
      echo "Files can be found in the build directory.") || exit 4
+    cd ..
 fi
 
 #
 # Install
 #
-if test x$install = xyes; then
-    echo "Install not implemented"
-    exit 1
+do_install()
+{
+    echo $*
+    $* || exit 5
+}
+if test x$prefix = x; then
+    prefix=/usr/local
+fi
+if test x$exec_prefix = x; then
+    exec_prefix=$prefix
+fi
+if test x$bindir = x; then
+    bindir=$exec_prefix/bin
+fi
+if test x$libdir = x; then
+    libdir=$exec_prefix/lib
+fi
+if test x$includedir = x; then
+    includedir=$prefix/include
+fi
+if test x$datadir = x; then
+    datadir=$prefix/share
+fi
+if test x$mandir = x; then
+    mandir=$prefix/man
 fi
+if test x$install_bin = xyes; then
+    do_install sh $auxdir/mkinstalldirs $bindir
+    do_install /usr/bin/install -c -m 755 build/$native_path/sdl-config $bindir/sdl-config
+fi
+if test x$install_hdrs = xyes; then
+    do_install sh $auxdir/mkinstalldirs $includedir/SDL
+    for src in $srcdir/include/*.h; do \
+        file=`echo $src | sed -e 's|^.*/||'`; \
+        do_install /usr/bin/install -c -m 644 $src $includedir/SDL/$file; \
+    done
+    do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL/SDL_config.h
+fi
+if test x$install_lib = xyes; then
+    do_install sh $auxdir/mkinstalldirs $libdir
+    do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c  build/libSDL.la $libdir/libSDL.la
+    do_install /usr/bin/install -c -m 644 build/libSDLmain.a $libdir/libSDLmain.a
+    do_install ranlib $libdir/libSDLmain.a
+fi
+if test x$install_data = xyes; then
+    do_install sh $auxdir/mkinstalldirs $datadir/aclocal
+    do_install /usr/bin/install -c -m 644 $srcdir/sdl.m4 $datadir/aclocal/sdl.m4
+fi
+if test x$install_man = xyes; then
+    do_install sh $auxdir/mkinstalldirs $mandir/man3
+    for src in $srcdir/docs/man3/*.3; do \
+        file=`echo $src | sed -e 's|^.*/||'`; \
+        do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
+    done
+fi
--- a/configure.in	Thu Apr 20 16:33:51 2006 +0000
+++ b/configure.in	Sat Apr 22 19:17:14 2006 +0000
@@ -65,7 +65,7 @@
         BASE_LDFLAGS=""
         ;;
 esac
-BUILD_CFLAGS="$CFLAGS"
+BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
 BUILD_LDFLAGS="$LDFLAGS"
 EXTRA_LDFLAGS="$BASE_LDFLAGS"
@@ -2336,6 +2336,15 @@
         CheckDiskAudio
         CheckDummyAudio
         CheckDLOPEN
+
+        # Set up files for the shared object loading library
+        # (this needs to be done before the dynamic X11 check)
+        if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
+            AC_DEFINE(SDL_LOADSO_DLCOMPAT)
+            SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
+            have_loadso=yes
+        fi
+
         CheckCOCOA
         CheckCARBON
         CheckX11
@@ -2374,12 +2383,6 @@
             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
             have_timers=yes
         fi
-        # Set up files for the shared object loading library
-        if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
-            AC_DEFINE(SDL_LOADSO_DLCOMPAT)
-            SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
-            have_loadso=yes
-        fi
         # The Mac OS X platform requires special setup.
         SDLMAIN_SOURCES="$srcdir/src/main/macosx/*.m"
         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
--- a/src/loadso/macosx/SDL_sysloadso.c	Thu Apr 20 16:33:51 2006 +0000
+++ b/src/loadso/macosx/SDL_sysloadso.c	Sat Apr 22 19:17:14 2006 +0000
@@ -109,7 +109,7 @@
 #endif /* ! _POSIX_SOURCE */
 
 static int SDL_OSX_dlclose(void * handle);
-static char * SDL_OSX_dlerror(void);
+static const char * SDL_OSX_dlerror(void);
 static void * SDL_OSX_dlopen(const char *path, int mode);
 static void * SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict symbol);
 
@@ -249,7 +249,7 @@
 static void resetdlerror(void);
 static const struct mach_header *my_find_image(const char *name);
 static const struct mach_header *image_for_address(const void *address);
-static inline const char *dyld_error_str(void);
+static inline char *dyld_error_str(void);
 
 #if FINK_BUILD
 /* Two Global Functions */
@@ -623,7 +623,7 @@
 }
 
 /* Up to the caller to SDL_free() returned string */
-static inline const char *dyld_error_str()
+static inline char *dyld_error_str()
 {
 	NSLinkEditErrors dylder;
 	int dylderno;
@@ -647,7 +647,7 @@
 	void *caller = NULL;
 #endif
 	const struct mach_header *caller_mh = 0;
-	char* savedErrorStr = NULL;
+	char *savedErrorStr = NULL;
 	resetdlerror();
 #ifndef RTLD_SELF
 #define	RTLD_SELF		((void *) -3)
@@ -1168,7 +1168,7 @@
 	return 1;
 }
 
-static char *SDL_OSX_dlerror(void)
+static const char *SDL_OSX_dlerror(void)
 {
 	struct dlthread  *tss;
 	const char * err_str = NULL;
@@ -1378,7 +1378,7 @@
 void *SDL_LoadObject(const char *sofile)
 {
 	void *handle = SDL_OSX_dlopen(sofile, RTLD_NOW);
-	const char *loaderror = (char *)SDL_OSX_dlerror();
+	const char *loaderror = SDL_OSX_dlerror();
 	if ( handle == NULL ) {
 		SDL_SetError("Failed loading %s: %s", sofile, loaderror);
 	}
@@ -1389,7 +1389,7 @@
 {
 	void *symbol = SDL_OSX_dlsym(handle, name);
 	if ( symbol == NULL ) {
-		SDL_SetError("Failed loading %s: %s", name, (const char *)SDL_OSX_dlerror());
+		SDL_SetError("Failed loading %s: %s", name, SDL_OSX_dlerror());
 	}
 	return(symbol);
 }
--- a/src/video/quartz/SDL_QuartzVideo.h	Thu Apr 20 16:33:51 2006 +0000
+++ b/src/video/quartz/SDL_QuartzVideo.h	Sat Apr 22 19:17:14 2006 +0000
@@ -54,7 +54,8 @@
 #include <Cocoa/Cocoa.h>
 #include <Carbon/Carbon.h>
 #include <QuickTime/QuickTime.h>
-#include <IOKit/IOKitLib.h> /* For powersave handling */
+#include <OpenGL/CGLTypes.h>	/* For CGLContextObj */
+#include <IOKit/IOKitLib.h>	/* For powersave handling */
 #include <pthread.h>
 
 #include "SDL_thread.h"
--- a/src/video/quartz/SDL_QuartzYUV.m	Thu Apr 20 16:33:51 2006 +0000
+++ b/src/video/quartz/SDL_QuartzYUV.m	Sat Apr 22 19:17:14 2006 +0000
@@ -47,31 +47,31 @@
     ;
 }
 
-static int QZ_DisplayYUV (_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) {
+static int QZ_DisplayYUV (_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst) {
 
     OSErr err;
     CodecFlags flags;
 
-    if (dstrect->x != 0 || dstrect->y != 0) {
+    if (dst->x != 0 || dst->y != 0) {
 
-        SDL_SetError ("Need a dstrect at (0,0)");
+        SDL_SetError ("Need a dst at (0,0)");
         return -1;
     }
 
-    if (dstrect->w != yuv_width || dstrect->h != yuv_height) {
+    if (dst->w != yuv_width || dst->h != yuv_height) {
 
         Fixed scale_x, scale_y;
 
-        scale_x = FixDiv ( Long2Fix (dstrect->w), Long2Fix (overlay->w) );
-        scale_y = FixDiv ( Long2Fix (dstrect->h), Long2Fix (overlay->h) );
+        scale_x = FixDiv ( Long2Fix (dst->w), Long2Fix (overlay->w) );
+        scale_y = FixDiv ( Long2Fix (dst->h), Long2Fix (overlay->h) );
 
         SetIdentityMatrix (yuv_matrix);
         ScaleMatrix (yuv_matrix, scale_x, scale_y, Long2Fix (0), Long2Fix (0));
 
         SetDSequenceMatrix (yuv_seq, yuv_matrix);
 
-        yuv_width = dstrect->w;
-        yuv_height = dstrect->h;
+        yuv_width = dst->w;
+        yuv_height = dst->h;
     }
 
     if( ( err = DecompressSequenceFrameS(
--- a/src/video/x11/SDL_x11dyn.c	Thu Apr 20 16:33:51 2006 +0000
+++ b/src/video/x11/SDL_x11dyn.c	Sat Apr 22 19:17:14 2006 +0000
@@ -31,7 +31,6 @@
 
 #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
 
-#include <dlfcn.h>
 #include "SDL_name.h"
 #include "SDL_loadso.h"