gitweb / Makefileon commit Merge branch 'maint' (38a1887)
   1# The default target of this Makefile is...
   2all::
   3
   4# Define V=1 to have a more verbose compile.
   5#
   6# Define JSMIN to point to JavaScript minifier that functions as
   7# a filter to have static/gitweb.js minified.
   8#
   9# Define CSSMIN to point to a CSS minifier in order to generate a minified
  10# version of static/gitweb.css
  11#
  12
  13prefix ?= $(HOME)
  14bindir ?= $(prefix)/bin
  15gitwebdir ?= /var/www/cgi-bin
  16
  17RM ?= rm -f
  18INSTALL ?= install
  19
  20# default configuration for gitweb
  21GITWEB_CONFIG = gitweb_config.perl
  22GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
  23GITWEB_HOME_LINK_STR = projects
  24GITWEB_SITENAME =
  25GITWEB_PROJECTROOT = /pub/git
  26GITWEB_PROJECT_MAXDEPTH = 2007
  27GITWEB_EXPORT_OK =
  28GITWEB_STRICT_EXPORT =
  29GITWEB_BASE_URL =
  30GITWEB_LIST =
  31GITWEB_HOMETEXT = indextext.html
  32GITWEB_CSS = static/gitweb.css
  33GITWEB_LOGO = static/git-logo.png
  34GITWEB_FAVICON = static/git-favicon.png
  35GITWEB_JS = static/gitweb.js
  36GITWEB_SITE_HEADER =
  37GITWEB_SITE_FOOTER =
  38HIGHLIGHT_BIN = highlight
  39
  40# include user config
  41-include ../config.mak.autogen
  42-include ../config.mak
  43
  44# determine version
  45../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
  46        $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
  47
  48-include ../GIT-VERSION-FILE
  49
  50### Build rules
  51
  52SHELL_PATH ?= $(SHELL)
  53PERL_PATH  ?= /usr/bin/perl
  54
  55# Shell quote;
  56bindir_SQ = $(subst ','\'',$(bindir))#'
  57gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
  58gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
  59SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
  60PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))#'
  61DESTDIR_SQ    = $(subst ','\'',$(DESTDIR))#'
  62
  63# Quiet generation (unless V=1)
  64QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
  65QUIET_SUBDIR1  =
  66
  67ifneq ($(findstring $(MAKEFLAGS),w),w)
  68PRINT_DIR = --no-print-directory
  69else # "make -w"
  70NO_SUBDIR = :
  71endif
  72
  73ifneq ($(findstring $(MAKEFLAGS),s),s)
  74ifndef V
  75        QUIET          = @
  76        QUIET_GEN      = $(QUIET)echo '   ' GEN $@;
  77        QUIET_SUBDIR0  = +@subdir=
  78        QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
  79                         $(MAKE) $(PRINT_DIR) -C $$subdir
  80        export V
  81        export QUIET
  82        export QUIET_GEN
  83        export QUIET_SUBDIR0
  84        export QUIET_SUBDIR1
  85endif
  86endif
  87
  88all:: gitweb.cgi
  89
  90GITWEB_PROGRAMS = gitweb.cgi
  91
  92ifdef JSMIN
  93GITWEB_FILES += static/gitweb.min.js
  94GITWEB_JS = static/gitweb.min.js
  95all:: static/gitweb.min.js
  96static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS
  97        $(QUIET_GEN)$(JSMIN) <$< >$@
  98else
  99GITWEB_FILES += static/gitweb.js
 100endif
 101
 102ifdef CSSMIN
 103GITWEB_FILES += static/gitweb.min.css
 104GITWEB_CSS = static/gitweb.min.css
 105all:: static/gitweb.min.css
 106static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS
 107        $(QUIET_GEN)$(CSSMIN) <$< >$@
 108else
 109GITWEB_FILES += static/gitweb.css
 110endif
 111
 112GITWEB_FILES += static/git-logo.png static/git-favicon.png
 113
 114GITWEB_REPLACE = \
 115        -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 116        -e 's|++GIT_BINDIR++|$(bindir)|g' \
 117        -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 118        -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
 119        -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
 120        -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
 121        -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 122        -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
 123        -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
 124        -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
 125        -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
 126        -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
 127        -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
 128        -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
 129        -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 130        -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
 131        -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
 132        -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 133        -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
 134        -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
 135
 136GITWEB-BUILD-OPTIONS: FORCE
 137        @rm -f $@+
 138        @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
 139        @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
 140
 141gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
 142        $(QUIET_GEN)$(RM) $@ $@+ && \
 143        sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 144                $(GITWEB_REPLACE) $< >$@+ && \
 145        chmod +x $@+ && \
 146        mv $@+ $@
 147
 148### Installation rules
 149
 150install: all
 151        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 152        $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 153        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 154        $(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 155
 156### Cleaning rules
 157
 158clean:
 159        $(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
 160
 161.PHONY: all clean install .FORCE-GIT-VERSION-FILE FORCE
 162