From e34e6f56647f7fd81b317bcc56bc7141e5c3568d Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Fri, 8 Oct 1999 11:00:16 +0000
Subject: [PATCH] [project @ 1999-10-08 11:00:16 by sof] Improved on the
 install rules for libexecs and bins a little (at least from a Win32 pov - you
 can now install "happy.bin" without trouble.)

---
 mk/target.mk | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/mk/target.mk b/mk/target.mk
index 8528b59290e1..a48358cd010e 100644
--- a/mk/target.mk
+++ b/mk/target.mk
@@ -581,17 +581,29 @@ install-dirs ::
 #install:: install-dirs
 
 ifneq "$(INSTALL_PROGS)" ""
+
+#
+# Here's an interesting one - when using the win32 version
+# of install (provided via the cygwin toolkit), we have to
+# supply the .exe suffix, *if* there's no other suffix.
+#
+# The rule below does this by ferreting out the suffix of each
+# entry in the INSTALL_PROGS list. If there's no suffix, use
+# $(exeext).
+# 
+# This is bit of a pain to express since GNU make doesn't have
+# something like $(if ...), but possible using $(subst ..)
+# [Aside: I added support for $(if ..) to my local copy of GNU
+# make at one stage, perhaps I should propagate the patch to
+# the GNU make maintainers..] 
+#
+INSTALL_PROGS := $(foreach p, $(INSTALL_PROGS), $(addsuffix $(subst _,,$(subst __,$(exeext),_$(suffix $(p))_)), $(basename $(p))))
+
 install:: $(INSTALL_PROGS)
 	@$(INSTALL_DIR) $(bindir)
 	@for i in $(INSTALL_PROGS); do \
-		case $$i in \
-		  *.dll) \
-		    echo $(INSTALL_DATA) $(INSTALL_BIN_OPTS) $$i $(bindir); \
-		    $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir) ;; \
-		  *) \
-		    echo $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i$(exeext) $(bindir); \
-		    $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i$(exeext) $(bindir) ;;  \
-		esac; \
+		    echo $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir); \
+		    $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir) ;;  \
 	done
 endif
 
@@ -640,10 +652,16 @@ install:: $(INSTALL_LIBS)
 endif
 
 ifneq "$(INSTALL_LIBEXECS)" ""
+#
+# See above comment next to defn of INSTALL_PROGS for what
+# the purpose of this one-liner is.
+# 
+INSTALL_LIBEXECS := $(foreach p, $(INSTALL_LIBEXECS), $(addsuffix $(subst _,,$(subst __,$(exeext),_$(suffix $(p))_)), $(basename $(p))))
+
 install:: $(INSTALL_LIBEXECS)
 	@$(INSTALL_DIR) $(libexecdir)
 	-for i in $(INSTALL_LIBEXECS); do \
-		$(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i$(exeext) $(libexecdir); \
+		$(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(libexecdir); \
 	done
 endif
 
-- 
GitLab