Makefileon commit Merge branch 'maint' (5f51ccd)
   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
  34INSTALL_D0 = $(INSTALL) -d -m755 # space is required here
  35INSTALL_D1 =
  36INSTALL_R0 = $(INSTALL) -m644 # space is required here
  37INSTALL_R1 =
  38INSTALL_X0 = $(INSTALL) -m755 # space is required here
  39INSTALL_X1 =
  40INSTALL_L0 = rm -f # space is required here
  41INSTALL_L1 = && ln # space is required here
  42INSTALL_L2 =
  43INSTALL_L3 =
  44
  45ifndef V
  46        QUIET          = @
  47        QUIET_GEN      = $(QUIET)echo '   ' GEN $@ &&
  48        QUIET_BUILT_IN = $(QUIET)echo '   ' BUILTIN $@ &&
  49        QUIET_INDEX    = $(QUIET)echo '   ' INDEX $(dir $@) &&
  50        QUIET_MSGFMT0  = $(QUIET)printf '    MSGFMT %12s ' $@ && v=`
  51        QUIET_MSGFMT1  = 2>&1` && echo "$$v" | sed -e 's/fuzzy translations/fuzzy/' | sed -e 's/ messages//g'
  52        QUIET_2DEVNULL = 2>/dev/null
  53
  54        INSTALL_D0 = dir=
  55        INSTALL_D1 = && echo ' ' DEST $$dir && $(INSTALL) -d -m755 "$$dir"
  56        INSTALL_R0 = src=
  57        INSTALL_R1 = && echo '   ' INSTALL 644 `basename $$src` && $(INSTALL) -m644 $$src
  58        INSTALL_X0 = src=
  59        INSTALL_X1 = && echo '   ' INSTALL 755 `basename $$src` && $(INSTALL) -m755 $$src
  60
  61        INSTALL_L0 = dst=
  62        INSTALL_L1 = && src=
  63        INSTALL_L2 = && dst=
  64        INSTALL_L3 = && echo '   ' 'LINK       ' `basename "$$dst"` '->' `basename "$$src"` && rm -f "$$dst" && ln "$$src" "$$dst"
  65endif
  66
  67TCL_PATH   ?= tclsh
  68TCLTK_PATH ?= wish
  69
  70ifeq ($(findstring $(MAKEFLAGS),s),s)
  71QUIET_GEN =
  72QUIET_BUILT_IN =
  73endif
  74
  75DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  76gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
  77SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  78TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
  79TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
  80
  81gg_libdir ?= $(sharedir)/git-gui/lib
  82libdir_SQ  = $(subst ','\'',$(gg_libdir))
  83
  84exedir    = $(dir $(gitexecdir))share/git-gui/lib
  85exedir_SQ = $(subst ','\'',$(exedir))
  86
  87$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
  88        $(QUIET_GEN)rm -f $@ $@+ && \
  89        GITGUI_RELATIVE= && \
  90        if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \
  91                if test "$(uname_O)" = Cygwin; \
  92                then GITGUI_RELATIVE= ; \
  93                else GITGUI_RELATIVE=1; \
  94                fi; \
  95        fi && \
  96        sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
  97                -e 's|^ exec wish "$$0"| exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
  98                -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
  99                -e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \
 100                -e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \
 101                $@.sh >$@+ && \
 102        chmod +x $@+ && \
 103        mv $@+ $@
 104
 105$(GITGUI_BUILT_INS): git-gui
 106        $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
 107
 108XGETTEXT   ?= xgettext
 109MSGFMT     ?= msgfmt
 110msgsdir     = $(gg_libdir)/msgs
 111msgsdir_SQ  = $(subst ','\'',$(msgsdir))
 112PO_TEMPLATE = po/git-gui.pot
 113ALL_POFILES = $(wildcard po/*.po)
 114ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES))
 115
 116$(PO_TEMPLATE): $(SCRIPT_SH) $(ALL_LIBFILES)
 117        $(XGETTEXT) -kmc -LTcl -o $@ $(SCRIPT_SH) $(ALL_LIBFILES)
 118update-po:: $(PO_TEMPLATE)
 119        $(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U $p $(PO_TEMPLATE) ; )
 120$(ALL_MSGFILES): %.msg : %.po
 121        $(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@) $(QUIET_MSGFMT1)
 122
 123lib/tclIndex: $(ALL_LIBFILES)
 124        $(QUIET_INDEX)if echo \
 125          $(foreach p,$(PRELOAD_FILES),source $p\;) \
 126          auto_mkindex lib '*.tcl' \
 127        | $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
 128        else \
 129         echo 1>&2 "    * $(TCL_PATH) failed; using unoptimized loading"; \
 130         rm -f $@ ; \
 131         echo '# Autogenerated by git-gui Makefile' >$@ && \
 132         echo >>$@ && \
 133         $(foreach p,$(PRELOAD_FILES) $(ALL_LIBFILES),echo '$(subst lib/,,$p)' >>$@ &&) \
 134         echo >>$@ ; \
 135        fi
 136
 137# These can record GITGUI_VERSION
 138$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
 139lib/tclIndex: GIT-GUI-VARS
 140
 141TRACK_VARS = \
 142        $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
 143        $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
 144        $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
 145        $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
 146        $(subst ','\'',gg_libdir='$(libdir_SQ)') \
 147#end TRACK_VARS
 148
 149GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
 150        @VARS='$(TRACK_VARS)'; \
 151        if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
 152                echo 1>&2 "    * new locations or Tcl/Tk interpreter"; \
 153                echo 1>$@ "$$VARS"; \
 154        fi
 155
 156all:: $(ALL_PROGRAMS) lib/tclIndex $(ALL_MSGFILES)
 157
 158install: all
 159        $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
 160        $(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
 161        $(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(INSTALL_L0)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L1)'$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' $(INSTALL_L2)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L3) &&) true
 162        $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(INSTALL_D1)
 163        $(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
 164        $(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
 165        $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(INSTALL_D1)
 166        $(QUIET)$(foreach p,$(ALL_MSGFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
 167
 168dist-version:
 169        @mkdir -p $(TARDIR)
 170        @echo $(GITGUI_VERSION) > $(TARDIR)/version
 171
 172clean::
 173        rm -f $(ALL_PROGRAMS) lib/tclIndex po/*.msg
 174        rm -f GIT-VERSION-FILE GIT-GUI-VARS
 175
 176.PHONY: all install dist-version clean
 177.PHONY: .FORCE-GIT-VERSION-FILE
 178.PHONY: .FORCE-GIT-GUI-VARS