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