Makefileon commit git-gui: Include a Push action on the left toolbar (87b49a5)
   1all::
   2
   3# Define V=1 to have a more verbose compile.
   4#
   5
   6GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
   7        @$(SHELL_PATH) ./GIT-VERSION-GEN
   8-include GIT-VERSION-FILE
   9
  10uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
  11
  12SCRIPT_SH = git-gui.sh
  13GITGUI_BUILT_INS = git-citool
  14ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH))
  15ALL_LIBFILES = $(wildcard lib/*.tcl)
  16PRELOAD_FILES = lib/class.tcl
  17
  18ifndef SHELL_PATH
  19        SHELL_PATH = /bin/sh
  20endif
  21
  22ifndef gitexecdir
  23        gitexecdir := $(shell git --exec-path)
  24endif
  25
  26ifndef sharedir
  27        sharedir := $(dir $(gitexecdir))share
  28endif
  29
  30ifndef INSTALL
  31        INSTALL = install
  32endif
  33
  34ifndef V
  35        QUIET_GEN      = @echo '   ' GEN $@;
  36        QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
  37        QUIET_INDEX    = @echo '   ' INDEX $(dir $@);
  38        QUIET_2DEVNULL = 2>/dev/null
  39endif
  40
  41TCL_PATH   ?= tclsh
  42TCLTK_PATH ?= wish
  43
  44ifeq ($(findstring $(MAKEFLAGS),s),s)
  45QUIET_GEN =
  46QUIET_BUILT_IN =
  47endif
  48
  49DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  50gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
  51SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  52TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
  53TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
  54
  55libdir   ?= $(sharedir)/git-gui/lib
  56libdir_SQ = $(subst ','\'',$(libdir))
  57
  58exedir    = $(dir $(gitexecdir))share/git-gui/lib
  59exedir_SQ = $(subst ','\'',$(exedir))
  60
  61$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
  62        $(QUIET_GEN)rm -f $@ $@+ && \
  63        GITGUI_RELATIVE= && \
  64        if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \
  65                if test "$(uname_O)" = Cygwin; \
  66                then GITGUI_RELATIVE= ; \
  67                else GITGUI_RELATIVE=1; \
  68                fi; \
  69        fi && \
  70        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
  71                -e 's|^ exec wish "$$0"| exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
  72                -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
  73                -e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \
  74                -e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \
  75                $@.sh >$@+ && \
  76        chmod +x $@+ && \
  77        mv $@+ $@
  78
  79$(GITGUI_BUILT_INS): git-gui
  80        $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
  81
  82lib/tclIndex: $(ALL_LIBFILES)
  83        $(QUIET_INDEX)if echo \
  84          $(foreach p,$(PRELOAD_FILES),source $p\;) \
  85          auto_mkindex lib '*.tcl' \
  86        | $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
  87        else \
  88         echo 1>&2 "    * $(TCL_PATH) failed; using unoptimized loading"; \
  89         rm -f $@ ; \
  90         echo '# Autogenerated by git-gui Makefile' >$@ && \
  91         echo >>$@ && \
  92         $(foreach p,$(PRELOAD_FILES) $(ALL_LIBFILES),echo '$(subst lib/,,$p)' >>$@ &&) \
  93         echo >>$@ ; \
  94        fi
  95
  96# These can record GITGUI_VERSION
  97$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
  98lib/tclIndex: GIT-GUI-VARS
  99
 100TRACK_VARS = \
 101        $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
 102        $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
 103        $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
 104        $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
 105        $(subst ','\'',libdir='$(libdir_SQ)') \
 106#end TRACK_VARS
 107
 108GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
 109        @VARS='$(TRACK_VARS)'; \
 110        if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
 111                echo 1>&2 "    * new locations or Tcl/Tk interpreter"; \
 112                echo 1>$@ "$$VARS"; \
 113        fi
 114
 115all:: $(ALL_PROGRAMS) lib/tclIndex
 116
 117install: all
 118        $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 119        $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 120        $(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
 121        $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(libdir_SQ)'
 122        $(INSTALL) -m644 lib/tclIndex '$(DESTDIR_SQ)$(libdir_SQ)'
 123        $(foreach p,$(ALL_LIBFILES), $(INSTALL) -m644 $p '$(DESTDIR_SQ)$(libdir_SQ)' ;)
 124
 125dist-version:
 126        @mkdir -p $(TARDIR)
 127        @echo $(GITGUI_VERSION) > $(TARDIR)/version
 128
 129clean::
 130        rm -f $(ALL_PROGRAMS) lib/tclIndex
 131        rm -f GIT-VERSION-FILE GIT-GUI-VARS
 132
 133.PHONY: all install dist-version clean
 134.PHONY: .FORCE-GIT-VERSION-FILE
 135.PHONY: .FORCE-GIT-GUI-VARS