git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH RESEND v2] make: add install-stripped target

From
Bagas Sanjaya <bagasdotme@gmail.com>
Date
Aug 31, 2021, 01:32 UTC
Message-ID
<20210831013235.388682-1-bagasdotme@gmail.com>
Add the target that install Git with stripped executables.

install and install-stripped share the almost-same recipe, with the difference only on extra arguments to $(INSTALL). In order for this to work properly, installing all programs ($(ALL_PROGRAMS) and $(install_bindir_programs)) must be splitted into separate portions for compiled programs and scripts. For the former, add $(INSTALL_OPTS) and for the latter, don't add anything.

$(INSTALL_OPTS) contains stripping options that are passed from install-stripped.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 Changes from v1:
 - Share recipes between install-stripped and install targets (suggested
   by Junio)
 - Don't delete 'strip' target. There may exist scripts that depend on
   that target. Once this patch is integrated, deprecation notice can
   be displayed when running the target, but it is done in separate
   patch.
 Makefile | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index d1feab008f..28d1e9bfae 100644
--- a/Makefile
+++ b/Makefile
@@ -3004,7 +3004,8 @@ mergetools_instdir = $(prefix)/$(mergetoolsdir)
 endif
 mergetools_instdir_SQ = $(subst ','\'',$(mergetools_instdir))
 
-install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
+install_bindir_xprograms := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X))
+install_bindir_programs := $(install_bindir_xprograms) $(BINDIR_PROGRAMS_NO_X)
 
 .PHONY: profile-install profile-fast-install
 profile-install: profile
@@ -3013,12 +3014,21 @@ profile-install: profile
 profile-fast-install: profile-fast
 	$(MAKE) install
 
-install: all
+INSTALL_OPTS =
+
+.PHONY: install-stripped
+
+install-stripped: INSTALL_OPTS = -s --strip-program=$(STRIP)
+
+install-stripped install: all
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-	$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+	$(INSTALL) $(INSTALL_OPTS) $(PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+	$(INSTALL) $(SCRIPTS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 	$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-	$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
+	$(INSTALL) $(INSTALL_OPTS) $(install_bindir_xprograms) '$(DESTDIR_SQ)$(bindir_SQ)'
+	$(INSTALL) $(BINDIR_PROGRAMS_NO_X) '$(DESTDIR_SQ)$(bindir_SQ)'
+
 ifdef MSVC
 	# We DO NOT install the individual foo.o.pdb files because they
 	# have already been rolled up into the exe's pdb file.

base-commit: c4203212e360b25a1c69467b5a8437d45a373cac
-- 
2.25.1
Next: Junio C Hamano
Message 1 of 4 in “make: add install-stripped target”
  1. make: add install-stripped targetBagas Sanjaya, Aug 31, 2021
  2. Junio C HamanoAug 31, 2021
  3. Bagas SanjayaSep 1, 2021
  4. Junio C HamanoSep 1, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.