gitweb.psgi: Use installed static files, if they are available
[git/jnareb-git.git] / gitweb / Makefile
blob6f673ff9a7749c1d111dbb71895b6e41e2db1c50
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
16 gitwebstaticdir ?= $(gitwebdir)/static
17 gitweblibdir ?= $(gitwebdir)/lib
19 RM ?= rm -f
20 INSTALL ?= install
22 # default configuration for gitweb
23 GITWEB_CONFIG = gitweb_config.perl
24 GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
25 GITWEB_CONFIG_COMMON = /etc/gitweb-common.conf
26 GITWEB_HOME_LINK_STR = projects
27 GITWEB_SITENAME =
28 GITWEB_PROJECTROOT = /pub/git
29 GITWEB_PROJECT_MAXDEPTH = 2007
30 GITWEB_EXPORT_OK =
31 GITWEB_STRICT_EXPORT =
32 GITWEB_BASE_URL =
33 GITWEB_LIST =
34 GITWEB_HOMETEXT = indextext.html
35 GITWEB_CSS = static/gitweb.css
36 GITWEB_LOGO = static/git-logo.png
37 GITWEB_FAVICON = static/git-favicon.png
38 GITWEB_JS = static/gitweb.js
39 GITWEB_SITE_HTML_HEAD_STRING =
40 GITWEB_SITE_HEADER =
41 GITWEB_SITE_FOOTER =
42 HIGHLIGHT_BIN = highlight
44 # include user config
45 -include ../config.mak.autogen
46 -include ../config.mak
47 -include config.mak
49 # determine version
50 ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
51 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
53 -include ../GIT-VERSION-FILE
55 ### Build rules
57 SHELL_PATH ?= $(SHELL)
58 PERL_PATH ?= /usr/bin/perl
60 # Shell quote;
61 bindir_SQ = $(subst ','\'',$(bindir))#'
62 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
63 gitwebstaticdir_SQ = $(subst ','\'',$(gitwebstaticdir))#'
64 gitweblibdir_SQ = $(subst ','\'',$(gitweblibdir))#'
65 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
66 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#'
67 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#'
69 # Quiet generation (unless V=1)
70 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
71 QUIET_SUBDIR1 =
73 ifneq ($(findstring $(MAKEFLAGS),w),w)
74 PRINT_DIR = --no-print-directory
75 else # "make -w"
76 NO_SUBDIR = :
77 endif
79 ifneq ($(findstring $(MAKEFLAGS),s),s)
80 ifndef V
81 QUIET = @
82 QUIET_GEN = $(QUIET)echo ' ' GEN $@;
83 QUIET_SUBDIR0 = +@subdir=
84 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
85 $(MAKE) $(PRINT_DIR) -C $$subdir
86 export V
87 export QUIET
88 export QUIET_GEN
89 export QUIET_SUBDIR0
90 export QUIET_SUBDIR1
91 endif
92 endif
94 all:: gitweb.cgi static/gitweb.js
96 GITWEB_PROGRAMS = gitweb.cgi
98 ifdef JSMIN
99 GITWEB_FILES += static/gitweb.min.js
100 GITWEB_JS = static/gitweb.min.js
101 all:: static/gitweb.min.js
102 static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS
103 $(QUIET_GEN)$(JSMIN) <$< >$@
104 else
105 GITWEB_FILES += static/gitweb.js
106 endif
108 ifdef CSSMIN
109 GITWEB_FILES += static/gitweb.min.css
110 GITWEB_CSS = static/gitweb.min.css
111 all:: static/gitweb.min.css
112 static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS
113 $(QUIET_GEN)$(CSSMIN) <$< >$@
114 else
115 GITWEB_FILES += static/gitweb.css
116 endif
118 GITWEB_FILES += static/git-logo.png static/git-favicon.png
120 # JavaScript files that are composed (concatenated) to form gitweb.js
122 # js/lib/common-lib.js should be always first, then js/lib/*.js,
123 # then the rest of files; js/gitweb.js should be last (if it exists)
124 GITWEB_JSLIB_FILES += static/js/lib/common-lib.js
125 GITWEB_JSLIB_FILES += static/js/lib/datetime.js
126 GITWEB_JSLIB_FILES += static/js/lib/cookies.js
127 GITWEB_JSLIB_FILES += static/js/javascript-detection.js
128 GITWEB_JSLIB_FILES += static/js/adjust-timezone.js
129 GITWEB_JSLIB_FILES += static/js/blame_incremental.js
132 GITWEB_REPLACE = \
133 -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
134 -e 's|++GIT_BINDIR++|$(bindir)|g' \
135 -e 's|++GITWEBSTATICDIR++|$(gitwebstaticdir)|g' \
136 -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
137 -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
138 -e 's|++GITWEB_CONFIG_COMMON++|$(GITWEB_CONFIG_COMMON)|g' \
139 -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
140 -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
141 -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
142 -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
143 -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
144 -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
145 -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
146 -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
147 -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
148 -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
149 -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
150 -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
151 -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
152 -e 's|++GITWEB_SITE_HTML_HEAD_STRING++|$(GITWEB_SITE_HTML_HEAD_STRING)|g' \
153 -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
154 -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
155 -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
157 GITWEB-BUILD-OPTIONS: FORCE
158 @rm -f $@+
159 @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
160 @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
162 gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
163 $(QUIET_GEN)$(RM) $@ $@+ && \
164 sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
165 $(GITWEB_REPLACE) $< >$@+ && \
166 chmod +x $@+ && \
167 mv $@+ $@
169 static/gitweb.js: $(GITWEB_JSLIB_FILES)
170 $(QUIET_GEN)$(RM) $@ $@+ && \
171 cat $^ >$@+ && \
172 mv $@+ $@
174 ### Testing rules
176 test:
177 $(MAKE) -C ../t gitweb-test
179 test-installed:
180 GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
181 $(MAKE) -C ../t gitweb-test
183 ### Installation rules
185 install: all install-modules
186 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
187 $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
188 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
189 $(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
191 install-modules:
192 install_dirs="$(sort $(dir $(GITWEB_MODULES)))" && \
193 for dir in $$install_dirs; do \
194 test -d '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir' || \
195 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$dir'; \
196 done
197 gitweb_modules="$(GITWEB_MODULES)" && \
198 for mod in $$gitweb_modules; do \
199 $(INSTALL) -m 644 $$mod '$(DESTDIR_SQ)$(gitwebdir_SQ)/$$(dirname $$mod)'; \
200 done
202 ### Cleaning rules
204 clean:
205 $(RM) gitweb.cgi static/gitweb.js \
206 static/gitweb.min.js static/gitweb.min.css \
207 GITWEB-BUILD-OPTIONS
209 .PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE