gitweb / Makefileon commit Merge branch 'cb/maint-stash-orphaned-file' (b7ef48d)
   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
  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 = gitweb.css
  33GITWEB_LOGO = git-logo.png
  34GITWEB_FAVICON = git-favicon.png
  35GITWEB_JS = gitweb.js
  36GITWEB_SITE_HEADER =
  37GITWEB_SITE_FOOTER =
  38
  39# include user config
  40-include ../config.mak.autogen
  41-include ../config.mak
  42
  43# determine version
  44../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
  45        $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
  46
  47-include ../GIT-VERSION-FILE
  48
  49### Build rules
  50
  51SHELL_PATH ?= $(SHELL)
  52PERL_PATH  ?= /usr/bin/perl
  53
  54# Shell quote;
  55bindir_SQ = $(subst ','\'',$(bindir))#'
  56gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
  57SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
  58PERL_PATH_SQ  = $(subst ','\'',$(PERL_PATH))#'
  59DESTDIR_SQ    = $(subst ','\'',$(DESTDIR))#'
  60
  61# Quiet generation (unless V=1)
  62QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
  63QUIET_SUBDIR1  =
  64
  65ifneq ($(findstring $(MAKEFLAGS),w),w)
  66PRINT_DIR = --no-print-directory
  67else # "make -w"
  68NO_SUBDIR = :
  69endif
  70
  71ifneq ($(findstring $(MAKEFLAGS),s),s)
  72ifndef V
  73        QUIET          = @
  74        QUIET_GEN      = $(QUIET)echo '   ' GEN $@;
  75        QUIET_SUBDIR0  = +@subdir=
  76        QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
  77                         $(MAKE) $(PRINT_DIR) -C $$subdir
  78        export V
  79        export QUIET
  80        export QUIET_GEN
  81        export QUIET_SUBDIR0
  82        export QUIET_SUBDIR1
  83endif
  84endif
  85
  86all:: gitweb.cgi
  87
  88GITWEB_PROGRAMS = gitweb.cgi
  89
  90ifdef JSMIN
  91GITWEB_FILES += gitweb.min.js
  92GITWEB_JS = gitweb.min.js
  93all:: gitweb.min.js
  94gitweb.min.js: gitweb.js GITWEB-BUILD-OPTIONS
  95        $(QUIET_GEN)$(JSMIN) <$< >$@
  96else
  97GITWEB_FILES += gitweb.js
  98endif
  99
 100ifdef CSSMIN
 101GITWEB_FILES += gitweb.min.css
 102GITWEB_CSS = gitweb.min.css
 103all:: gitweb.min.css
 104gitweb.min.css: gitweb.css GITWEB-BUILD-OPTIONS
 105        $(QUIET_GEN)$(CSSMIN) <$ >$@
 106else
 107GITWEB_FILES += gitweb.css
 108endif
 109
 110GITWEB_FILES += git-logo.png git-favicon.png
 111
 112GITWEB_REPLACE = \
 113        -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
 114        -e 's|++GIT_BINDIR++|$(bindir)|g' \
 115        -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
 116        -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
 117        -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
 118        -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
 119        -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 120        -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
 121        -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
 122        -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
 123        -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
 124        -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
 125        -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
 126        -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
 127        -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 128        -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
 129        -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
 130        -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 131        -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g'
 132
 133GITWEB-BUILD-OPTIONS: FORCE
 134        @rm -f $@+
 135        @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
 136        @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
 137
 138gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
 139        $(QUIET_GEN)$(RM) $@ $@+ && \
 140        sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 141                $(GITWEB_REPLACE) $< >$@+ && \
 142        chmod +x $@+ && \
 143        mv $@+ $@
 144
 145### Installation rules
 146
 147install: all
 148        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 149        $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 150        $(INSTALL) -m 644 $(GITWEB_FILES)    '$(DESTDIR_SQ)$(gitwebdir_SQ)'
 151
 152### Cleaning rules
 153
 154clean:
 155        $(RM) gitweb.cgi gitweb.min.js gitweb.min.css GITWEB-BUILD-OPTIONS
 156
 157.PHONY: all clean install .FORCE-GIT-VERSION-FILE FORCE
 158