gitweb / Makefileon commit Gitweb: add support for minifying gitweb.css (0e6ce21)
   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 gitweb.js minified.
   8#
   9# Define CSSMIN to point to a CSS minifier in order to generate a minified
  10# version of gitweb.css
  11#
  12
  13prefix ?= $(HOME)
  14bindir ?= $(prefix)/bin
  15RM ?= rm -f
  16
  17# JavaScript/CSS minifier invocation that can function as filter
  18JSMIN ?=
  19CSSMIN ?=
  20
  21# default configuration for gitweb
  22GITWEB_CONFIG = gitweb_config.perl
  23GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
  24GITWEB_HOME_LINK_STR = projects
  25GITWEB_SITENAME =
  26GITWEB_PROJECTROOT = /pub/git
  27GITWEB_PROJECT_MAXDEPTH = 2007
  28GITWEB_EXPORT_OK =
  29GITWEB_STRICT_EXPORT =
  30GITWEB_BASE_URL =
  31GITWEB_LIST =
  32GITWEB_HOMETEXT = indextext.html
  33ifdef CSSMIN
  34GITWEB_CSS = gitweb.min.css
  35else
  36GITWEB_CSS = gitweb.css
  37endif
  38GITWEB_LOGO = git-logo.png
  39GITWEB_FAVICON = git-favicon.png
  40ifdef JSMIN
  41GITWEB_JS = gitweb.min.js
  42else
  43GITWEB_JS = gitweb.js
  44endif
  45GITWEB_SITE_HEADER =
  46GITWEB_SITE_FOOTER =
  47
  48# include user config
  49-include ../config.mak.autogen
  50-include ../config.mak
  51
  52# determine version
  53../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
  54        $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
  55
  56-include ../GIT-VERSION-FILE
  57
  58### Build rules
  59
  60SHELL_PATH ?= $(SHELL)
  61PERL_PATH  ?= /usr/bin/perl
  62
  63# Shell quote;
  64bindir_SQ = $(subst ','\'',$(bindir))         #'
  65SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) #'
  66PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))  #'
  67
  68# Quiet generation (unless V=1)
  69QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
  70QUIET_SUBDIR1  =
  71
  72ifneq ($(findstring $(MAKEFLAGS),w),w)
  73PRINT_DIR = --no-print-directory
  74else # "make -w"
  75NO_SUBDIR = :
  76endif
  77
  78ifneq ($(findstring $(MAKEFLAGS),s),s)
  79ifndef V
  80        QUIET          = @
  81        QUIET_GEN      = $(QUIET)echo '   ' GEN $@;
  82        QUIET_SUBDIR0  = +@subdir=
  83        QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
  84                         $(MAKE) $(PRINT_DIR) -C $$subdir
  85        export V
  86        export QUIET
  87        export QUIET_GEN
  88        export QUIET_SUBDIR0
  89        export QUIET_SUBDIR1
  90endif
  91endif
  92
  93all:: gitweb.cgi
  94
  95FILES = gitweb.cgi
  96ifdef JSMIN
  97FILES += gitweb.min.js
  98endif
  99ifdef CSSMIN
 100FILES += gitweb.min.css
 101endif
 102gitweb.cgi: gitweb.perl $(GITWEB_JS) $(GITWEB_CSS)
 103
 104gitweb.cgi:
 105        $(QUIET_GEN)$(RM) $@ $@+ && \
 106        sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 107            -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 108            -e 's|++GIT_BINDIR++|$(bindir)|g' \
 109            -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 110            -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
 111            -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
 112            -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
 113            -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 114            -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
 115            -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
 116            -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
 117            -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
 118            -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
 119            -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
 120            -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
 121            -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 122            -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
 123            -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
 124            -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 125            -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
 126            $< >$@+ && \
 127        chmod +x $@+ && \
 128        mv $@+ $@
 129
 130ifdef JSMIN
 131gitweb.min.js: gitweb.js
 132        $(QUIET_GEN)$(JSMIN) <$< >$@
 133endif # JSMIN
 134
 135ifdef CSSMIN
 136gitweb.min.css: gitweb.css
 137        $(QUIET_GEN)$(CSSMIN) <$ >$@
 138endif
 139
 140clean:
 141        $(RM) $(FILES)
 142
 143.PHONY: all clean .FORCE-GIT-VERSION-FILE