Commit 93dd0828 authored by Bruno Coudoin's avatar Bruno Coudoin

Cleanup, removed old way of doing MacOSX Bundles.

parent 34fce027
......@@ -96,116 +96,3 @@ all-local:
ACLOCAL_AMFLAGS = -I m4
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
ETC_PANGO=etc/pango
ETC_GTK=etc/gtk-2.0
GTK_CONF_FILES=gtk.immodules gdk-pixbuf.loaders im-multipress.conf
PANGO_CONF_FILES=pango.modules
FONTCONFIG_PATH=etc/fonts
GTK_MODULES_PATH=lib/gtk-2.0
PANGO_MODULES_PATH=lib/pango
EXTERN_BIN= gnuchess gnucap
PYTHON_MODULES_PATH_ORIG=lib/python$(PYTHON_VERSION)
PYTHON_MODULES_PATH_DEST=lib/python
PLIST=Info.plist
ICON=gcompris.png
FCT_CP_TAR=function cp_tar { \
$(INSTALL) -d $$2 ; \
(cd $$1 ; tar cf - $$3 * )| ( cd $$2; tar xf -) ; \
}
FCT_LDD_CP=function ldd_cp { \
for f in $$(ldd $$1 | grep $$2 | eval "sed -e 's,^.*$$2/\(.*\) (.*$$,\1,' " ); do \
if test ! -f $$3/$$f ; then \
echo $(INSTALL_D) $$2/$$f $$3/$$f ; \
$(INSTALL_D) $$2/$$f $$3/$$f ;\
ldd_cp $$3/$$f $$2 $$3;\
fi \
done ; }
FCT_OTOOL_CP=function otool_cp { \
for f in $$(otool -L $$1 | grep $$2 | eval "sed -e 's,^.*$$2/\(.*.dylib\).*$$,\1,' " ); do \
echo install_name_tool -change $$2/$$f @executable_path$$4/$$f $$1;\
install_name_tool -change $$2/$$f @executable_path$$4/$$f $$1 ; \
if test ! -f $$3/$$f ; then \
echo "$(INSTALL) -d $$(dirname $$3/$$f)"; \
echo "$(INSTALL) $$2/$$f $$3/$$f "; \
$(INSTALL) -d $$(dirname $$3/$$f); \
$(INSTALL) $$2/$$f $$3/$$f ;\
echo "install_name_tool -id @executable_path$$4/$$f $$3/$$f";\
install_name_tool -id @executable_path$$4/$$f $$3/$$f;\
otool_cp $$3/$$f $$2 $$3 $$4 ;\
fi \
done; \
}
if OS_MACOSX
INSTALL_D=function install_d { $(INSTALL) -d $$(dirname $$2); $(INSTALL) $$1 $$2 ;}; install_d
else
INSTALL_D=$(INSTALL) -D
endif
nsbundle:
$(INSTALL) -d $(BUNDLE_RESOURCES_DIR)
$(INSTALL) -d $(BUNDLE_EXEC_DIR)
$(INSTALL) -d $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_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)
if OS_MACOSX
$(FCT_OTOOL_CP); otool_cp $(BUNDLE_EXEC_DIR)/$(BUNDLE_NAME) $(prefix) $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR) $(NSBUNDLE_GTK_DIR)
else
$(FCT_LDD_CP); ldd_cp $(BUNDLE_EXEC_DIR)/$(BUNDLE_NAME) $(prefix) $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)
endif
$(INSTALL) -d $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(ETC_GTK)
#sed -e 's,$(prefix),@{prefix},g' $(prefix)/$(ETC_PANGO)/pangorc > $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(ETC_PANGO)/pangord
for f in $(GTK_CONF_FILES); do\
sed -e 's,$(prefix),@{prefix},g' $(prefix)/$(ETC_GTK)/$$f > $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(ETC_GTK)/$$f ;\
done
$(INSTALL) -d $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(ETC_PANGO)
for f in $(PANGO_CONF_FILES); do\
sed -e 's,$(prefix),@{prefix},g' $(prefix)/$(ETC_PANGO)/$$f > $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(ETC_PANGO)/$$f ;\
done
$(INSTALL) $(top_srcdir)/macosx/pangorc $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(ETC_PANGO)/pangorc
$(INSTALL) -d $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(FONTCONFIG_PATH)
$(FCT_CP_TAR); cp_tar $(prefix)/$(FONTCONFIG_PATH) $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(FONTCONFIG_PATH)
$(INSTALL) macosx/fonts.conf $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(FONTCONFIG_PATH)
$(FCT_CP_TAR); cp_tar $(prefix)/$(GTK_MODULES_PATH) $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(GTK_MODULES_PATH) "--exclude include"
$(FCT_CP_TAR); cp_tar $(prefix)/$(PANGO_MODULES_PATH) $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(PANGO_MODULES_PATH)
$(FCT_CP_TAR); cp_tar $(prefix)/$(PYTHON_MODULES_PATH_ORIG) $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/$(PYTHON_MODULES_PATH_DEST)
for f in $(EXTERN_BIN); do \
$(INSTALL_D) $(prefix)/bin/$$f $(BUNDLE_RESOURCES_DIR)/bin/$$f; \
done
if OS_MACOSX
$(INSTALL) $(top_srcdir)/macosx/Info.plist $(BUNDLE_RESOURCES_DIR)/../
$(INSTALL) $(top_srcdir)/macosx/PkgInfo $(BUNDLE_RESOURCES_DIR)/../
$(INSTALL) $(top_srcdir)/macosx/GCompris.icns $(BUNDLE_RESOURCES_DIR)/
$(FCT_OTOOL_CP) ; for s in $$(find $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR)/ -name '*.so') ; do \
otool_cp $$s $(prefix) $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR) $(NSBUNDLE_GTK_DIR) ; \
done
$(FCT_OTOOL_CP) ; for s in $$(find $(BUNDLE_RESOURCES_DIR) -name '*.so') ; do \
otool_cp $$s $(prefix) $(BUNDLE_EXEC_DIR)$(NSBUNDLE_GTK_DIR) $(NSBUNDLE_GTK_DIR) ; \
done
echo WARNING ! I suppose SDL Framewroks installed in /Library/Frameworks
$(FCT_CP_TAR); cp_tar /Library/Frameworks/SDL.framework $(BUNDLE_EXEC_DIR)/../Frameworks/SDL.framework
$(FCT_CP_TAR); cp_tar /Library/Frameworks/SDL_mixer.framework $(BUNDLE_EXEC_DIR)/../Frameworks/SDL_mixer.framework
else
$(INSTALL) $(top_srcdir)/macosx/gcompris.png $(BUNDLE_RESOURCES_DIR)/
$(INSTALL) $(top_srcdir)/macosx/Info-gnustep.plist $(BUNDLE_RESOURCES_DIR)/
endif
endif
......@@ -87,10 +87,6 @@ AC_ARG_ENABLE(nsbundle,
[Turn on nsbundle packaging (needs Cocoa/GNUstep)]),
nsbundle="$enableval", nsbundle="no")
NSBUNDLE_CPPFLAGS=
NSBUNDLE_LDFLAGS=
NSBUNDLE_GTK_DIR=
#check header for nsbundle
if test "x$nsbundle" = "xyes"; then
AC_PROG_OBJC([gcc])
......@@ -102,8 +98,6 @@ if test "x$nsbundle" = "xyes"; then
if test "x$NSFoundation" = "x$no"; then
AC_MSG_ERROR([You need development tools to use nsbundle. Make sure XCode is installed." ])
fi
NSBUNDLE_GTK_DIR="/../GTK"
NSBUNDLE_LDFLAGS="-framework Cocoa "
OBJCFLAGS="$OBJCFLAGS $CFLAGS"
AC_LANG_POP([Objective C])
......@@ -119,35 +113,22 @@ if test "x$nsbundle" = "xyes"; then
fi
CPPFLAGS="$saved_CPPFLAGS"
OBJCFLAGS="$OBJCFLAGS $CFLAGS -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -fconstant-string-class=NSConstantString -I$GNUSTEP_SYSTEM_ROOT/Library/Headers "
NSBUNDLE_GTK_DIR="/GTK"
NSBUNDLE_LDFLAGS="-rdynamic -fgnu-runtime -L$GNUSTEP_SYSTEM_ROOT/Library/Libraries -lgnustep-base -lgnustep-gui -Wl,-rpath=\\\$\$ORIGIN/$NSBUNDLE_GTK_DIR/lib "
AC_LANG_POP([Objective C])
fi
AC_DEFINE_UNQUOTED(NSBUNDLE, 1, [ Define to 1 to use NSBundle for relocation (OSX/GNUstep) ])
AC_DEFINE_UNQUOTED(NSBUNDLE_GTK_DIR, "$NSBUNDLE_GTK_DIR", [ Define to 1 to use NSBundle for relocation (OSX/GNUstep) ])
else
OBJC=$CC
AC_SUBST(OBJC)
OBJC=$CC
AC_SUBST(OBJC)
fi
_AM_DEPENDENCIES([OBJC])
AC_SUBST(NSBUNDLE_CPPFLAGS)
AC_SUBST(NSBUNDLE_LDFLAGS)
AC_SUBST(NSBUNDLE_GTK_DIR)
# 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)
AM_CONDITIONAL(WITH_NSBUNDLE, test "$nsbundle" = yes)
### --------------------------------------------------------------------------
### Check to see if GDK uses the quartz backend and if we can use
### MacOSX integration
......
gchar *gcompris_nsbundle_resource(void);
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
#include "gcompris.h"
#include "config.h"
void gcompris_fix_gtk_etc (void);
void gcompris_fix_lang(void);
void set_prefix( NSString *prefix_source_dir,
NSString *source_dir,
NSString *filename,
NSString *tmp_dir,
NSString *prefix,
const char *var);
@interface GComprisController : NSObject
- (void) quit: (id)sender;
- (void) applicationWillFinishLaunching: (NSNotification *)not;
@end
gchar *gcompris_nsbundle_resource(void)
{
NSAutoreleasePool *pool;
pool = [NSAutoreleasePool new];
[NSApplication sharedApplication];
[NSApp setDelegate: [GComprisController new]];
gchar *resourcePath = NULL;
resourcePath = g_strdup_printf("%s",[[[NSBundle mainBundle] resourcePath] UTF8String]);
printf("NSBundle resourcePath %s\n", resourcePath);
gcompris_fix_gtk_etc ();
gcompris_fix_lang();
[pool release];
return resourcePath;
}
void gcompris_fix_lang (void)
{
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSString* locale = [defs objectForKey:@"AppleLocale"];
if (locale != nil) {
printf ("Language %s\n", [locale UTF8String]);
setenv("LANG", [locale UTF8String], 0);
}
}
void gcompris_fix_gtk_etc (void)
{
NSMutableString *gtk_path = [[[[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent] mutableCopy] autorelease] ;
NSString *gtk_dir = @NSBUNDLE_GTK_DIR ;
NSString *gtk_conf_dir = @"/etc/gtk-2.0";
NSString *pango_conf_dir = @"/etc/pango";
NSString *gtk_immodules = @"/gtk.immodules";
NSString *gdk_pixbuf_loaders = @"/gdk-pixbuf.loaders";
NSString *pango_modules = @"/pango.modules";
NSString *pangorc = @"/pangorc";
NSString *pythonpath1 = @"/lib/python/site-packages:";
NSString *pythonpath2 = @"/lib/python/site-packages/gtk-2.0";
printf("NSBundle executablePath %s\n\n", [gtk_path UTF8String]);
// first is to suppress last component (executable name)
[gtk_path appendString: gtk_dir];
gtk_path = [gtk_path stringByStandardizingPath];
printf("NSBundle Gtk Dir Path %s\n\n", [gtk_path UTF8String]);
// Get the temporary filenames
NSString *tmp_dir = NSTemporaryDirectory();
printf("Temporary directory %s\n\n", [tmp_dir UTF8String]);
set_prefix( gtk_path,
gtk_conf_dir,
gtk_immodules,
tmp_dir,
gtk_path,
"GTK_IM_MODULE_FILE");
set_prefix( gtk_path,
gtk_conf_dir,
gdk_pixbuf_loaders,
tmp_dir,
gtk_path,
"GDK_PIXBUF_MODULE_FILE");
set_prefix( gtk_path,
pango_conf_dir,
pango_modules,
tmp_dir,
gtk_path,
NULL);
// Warning -> the tmp_dir because the files are in tmp directory too !!!
set_prefix( gtk_path,
pango_conf_dir,
pangorc,
tmp_dir,
tmp_dir,
"PANGO_RC_FILE");
//Now we just need to adjust some environnement variables
setenv ("GTK_EXE_PREFIX", g_strdup([gtk_path UTF8String]), TRUE);
setenv ("GTK_DATA_PREFIX", g_strdup([gtk_path UTF8String]), TRUE);
printf ("GTK_EXE_PREFIX environnemnt set to %s\n", getenv("GTK_EXE_PREFIX"));
printf ("GTK_DATA_PREFIX environnemnt set to %s\n", getenv("GTK_DATA_PREFIX"));
// Unused ?
NSMutableString *gtk_rc = [[gtk_path mutableCopy] autorelease];
[gtk_rc appendString: gtk_conf_dir];
[gtk_rc appendString: @"/gtkrc"];
setenv ("GTK2_RC_FILES", g_strdup([gtk_rc UTF8String]), TRUE);
printf ("GTK2_RC_FILES environnemnt set to %s\n", getenv("GTK2_RC_FILES"));
// is that usefull for GCompris ?
NSMutableString *fontconfig_path = [[gtk_path mutableCopy] autorelease];
[fontconfig_path appendString: @"/etc/fonts"];
setenv ("FONTCONFIG_PATH", g_strdup([fontconfig_path UTF8String]), TRUE);
printf ("FONTCONFIG_PATH environnemnt set %s\n", getenv("FONTCONFIG_PATH"));
NSMutableString *python_modules_path = [[gtk_path mutableCopy] autorelease];
[python_modules_path appendString: pythonpath1];
[python_modules_path appendString: gtk_path];
[python_modules_path appendString: pythonpath2];
setenv ("PYTHONPATH", g_strdup([python_modules_path UTF8String]), TRUE);
printf ("PYTHONPATH environnemnt set %s\n", getenv("PYTHONPATH"));
}
void set_prefix( NSString *prefix_source_dir,
NSString *source_dir,
NSString *filename,
NSString *tmp_dir,
NSString *prefix,
const char *var)
{
NSMutableString *source_file = [[prefix_source_dir mutableCopy] autorelease];
[source_file appendString: source_dir];
[source_file appendString: filename];
NSMutableString *tmp_file = [[tmp_dir mutableCopy] autorelease];
[tmp_file appendString: filename];
NSMutableString *file_content = [[[NSString stringWithContentsOfFile: source_file] mutableCopy] autorelease];
[file_content replaceOccurrencesOfString: @"@{prefix}"
withString: prefix
options: NSLiteralSearch
range: NSMakeRange(0, [file_content length])];
[file_content writeToFile: tmp_file atomically: NO ];
printf("Write %s\n to %s\n", [source_file UTF8String], [tmp_file UTF8String]);
if (var) {
setenv(var, g_strdup([tmp_file UTF8String]), 1);
printf ("%s environnemnt set to %s\n\n", var, getenv(var));
}
}
@implementation GComprisController : NSObject
- (void) quit: (id)sender
{
printf ("Received Quit from NSMenu!\n");
[NSApp terminate: self];
gc_exit();
}
- (void) applicationWillFinishLaunching: (NSNotification *)not
{
NSMenu *menu;
menu = AUTORELEASE ([NSMenu new]);
[menu addItemWithTitle: @"Quit"
action: @selector (quit:)
keyEquivalent: @"q"];
[NSApp setMainMenu: menu];
}
@end
......@@ -28,7 +28,7 @@
#ifdef WIN32
// WIN32
#elif NSBUNDLE
#elif MAC_INTEGRATION
// MACOSX
#else
#include <X11/Xlib.h>
......@@ -53,11 +53,6 @@
#include "binreloc.h"
/* for NSBUNDLE */
#ifdef NSBUNDLE
//#include "gcompris-nsbundle.h"
#endif
/* get the default database name */
#define DEFAULT_DATABASE "gcompris_sqlite.db"
......@@ -77,7 +72,7 @@ gchar * exec_prefix = NULL;
static void quit_cb (GtkWidget *widget, gpointer data);
static void map_cb (GtkWidget *widget, gpointer data);
#ifdef WIN32
#elif NSBUNDLE
#elif MAC_INTEGRATION
#else
static gboolean _realize_callback (GtkWidget *widget, GdkEventExpose *event,
gpointer data);
......@@ -650,7 +645,7 @@ gc_set_default_background(GooCanvasItem *parent)
* Sugar requires properties to be set before the windows is realized
*/
#ifdef WIN32
#elif NSBUNDLE
#elif MAC_INTEGRATION
#else
static gboolean
_realize_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
......@@ -817,7 +812,7 @@ static void setup_window ()
gtk_window_set_default_size(GTK_WINDOW(window), BOARDWIDTH, BOARDHEIGHT);
gtk_window_set_wmclass(GTK_WINDOW(window), "gcompris", "GCompris");
#ifdef WIN32
#elif NSBUNDLE
#elif MAC_INTEGRATION
#else
g_signal_connect (GTK_OBJECT (window), "realize",
G_CALLBACK (_realize_callback), NULL);
......@@ -1098,8 +1093,8 @@ void gc_fullscreen_set(gboolean state)
// WARNING: Doing this is required on Windows
// but keep the window hidden on GNU/Linux
gtk_widget_hide ( window );
#elif NSBUNDLE
// WARNING: Doing this is required on Windows
#elif MAC_INTEGRATION
// WARNING: Doing this is required on MacOSX
// but keep the window hidden on GNU/Linux
gtk_widget_hide ( window );
#else
......@@ -1115,7 +1110,6 @@ void gc_fullscreen_set(gboolean state)
gtk_window_move ( GTK_WINDOW ( window ), 0, 0 );
GdkScreen *screen = gtk_window_get_screen ( GTK_WINDOW ( window ) );
printf("%d // %d\n", gdk_screen_get_width (screen), gdk_screen_get_height (screen) );
gtk_window_resize ( GTK_WINDOW ( window ),
gdk_screen_get_width (screen),
gdk_screen_get_height (screen) );
......@@ -1234,14 +1228,7 @@ static void load_properties ()
g_error_free (error);
}
/* usefull for OSX bundle app */
/* FIXME exec_prefix should be put in properties */
/* usefull for OSX bundle app */
//#ifdef NSBUNDLE
// exec_prefix = gcompris_nsbundle_resource ();
//#else
exec_prefix = gbr_find_exe_dir(NULL);
//#endif
g_warning("exec_prefix %s\n", (exec_prefix==NULL ? "NONE" : exec_prefix));
{
......
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