gitweb/lib - Use locking to avoid 'cache miss stampede' problem
[git/jnareb-git.git] / gitweb / Makefile
blobacc4f5cb2f90b1d2b94cbba151d083518a023909
1 # The default target of this Makefile is...
2 all::
4 # Define V=1 to have a more verbose compile.
6 # Define JSMIN to point to JavaScript minifier that functions as
7 # a filter to have static/gitweb.js minified.
9 # Define CSSMIN to point to a CSS minifier in order to generate a minified
10 # version of static/gitweb.css
13 prefix ?= $(HOME)
14 bindir ?= $(prefix)/bin
15 gitwebdir ?= /var/www/cgi-bin
17 RM ?= rm -f
18 INSTALL ?= install
20 # default configuration for gitweb
21 GITWEB_CONFIG = gitweb_config.perl
22 GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
23 GITWEB_HOME_LINK_STR = projects
24 GITWEB_SITENAME =
25 GITWEB_PROJECTROOT = /pub/git
26 GITWEB_PROJECT_MAXDEPTH = 2007
27 GITWEB_EXPORT_OK =
28 GITWEB_STRICT_EXPORT =
29 GITWEB_BASE_URL =
30 GITWEB_LIST =
31 GITWEB_HOMETEXT = indextext.html
32 GITWEB_CSS = static/gitweb.css
33 GITWEB_LOGO = static/git-logo.png
34 GITWEB_FAVICON = static/git-favicon.png
35 GITWEB_JS = static/gitweb.js
36 GITWEB_SITE_HEADER =
37 GITWEB_SITE_FOOTER =
38 HIGHLIGHT_BIN = highlight
40 # include user config
41 -include ../config.mak.autogen
42 -include ../config.mak
43 -include config.mak
45 # determine version
46 ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
47 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
49 -include ../GIT-VERSION-FILE
51 ### Build rules
53 SHELL_PATH ?= $(SHELL)
54 PERL_PATH ?= /usr/bin/perl
56 # Shell quote;
57 bindir_SQ = $(subst ','\'',$(bindir))#'
58 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
59 gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
60 gitweblibdir_SQ = $(subst ','\'',$(gitwebdir)/lib)#'
61 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
62 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#'
63 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#'
65 # Quiet generation (unless V=1)
66 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
67 QUIET_SUBDIR1 =
69 ifneq ($(findstring $(MAKEFLAGS),w),w)
70 PRINT_DIR = --no-print-directory
71 else # "make -w"
72 NO_SUBDIR = :
73 endif
75 ifneq ($(findstring $(MAKEFLAGS),s),s)
76 ifndef 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
87 endif
88 endif
90 all:: gitweb.cgi
92 GITWEB_PROGRAMS = gitweb.cgi
94 ifdef JSMIN
95 GITWEB_FILES += static/gitweb.min.js
96 GITWEB_JS = static/gitweb.min.js
97 all:: static/gitweb.min.js
98 static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS
99 $(QUIET_GEN)$(JSMIN) <$< >$@
100 else
101 GITWEB_FILES += static/gitweb.js
102 endif
104 ifdef CSSMIN
105 GITWEB_FILES += static/gitweb.min.css
106 GITWEB_CSS = static/gitweb.min.css
107 all:: static/gitweb.min.css
108 static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS
109 $(QUIET_GEN)$(CSSMIN) <$< >$@
110 else
111 GITWEB_FILES += static/gitweb.css
112 endif
114 GITWEB_FILES += static/git-logo.png static/git-favicon.png
116 # gitweb output caching
117 GITWEB_MODULES += GitwebCache/CacheOutput.pm
118 GITWEB_MODULES += GitwebCache/SimpleFileCache.pm
119 GITWEB_MODULES += GitwebCache/FileCacheWithLocking.pm
120 GITWEB_MODULES += GitwebCache/Capture/Simple.pm
122 GITWEB_REPLACE = \
123 -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
124 -e 's|++GIT_BINDIR++|$(bindir)|g' \
125 -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
126 -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
127 -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
128 -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
129 -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
130 -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
131 -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
132 -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
133 -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
134 -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
135 -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
136 -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
137 -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
138 -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
139 -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
140 -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
141 -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
142 -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
144 GITWEB-BUILD-OPTIONS: FORCE
145 @rm -f $@+
146 @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
147 @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
149 gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
150 $(QUIET_GEN)$(RM) $@ $@+ && \
151 sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
152 $(GITWEB_REPLACE) $< >$@+ && \
153 chmod +x $@+ && \
154 mv $@+ $@
156 ### Testing rules
158 test:
159 $(MAKE) -C ../t gitweb-test
161 test-installed:
162 GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
163 GITWEBLIBDIR='$(DESTDIR_SQ)$(gitweblibdir_SQ)' \
164 $(MAKE) -C ../t gitweb-test
166 ### Installation rules
168 install: all install-modules
169 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
170 $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
171 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
172 $(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
174 install-modules:
175 install_dirs="$(sort $(dir $(GITWEB_MODULES)))" && \
176 for dir in $$install_dirs; do \
177 test -d '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir" || \
178 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir"; \
179 done
180 gitweb_modules="$(GITWEB_MODULES)" && \
181 for mod in $$gitweb_modules; do \
182 $(INSTALL) -m 644 "lib/$$mod" '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$(dirname $$mod)"; \
183 done
185 ### Cleaning rules
187 clean:
188 $(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
190 .PHONY: all clean install install-modules test test-installed .FORCE-GIT-VERSION-FILE FORCE