From 7decdb9b4ac322158069645685b7527cba65a7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Jun 2022 12:15:55 +0200 Subject: [PATCH 1/8] gitweb/Makefile: define all .PHONY prerequisites inline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the '.PHONY' definition so that it's split up and accompanies the relevant as they're defined. This will make a subsequent diff smaller as we'll remove some of these, and won't need to re-edit the now-removed '.PHONY' line. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- gitweb/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gitweb/Makefile b/gitweb/Makefile index f13e23c4de..abb5c9f9ab 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -1,5 +1,6 @@ # The default target of this Makefile is... all:: +.PHONY: all # Define V=1 to have a more verbose compile. # @@ -45,6 +46,7 @@ HIGHLIGHT_BIN = highlight -include config.mak # determine version +.PHONY: .FORCE-GIT-VERSION-FILE ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE @@ -152,6 +154,7 @@ GITWEB_REPLACE = \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g' +.PHONY: FORCE GITWEB-BUILD-OPTIONS: FORCE @rm -f $@+ @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+ @@ -171,15 +174,18 @@ static/gitweb.js: $(GITWEB_JSLIB_FILES) ### Testing rules +.PHONY: test test: $(MAKE) -C ../t gitweb-test +.PHONY: test-installed test-installed: GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \ $(MAKE) -C ../t gitweb-test ### Installation rules +.PHONY: install install: all $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)' $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)' @@ -188,10 +194,8 @@ install: all ### Cleaning rules +.PHONY: clean clean: $(RM) gitweb.cgi static/gitweb.js \ static/gitweb.min.js static/gitweb.min.css \ GITWEB-BUILD-OPTIONS - -.PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE - From 1e08fa5e2bf9cd254a742a0ac3e950a12fc45915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Jun 2022 12:15:56 +0200 Subject: [PATCH 2/8] gitweb/Makefile: add a $(GITWEB_ALL) variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Declare the targets that the "all" target depends on with a new $(GITWEB_ALL) variable. This will help to reduce churn in subsequent commits. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- gitweb/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gitweb/Makefile b/gitweb/Makefile index abb5c9f9ab..733b60f925 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -54,6 +54,11 @@ ifneq ($(MAKECMDGOALS),clean) -include ../GIT-VERSION-FILE endif +# What targets we'll add to 'all' for "make gitweb" +GITWEB_ALL = +GITWEB_ALL += gitweb.cgi +GITWEB_ALL += static/gitweb.js + ### Build rules SHELL_PATH ?= $(SHELL) @@ -92,7 +97,7 @@ ifndef V endif endif -all:: gitweb.cgi static/gitweb.js +all:: $(GITWEB_ALL) GITWEB_PROGRAMS = gitweb.cgi From 564ebde3d323fc3b22534dcbb32723807771b955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Jun 2022 12:15:57 +0200 Subject: [PATCH 3/8] gitweb/Makefile: clear up and de-duplicate the gitweb.{css,js} vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the variable definitions for the $(GITWEB_CSS) and $(GITWEB_JS) so that we have a clear separation between what we use as "in" files, v.s. our "min" files. We can now make the appending to $(GITWEB_FILES) unconditional, since $(GITWEB_{JS,CSS}) is either the "min" or non-"min" version. This reduces the duplication within the file. While we're at it let's initialize "GITWEB_JSLIB_FILES" as we normally do with such variables. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- gitweb/Makefile | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/gitweb/Makefile b/gitweb/Makefile index 733b60f925..a8752c1f11 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -31,10 +31,12 @@ GITWEB_STRICT_EXPORT = GITWEB_BASE_URL = GITWEB_LIST = GITWEB_HOMETEXT = indextext.html -GITWEB_CSS = static/gitweb.css +GITWEB_CSS_IN = static/gitweb.css +GITWEB_CSS = $(GITWEB_CSS_IN) GITWEB_LOGO = static/git-logo.png GITWEB_FAVICON = static/git-favicon.png -GITWEB_JS = static/gitweb.js +GITWEB_JS_IN = static/gitweb.js +GITWEB_JS = $(GITWEB_JS_IN) GITWEB_SITE_HTML_HEAD_STRING = GITWEB_SITE_HEADER = GITWEB_SITE_FOOTER = @@ -57,7 +59,7 @@ endif # What targets we'll add to 'all' for "make gitweb" GITWEB_ALL = GITWEB_ALL += gitweb.cgi -GITWEB_ALL += static/gitweb.js +GITWEB_ALL += $(GITWEB_JS) ### Build rules @@ -101,25 +103,23 @@ all:: $(GITWEB_ALL) GITWEB_PROGRAMS = gitweb.cgi +GITWEB_JS_MIN = static/gitweb.min.js ifdef JSMIN -GITWEB_FILES += static/gitweb.min.js -GITWEB_JS = static/gitweb.min.js -all:: static/gitweb.min.js -static/gitweb.min.js: static/gitweb.js GITWEB-BUILD-OPTIONS +GITWEB_JS = $(GITWEB_JS_MIN) +all:: $(GITWEB_JS_MIN) +$(GITWEB_JS_MIN): $(GITWEB_JS_IN) GITWEB-BUILD-OPTIONS $(QUIET_GEN)$(JSMIN) <$< >$@ -else -GITWEB_FILES += static/gitweb.js endif +GITWEB_FILES += $(GITWEB_JS) +GITWEB_CSS_MIN = static/gitweb.min.css ifdef CSSMIN -GITWEB_FILES += static/gitweb.min.css -GITWEB_CSS = static/gitweb.min.css -all:: static/gitweb.min.css -static/gitweb.min.css: static/gitweb.css GITWEB-BUILD-OPTIONS +GITWEB_CSS = $(GITWEB_CSS_MIN) +all:: $(GITWEB_CSS_MIN) +$(GITWEB_CSS_MIN): $(GITWEB_CSS_IN) GITWEB-BUILD-OPTIONS $(QUIET_GEN)$(CSSMIN) <$< >$@ -else -GITWEB_FILES += static/gitweb.css endif +GITWEB_FILES += $(GITWEB_CSS) GITWEB_FILES += static/git-logo.png static/git-favicon.png @@ -127,6 +127,7 @@ GITWEB_FILES += static/git-logo.png static/git-favicon.png # # js/lib/common-lib.js should be always first, then js/lib/*.js, # then the rest of files; js/gitweb.js should be last (if it exists) +GITWEB_JSLIB_FILES = GITWEB_JSLIB_FILES += static/js/lib/common-lib.js GITWEB_JSLIB_FILES += static/js/lib/datetime.js GITWEB_JSLIB_FILES += static/js/lib/cookies.js @@ -201,6 +202,6 @@ install: all .PHONY: clean clean: - $(RM) gitweb.cgi static/gitweb.js \ - static/gitweb.min.js static/gitweb.min.css \ + $(RM) gitweb.cgi $(GITWEB_JS_IN) \ + $(GITWEB_JS_MIN) $(GITWEB_CSS_MIN) \ GITWEB-BUILD-OPTIONS From b82d66eb0cf840a991ff906ab4679785eae4605a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Jun 2022 12:15:58 +0200 Subject: [PATCH 4/8] gitweb/Makefile: prepare to merge into top-level Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the "gitweb/Makefile" was split out from the top-level Makefile in 62331ef1637 (gitweb: Makefile improvements, 2010-01-30) we've kept the inter-dependencies between the two, and worse have dealt with a lot of duplication as a result. In preparation for merging the two again add a MAK_DIR_GITWEB variable to various rules in it. This will allow us to set this variable to "gitweb/" as we include it in the top-level Makefile, which will minimize the size of the subsequent diff. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- gitweb/Makefile | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/gitweb/Makefile b/gitweb/Makefile index a8752c1f11..74e896767e 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -2,6 +2,8 @@ all:: .PHONY: all +MAK_DIR_GITWEB = + # Define V=1 to have a more verbose compile. # # Define JSMIN to point to JavaScript minifier that functions as @@ -106,8 +108,9 @@ GITWEB_PROGRAMS = gitweb.cgi GITWEB_JS_MIN = static/gitweb.min.js ifdef JSMIN GITWEB_JS = $(GITWEB_JS_MIN) -all:: $(GITWEB_JS_MIN) -$(GITWEB_JS_MIN): $(GITWEB_JS_IN) GITWEB-BUILD-OPTIONS +all:: $(MAK_DIR_GITWEB)$(GITWEB_JS_MIN) +$(MAK_DIR_GITWEB)$(GITWEB_JS_MIN): $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS +$(MAK_DIR_GITWEB)$(GITWEB_JS_MIN): $(MAK_DIR_GITWEB)$(GITWEB_JS_IN) $(QUIET_GEN)$(JSMIN) <$< >$@ endif GITWEB_FILES += $(GITWEB_JS) @@ -115,8 +118,9 @@ GITWEB_FILES += $(GITWEB_JS) GITWEB_CSS_MIN = static/gitweb.min.css ifdef CSSMIN GITWEB_CSS = $(GITWEB_CSS_MIN) -all:: $(GITWEB_CSS_MIN) -$(GITWEB_CSS_MIN): $(GITWEB_CSS_IN) GITWEB-BUILD-OPTIONS +all:: $(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN) +$(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN): $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS +$(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN): $(MAK_DIR_GITWEB)$(GITWEB_CSS_IN) $(QUIET_GEN)$(CSSMIN) <$< >$@ endif GITWEB_FILES += $(GITWEB_CSS) @@ -161,19 +165,20 @@ GITWEB_REPLACE = \ -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g' .PHONY: FORCE -GITWEB-BUILD-OPTIONS: FORCE +$(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS: FORCE @rm -f $@+ @echo "x" '$(PERL_PATH_SQ)' $(GITWEB_REPLACE) "$(JSMIN)|$(CSSMIN)" >$@+ @cmp -s $@+ $@ && rm -f $@+ || mv -f $@+ $@ -gitweb.cgi: gitweb.perl GITWEB-BUILD-OPTIONS +$(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS +$(MAK_DIR_GITWEB)gitweb.cgi: $(MAK_DIR_GITWEB)gitweb.perl $(QUIET_GEN)$(RM) $@ $@+ && \ sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \ $(GITWEB_REPLACE) $< >$@+ && \ chmod +x $@+ && \ mv $@+ $@ -static/gitweb.js: $(GITWEB_JSLIB_FILES) +$(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_FILES)) $(QUIET_GEN)$(RM) $@ $@+ && \ cat $^ >$@+ && \ mv $@+ $@ @@ -194,14 +199,16 @@ test-installed: .PHONY: install install: all $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)' - $(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)' + $(INSTALL) -m 755 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_PROGRAMS)) \ + '$(DESTDIR_SQ)$(gitwebdir_SQ)' $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)' - $(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)' + $(INSTALL) -m 644 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_FILES)) \ + '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)' ### Cleaning rules .PHONY: clean clean: - $(RM) gitweb.cgi $(GITWEB_JS_IN) \ + $(RM) $(addprefix $(MAK_DIR_GITWEB),gitweb.cgi $(GITWEB_JS_IN) \ $(GITWEB_JS_MIN) $(GITWEB_CSS_MIN) \ - GITWEB-BUILD-OPTIONS + GITWEB-BUILD-OPTIONS) From 27438ef5e043ebca6336274c5b4e79287749eca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Jun 2022 12:15:59 +0200 Subject: [PATCH 5/8] gitweb: remove "test" and "test-installed" targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the special "test" targets for gitweb added in 958a8467216 (gitweb/Makefile: Add 'test' and 'test-installed' targets, 2010-09-26). Unlike e.g. "contrib/scalar" and "contrib/subtree" the "gitweb" tests themselves live in our top-level t/ directory. It therefore doesn't make sense to maintain this indirection, no more than it would to have a "git-send-email-test". By dropping it we'll also free other tests to use the t95*.sh prefix. These removed targets are unlikely to be used by anyone, and to the extent that they are we can easily use an invocation like this instead: make test T='t[0-9]*gitweb*.sh' Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- gitweb/Makefile | 11 ----------- t/Makefile | 4 ---- 2 files changed, 15 deletions(-) diff --git a/gitweb/Makefile b/gitweb/Makefile index 74e896767e..eaf0cfcf80 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -183,17 +183,6 @@ $(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_ cat $^ >$@+ && \ mv $@+ $@ -### Testing rules - -.PHONY: test -test: - $(MAKE) -C ../t gitweb-test - -.PHONY: test-installed -test-installed: - GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \ - $(MAKE) -C ../t gitweb-test - ### Installation rules .PHONY: install diff --git a/t/Makefile b/t/Makefile index 056ce55dcc..7f56e52f76 100644 --- a/t/Makefile +++ b/t/Makefile @@ -35,7 +35,6 @@ TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY)) CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP)) T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) -TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh)) THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh))) TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh)) CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test))) @@ -112,9 +111,6 @@ aggregate-results: echo "$$f"; \ done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh -gitweb-test: - $(MAKE) $(TGITWEB) - valgrind: $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind" From affc3b755cb4d1ac87096bbb93f5f2e57b703894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Jun 2022 12:16:00 +0200 Subject: [PATCH 6/8] gitweb/Makefile: include in top-level Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- Makefile | 23 +++++++------ gitweb/Makefile | 91 +++++++++---------------------------------------- 2 files changed, 29 insertions(+), 85 deletions(-) diff --git a/Makefile b/Makefile index 18ca6744a5..d251838c55 100644 --- a/Makefile +++ b/Makefile @@ -538,6 +538,7 @@ gitexecdir = libexec/git-core mergetoolsdir = $(gitexecdir)/mergetools sharedir = $(prefix)/share gitwebdir = $(sharedir)/gitweb +gitwebstaticdir = $(gitwebdir)/static perllibdir = $(sharedir)/perl5 localedir = $(sharedir)/locale template_dir = share/git-core/templates @@ -556,7 +557,7 @@ localedir_relative = $(patsubst $(prefix)/%,%,$(localedir)) htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir)) perllibdir_relative = $(patsubst $(prefix)/%,%,$(perllibdir)) -export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir +export prefix bindir sharedir sysconfdir perllibdir localedir # Set our default programs CC = cc @@ -2071,6 +2072,7 @@ htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative)) prefix_SQ = $(subst ','\'',$(prefix)) perllibdir_relative_SQ = $(subst ','\'',$(perllibdir_relative)) gitwebdir_SQ = $(subst ','\'',$(gitwebdir)) +gitwebstaticdir_SQ = $(subst ','\'',$(gitwebstaticdir)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH)) @@ -2399,10 +2401,6 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile perllibdir: @echo '$(perllibdir_SQ)' -.PHONY: gitweb -gitweb: - $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all - git-instaweb: git-instaweb.sh GIT-SCRIPT-DEFINES $(QUIET_GEN)$(cmd_munge_script) && \ chmod +x $@+ && \ @@ -3036,6 +3034,15 @@ coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.c .PHONY: coccicheck coccicheck-pending +# "Sub"-Makefiles, not really because they can't be run stand-alone, +# only there to contain directory-specific rules and variables +## gitweb/Makefile inclusion: +MAK_DIR_GITWEB = gitweb/ +include gitweb/Makefile + +.PHONY: gitweb +gitweb: $(MAK_DIR_GITWEB_ALL) + ### Installation rules ifneq ($(filter /%,$(firstword $(template_dir))),) @@ -3108,7 +3115,6 @@ ifndef NO_PERL $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perllibdir_SQ)' (cd perl/build/lib && $(TAR) cf - .) | \ (cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xof -) - $(MAKE) -C gitweb install endif ifndef NO_TCLTK $(MAKE) -C gitk-git install @@ -3163,10 +3169,8 @@ endif cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; } \ done -.PHONY: install-gitweb install-doc install-man install-man-perl install-html install-info install-pdf +.PHONY: install-doc install-man install-man-perl install-html install-info install-pdf .PHONY: quick-install-doc quick-install-man quick-install-html -install-gitweb: - $(MAKE) -C gitweb install install-doc: install-man-perl $(MAKE) -C Documentation install @@ -3310,7 +3314,6 @@ clean: profile-clean coverage-clean cocciclean $(MAKE) -C Documentation/ clean $(RM) Documentation/GIT-EXCLUDED-PROGRAMS ifndef NO_PERL - $(MAKE) -C gitweb clean $(RM) -r perl/build/ endif $(MAKE) -C templates/ clean diff --git a/gitweb/Makefile b/gitweb/Makefile index eaf0cfcf80..66fceb9e94 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -1,11 +1,8 @@ -# The default target of this Makefile is... -all:: -.PHONY: all +ifndef MAK_DIR_GITWEB +$(error do not run gitweb/Makefile stand-alone anymore. The "gitweb" and \ +"install-gitweb" targets now live in the top-level Makefile) +endif -MAK_DIR_GITWEB = - -# Define V=1 to have a more verbose compile. -# # Define JSMIN to point to JavaScript minifier that functions as # a filter to have static/gitweb.js minified. # @@ -13,13 +10,6 @@ MAK_DIR_GITWEB = # version of static/gitweb.css # -prefix ?= $(HOME) -bindir ?= $(prefix)/bin -gitwebdir ?= /var/www/cgi-bin - -RM ?= rm -f -INSTALL ?= install - # default configuration for gitweb GITWEB_CONFIG = gitweb_config.perl GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf @@ -44,71 +34,19 @@ GITWEB_SITE_HEADER = GITWEB_SITE_FOOTER = HIGHLIGHT_BIN = highlight -# include user config --include ../config.mak.autogen --include ../config.mak --include config.mak - -# determine version -.PHONY: .FORCE-GIT-VERSION-FILE -../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE - $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE - -ifneq ($(MAKECMDGOALS),clean) --include ../GIT-VERSION-FILE -endif - # What targets we'll add to 'all' for "make gitweb" GITWEB_ALL = GITWEB_ALL += gitweb.cgi GITWEB_ALL += $(GITWEB_JS) -### Build rules - -SHELL_PATH ?= $(SHELL) -PERL_PATH ?= /usr/bin/perl - -# Shell quote; -bindir_SQ = $(subst ','\'',$(bindir))#' -gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#' -gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#' -SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#' -PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#' -DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#' - -# Quiet generation (unless V=1) -QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir -QUIET_SUBDIR1 = - -ifneq ($(findstring $(MAKEFLAGS),w),w) -PRINT_DIR = --no-print-directory -else # "make -w" -NO_SUBDIR = : -endif - -ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V - QUIET = @ - QUIET_GEN = $(QUIET)echo ' ' GEN $@; - QUIET_SUBDIR0 = +@subdir= - QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ - $(MAKE) $(PRINT_DIR) -C $$subdir - export V - export QUIET - export QUIET_GEN - export QUIET_SUBDIR0 - export QUIET_SUBDIR1 -endif -endif - -all:: $(GITWEB_ALL) +MAK_DIR_GITWEB_ALL = $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_ALL)) GITWEB_PROGRAMS = gitweb.cgi GITWEB_JS_MIN = static/gitweb.min.js ifdef JSMIN GITWEB_JS = $(GITWEB_JS_MIN) -all:: $(MAK_DIR_GITWEB)$(GITWEB_JS_MIN) +GITWEB_ALL += $(MAK_DIR_GITWEB)$(GITWEB_JS_MIN) $(MAK_DIR_GITWEB)$(GITWEB_JS_MIN): $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS $(MAK_DIR_GITWEB)$(GITWEB_JS_MIN): $(MAK_DIR_GITWEB)$(GITWEB_JS_IN) $(QUIET_GEN)$(JSMIN) <$< >$@ @@ -118,7 +56,7 @@ GITWEB_FILES += $(GITWEB_JS) GITWEB_CSS_MIN = static/gitweb.min.css ifdef CSSMIN GITWEB_CSS = $(GITWEB_CSS_MIN) -all:: $(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN) +GITWEB_ALL += $(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN) $(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN): $(MAK_DIR_GITWEB)GITWEB-BUILD-OPTIONS $(MAK_DIR_GITWEB)$(GITWEB_CSS_MIN): $(MAK_DIR_GITWEB)$(GITWEB_CSS_IN) $(QUIET_GEN)$(CSSMIN) <$< >$@ @@ -185,19 +123,22 @@ $(MAK_DIR_GITWEB)static/gitweb.js: $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_JSLIB_ ### Installation rules -.PHONY: install -install: all +.PHONY: install-gitweb +install-gitweb: $(MAK_DIR_GITWEB_ALL) $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)' - $(INSTALL) -m 755 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_PROGRAMS)) \ - '$(DESTDIR_SQ)$(gitwebdir_SQ)' + $(INSTALL) -m 755 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_PROGRAMS)) '$(DESTDIR_SQ)$(gitwebdir_SQ)' $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)' $(INSTALL) -m 644 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_FILES)) \ '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)' +ifndef NO_PERL +install: install-gitweb +endif ### Cleaning rules -.PHONY: clean -clean: +.PHONY: gitweb-clean +gitweb-clean: $(RM) $(addprefix $(MAK_DIR_GITWEB),gitweb.cgi $(GITWEB_JS_IN) \ $(GITWEB_JS_MIN) $(GITWEB_CSS_MIN) \ GITWEB-BUILD-OPTIONS) +clean: gitweb-clean From d3b827408c5a1148d7c7ec46d07380c31b0796e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Tue, 28 Jun 2022 12:16:01 +0200 Subject: [PATCH 7/8] Makefile: build 'gitweb' in the default target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our Makefile's default target used to build 'gitweb', though indirectly: the 'all' target depended on 'git-instaweb', which in turn depended on 'gitweb'. Then e25c7cc146 (Makefile: drop dependency between git-instaweb and gitweb, 2015-05-29) removed the latter dependency, and for good reasons (quoting its commit message): "1. git-instaweb has no build-time dependency on gitweb; it is a run-time dependency 2. gitweb is a directory that we want to recursively make in. As a result, its recipe is marked .PHONY, which causes "make" to rebuild git-instaweb every time it is run." Since then a simple 'make' doesn't build 'gitweb'. Luckily, installing 'gitweb' is not broken: although 'make install' doesn't depend on the 'gitweb' target, it has a dependency on the 'install-gitweb' target, which does generate all the necessary files for 'gitweb' and installs them. However, if someone runs 'make && sudo make install', then those files in the 'gitweb' directory will be generated and owned by root, which is not nice. List 'gitweb' as a direct dependency of the default target, so a plain 'make' will build it. Signed-off-by: SZEDER Gábor Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index d251838c55..63057b1063 100644 --- a/Makefile +++ b/Makefile @@ -3042,6 +3042,7 @@ include gitweb/Makefile .PHONY: gitweb gitweb: $(MAK_DIR_GITWEB_ALL) +all:: gitweb ### Installation rules From a35258c62adf5c0e591f2335f3427434ff0b63f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 28 Jun 2022 12:16:02 +0200 Subject: [PATCH 8/8] gitweb/Makefile: add a "NO_GITWEB" parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From looking at the {Free,Net,Dragonfly}BSD packages for git[1] they've been monkeypatching "gitweb" out of the Makefile, let's be nicer and provide a NO_GITWEB=Y for their use. For the "all" target this allows for optionally restoring what's been the status quo before the preceding commit, but now we'll also behave correctly on the subsequent "make install". As before our installation of gitweb can be suppressed with NO_PERL. For backwards compatibility the NO_PERL=Y flag by itself still doesn't change whether or not we build gitweb, unlike the new NO_GITWEB=Y flag. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 7 +++++++ gitweb/Makefile | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 63057b1063..88ce3e857d 100644 --- a/Makefile +++ b/Makefile @@ -309,6 +309,11 @@ include shared.mak # distributions that want to use their packaged versions of Perl # modules, instead of the fallbacks shipped with Git. # +# Define NO_GITWEB if you do not want to build or install +# 'gitweb'. Note that defining NO_PERL currently has the same effect +# on not installing gitweb, but not on whether it's built in the +# gitweb/ directory. +# # Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python # but /usr/bin/python2.7 or /usr/bin/python3 on some platforms). # @@ -3042,7 +3047,9 @@ include gitweb/Makefile .PHONY: gitweb gitweb: $(MAK_DIR_GITWEB_ALL) +ifndef NO_GITWEB all:: gitweb +endif ### Installation rules diff --git a/gitweb/Makefile b/gitweb/Makefile index 66fceb9e94..3b68ab2d67 100644 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@ -130,9 +130,11 @@ install-gitweb: $(MAK_DIR_GITWEB_ALL) $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)' $(INSTALL) -m 644 $(addprefix $(MAK_DIR_GITWEB),$(GITWEB_FILES)) \ '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)' +ifndef NO_GITWEB ifndef NO_PERL install: install-gitweb endif +endif ### Cleaning rules