Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYves Combe <ycombe@src.gnome.org>2007-03-18 23:40:48 (GMT)
committer Yves Combe <ycombe@src.gnome.org>2007-03-18 23:40:48 (GMT)
commita4eb402c316529c7cb183a7c08706c21a0aa3179 (patch)
tree5ca6f4cb474faa6f868b3206a40c6abdcfb55744
parent8900980775782ebf5bc4bed75e463ff0e83969d9 (diff)
NSBundle usage for reloc
Bundle construction svn path=/trunk/; revision=2525
-rw-r--r--ChangeLog13
-rw-r--r--Makefile.am25
-rw-r--r--configure.in75
-rw-r--r--src/gcompris/Makefile.am16
-rw-r--r--src/gcompris/gcompris-nsbundle.h1
-rw-r--r--src/gcompris/gcompris-nsbundle.m20
-rw-r--r--src/gcompris/gcompris.c11
7 files changed, 148 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 82e9c7f..7e7aa3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-03-19 Yves Combe <yves@ycombe.net>
+
+ Add --enable-nsbundle to configure.in, with foundation/Foundation.h check.
+ Add NSBundle usage to reloc in this case
+ Add NSBundle construction target in Makefile.am
+
+ * Makefile.am:
+ * configure.in:
+ * src/gcompris/Makefile.am:
+ * src/gcompris/gcompris-nsbundle.h:
+ * src/gcompris/gcompris-nsbundle.m:
+ * src/gcompris/gcompris.c: (main):
+
2007-03-19 Bruno coudoin <bruno.coudoin@free.fr>
* src/boards/python/searace.py: does instant rotation now. improved the parameters
diff --git a/Makefile.am b/Makefile.am
index 600e82f..654f3e9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -73,6 +73,7 @@ CLEANFILES = core-translation-report gcompris.desktop gcompris-edit.desktop gcom
clean-local:
rm -f intltool-extract intltool-merge intltool-update
+ -rm -fr $(BUNDLE_APPDIR)
# Creates separates distribution files for the sounds by locale
dist-sounds:
@@ -90,3 +91,27 @@ all-local:
ACLOCAL_AMFLAGS =
+
+if OS_MACOSX
+BUNDLE_RESOURCES_DIR=$(BUNDLE_APPDIR)/Contents/Resources
+BUNDLE_EXEC_DIR=$(BUNDLE_APPDIR)/Contents/MacOS
+else
+BUNDLE_RESOURCES_DIR=$(BUNDLE_APPDIR)/Resources
+BUNDLE_EXEC_DIR=$(BUNDLE_APPDIR)
+endif
+
+if WITH_NSBUNDLE
+nsbundle:
+ $(INSTALL) -d $(BUNDLE_RESOURCES_DIR)
+ $(INSTALL) -d $(BUNDLE_EXEC_DIR)
+
+ make install prefix=$(BUNDLE_RESOURCES_DIR) \
+ exec_prefix=$(BUNDLE_RESOURCES_DIR) \
+ bindir=$(BUNDLE_EXEC_DIR) \
+ PYTHON_PLUGIN_DIR=$(BUNDLE_RESOURCES_DIR)/share/gcompris/python
+
+ mv $(BUNDLE_EXEC_DIR)/gcompris $(BUNDLE_EXEC_DIR)/$(BUNDLE_NAME)
+# check info.plist instead.
+endif
+
+
diff --git a/configure.in b/configure.in
index 6f5cc39..f09e5f0 100644
--- a/configure.in
+++ b/configure.in
@@ -6,10 +6,6 @@ AM_INIT_AUTOMAKE(gcompris, 8.3BETA1)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
-# Provide relocatable API from autopackage
-# From http://autopackage.org/docs/binreloc/
-AM_BINRELOC
-
dnl libtool versioning from libgnome
AC_ISC_POSIX
@@ -52,6 +48,75 @@ AC_MSG_RESULT([$native_osx])
AM_CONDITIONAL(OS_MACOSX, test "$native_osx" = yes)
+# nsbundle default is no even for osx
+nsbundle="no"
+
+AC_ARG_ENABLE(nsbundle,
+ AC_HELP_STRING(
+ [--enable-nsbundle],
+ [Turn on nsbundle packaging (needs Cocoa/GNUstep)]),
+ nsbundle="$enableval", nsbundle="no")
+
+NSBUNDLE_CPPFLAGS=
+NSBUNDLE_LDFLAGS=
+
+#check header for nsbundle
+if test "x$nsbundle" = "xyes"; then
+ AC_PROG_OBJC
+ AC_PROG_OBJCPP
+ _AM_DEPENDENCIES([OBJC])
+ if test "x$native_osx" = "xyes"; then
+ AC_LANG_PUSH([Objective C])
+ AC_CHECK_HEADER(Foundation/Foundation.h, NSFoundation="yes" , NSFoundation="no")
+ if test "x$NSFoundation" = "x$no"; then
+ AC_MSG_ERROR([You need development tools to use nsbundle. Make sure XCode is installed." ])
+ fi
+ NSBUNDLE_LDFLAGS="-framework Cocoa "
+ AC_LANG_POP([Objective C])
+ else
+ AC_LANG_PUSH([Objective C])
+ saved_CPPFLAGS="$CPPFLAGS"
+ if test "x$GNUSTEP_SYSTEM_ROOT" != "x"; then
+ CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_ROOT/Library/Headers "
+ fi
+ AC_CHECK_HEADER(Foundation/Foundation.h, NSFoundation="yes" , NSFoundation="no")
+ if test "x$NSFoundation" = "xno"; then
+ AC_MSG_ERROR([You need GNUstep dev to use nsbundle. Make sure GNUSTEP_SYSTEM_ROOT is set." ])
+ fi
+ CPPFLAGS="$saved_CPPFLAGS"
+ NSBUNDLE_CPPFLAGS=" -I$GNUSTEP_SYSTEM_ROOT/Library/Headers "
+ NSBUNDLE_LDFLAGS="-rdynamic -fgnu-runtime -L$GNUSTEP_SYSTEM_ROOT/Library/Libraries -lgnustep-base"
+ AC_LANG_POP([Objective C])
+ fi
+fi
+
+AC_SUBST(NSBUNDLE_CPPFLAGS)
+AC_SUBST(NSBUNDLE_LDFLAGS)
+
+# Todo: add a AC_ARG_WITH to allow change.
+bundlename=GCompris
+
+
+nsbundledir=$(pwd)"/$bundlename.app"
+BUNDLE_APPDIR="$nsbundledir"
+BUNDLE_NAME="$bundlename"
+AC_SUBST(BUNDLE_APPDIR)
+AC_SUBST(BUNDLE_NAME)
+
+AC_DEFINE_UNQUOTED(NSBUNDLE, 1, [ Define to 1 to use NSBundle for relocation (OSX/GNUstep) ])
+
+AM_CONDITIONAL(WITH_NSBUNDLE, test "$nsbundle" = yes)
+
+
+# Provide relocatable API from autopackage
+# From http://autopackage.org/docs/binreloc/
+if test x"$nsbundle" = "xyes" ; then
+enable_binreloc=no
+AC_MSG_NOTICE([binreloc disabled by nsbundle])
+fi
+
+AM_BINRELOC
+
sdl_mixer_framework="no"
sdl_framework="no"
@@ -628,6 +693,8 @@ echo "SQLITE database (--enable-sqlite) = $with_sqlite (profiles depend o
echo "GNET Networking (--enable-gnet) = $with_gnet (networking depends on this)"
echo "BINRELOC (--enable-binreloc) = $enable_binreloc"
+echo "NSBundle (--enable-nsbundle) = $nsbundle"
+
echo
echo gcompris will be installed in ${prefix}
diff --git a/src/gcompris/Makefile.am b/src/gcompris/Makefile.am
index 9da5343..390918e 100644
--- a/src/gcompris/Makefile.am
+++ b/src/gcompris/Makefile.am
@@ -35,6 +35,14 @@ no_undefined =
shared =
endif
+if WITH_NSBUNDLE
+gcompris_nsbundle_m = gcompris-nsbundle.m
+gcompris_nsbundle_h = gcompris-nsbundle.h
+else
+gcompris_nsbundle_m =
+gcompris_nsbundle_h =
+endif
+
bin_PROGRAMS = gcompris
INCLUDES = \
@@ -47,11 +55,14 @@ INCLUDES = \
-DGNOME_DISABLE_DEPRECATED \
$(sqlite_cflags) \
$(GNET_CFLAGS) \
- $(cairo_cflags)
+ $(cairo_cflags) \
+ $(NSBUNDLE_CPPFLAGS)
gcompris_SOURCES = \
$(cairo_c) \
$(cairo_h) \
+ $(gcompris_nsbundle_h) \
+ $(gcompris_nsbundle_m) \
about.c \
about.h \
anim.c \
@@ -115,8 +126,7 @@ gcompris_LDFLAGS = \
gcompris_LDADD = \
$(GCOMPRIS_LIBS) $(sqlite_ldadd) $(XML_LIBS) $(GNET_LIBS) $(SDL_LIBS) \
- $(INTLLIBS)
-
+ $(INTLLIBS) $(NSBUNDLE_LDFLAGS)
# $(LIBICONV)
diff --git a/src/gcompris/gcompris-nsbundle.h b/src/gcompris/gcompris-nsbundle.h
new file mode 100644
index 0000000..0c72b62
--- /dev/null
+++ b/src/gcompris/gcompris-nsbundle.h
@@ -0,0 +1 @@
+gchar *gcompris_nsbundle_resource(void);
diff --git a/src/gcompris/gcompris-nsbundle.m b/src/gcompris/gcompris-nsbundle.m
new file mode 100644
index 0000000..9b0550d
--- /dev/null
+++ b/src/gcompris/gcompris-nsbundle.m
@@ -0,0 +1,20 @@
+#include <Foundation/Foundation.h>
+#include "gcompris.h"
+
+gchar *gcompris_nsbundle_resource(void)
+{
+#ifdef NSBUNDLE
+ NSAutoreleasePool *pool;
+ gchar *resourcePath = NULL;
+ pool = [NSAutoreleasePool new];
+
+ resourcePath = g_strdup_printf("%s",[[[NSBundle mainBundle] resourcePath] UTF8String]);
+
+ printf("NSBundle resourcePath %s\n", resourcePath);
+
+ RELEASE(pool);
+ return resourcePath;
+#else
+ return NULL;
+#endif
+}
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index 7859995..4af5bc9 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -43,6 +43,9 @@
#include <X11/extensions/xf86vmode.h>
#endif
+/* for NSBUNDLE */
+#include "gcompris-nsbundle.h"
+
/* get the default database name */
#define DEFAULT_DATABASE "gcompris_sqlite.db"
@@ -1377,12 +1380,8 @@ main (int argc, char *argv[])
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);
- }
+ exec_prefix = gcompris_nsbundle_resource ();
+ 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);