Commit fde8c26f authored by Yves Combe's avatar Yves Combe

first work on OSX support.


svn path=/trunk/; revision=2507
parent 62eefaa8
2007-03-12 Yves Combe <yves@ycombe.net>
OSX support. No universal binary yet.
Prepared for OSX bundlisation.
* acinclude.m4: add SDL.m4 inside. NEEDS cleaning (probably), we don't need that on OSX.
* configure.in: detect apple darwin platform. Detect SDL and SDL_mixer frameworks.
* src/boards/chess.c: (start_board): check for gnuchess in same bin/
* src/boards/mypaint/mydrawwidget.override: NO_IMPORT_PYGOBJECT
* src/boards/py-gcompris-board.c: NO_IMPORT_PYGOBJECT
* src/boards/py-gcompris-class.c: NO_IMPORT_PYGOBJECT
* src/boards/py-gcompris-group.c: NO_IMPORT_PYGOBJECT
* src/boards/py-gcompris-profile.c: NO_IMPORT_PYGOBJECT
* src/boards/py-gcompris-properties.c: NO_IMPORT_PYGOBJECT
* src/boards/py-gcompris-user.c: NO_IMPORT_PYGOBJECT
* src/boards/py-gcompris-wordlist.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-admin.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-anim.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-bonus.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-gcompris.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-score.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-skin.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-sound.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-timer.c: NO_IMPORT_PYGOBJECT
* src/boards/py-mod-utils.c: NO_IMPORT_PYGOBJECT
* src/boards/python.c: NO_IMPORT_PYGOBJECT
* src/boards/python/electric.py: check gnucap in same bin/
* src/gcompris/Makefile.am: suppress python flags, unused here.
* src/gcompris/binreloc.c: (gbr_find_prefix): get prefix from argv[0] if full path (bundlisation).
* src/gcompris/gcompris.c: (main): get prefix from argv[0] if full path (bundlisation).
* src/gcompris/sdlplayer.c: get SDL eand SDL_mixer from frameworks if detected.
*** RELEASE 8.3BETA1 ***
......
......@@ -177,3 +177,178 @@ AC_DEFUN([AM_BINRELOC],
AC_SUBST(BINRELOC_CFLAGS)
AC_SUBST(BINRELOC_LIBS)
])
# Configure paths for SDL
# Sam Lantinga 9/21/99
# stolen from Manish Singh
# stolen back from Frank Belew
# stolen from Manish Singh
# Shamelessly stolen from Owen Taylor
dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
dnl
AC_DEFUN([AM_PATH_SDL],
[dnl
dnl Get the cflags and libraries from the sdl-config script
dnl
AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
sdl_prefix="$withval", sdl_prefix="")
AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
sdl_exec_prefix="$withval", sdl_exec_prefix="")
AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
, enable_sdltest=yes)
if test x$sdl_exec_prefix != x ; then
sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
fi
fi
if test x$sdl_prefix != x ; then
sdl_args="$sdl_args --prefix=$sdl_prefix"
if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_prefix/bin/sdl-config
fi
fi
AC_REQUIRE([AC_CANONICAL_TARGET])
PATH="$prefix/bin:$prefix/usr/bin:$PATH"
AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
min_sdl_version=ifelse([$1], ,0.11.0,$1)
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
no_sdl=""
if test "$SDL_CONFIG" = "no" ; then
no_sdl=yes
else
SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_sdltest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
dnl
dnl Now check if the installed SDL is sufficiently new. (Also sanity
dnl checks the results of sdl-config to some extent
dnl
rm -f conf.sdltest
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL.h"
char*
my_strdup (char *str)
{
char *new_str;
if (str)
{
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
strcpy (new_str, str);
}
else
new_str = NULL;
return new_str;
}
int main (int argc, char *argv[])
{
int major, minor, micro;
char *tmp_version;
/* This hangs on some systems (?)
system ("touch conf.sdltest");
*/
{ FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = my_strdup("$min_sdl_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_sdl_version");
exit(1);
}
if (($sdl_major_version > major) ||
(($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
(($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
printf("*** best to upgrade to the required version.\n");
printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
printf("*** to point to the correct copy of sdl-config, and remove the file\n");
printf("*** config.cache before re-running configure\n");
return 1;
}
}
],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_sdl" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$SDL_CONFIG" = "no" ; then
echo "*** The sdl-config script installed by SDL could not be found"
echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the SDL_CONFIG environment variable to the"
echo "*** full path to sdl-config."
else
if test -f conf.sdltest ; then
:
else
echo "*** Could not run SDL test program, checking why..."
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
AC_TRY_LINK([
#include <stdio.h>
#include "SDL.h"
int main(int argc, char *argv[])
{ return 0; }
#undef main
#define main K_and_R_C_main
], [ return 0; ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding SDL or finding the wrong"
echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means SDL was incorrectly installed"
echo "*** or that you have moved SDL since it was installed. In the latter case, you"
echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
SDL_CFLAGS=""
SDL_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
rm -f conf.sdltest
])
......@@ -19,7 +19,6 @@ GDK_PIXBUF_REQUIRED=2.4.0
LIBGNOMECANVAS_REQUIRED=2.3.6
PKG_CHECK_MODULES(GCOMPRIS, gtk+-2.0 >= $GTK_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED gthread-2.0)
AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio,, AC_MSG_ERROR([*** SDL_mixer not found. Visit http://www.libsdl.org and get it]))
AC_SUBST(GCOMPRIS_CFLAGS)
AC_SUBST(GCOMPRIS_LIBS)
......@@ -36,23 +35,57 @@ AM_DISABLE_STATIC
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
dnl Check for SDL
SDL_VERSION=1.2.3
cflags_previous=$CFLAGS
libs_previous=$LIBS
dnl OSX Specifics
AC_MSG_CHECKING([for OSX])
case "$host" in
*-apple-darwin*)
native_osx=yes
;;
*)
native_osx=no
;;
esac
AC_MSG_RESULT([$native_osx])
if test "x$native_osx" = "xyes"; then
AC_CHECK_HEADER(SDL/SDL.h, sdl_framework="yes" , sdl_framework="no")
if test "$sdl_framework" = "yes"; then
AC_CHECK_HEADER(SDL_mixer/SDL_mixer.h, sdl_mixer_framework="yes" , sdl_mixer_framework="no")
fi
fi
if test "x$sdl_mixer_framework" = "xno"; then
AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio,, AC_MSG_ERROR([*** SDL_mixer not found. Visit http://www.libsdl.org and get it]))
dnl Check for SDL
SDL_VERSION=1.2.3
cflags_previous=$CFLAGS
libs_previous=$LIBS
if test "x$SDL_CFLAGS" = "x" -o "x$SDL_LIBS" = "x" ; then
AM_PATH_SDL($SDL_VERSION,
if test "x$SDL_CFLAGS" = "x" -o "x$SDL_LIBS" = "x" ; then
AM_PATH_SDL($SDL_VERSION,
:,
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
)
)
else
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
echo "*** Not checking SDL. Using existing SDL_FLAGS and SDL_LIBS ***"
fi
dnl check n
else
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
echo "*** Not checking SDL. Using existing SDL_FLAGS and SDL_LIBS ***"
SDL_CFLAGS=
SDL_LIBS="-Xlinker -framework -Xlinker SDL -Xlinker -framework -Xlinker SDL_mixer"
AC_MSG_CHECKING([flags for SDL and SDL_mixer frameworks])
AC_MSG_RESULT($SDL_LIBS)
AC_DEFINE_UNQUOTED(SDL_FRAMEWORKS, 1, [ Define to 1 if compile for OSX with SDL and SDL_mixer frameworks ])
fi
dnl RESTAURE PREVIOUSLY SET VALUES
CFLAGS=$cflags_previous
LIBS=$libs_previous
......@@ -93,8 +126,8 @@ if test "x$USE_XF86VM" == "xyes" ; then
fi
fi
LDFLAGS="-Wl,--as-needed ${LDFLAGS} ${XF86VM_LIBS}"
#LDFLAGS="${LDFLAGS} ${XF86VM_LIBS}"
#LDFLAGS="-Wl,--as-needed ${LDFLAGS} ${XF86VM_LIBS}"
LDFLAGS="${LDFLAGS} ${XF86VM_LIBS}"
dnl Add the languages which your application supports here.
ALL_LINGUAS="am ar az bg ca cs da de dz el en_CA en_GB es et eu fi fr ga gu he hi hr hu id it ja ka ko lt mk ml mr ms nb ne nl nn pa pl pt pt_BR ro ru rw sk sl so sq sr sr@Latn sv th tr vi wa zh_CN zh_TW"
......
......@@ -185,18 +185,26 @@ static void start_board (GcomprisBoard *agcomprisBoard)
{
gnuchess_pid = 0;
gchar *gnuchess_bin = GNUCHESS;
#ifndef WIN32
signal(SIGTRAP, gnuchess_died);
signal(SIGPIPE, gnuchess_died);
if (!g_file_test (GNUCHESS, G_FILE_TEST_EXISTS))
if (!g_file_test (gnuchess_bin, G_FILE_TEST_EXISTS))
{
gc_dialog(_("Error: The external program gnuchess is required\nto play chess in gcompris.\n"
"Find this program on http://www.rpmfind.net or in your\nGNU/Linux distribution\n"
"And check it is located here: "GNUCHESS),
gc_board_stop);
return;
/* check in same bin/ as we are */
extern gchar *exec_prefix;
gnuchess_bin = g_build_filename( exec_prefix, "bin", "gnuchess", NULL);
if (!g_file_test (gnuchess_bin, G_FILE_TEST_EXISTS)) {
gc_dialog(_("Error: The external program gnuchess is required\nto play chess in gcompris.\n"
"Find this program on http://www.rpmfind.net or in your\nGNU/Linux distribution\n"
"And check it is located here: "GNUCHESS),
gc_board_stop);
return;
}
}
g_warning("GNUCHESS found %s", gnuchess_bin);
#endif
if(agcomprisBoard!=NULL)
......@@ -230,7 +238,7 @@ static void start_board (GcomprisBoard *agcomprisBoard)
gc_bar_set(0);
}
if(start_child (GNUCHESS, &read_chan,
if(start_child (gnuchess_bin, &read_chan,
&write_chan, &gnuchess_pid)==FALSE)
{
gc_dialog(_("Error: The external program gnuchess is mandatory\n"
......
%%
headers
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include "pygobject.h"
#include "gtkmydrawwidget.h"
#include "gtkmybrush.h"
......
#include "py-gcompris-board.h"
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
staticforward PyTypeObject pyGcomprisBoardType;
......
#include "py-gcompris-profile.h"
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
staticforward PyTypeObject pyGcomprisClassType;
......
#include "py-gcompris-profile.h"
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
staticforward PyTypeObject pyGcomprisGroupType;
......
#include "py-gcompris-profile.h"
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
staticforward PyTypeObject pyGcomprisProfileType;
......
#include "py-gcompris-properties.h"
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "py-gcompris-profile.h"
#include "py-gcompris-board.h"
......
#include "py-gcompris-profile.h"
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
staticforward PyTypeObject pyGcomprisUserType;
......
#include "py-gcompris-wordlist.h"
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "py-gcompris-profile.h"
#include "py-gcompris-board.h"
......
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-mod-admin.h"
......
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-gcompris-board.h"
......
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-mod-bonus.h"
......
......@@ -20,6 +20,7 @@
*/
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-mod-gcompris.h"
......
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-mod-utils.h"
......
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-mod-skin.h"
......
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include <stdarg.h>
#include "gcompris/gcompris.h"
......
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-mod-utils.h"
......
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-mod-utils.h"
......
......@@ -18,6 +18,7 @@
*/
#include <Python.h>
#define NO_IMPORT_PYGOBJECT 1
#include <pygobject.h>
#include "gcompris/gcompris.h"
#include "py-gcompris-board.h"
......
......@@ -85,7 +85,8 @@ class Gcompris_electric:
#
for binary in ("/usr/bin/gnucap",
"/usr/local/bin/gnucap",
"gnucap.exe"):
"gnucap.exe",
os.path.join(gcompris.DATA_DIR, '..' , '..', '..', 'bin', 'gnucap')):
if(os.path.exists(binary)):
self.gnucap_binary = binary
break
......
......@@ -110,14 +110,16 @@ gcompris_SOURCES = \
wordlist.h
gcompris_LDFLAGS = \
-export-dynamic $(python_ldflags) $(cairo_ldflags)
-export-dynamic $(cairo_ldflags)
gcompris_LDADD = \
$(GCOMPRIS_LIBS) $(sqlite_ldadd) $(XML_LIBS) $(GNET_LIBS) $(SDL_LIBS) \
$(LIBICONV) \
$(INTLLIBS) \
$(python_ldadd)
$(INTLLIBS)
# $(LIBICONV)
EXTRA_DIST = \
Makefile.mingw gcomprisrc.rc
......@@ -444,13 +444,14 @@ gchar *
gbr_find_prefix (const gchar *default_prefix)
{
gchar *dir1, *dir2;
extern gchar *exec_prefix;
if (exe == NULL) {
/* BinReloc not initialized. */
if (default_prefix != NULL)
return g_strdup (default_prefix);
else
return NULL;
return g_strdup (exec_prefix);
}
dir1 = g_path_get_dirname (exe);
......
......@@ -51,6 +51,8 @@ static GnomeCanvas *canvas;
static GnomeCanvas *canvas_bar;
static GnomeCanvas *canvas_bg;
gchar * exec_prefix = NULL;
//static gint pause_board_cb (GtkWidget *widget, gpointer data);
static void quit_cb (GtkWidget *widget, gpointer data);
static void map_cb (GtkWidget *widget, gpointer data);
......@@ -1375,6 +1377,14 @@ main (int argc, char *argv[])
GError *error = NULL;
GOptionContext *context;
/* usefull for OSX bundle app */
if (g_path_is_absolute (argv[0])) {
const gchar *dirname = g_path_get_dirname((const gchar *)argv[0]);
exec_prefix = g_build_filename (dirname, "..", NULL);
printf("dirname %s\n", dirname);
printf("exec_prefix %s\n", exec_prefix);
}
/* First, Remove the gnome crash dialog because it locks the user when in full screen */
signal(SIGSEGV, gc_terminate);
signal(SIGINT, gc_terminate);
......
......@@ -18,10 +18,20 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "soundutil.h"
#ifndef SDL_FRAMEWORKS
#include "SDL.h"
#include "SDL_thread.h"
#include "SDL_mixer.h"
#include "SDL_audio.h"
#else
/* we use SDL and SDL_mixer framework */
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include <SDL_mixer/SDL_mixer.h>
#include <SDL/SDL_audio.h>
#endif
#include <stdarg.h>
#include <unistd.h>
......@@ -31,8 +41,6 @@
#include <glib.h>
#include "soundutil.h"
Sint16 stream[2][4096];
int len=4096, bits=0, which=0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment