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

[PATCH v3] make: add INSTALL_STRIP option variable

From
Bagas Sanjaya <bagasdotme@gmail.com>
Date
Sep 2, 2021, 12:11 UTC
Message-ID
<20210902121104.14778-1-bagasdotme@gmail.com>
From: Junio C Hamano <gitster@pobox.com>

Add $(INSTALL_STRIP), which allows passing stripping options to $(INSTALL).

For this to work, installing executables must be split to installing compiled binaries and scripts portions, since $(INSTALL_STRIP) is only meaningful to the former.

Users can set this variable depending on their system. For example, Linux users can use `-s --strip-program=strip`, while FreeBSD users can simply set to `-s` and choose strip program with $STRIPBIN.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 Changes from v3 [1]:
   - Squash suggestion patch from Junio, which suggests dropping
     install-stripped target and rename $(INSTALL_OPTS) to
     $(INSTALL_STRIP).
   - Describe $(INSTALL_STRIP) usage on the top of Makefile
 Note: In the future, we may add global $(INSTALL_OPTS), which applies
 to both compiled binaries and scripts. When such happens, we should
 rename $(INSTALL_STRIP) to $(INSTALL_STRIP_OPTS).
 [1]: https://lore.kernel.org/git/xmqqo89cqkt9.fsf@gitster.g/T/#t
 Makefile | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index d1feab008f..ebef4da50c 100644
--- a/Makefile
+++ b/Makefile
@@ -465,6 +465,9 @@ all::
 # the global variable _wpgmptr containing the absolute path of the current
 # executable (this is the case on Windows).
 #
+# INSTALL_STRIP can be set to "-s" to strip binaries during installation,
+# if your $(INSTALL) command supports the option.
+#
 # Define GENERATE_COMPILATION_DATABASE to "yes" to generate JSON compilation
 # database entries during compilation if your compiler supports it, using the
 # `-MJ` flag. The JSON entries will be placed in the `compile_commands/`
@@ -3004,7 +3007,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 +3017,17 @@ profile-install: profile
 profile-fast-install: profile-fast
 	$(MAKE) install
 
+INSTALL_STRIP =
+
 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_STRIP) $(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_STRIP) $(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: 6c40894d2466d4e7fddc047a05116aa9d14712ee
-- 
2.25.1
Next: Ævar Arnfjörð Bjarmason
Message 1 of 5 in “make: add INSTALL_STRIP option variable”
  1. make: add INSTALL_STRIP option variableBagas Sanjaya, Sep 2, 2021
  2. Ævar Arnfjörð BjarmasonSep 16, 2021
  3. Bagas SanjayaSep 16, 2021
  4. Ævar Arnfjörð BjarmasonSep 18, 2021
  5. Junio C HamanoSep 16, 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.