Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-09-27 10:30:51 +0400
committerShawn O. Pearce <spearce@spearce.org>2007-09-28 06:17:00 +0400
commit72a8e81d457a1ee1283817d03d8e28303c2b4e7e (patch)
tree4022e4760b5c5b6d92fe6489d520a6a3ef0e3562 /Makefile
parent1bdd8a153528b539fdaed23c18e87a374b1f3ff8 (diff)
git-gui: Support a native Mac OS X application bundle
If we are building on Darwin (sometimes known as Mac OS X) and we find the Mac OS X Tk.framework in the expected location we build a proper Mac OS X application bundle with icons and info list. The git-gui and git-citool commands are modified to be very short shell scripts that just execute the application bundle, starting Tk with our own info list and icon set. Although the Makefile change here is rather large it makes for a much more pleasant user experience on Mac OS X as git-gui now has its own icon on the dock, in the standard tk_messageBox dialogs, and the application name now says "Git Gui" instead of "Wish" in locations such as the menu bar and the alt-tab window. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile96
1 files changed, 76 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index ea83263406..818a0ab45c 100644
--- a/Makefile
+++ b/Makefile
@@ -11,11 +11,12 @@ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@$(SHELL_PATH) ./GIT-VERSION-GEN
-include GIT-VERSION-FILE
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
SCRIPT_SH = git-gui.sh
+GITGUI_MAIN := git-gui
GITGUI_BUILT_INS = git-citool
-ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH))
ALL_LIBFILES = $(wildcard lib/*.tcl)
PRELOAD_FILES = lib/class.tcl
@@ -35,7 +36,7 @@ ifndef INSTALL
INSTALL = install
endif
-RM_F ?= rm -f
+RM_RF ?= rm -rf
RMDIR ?= rmdir
INSTALL_D0 = $(INSTALL) -d -m755 # space is required here
@@ -44,6 +45,8 @@ INSTALL_R0 = $(INSTALL) -m644 # space is required here
INSTALL_R1 =
INSTALL_X0 = $(INSTALL) -m755 # space is required here
INSTALL_X1 =
+INSTALL_A0 = find # space is required here
+INSTALL_A1 = | cpio -pud
INSTALL_L0 = rm -f # space is required here
INSTALL_L1 = && ln # space is required here
INSTALL_L2 =
@@ -51,14 +54,13 @@ INSTALL_L3 =
REMOVE_D0 = $(RMDIR) # space is required here
REMOVE_D1 = || true
-REMOVE_F0 = $(RM_F) # space is required here
+REMOVE_F0 = $(RM_RF) # space is required here
REMOVE_F1 =
CLEAN_DST = true
ifndef V
QUIET = @
- QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
- QUIET_BUILT_IN = $(QUIET)echo ' ' BUILTIN $@ &&
+ QUIET_GEN = $(QUIET)echo ' ' GEN '$@' &&
QUIET_INDEX = $(QUIET)echo ' ' INDEX $(dir $@) &&
QUIET_MSGFMT0 = $(QUIET)printf ' MSGFMT %12s ' $@ && v=`
QUIET_MSGFMT1 = 2>&1` && echo "$$v" | sed -e 's/fuzzy translations/fuzzy/' | sed -e 's/ messages//g'
@@ -70,6 +72,8 @@ ifndef V
INSTALL_R1 = && echo ' ' INSTALL 644 `basename $$src` && $(INSTALL) -m644 $$src
INSTALL_X0 = src=
INSTALL_X1 = && echo ' ' INSTALL 755 `basename $$src` && $(INSTALL) -m755 $$src
+ INSTALL_A0 = src=
+ INSTALL_A1 = && echo ' ' INSTALL ' ' `basename "$$src"` && find "$$src" | cpio -pud
INSTALL_L0 = dst=
INSTALL_L1 = && src=
@@ -80,15 +84,15 @@ ifndef V
REMOVE_D0 = dir=
REMOVE_D1 = && echo ' ' REMOVE $$dir && test -d "$$dir" && $(RMDIR) "$$dir" || true
REMOVE_F0 = dst=
- REMOVE_F1 = && echo ' ' REMOVE `basename "$$dst"` && $(RM_F) "$$dst"
+ REMOVE_F1 = && echo ' ' REMOVE `basename "$$dst"` && $(RM_RF) "$$dst"
endif
TCL_PATH ?= tclsh
TCLTK_PATH ?= wish
+TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
ifeq ($(findstring $(MAKEFLAGS),s),s)
QUIET_GEN =
-QUIET_BUILT_IN =
endif
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
@@ -105,6 +109,7 @@ exedir = $(dir $(gitexecdir))share/git-gui/lib
GITGUI_SCRIPT := $$0
GITGUI_RELATIVE :=
+GITGUI_MACOSXAPP :=
ifeq ($(exedir),$(gg_libdir))
GITGUI_RELATIVE := 1
@@ -116,8 +121,51 @@ ifeq ($(uname_O),Cygwin)
gg_libdir := $(shell cygpath --windows --absolute "$(gg_libdir)")
endif
endif
+ifeq ($(uname_S),Darwin)
+ ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y)
+ GITGUI_MACOSXAPP := YesPlease
+ endif
+endif
-$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
+ifdef GITGUI_MACOSXAPP
+GITGUI_MAIN := git-gui.tcl
+
+git-gui: GIT-VERSION-FILE GIT-GUI-VARS
+ $(QUIET_GEN)rm -f $@ $@+ && \
+ echo '#!$(SHELL_PATH_SQ)' >$@+ && \
+ echo 'if test "z$$*" = zversion ||' >>$@+ && \
+ echo ' test "z$$*" = z--version' >>$@+ && \
+ echo then >>$@+ && \
+ echo ' 'echo \'git-gui version '$(GITGUI_VERSION)'\' >>$@+ && \
+ echo else >>$@+ && \
+ echo ' 'exec \''$(libdir_SQ)/Git Gui.app/Contents/MacOS/Wish'\' \
+ '"$$0" "$$@"' >>$@+ && \
+ echo fi >>$@+ && \
+ chmod +x $@+ && \
+ mv $@+ $@
+
+Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
+ macosx/Info.plist \
+ macosx/git-gui.icns \
+ macosx/AppMain.tcl \
+ $(TKFRAMEWORK)/Contents/MacOS/Wish
+ $(QUIET_GEN)rm -rf '$@' '$@'+ && \
+ mkdir -p '$@'+/Contents/MacOS && \
+ mkdir -p '$@'+/Contents/Resources/Scripts && \
+ cp '$(subst ','\'',$(TKFRAMEWORK))/Contents/MacOS/Wish' \
+ '$@'+/Contents/MacOS && \
+ cp macosx/git-gui.icns '$@'+/Contents/Resources && \
+ sed -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
+ macosx/Info.plist \
+ >'$@'+/Contents/Info.plist && \
+ sed -e 's|@@gitexecdir@@|$(gitexecdir_SQ)|' \
+ -e 's|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
+ macosx/AppMain.tcl \
+ >'$@'+/Contents/Resources/Scripts/AppMain.tcl && \
+ mv '$@'+ '$@'
+endif
+
+$(GITGUI_MAIN): git-gui.sh GIT-VERSION-FILE GIT-GUI-VARS
$(QUIET_GEN)rm -f $@ $@+ && \
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e '1,30s|^ argv0=$$0| argv0=$(GITGUI_SCRIPT)|' \
@@ -125,13 +173,10 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
-e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
-e 's|@@GITGUI_RELATIVE@@|$(GITGUI_RELATIVE)|' \
-e '$(GITGUI_RELATIVE)s|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
- $@.sh >$@+ && \
+ git-gui.sh >$@+ && \
chmod +x $@+ && \
mv $@+ $@
-$(GITGUI_BUILT_INS): git-gui
- $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
-
XGETTEXT ?= xgettext
ifdef NO_MSGFMT
MSGFMT ?= $(TCL_PATH) po/po2msg.sh
@@ -152,7 +197,7 @@ update-po:: $(PO_TEMPLATE)
$(ALL_MSGFILES): %.msg : %.po
$(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@) $(QUIET_MSGFMT1)
-lib/tclIndex: $(ALL_LIBFILES)
+lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
$(QUIET_INDEX)if echo \
$(foreach p,$(PRELOAD_FILES),source $p\;) \
auto_mkindex lib '*.tcl' \
@@ -166,16 +211,13 @@ lib/tclIndex: $(ALL_LIBFILES)
echo >>$@ ; \
fi
-# These can record GITGUI_VERSION
-$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
-lib/tclIndex: GIT-GUI-VARS
-
TRACK_VARS = \
$(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
$(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
$(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
$(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
$(subst ','\'',gg_libdir='$(libdir_SQ)') \
+ GITGUI_MACOSXAPP=$(GITGUI_MACOSXAPP) \
#end TRACK_VARS
GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
@@ -185,7 +227,10 @@ GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
echo 1>$@ "$$VARS"; \
fi
-all:: $(ALL_PROGRAMS) lib/tclIndex $(ALL_MSGFILES)
+ifdef GITGUI_MACOSXAPP
+all:: git-gui Git\ Gui.app
+endif
+all:: $(GITGUI_MAIN) lib/tclIndex $(ALL_MSGFILES)
install: all
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
@@ -194,6 +239,10 @@ install: all
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(INSTALL_D1)
$(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
$(QUIET)$(INSTALL_R0)lib/git-gui.ico $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
+ifdef GITGUI_MACOSXAPP
+ $(QUIET)$(INSTALL_A0)'Git Gui.app' $(INSTALL_A1) '$(DESTDIR_SQ)$(libdir_SQ)'
+ $(QUIET)$(INSTALL_X0)git-gui.tcl $(INSTALL_X1) '$(DESTDIR_SQ)$(libdir_SQ)'
+endif
$(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(INSTALL_D1)
$(QUIET)$(foreach p,$(ALL_MSGFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
@@ -205,6 +254,10 @@ uninstall:
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(libdir_SQ)'
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/tclIndex $(REMOVE_F1)
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/git-gui.ico $(REMOVE_F1)
+ifdef GITGUI_MACOSXAPP
+ $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)/Git Gui.app' $(REMOVE_F1)
+ $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/git-gui.tcl $(REMOVE_F1)
+endif
$(QUIET)$(foreach p,$(ALL_LIBFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(msgsdir_SQ)'
$(QUIET)$(foreach p,$(ALL_MSGFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
@@ -218,8 +271,11 @@ dist-version:
@echo $(GITGUI_VERSION) > $(TARDIR)/version
clean::
- rm -f $(ALL_PROGRAMS) lib/tclIndex po/*.msg
- rm -f GIT-VERSION-FILE GIT-GUI-VARS
+ $(RM_RF) $(GITGUI_MAIN) lib/tclIndex po/*.msg
+ $(RM_RF) GIT-VERSION-FILE GIT-GUI-VARS
+ifdef GITGUI_MACOSXAPP
+ $(RM_RF) 'Git Gui.app'* git-gui
+endif
.PHONY: all install uninstall dist-version clean
.PHONY: .FORCE-GIT-VERSION-FILE