Skip to content

Commit 48e88a4

Browse files
committed
Merge branch 'ab/build-gitweb'
Teach "make all" to build gitweb as well. * ab/build-gitweb: gitweb/Makefile: add a "NO_GITWEB" parameter Makefile: build 'gitweb' in the default target gitweb/Makefile: include in top-level Makefile gitweb: remove "test" and "test-installed" targets gitweb/Makefile: prepare to merge into top-level Makefile gitweb/Makefile: clear up and de-duplicate the gitweb.{css,js} vars gitweb/Makefile: add a $(GITWEB_ALL) variable gitweb/Makefile: define all .PHONY prerequisites inline
2 parents f63ac61 + a35258c commit 48e88a4

File tree

3 files changed

+68
-112
lines changed

3 files changed

+68
-112
lines changed

Makefile

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ include shared.mak
309309
# distributions that want to use their packaged versions of Perl
310310
# modules, instead of the fallbacks shipped with Git.
311311
#
312+
# Define NO_GITWEB if you do not want to build or install
313+
# 'gitweb'. Note that defining NO_PERL currently has the same effect
314+
# on not installing gitweb, but not on whether it's built in the
315+
# gitweb/ directory.
316+
#
312317
# Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
313318
# but /usr/bin/python2.7 or /usr/bin/python3 on some platforms).
314319
#
@@ -544,6 +549,7 @@ gitexecdir = libexec/git-core
544549
mergetoolsdir = $(gitexecdir)/mergetools
545550
sharedir = $(prefix)/share
546551
gitwebdir = $(sharedir)/gitweb
552+
gitwebstaticdir = $(gitwebdir)/static
547553
perllibdir = $(sharedir)/perl5
548554
localedir = $(sharedir)/locale
549555
template_dir = share/git-core/templates
@@ -562,7 +568,7 @@ localedir_relative = $(patsubst $(prefix)/%,%,$(localedir))
562568
htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
563569
perllibdir_relative = $(patsubst $(prefix)/%,%,$(perllibdir))
564570

565-
export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
571+
export prefix bindir sharedir sysconfdir perllibdir localedir
566572

567573
# Set our default programs
568574
CC = cc
@@ -2089,6 +2095,7 @@ htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
20892095
prefix_SQ = $(subst ','\'',$(prefix))
20902096
perllibdir_relative_SQ = $(subst ','\'',$(perllibdir_relative))
20912097
gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
2098+
gitwebstaticdir_SQ = $(subst ','\'',$(gitwebstaticdir))
20922099

20932100
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
20942101
TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH))
@@ -2417,10 +2424,6 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
24172424
perllibdir:
24182425
@echo '$(perllibdir_SQ)'
24192426

2420-
.PHONY: gitweb
2421-
gitweb:
2422-
$(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
2423-
24242427
git-instaweb: git-instaweb.sh GIT-SCRIPT-DEFINES
24252428
$(QUIET_GEN)$(cmd_munge_script) && \
24262429
chmod +x $@+ && \
@@ -3149,6 +3152,18 @@ coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.c
31493152

31503153
.PHONY: coccicheck coccicheck-pending
31513154

3155+
# "Sub"-Makefiles, not really because they can't be run stand-alone,
3156+
# only there to contain directory-specific rules and variables
3157+
## gitweb/Makefile inclusion:
3158+
MAK_DIR_GITWEB = gitweb/
3159+
include gitweb/Makefile
3160+
3161+
.PHONY: gitweb
3162+
gitweb: $(MAK_DIR_GITWEB_ALL)
3163+
ifndef NO_GITWEB
3164+
all:: gitweb
3165+
endif
3166+
31523167
### Installation rules
31533168

31543169
ifneq ($(filter /%,$(firstword $(template_dir))),)
@@ -3221,7 +3236,6 @@ ifndef NO_PERL
32213236
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perllibdir_SQ)'
32223237
(cd perl/build/lib && $(TAR) cf - .) | \
32233238
(cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xof -)
3224-
$(MAKE) -C gitweb install
32253239
endif
32263240
ifndef NO_TCLTK
32273241
$(MAKE) -C gitk-git install
@@ -3276,10 +3290,8 @@ endif
32763290
cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; } \
32773291
done
32783292

