gitweb / Makefileon commit Merge branch 'rc/histogram-diff' (ca01600)
   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_CONFIG_COMMON = /etc/gitweb-common.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
  33GITWEB_CSS = static/gitweb.css
  34GITWEB_LOGO = static/git-logo.png
  35GITWEB_FAVICON = static/git-favicon.png
  36GITWEB_JS = static/gitweb.js
  37GITWEB_SITE_HEADER =
  38GITWEB_SITE_FOOTER =
  39HIGHLIGHT_BIN = highlight
  40
  41# include user config
  42-include ../config.mak.autogen
  43-include ../config.mak
  44-include config.mak
  45
  46# determine version
  47../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
  48        $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
  49
  50-include ../GIT-VERSION-FILE
  51
  52### Build rules
  53
  54SHELL_PATH ?= $(SHELL)
  55PERL_PATH  ?= /usr/bin/perl
  56
  57# Shell quote;
  58bindir_SQ = $(subst ','\'',$(bindir))#'
  59gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
  60gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
  61SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
  62PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))#'
  63DESTDIR_SQ    = $(subst ','\'',$(DESTDIR))#'
  64
  65# Quiet generation (unless V=1)
  66QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
  67QUIET_SUBDIR1  =
  68
  69ifneq ($(findstring $(MAKEFLAGS),w),w)
  70PRINT_DIR = --no-print-directory
  71else # "make -w"
  72NO_SUBDIR = :
  73endif
  74
  75ifneq ($(findstring $(MAKEFLAGS),s),s)
  76ifndef V
  77        QUIET          = @
  78        QUIET_GEN      = $(QUIET)echo '   ' GEN $@;
  79        QUIET_SUBDIR0  = +@subdir=
  80        QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
  81                         $(MAKE) $(PRINT_DIR) -C $$subdir
  82        export V
  83        export QUIET
  84        export QUIET_GEN
  85        export QUIET_SUBDIR0
  86        export QUIET_SUBDIR1
  87endif
  88endif
  89
  90all:: gitweb.cgi static/gitweb.js
  91
  92GITWEB_PROGRAMS = gitweb.cgi
  93
  94ifdef JSMIN
  95GITWEB_FILES += static/gitweb.min.js
  96GITWEB_JS = static/gitweb.min.js
  97all:: static/gitweb.min.js
  98static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS
  99        $(QUIET_GEN)$(JSMIN) <$< >$@
 100else
 101GITWEB_FILES += static/gitweb.js
 102endif
 103
 104ifdef CSSMIN
 105GITWEB_FILES += static/gitweb.min.css
 106GITWEB_CSS = static/gitweb.min.css
 107all:: static/gitweb.min.css
 108static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS
 109        $(QUIET_GEN)$(CSSMIN) <$< >$@
 110else
 111GITWEB_FILES += static/gitweb.css
 112endif
 113
 114GITWEB_FILES += static/git-logo.png static/git-favicon.png
 115
 116# JavaScript files that are composed (concatenated) to form gitweb.js
 117#
 118# js/lib/common-lib.js should be always first, then js/lib/*.js,
 119# then the rest of files; js/gitweb.js should be last (if it exists)
 120GITWEB_JSLIB_FILES += static/js/lib/common-lib.js
 121GITWEB_JSLIB_FILES += static/js/lib/datetime.js
 122GITWEB_JSLIB_FILES += static/js/lib/cookies.js
 123GITWEB_JSLIB_FILES += static/js/javascript-detection.js
 124GITWEB_JSLIB_FILES += static/js/adjust-timezone.js
 125GITWEB_JSLIB_FILES += static/js/blame_incremental.js
 126
 127
 128GITWEB_REPLACE = \
 129        -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 130        -e 's|++GIT_BINDIR++|$(bindir)|g' \
 131        -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 132        -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
 133        -e 's|++GITWEB_CONFIG_COMMON++|$(GITWEB_CONFIG_COMMON)|g' \
 134        -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
 135        -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
 136        -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 137        -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
 138        -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
 139        -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
 140        -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
 141        -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
 142        -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
 143        -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
 144        -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 145        -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
 146        -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
 147        -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 148        -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
 149        -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
 150
 151GITWEB-BUILD-OPTIONS: FORCE
 152        @rm -f $@+
 153        @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
 154        @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
 155
 156gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
 157        $(QUIET_GEN)$(RM) $@ $@+ && \
 158        sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 159                $(GITWEB_REPLACE) $< >$@+ && \
 160        chmod +x $@+ && \
 161        mv $@+ $@
 162
 163static/gitweb.js: $(GITWEB_JSLIB_FILES)
 164        $(QUIET_GEN)$(RM) $@ $@+ && \
 165        cat $^ >$@+ && \
 166        mv $@+ $@
 167
 168### Testing rules
 169
 170test:
 171        $(MAKE) -C ../t gitweb-test
 172
 173test-installed:
 174        GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
 175                $(MAKE) -C ../t gitweb-test
 176
 177### Installation rules
 178
 179install: all
 180        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 181        $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 182        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 183        $(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
 184
 185### Cleaning rules
 186
 187clean:
 188        $(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
 189
 190.PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE
 191