gitweb/Makefile: include in top-level Makefile

Include the gitweb/Makefile in the top-level Makefile rather than calling it as a sub-Makefile. As noted in the thread starting at at [1] (in particular [2]) we'll pay a high cost on NOOP runs of "make" just to figure out that we have nothing to do for "make gitweb". The "gitweb" script also isn't maintained out-of-tree, unlike "gitk-git" or "git-gui", which both have their own "Makefile". Other parts of it are already integrated into our main Makefiles, e.g. the documentation is built by Documentation/Makefile since 07ea4df2780 (gitweb: Add gitweb(1) manpage for gitweb itself, 2011-10-16). 1. https://lore.kernel.org/git/20220525205651.825669-1-szeder.dev@gmail.com/ 2. https://lore.kernel.org/git/220526.86k0a96sv2.gmgdl@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jun 28, 2022 at 12:16 UTC affc3b755cb4d1ac87096bbb93f5f2e57b703894
2 files changed +29 -85
Makefile
+13 -10
@@ -538,6 +538,7 @@ gitexecdir = libexec/git-core
538 mergetoolsdir = $(gitexecdir)/mergetools
539 sharedir = $(prefix)/share
540 gitwebdir = $(sharedir)/gitweb
541 +gitwebstaticdir = $(gitwebdir)/static
542 perllibdir = $(sharedir)/perl5
543 localedir = $(sharedir)/locale
544 template_dir = share/git-core/templates
@@ -556,7 +557,7 @@ localedir_relative = $(patsubst $(prefix)/%,%,$(localedir))
557 htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
558 perllibdir_relative = $(patsubst $(prefix)/%,%,$(perllibdir))
559
559 -export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
560 +export prefix bindir sharedir sysconfdir perllibdir localedir
561
562 # Set our default programs
563 CC = cc
@@ -2071,6 +2072,7 @@ htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
2072 prefix_SQ = $(subst ','\'',$(prefix))
2073 perllibdir_relative_SQ = $(subst ','\'',$(perllibdir_relative))
2074 gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
2075 +gitwebstaticdir_SQ = $(subst ','\'',$(gitwebstaticdir))
2076
2077 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
2078 TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH))
@@ -2399,10 +2401,6 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
2401 perllibdir:
2402 @echo '$(perllibdir_SQ)'
2403
2402 -.PHONY: gitweb
2403 -gitweb:
2404 - $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all
2405 -
2404 git-instaweb: git-instaweb.sh GIT-SCRIPT-DEFINES
2405 $(QUIET_GEN)$(cmd_munge_script) && \
2406 chmod +x $@+ && \
@@ -3036,6 +3034,15 @@ coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.c
3034
3035 .PHONY: coccicheck coccicheck-pending
3036
3037 +# "Sub"-Makefiles, not really because they can't be run stand-alone,
3038 +# only there to contain directory-specific rules and variables
3039 +## gitweb/Makefile inclusion:
3040 +MAK_DIR_GITWEB = gitweb/
3041 +include gitweb/Makefile
3042 +
3043 +.PHONY: gitweb
3044 +gitweb: $(MAK_DIR_GITWEB_ALL)
3045 +
3046 ### Installation rules
3047
3048 ifneq ($(filter /%,$(firstword $(template_dir))),)
@@ -3108,7 +3115,6 @@ ifndef NO_PERL
3115 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perllibdir_SQ)'
3116 (cd perl/build/lib && $(TAR) cf - .) | \
3117 (cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xof -)
3111 - $(MAKE) -C gitweb install
3118 endif
3119 ifndef NO_TCLTK
3120 $(MAKE) -C gitk-git install
@@ -3163,10 +3169,8 @@ endif
3169 cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; } \
3170 done
3171
3166 -.PHONY: install-gitweb install-doc install-man install-man-perl install-html install-info install-pdf
3172 +.PHONY: install-doc install-man install-man-perl install-html install-info install-pdf
3173 .PHONY: quick-install-doc quick-install-man quick-install-html
3168 -install-gitweb:
3169 - $(MAKE) -C gitweb install
3174
3175 install-doc: install-man-perl
3176 $(MAKE) -C Documentation install
@@ -3310,7 +3314,6 @@ clean: profile-clean coverage-clean cocciclean
3314 $(MAKE) -C Documentation/ clean
3315 $(RM) Documentation/GIT-EXCLUDED-PROGRAMS
3316 ifndef NO_PERL
3313 - $(MAKE) -C gitweb clean
3317 $(RM) -r perl/build/
3318 endif
3319 $(MAKE) -C templates/ clean
gitweb/Makefile
+16 -75
@@ -1,11 +1,8 @@
1 -# The default target of this Makefile is...
2 -all::
3 -.PHONY: all
4 -
5 -MAK_DIR_GITWEB =
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
5
7 -# Define V=1 to have a more verbose compile.
8 -#
6 # Define JSMIN to point to JavaScript minifier that functions as
7 # a filter to have static/gitweb.js minified.
8 #
@@ -13,13 +10,6 @@ MAK_DIR_GITWEB =
10 # version of static/gitweb.css
11 #
12
16 -prefix ?= $(HOME)
17 -bindir ?= $(prefix)/bin
18 -gitwebdir ?= /var/www/cgi-bin
19 -
20 -RM ?= rm -f
21 -INSTALL ?= install
22 -
13 # default configuration for gitweb
14 GITWEB_CONFIG = gitweb_config.perl
15 GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
@@ -44,71 +34,19 @@ GITWEB_SITE_HEADER =
34 GITWEB_SITE_FOOTER =
35 HIGHLIGHT_BIN = highlight
36
47 -# include user config
48 --include ../config.mak.autogen
49 --include ../config.mak
50 --include config.mak
51 -
52 -# determine version
53 -.PHONY: .FORCE-GIT-VERSION-FILE
54 -../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
55 - $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
56 -
57 -ifneq ($(MAKECMDGOALS),clean)
58 --include ../GIT-VERSION-FILE
59 -endif
60 -
37 # What targets we'll add to 'all' for "make gitweb"
38 GITWEB_ALL =
39 GITWEB_ALL += gitweb.cgi
40 GITWEB_ALL += $(GITWEB_JS)
41
66 -### Build rules
67 -
68 -SHELL_PATH ?= $(SHELL)
69 -PERL_PATH ?= /usr/bin/perl
70 -
71 -# Shell quote;
72 -bindir_SQ = $(subst ','\'',$(bindir))#'
73 -gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
74 -gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
75 -SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
76 -PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#'
77 -DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#'
78 -
79 -# Quiet generation (unless V=1)
80 -QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
81 -QUIET_SUBDIR1 =
82 -
83 -ifneq ($(findstring $(MAKEFLAGS),w),w)
84 -PRINT_DIR = --no-print-directory
85 -else # "make -w"
86 -NO_SUBDIR = :
87 -endif
88 -
89 -ifneq ($(findstring $(MAKEFLAGS),s),s)
90 -ifndef V
91 - QUIET = @
92 - QUIET_GEN = $(QUIET)echo ' ' GEN $@;
93 - QUIET_SUBDIR0 = +@subdir=
94 - QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
95 - $(MAKE) $(PRINT_DIR) -C $$subdir
96 - export V
97 - export QUIET
98 - export QUIET_GEN
99 - export QUIET_SUBDIR0
100 - export QUIET_SUBDIR1
101 -endif
102 -endif
103 -
104 -all:: $(GITWEB_ALL)
42 +MAK_DIR_GITWEB_ALL = $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_ALL))
43
44 GITWEB_PROGRAMS = gitweb.cgi
45
46 GITWEB_JS_MIN = static/gitweb.min.js
47 ifdef JSMIN
48 GITWEB_JS = $(GITWEB_JS_MIN)
111 -all:: $(MAK_DIR_GITWEB)$(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)
52 $(QUIET_GEN)$(JSMIN) <$< >$@
@@ -118,7 +56,7 @@ GITWEB_FILES += $(GITWEB_JS)
56 GITWEB_CSS_MIN = static/gitweb.min.css
57 ifdef CSSMIN
58 GITWEB_CSS = $(GITWEB_CSS_MIN)
121 -all:: $(MAK_DIR_GITWEB)$(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)
62 $(QUIET_GEN)$(CSSMIN) <$< >$@
@@ -185,19 +123,22 @@ $(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_
123
124 ### Installation rules
125
188 -.PHONY: install
189 -install: all
126 +.PHONY: install-gitweb
127 +install-gitweb: $(MAK_DIR_GITWEB_ALL)
128 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
191 - $(INSTALL) -m 755 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_PROGRAMS)) \
192 - '$(DESTDIR_SQ)$(gitwebdir_SQ)'
129 + $(INSTALL) -m 755 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_PROGRAMS)) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
130 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
131 $(INSTALL) -m 644 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_FILES)) \
132 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
133 +ifndef NO_PERL
134 +install: install-gitweb
135 +endif
136
137 ### Cleaning rules
138
199 -.PHONY: clean
200 -clean:
139 +.PHONY: gitweb-clean
140 +gitweb-clean:
141 $(RM) $(addprefix $(MAK_DIR_GITWEB),gitweb.cgi $(GITWEB_JS_IN) \
142 $(GITWEB_JS_MIN) $(GITWEB_CSS_MIN) \
143 GITWEB-BUILD-OPTIONS)
144 +clean: gitweb-clean