3279-
.PHONY: install-gitweb install-doc install-man install-man-perl install-html install-info install-pdf
3293+
.PHONY: install-doc install-man install-man-perl install-html install-info install-pdf
32803294
.PHONY: quick-install-doc quick-install-man quick-install-html
3281-
install-gitweb:
3282-
$(MAKE) -C gitweb install
32833295

32843296
install-doc: install-man-perl
32853297
$(MAKE) -C Documentation install
@@ -3425,7 +3437,6 @@ clean: profile-clean coverage-clean cocciclean
34253437
$(MAKE) -C Documentation/ clean
34263438
$(RM) Documentation/GIT-EXCLUDED-PROGRAMS
34273439
ifndef NO_PERL
3428-
$(MAKE) -C gitweb clean
34293440
$(RM) -r perl/build/
34303441
endif
34313442
$(MAKE) -C templates/ clean

gitweb/Makefile

Lines changed: 47 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
# The default target of this Makefile is...
2-
all::
1+
ifndef MAK_DIR_GITWEB
2+
$(error do not run gitweb/Makefile stand-alone anymore. The "gitweb" and \
3+
"install-gitweb" targets now live in the top-level Makefile)
4+
endif
35

4-
# Define V=1 to have a more verbose compile.
5-
#
66
# Define JSMIN to point to JavaScript minifier that functions as
77
# a filter to have static/gitweb.js minified.
88
#
99
# Define CSSMIN to point to a CSS minifier in order to generate a minified
1010
# version of static/gitweb.css
1111
#
1212

13-
prefix ?= $(HOME)
14-
bindir ?= $(prefix)/bin
15-
gitwebdir ?= /var/www/cgi-bin
16-
17-
RM ?= rm -f
18-
INSTALL ?= install
19-
2013
# default configuration for gitweb
2114
GITWEB_CONFIG = gitweb_config.perl
2215
GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
@@ -30,96 +23,53 @@ GITWEB_STRICT_EXPORT =
3023
GITWEB_BASE_URL =
3124
GITWEB_LIST =
3225
GITWEB_HOMETEXT = indextext.html
33-
GITWEB_CSS = static/gitweb.css
26+
GITWEB_CSS_IN = static/gitweb.css
27+
GITWEB_CSS = $(GITWEB_CSS_IN)
3428
GITWEB_LOGO = static/git-logo.png
3529
GITWEB_FAVICON = static/git-favicon.png
36-
GITWEB_JS = static/gitweb.js
30+
GITWEB_JS_IN = static/gitweb.js
31+
GITWEB_JS = $(GITWEB_JS_IN)
3732
GITWEB_SITE_HTML_HEAD_STRING =
3833
GITWEB_SITE_HEADER =
3934
GITWEB_SITE_FOOTER =
4035
HIGHLIGHT_BIN = highlight
4136

42-
# include user config
43-
-include ../config.mak.autogen
44-
-include ../config.mak
45-
-include config.mak
46-
47-
# determine version
48-
../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
49-
$(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
50-
51-
ifneq ($(MAKECMDGOALS),clean)
52-
-include ../GIT-VERSION-FILE
53-
endif
54-
55-
### Build rules
56-
57-
SHELL_PATH ?= $(SHELL)
58-
PERL_PATH ?= /usr/bin/perl
37+
# What targets we'll add to 'all' for "make gitweb"
38+
GITWEB_ALL =
39+
GITWEB_ALL += gitweb.cgi
40+
GITWEB_ALL += $(GITWEB_JS)
5941

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))#'
67-
68-
# Quiet generation (unless V=1)
69-
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
70-
QUIET_SUBDIR1 =
71-
72-
ifneq ($(findstring $(MAKEFLAGS),w),w)
73-
PRINT_DIR = --no-print-directory
74-
else # "make -w"
75-
NO_SUBDIR = :
76-
endif
77-
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
92-
93-
all:: gitweb.cgi static/gitweb.js
42+
MAK_DIR_GITWEB_ALL = $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_ALL))
9443

9544
GITWEB_PROGRAMS = gitweb.cgi
9645

