[PATCH 2/6] Makefile: begin refactoring out "ln || ln -s || cp" pattern

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Begin refactoring out the "ln || ln -s || cp" pattern in the Makefile
into a script. For now this is trivial, but in subsequent commits
it'll simplify things a lot.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 Makefile    | 8 ++------
 ln-or-cp.sh | 8 ++++++++
 2 files changed, 10 insertions(+), 6 deletions(-)
 create mode 100755 ln-or-cp.sh

diff --git a/Makefile b/Makefile
index 1e59d90a8d2..cfc87d7734d 100644
--- a/Makefile
+++ b/Makefile
@@ -2199,9 +2199,7 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \
 
 $(BUILT_INS): git$X
 	$(QUIET_BUILT_IN)$(RM) $@ && \
-	ln $< $@ 2>/dev/null || \
-	ln -s $< $@ 2>/dev/null || \
-	cp $< $@
+	./ln-or-cp.sh $< $@
 
 config-list.h: generate-configlist.sh
 
@@ -2552,9 +2550,7 @@ git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
 
 $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
 	$(QUIET_LNCP)$(RM) $@ && \
-	ln $< $@ 2>/dev/null || \
-	ln -s $< $@ 2>/dev/null || \
-	cp $< $@
+	./ln-or-cp.sh $< $@
 
 $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@+ $(ALL_LDFLAGS) $(filter %.o,$^) \
diff --git a/ln-or-cp.sh b/ln-or-cp.sh
new file mode 100755
index 00000000000..de79cd85a81
--- /dev/null
+++ b/ln-or-cp.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+target="$1"
+link="$2"
+
+ln "$target" "$link" 2>/dev/null ||
+ln -s "$target" "$link" 2>/dev/null ||
+cp "$target" "$link"
-- 
2.31.1.461.gd47399f6574




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux