Skip to contentSkip to conversation

Makefile: Split INSTALL out into INSTALL_{PROGRAM,LIB,DATA,SCRIPT}

PATCH Applied [email protected] 2 participants 2 messages Jan 4, 2018 1 message not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Split INSTALL out into INSTALL_{PROGRAM,LIB,DATA,SCRIPT}

For adoption into systems that may have additional arguments to be passed into install(1) upon install, split out INSTALL into the different types of files to be installed and use them appropriately. This allows, for instance, passing -s to strip binaries and libs while not botching directory installs or data/script installations.

---
 Makefile | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
Makefile +9 -4
index 9ba8121..5f1c274 100644
@@ -26,6 +26,10 @@ SWIG = swig
 PKG_CONFIG ?= pkg-config
 
 INSTALL = /usr/bin/install
+INSTALL_PROGRAM = $(INSTALL)
+INSTALL_LIB = $(INSTALL)
+INSTALL_DATA = $(INSTALL) -m 644
+INSTALL_SCRIPT = $(INSTALL)
 DESTDIR =
 PREFIX = $(HOME)
 BINDIR = $(PREFIX)/bin
@@ -191,20 +195,21 @@ endif
 install-bin: all $(SCRIPTS)
 	@$(VECHO) INSTALL-BIN
 	$(INSTALL) -d $(DESTDIR)$(BINDIR)
-	$(INSTALL) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
+	$(INSTALL_PROGRAM) $(BIN) $(DESTDIR)$(BINDIR)
+	$(INSTALL_SCRIPT) $(SCRIPTS) $(DESTDIR)$(BINDIR)
 
 install-lib: all
 	@$(VECHO) INSTALL-LIB
 	$(INSTALL) -d $(DESTDIR)$(LIBDIR)
-	$(INSTALL) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
+	$(INSTALL_LIB) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
 	ln -sf $(notdir $(LIBFDT_lib)) $(DESTDIR)$(LIBDIR)/$(LIBFDT_soname)
 	ln -sf $(LIBFDT_soname) $(DESTDIR)$(LIBDIR)/libfdt.$(SHAREDLIB_EXT)
-	$(INSTALL) -m 644 $(LIBFDT_archive) $(DESTDIR)$(LIBDIR)
+	$(INSTALL_DATA) $(LIBFDT_archive) $(DESTDIR)$(LIBDIR)
 
 install-includes:
 	@$(VECHO) INSTALL-INC
 	$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
-	$(INSTALL) -m 644 $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
+	$(INSTALL_DATA) $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
 
 install: install-bin install-lib install-includes
 
Signature · 1 line
2.15.1

A message that is not in the archive (sent off-list or not yet received): 20180104034923.2919-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org

Applied
#2 lore raw
Quoted 7 lines · On Wed, Jan 03, 2018 at 09:49:23PM -0600…

For adoption into systems that may have additional arguments to be passed into install(1) upon install, split out INSTALL into the different types of files to be installed and use them appropriately. This allows, for instance, passing -s to strip binaries and libs while not botching directory installs or data/script installations.

Applied, thanks.

Quoted 45 lines
---
 Makefile | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
Makefile +9 -4
index 9ba8121..5f1c274 100644
@@ -26,6 +26,10 @@ SWIG = swig
 PKG_CONFIG ?= pkg-config
 
 INSTALL = /usr/bin/install
+INSTALL_PROGRAM = $(INSTALL)
+INSTALL_LIB = $(INSTALL)
+INSTALL_DATA = $(INSTALL) -m 644
+INSTALL_SCRIPT = $(INSTALL)
 DESTDIR =
 PREFIX = $(HOME)
 BINDIR = $(PREFIX)/bin
@@ -191,20 +195,21 @@ endif
 install-bin: all $(SCRIPTS)
 	@$(VECHO) INSTALL-BIN
 	$(INSTALL) -d $(DESTDIR)$(BINDIR)
-	$(INSTALL) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
+	$(INSTALL_PROGRAM) $(BIN) $(DESTDIR)$(BINDIR)
+	$(INSTALL_SCRIPT) $(SCRIPTS) $(DESTDIR)$(BINDIR)
 
 install-lib: all
 	@$(VECHO) INSTALL-LIB
 	$(INSTALL) -d $(DESTDIR)$(LIBDIR)
-	$(INSTALL) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
+	$(INSTALL_LIB) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
 	ln -sf $(notdir $(LIBFDT_lib)) $(DESTDIR)$(LIBDIR)/$(LIBFDT_soname)
 	ln -sf $(LIBFDT_soname) $(DESTDIR)$(LIBDIR)/libfdt.$(SHAREDLIB_EXT)
-	$(INSTALL) -m 644 $(LIBFDT_archive) $(DESTDIR)$(LIBDIR)
+	$(INSTALL_DATA) $(LIBFDT_archive) $(DESTDIR)$(LIBDIR)
 
 install-includes:
 	@$(VECHO) INSTALL-INC
 	$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
-	$(INSTALL) -m 644 $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
+	$(INSTALL_DATA) $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
 
 install: install-bin install-lib install-includes
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson