git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Jeff King" <peff@peff.net>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v3 6/8] gitweb/Makefile: include in top-level Makefile
Date: Tue, 28 Jun 2022 12:16:00 +0200	[thread overview]
Message-ID: <patch-v3-6.8-5640587b9ae-20220628T100936Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v3-0.8-00000000000-20220628T100936Z-avarab@gmail.com>

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>
---
 Makefile        | 23 +++++++------
 gitweb/Makefile | 91 +++++++++----------------------------------------
 2 files changed, 29 insertions(+), 85 deletions(-)

diff --git a/Makefile b/Makefile
index 04d0fd1fe60..a5f29c11681 100644
--- a/Makefile
+++ b/Makefile
@@ -544,6 +544,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
@@ -562,7 +563,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
@@ -2089,6 +2090,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))
@@ -2417,10 +2419,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 $@+ && \
@@ -3149,6 +3147,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))),)
@@ -3221,7 +3228,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
@@ -3276,10 +3282,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
@@ -3425,7 +3429,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 eaf0cfcf80e..66fceb9e94f 100644
--- a/gitweb/Makefile
+++ b/gitweb/Makefile
@@ -1,11 +1,8 @@
-# The default target of this Makefile is...
-all::
-.PHONY: all
-
-MAK_DIR_GITWEB =
+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
 
-# 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
-- 
2.37.0.880.gf07d56b18ba


  parent reply	other threads:[~2022-06-28 10:19 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 20:56 [PATCH] Makefile: build 'gitweb' in the default target SZEDER Gábor
2022-05-26  0:14 ` Ævar Arnfjörð Bjarmason
2022-05-26  7:57   ` Jeff King
2022-05-26 21:33   ` SZEDER Gábor
2022-05-27  9:23     ` Ævar Arnfjörð Bjarmason
2022-05-31 17:45       ` [PATCH v2 0/7] gitweb: fix "make" not including "gitweb" without NOOP run slowdowns Ævar Arnfjörð Bjarmason
2022-05-31 17:45         ` [PATCH v2 1/7] gitweb/Makefile: define all .PHONY prerequisites inline Ævar Arnfjörð Bjarmason
2022-05-31 17:45         ` [PATCH v2 2/7] gitweb/Makefile: add a $(GITWEB_ALL) variable Ævar Arnfjörð Bjarmason
2022-05-31 17:45         ` [PATCH v2 3/7] gitweb/Makefile: clear up and de-duplicate the gitweb.{css,js} vars Ævar Arnfjörð Bjarmason
2022-05-31 17:45         ` [PATCH v2 4/7] gitweb/Makefile: prepare to merge into top-level Makefile Ævar Arnfjörð Bjarmason
2022-05-31 17:45         ` [PATCH v2 5/7] gitweb: remove "test" and "test-installed" targets Ævar Arnfjörð Bjarmason
2022-05-31 17:45         ` [PATCH v2 6/7] gitweb/Makefile: include in top-level Makefile Ævar Arnfjörð Bjarmason
2022-05-31 17:46         ` [PATCH v2 7/7] Makefile: build 'gitweb' in the default target Ævar Arnfjörð Bjarmason
2022-06-06 17:44         ` [PATCH v2 0/7] gitweb: fix "make" not including "gitweb" without NOOP run slowdowns Junio C Hamano
2022-06-20  8:32           ` SZEDER Gábor
2022-06-21  6:47             ` Jeff King
2022-06-22  9:27               ` Ævar Arnfjörð Bjarmason
2022-06-22 15:37                 ` Junio C Hamano
2022-06-23 10:29                   ` Ævar Arnfjörð Bjarmason
2022-06-23 23:25                     ` Junio C Hamano
2022-06-23 23:45                       ` Ævar Arnfjörð Bjarmason
2022-06-24  1:14                         ` Junio C Hamano
2022-06-28 10:15         ` [PATCH v3 0/8] " Ævar Arnfjörð Bjarmason
2022-06-28 10:15           ` [PATCH v3 1/8] gitweb/Makefile: define all .PHONY prerequisites inline Ævar Arnfjörð Bjarmason
2022-06-28 10:15           ` [PATCH v3 2/8] gitweb/Makefile: add a $(GITWEB_ALL) variable Ævar Arnfjörð Bjarmason
2022-06-28 10:15           ` [PATCH v3 3/8] gitweb/Makefile: clear up and de-duplicate the gitweb.{css,js} vars Ævar Arnfjörð Bjarmason
2022-06-28 10:15           ` [PATCH v3 4/8] gitweb/Makefile: prepare to merge into top-level Makefile Ævar Arnfjörð Bjarmason
2022-06-28 10:15           ` [PATCH v3 5/8] gitweb: remove "test" and "test-installed" targets Ævar Arnfjörð Bjarmason
2022-06-28 10:16           ` Ævar Arnfjörð Bjarmason [this message]
2022-06-28 10:16           ` [PATCH v3 7/8] Makefile: build 'gitweb' in the default target Ævar Arnfjörð Bjarmason
2022-06-28 10:16           ` [PATCH v3 8/8] gitweb/Makefile: add a "NO_GITWEB" parameter Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch-v3-6.8-5640587b9ae-20220628T100936Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).