Skip to content

Commit

Permalink
Mac OS X fat build works! :)
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Apr 22, 2006
1 parent b067467 commit 817a905
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 46 deletions.
142 changes: 120 additions & 22 deletions build-scripts/fatbuild.sh
Expand Up @@ -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 \
Expand All @@ -30,7 +34,9 @@ LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
#
# Find the configure script
#
cd `dirname $0`/..
srcdir=`dirname $0`/..
auxdir=$srcdir/build-scripts
cd $srcdir

#
# Figure out which phase to build:
Expand Down Expand Up @@ -76,7 +82,42 @@ case $phase in
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

Expand All @@ -96,7 +137,7 @@ done
#
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
Expand All @@ -107,7 +148,7 @@ fi
#
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
Expand All @@ -116,22 +157,79 @@ fi
#
# 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
17 changes: 10 additions & 7 deletions configure.in
Expand Up @@ -65,7 +65,7 @@ case "$host" in
BASE_LDFLAGS=""
;;
esac
BUILD_CFLAGS="$CFLAGS"
BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
BUILD_LDFLAGS="$LDFLAGS"
EXTRA_LDFLAGS="$BASE_LDFLAGS"
Expand Down Expand Up @@ -2336,6 +2336,15 @@ case "$host" in
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
Expand Down Expand Up @@ -2374,12 +2383,6 @@ case "$host" in
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"
Expand Down
14 changes: 7 additions & 7 deletions src/loadso/macosx/SDL_sysloadso.c
Expand Up @@ -109,7 +109,7 @@ static int SDL_OSX_dladdr(const void * dl_restrict, SDL_OSX_Dl_info * dl_restric
#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);

Expand Down Expand Up @@ -249,7 +249,7 @@ static void dlerrorfree(void *data);
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 */
Expand Down Expand Up @@ -623,7 +623,7 @@ static NSSymbol *search_linked_libs(const struct mach_header * mh, const char *s
}

/* 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;
Expand All @@ -647,7 +647,7 @@ static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetErr
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)
Expand Down Expand Up @@ -1168,7 +1168,7 @@ static int SDL_OSX_dlclose(void *handle)
return 1;
}

static char *SDL_OSX_dlerror(void)
static const char *SDL_OSX_dlerror(void)
{
struct dlthread *tss;
const char * err_str = NULL;
Expand Down Expand Up @@ -1378,7 +1378,7 @@ static dlfunc_t SDL_OSX_dlfunc(void * dl_restrict handle, const char * dl_restri
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);
}
Expand All @@ -1389,7 +1389,7 @@ void *SDL_LoadFunction(void *handle, const char *name)
{
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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/video/quartz/SDL_QuartzVideo.h
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions src/video/quartz/SDL_QuartzYUV.m
Expand Up @@ -47,31 +47,31 @@ static void QZ_UnlockYUV (_THIS, SDL_Overlay *overlay) {
;
}

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(
Expand Down
1 change: 0 additions & 1 deletion src/video/x11/SDL_x11dyn.c
Expand Up @@ -31,7 +31,6 @@

#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC

#include <dlfcn.h>
#include "SDL_name.h"
#include "SDL_loadso.h"

Expand Down

0 comments on commit 817a905

Please sign in to comment.