46+
GITWEB_JS_MIN = static/gitweb.min.js
9747
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
48+
GITWEB_JS = $(GITWEB_JS_MIN)
49+
GITWEB_ALL += $(MAK_DIR_GITWEB)$(GITWEB_JS_MIN)
50+
$(MAK_DIR_GITWEB)$(GITWEB_JS_MIN): $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS
51+
$(MAK_DIR_GITWEB)$(GITWEB_JS_MIN): $(MAK_DIR_GITWEB)$(GITWEB_JS_IN)
10252
$(QUIET_GEN)$(JSMIN) <$< >$@
103-
else
104-
GITWEB_FILES += static/gitweb.js
10553
endif
54+
GITWEB_FILES += $(GITWEB_JS)
10655

56+
GITWEB_CSS_MIN = static/gitweb.min.css
10757
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
58+
GITWEB_CSS = $(GITWEB_CSS_MIN)
59+
GITWEB_ALL += $(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN)
60+
$(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN): $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS
61+
$(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN): $(MAK_DIR_GITWEB)$(GITWEB_CSS_IN)
11262
$(QUIET_GEN)$(CSSMIN) <$< >$@
113-
else
114-
GITWEB_FILES += static/gitweb.css
11563
endif
64+
GITWEB_FILES += $(GITWEB_CSS)
11665

11766
GITWEB_FILES += static/git-logo.png static/git-favicon.png
11867

11968
# JavaScript files that are composed (concatenated) to form gitweb.js
12069
#
12170
# js/lib/common-lib.js should be always first, then js/lib/*.js,
12271
# then the rest of files; js/gitweb.js should be last (if it exists)
72+
GITWEB_JSLIB_FILES =
12373
GITWEB_JSLIB_FILES += static/js/lib/common-lib.js
12474
GITWEB_JSLIB_FILES += static/js/lib/datetime.js
12575
GITWEB_JSLIB_FILES += static/js/lib/cookies.js
@@ -152,46 +102,45 @@ GITWEB_REPLACE = \
152102
-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
153103
-e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
154104

155-
GITWEB-BUILD-OPTIONS: FORCE
105+
.PHONY: FORCE
106+
$(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS: FORCE
156107
@rm -f $@+
157108
@echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+
158109
@cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@
159110

160-
gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS
111+
$(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS
112+
$(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl
161113
$(QUIET_GEN)$(RM) $@ $@+ && \
162114
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
163115
$(GITWEB_REPLACE) $< >$@+ && \
164116
chmod +x $@+ && \
165117
mv $@+ $@
166118

167-
static/gitweb.js: $(GITWEB_JSLIB_FILES)
119+
$(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES))
168120
$(QUIET_GEN)$(RM) $@ $@+ && \
169121
cat $^ >$@+ && \
170122
mv $@+ $@
171123

172-
### Testing rules
173-
174-
test:
175-
$(MAKE) -C ../t gitweb-test
176-
177-
test-installed:
178-
GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
179-
$(MAKE) -C ../t gitweb-test
180-
181124
### Installation rules
182125

183-
install: all
126+
.PHONY: install-gitweb
127+
install-gitweb: $(MAK_DIR_GITWEB_ALL)
184128
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
185-
$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
129+
$(INSTALL) -m 755 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_PROGRAMS)) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
186130
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
187-
$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
131+
$(INSTALL) -m 644 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_FILES)) \
132+
'$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
133+
ifndef NO_GITWEB
134+
ifndef NO_PERL
135+
install: install-gitweb
136+
endif
137+
endif
188138

189139
### Cleaning rules
190140

191-
clean:
192-
$(RM) gitweb.cgi static/gitweb.js \
193-
static/gitweb.min.js static/gitweb.min.css \
194-
GITWEB-BUILD-OPTIONS
195-
196-
.PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE
197-
141+
.PHONY: gitweb-clean
142+
gitweb-clean:
143+
$(RM) $(addprefix $(MAK_DIR_GITWEB),gitweb.cgi $(GITWEB_JS_IN) \
144+
$(GITWEB_JS_MIN) $(GITWEB_CSS_MIN) \
145+
GITWEB-BUILD-OPTIONS)
146+
clean: gitweb-clean

t/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
3535
CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
3636

3737
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
38-
TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
3938
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
4039
TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
4140
CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
@@ -112,9 +111,6 @@ aggregate-results:
112111
echo "$$f"; \
113112
done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
114113

115-
gitweb-test:
116-
$(MAKE) $(TGITWEB)
117-
118114
valgrind:
119115
$(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
120116

0 commit comments

Comments
 (0)