Merge branch 'ab/sparse-index-cleanup'
[alt-git.git] / gitweb / Makefile
blobf13e23c4de41a602537043c0b21fab7ccb65df0b
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_CONFIG_COMMON = /etc/gitweb-common.conf
24 GITWEB_HOME_LINK_STR = projects
25 GITWEB_SITENAME =
26 GITWEB_PROJECTROOT = /pub/git
27 GITWEB_PROJECT_MAXDEPTH = 2007
28 GITWEB_EXPORT_OK =
29 GITWEB_STRICT_EXPORT =
30 GITWEB_BASE_URL =
31 GITWEB_LIST =
32 GITWEB_HOMETEXT = indextext.html
33 GITWEB_CSS = static/gitweb.css
34 GITWEB_LOGO = static/git-logo.png
35 GITWEB_FAVICON = static/git-favicon.png
36 GITWEB_JS = static/gitweb.js
37 GITWEB_SITE_HTML_HEAD_STRING =
38 GITWEB_SITE_HEADER =
39 GITWEB_SITE_FOOTER =
40 HIGHLIGHT_BIN = highlight
42 # include user config
43 -include ../config.mak.autogen
44 -include ../config.mak
45 -include config.mak
47 # determine version
48 ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
49 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
51 ifneq ($(MAKECMDGOALS),clean)
52 -include ../GIT-VERSION-FILE
53 endif
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 ','\'',$(gitwebdir)/static)#'
64 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
65 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#'
66 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#'
68 # Quiet generation (unless V=1)
69 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
70 QUIET_SUBDIR1 =
72 ifneq ($(findstring $(MAKEFLAGS),w),w)
73 PRINT_DIR = --no-print-directory
74 else # "make -w"
75 NO_SUBDIR = :
76 endif
78 ifneq ($(findstring $(MAKEFLAGS),s),s)
79 ifndef 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
90 endif
91 endif
93 all:: gitweb.cgi static/gitweb.js
95 GITWEB_PROGRAMS = gitweb.cgi
97 ifdef JSMIN
98 GITWEB_FILES += static/gitweb.min.js
99 GITWEB_JS = static/gitweb.min.js
100 all:: static/gitweb.min.js
101 static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS
102 $(QUIET_GEN)$(JSMIN) <$< >$@
103 else
104 GITWEB_FILES += static/gitweb.js
105 endif
107 ifdef CSSMIN
108 GITWEB_FILES += static/gitweb.min.css
109 GITWEB_CSS = static/gitweb.min.css
110 all:: static/gitweb.min.css
111 static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS
112 $(QUIET_GEN)$(CSSMIN) <$< >$@
113 else
114 GITWEB_FILES += static/gitweb.css
115 endif
117 GITWEB_FILES += static/git-logo.png static/git-favicon.png
119 # JavaScript files that are composed (concatenated) to form gitweb.js
121 # js/lib/common-lib.js should be always first, then js/lib/*.js,
122 # then the rest of files; js/gitweb.js should be last (if it exists)
123 GITWEB_JSLIB_FILES += static/js/lib/common-lib.js
124 GITWEB_JSLIB_FILES += static/js/lib/datetime.js
125 GITWEB_JSLIB_FILES += static/js/lib/cookies.js
126 GITWEB_JSLIB_FILES += static/js/javascript-detection.js
127 GITWEB_JSLIB_FILES += static/js/adjust-timezone.js
128 GITWEB_JSLIB_FILES += static/js/blame_incremental.js
131 GITWEB_REPLACE = \
132 -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
133 -e 's|++GIT_BINDIR++|$(bindir)|g' \
134 -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
135 -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
136 -e 's|++GITWEB_CONFIG_COMMON++|$(GITWEB_CONFIG_COMMON)|g' \
137 -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
138 -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
139 -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
140 -e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
141 -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
142 -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
143 -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
144 -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
145 -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
146 -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
147 -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
148 -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
149 -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
150 -e 's|++GITWEB_SITE_HTML_HEAD_STRING++|$(GITWEB_SITE_HTML_HEAD_STRING)|g' \
151 -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
152 -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
153 -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
155 GITWEB-BUILD-OPTIONS: FORCE
156 @rm -f $@+
157 @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
158 @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
160 gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
161 $(QUIET_GEN)$(RM) $@ $@+ && \
162 sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
163 $(GITWEB_REPLACE) $< >$@+ && \
164 chmod +x $@+ && \
165 mv $@+ $@
167 static/gitweb.js: $(GITWEB_JSLIB_FILES)
168 $(QUIET_GEN)$(RM) $@ $@+ && \
169 cat $^ >$@+ && \
170 mv $@+ $@
172 ### Testing rules
174 test:
175 $(MAKE) -C ../t gitweb-test
177 test-installed:
178 GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
179 $(MAKE) -C ../t gitweb-test
181 ### Installation rules
183 install: all
184 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
185 $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
186 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
187 $(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
189 ### Cleaning rules
191 clean:
192 $(RM) gitweb.cgi static/gitweb.js \
193 static/gitweb.min.js static/gitweb.min.css \
194 GITWEB-BUILD-OPTIONS
196 .PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE