diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-10-16 21:24:02 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-10-16 21:37:43 -0700 |
commit | 04c5e65b8cd52bf10d49375d22ba0908efbaa985 (patch) | |
tree | 2b3f25a64e6deb7dfe1e6a771e386a3a1b096388 | |
parent | 0d89d511bbebd76c9c59da3a2fdd2fd99e72e184 (diff) | |
download | subsurface-04c5e65b8cd52bf10d49375d22ba0908efbaa985.tar.gz |
Redoing the Mac bundling
With the right tools in place you can now create a bundle from the
Makefile by calling "make create-macos-bundle"
In the process of this I also moved the locale directory where we stage
our .mo files to share/locale (which is much more logical).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | Makefile | 42 | ||||
-rw-r--r-- | linux.c | 2 | ||||
-rw-r--r-- | macos.c | 14 | ||||
-rw-r--r-- | packaging/macosx/subsurface.bundle | 3 | ||||
-rwxr-xr-x | packaging/macosx/subsurface.sh | 5 |
5 files changed, 42 insertions, 24 deletions
@@ -102,14 +102,16 @@ else ifeq ($(UNAME), darwin) OSSUPPORT_CFLAGS = $(GTK2CFLAGS) MACOSXINSTALL = /Applications/Subsurface.app MACOSXFILES = packaging/macosx + MACOSXSTAGING = $(MACOSXFILES)/Subsurface.app EXTRALIBS = $(shell $(PKGCONFIG) --libs gtk-mac-integration) -framework CoreFoundation CFLAGS += $(shell $(PKGCONFIG) --cflags gtk-mac-integration) LDFLAGS += -headerpad_max_install_names + GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler else OSSUPPORT = windows OSSUPPORT_CFLAGS = $(GTK2CFLAGS) WINDOWSSTAGING = ./packaging/windows - WINMSGDIRS=$(addprefix locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) + WINMSGDIRS=$(addprefix share/locale/,$(shell ls po/*.po | sed -e 's/po\/\(..\)_.*/\1\/LC_MESSAGES/')) endif ifneq ($(strip $(LIBXSLT)),) @@ -122,7 +124,7 @@ endif LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBGCONF2) $(LIBDIVECOMPUTER) $(EXTRALIBS) $(LIBZIP) -lpthread -lm MSGLANGS=$(notdir $(wildcard po/*po)) -MSGOBJS=$(addprefix locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) +MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o \ parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ @@ -157,20 +159,34 @@ install-macosx: $(NAME) $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXINSTALL)/Contents/ $(INSTALL) $(ICONFILE) $(MACOSXINSTALL)/Contents/Resources/ $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXINSTALL)/Contents/Resources/ - for LOC in $(wildcard locale/*/LC_MESSAGES); do \ - $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/share/$$LOC; \ - $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/share/$$LOC/subsurface.mo; \ + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d -m 755 $(MACOSXINSTALL)/Contents/Resources/$$LOC; \ + $(INSTALL) $$LOC/subsurface.mo $(MACOSXINSTALL)/Contents/Resources/$$LOC/subsurface.mo; \ done +create-macosx-bundle: $(NAME) + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/MacOS + $(INSTALL) $(NAME) $(MACOSXSTAGING)/Contents/MacOS/ + $(INSTALL) $(MACOSXFILES)/PkgInfo $(MACOSXSTAGING)/Contents/ + $(INSTALL) $(MACOSXFILES)/Info.plist $(MACOSXSTAGING)/Contents/ + $(INSTALL) $(ICONFILE) $(MACOSXSTAGING)/Contents/Resources/ + $(INSTALL) $(MACOSXFILES)/Subsurface.icns $(MACOSXSTAGING)/Contents/Resources/ + for LOC in $(wildcard share/locale/*/LC_MESSAGES); do \ + $(INSTALL) -d -m 755 $(MACOSXSTAGING)/Contents/Resources/$$LOC; \ + $(INSTALL) $$LOC/subsurface.mo $(MACOSXSTAGING)/Contents/Resources/$$LOC/subsurface.mo; \ + done + $(GTK_MAC_BUNDLER) packaging/macos/subsurface.bundle + install-cross-windows: $(NAME) $(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/locale for MSG in $(WINMSGDIRS); do\ - $(INSTALL) -d -m 755 $(WINDOWSSTAGING)/share/$$MSG;\ - $(INSTALL) $(CROSS_LOCALE_PATH)/$$MSG/* $(WINDOWSSTAGING)/share/$$MSG;\ + $(INSTALL) -d -m 755 $(WINDOWSSTAGING)/$$MSG;\ + $(INSTALL) $(CROSS_LOCALE_PATH)/$$MSG/* $(WINDOWSSTAGING)/$$MSG;\ done for MSG in $(MSGOBJS); do\ - $(INSTALL) -d -m 755 $$(dirname $(WINDOWSSTAGING)/share/$$MSG);\ - $(INSTALL) $$MSG $(WINDOWSSTAGING)/share/$$MSG;\ + $(INSTALL) -d -m 755 $$(dirname $(WINDOWSSTAGING)/$$MSG);\ + $(INSTALL) $$MSG $(WINDOWSSTAGING)/$$MSG;\ done file.o: file.c dive.h file.h @@ -232,13 +248,13 @@ uemis-downloader.o: uemis-downloader.c dive.h uemis.h $(OSSUPPORT).o: $(OSSUPPORT).c display-gtk.h $(CC) $(CFLAGS) $(OSSUPPORT_CFLAGS) -c $(OSSUPPORT).c -locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po +share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po mkdir -p $(dir $@) msgfmt -c -o $@ po/$*.po @-if test -s po/$*.aliases; then \ for ALIAS in `cat po/$*.aliases`; do \ - mkdir -p locale/$$ALIAS/LC_MESSAGES; \ - cp $@ locale/$$ALIAS/LC_MESSAGES; \ + mkdir -p share/locale/$$ALIAS/LC_MESSAGES; \ + cp $@ share/locale/$$ALIAS/LC_MESSAGES; \ done; \ fi @@ -247,4 +263,4 @@ doc: clean: rm -f $(OBJS) *~ $(NAME) $(NAME).exe - rm -rf locale + rm -rf share @@ -86,7 +86,7 @@ const char *subsurface_default_filename() const char *subsurface_gettext_domainpath() { - return "./locale"; + return "./share/locale"; } void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, @@ -106,15 +106,13 @@ const char *subsurface_default_filename() const char *subsurface_gettext_domainpath() { - CFBundleRef mainBundle = CFBundleGetMainBundle(); - CFURLRef localeURL = CFBundleCopyResourceURL(mainBundle, CFSTR("share/locale"), CFSTR(""), NULL); - if (localeURL) { - CFStringRef localePath = CFURLCopyFileSystemPath(localeURL, kCFURLPOSIXPathStyle); - CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); - const char *path = CFStringGetCStringPtr(localePath, encodingMethod); - return path; + static char buffer[256]; + const char *resource_path = quartz_application_get_resource_path(); + if (resource_path) { + snprintf(buffer, sizeof(buffer), "%s/share/locale", resource_path); + return buffer; } - return "./locale"; + return "./share/locale"; } static void show_main_window(GtkWidget *w, gpointer data) diff --git a/packaging/macosx/subsurface.bundle b/packaging/macosx/subsurface.bundle index fcfd4f7f1..bff9c962e 100644 --- a/packaging/macosx/subsurface.bundle +++ b/packaging/macosx/subsurface.bundle @@ -86,6 +86,9 @@ ${prefix}/share/locale </translations> + <data dest="${bundle}/Contents/Resources/share/locale"> + ${project}/Subsurface.app/Contents/Resources/share/locale + </data> <!-- Data to copy in, usually Glade/UI files, images, sounds files etc. The destination inside the bundle can be specified if the diff --git a/packaging/macosx/subsurface.sh b/packaging/macosx/subsurface.sh index 0652e1afc..d6738abb4 100755 --- a/packaging/macosx/subsurface.sh +++ b/packaging/macosx/subsurface.sh @@ -34,7 +34,8 @@ export GTK_IM_MODULE_FILE="$bundle_etc/gtk-2.0/gtk.immodules" export GDK_PIXBUF_MODULE_FILE="$bundle_etc/gtk-2.0/gdk-pixbuf.loaders" export PANGO_RC_FILE="$bundle_etc/pango/pangorc" -APP=name +APP=$name +APPlower=`echo $APP | tr '[:upper:]' '[:lower:]'` I18NDIR="$bundle_data/locale" # Set the locale-related variables appropriately: unset LANG LC_MESSAGES LC_MONETARY LC_COLLATE @@ -48,7 +49,7 @@ if test "$APPLELANGUAGES"; then # Test, item per item, to see whether there is an corresponding locale. for L in $APPLELANGUAGES; do #test for exact matches: - if test -f "$I18NDIR/${L}/LC_MESSAGES/$APP.mo"; then + if test -f "$I18NDIR/${L}/LC_MESSAGES/${APPlower}.mo"; then export LANG=$L break fi |