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

[PATCH 1/2] Makefile: create an install-symlinks target

From
David Kastrup <dak@gnu.org>
Date
Jul 18, 2007, 10:41 UTC
Message-ID
<6e14af24a3aa8af7e21e0a3f92c83c82e147202a.1184770193.git.dak@gnu.org>
In-Reply-To
<861wf5iz6o.fsf@lola.quinscape.zz>

This target allows you to have git installed in one location, and have symbolic links to all of the programs installed in another location. For example, if git was installed to /opt/git with

	make prefix=/opt/git install
you can install symbolic links in /usr/local/bin with
	make symlinkprefix=/usr/local prefix=/opt/git \
		install-symlinks
This makes it reasonably easy to remove such a package, by doing
	rm -rf /opt/git
and then removing stale links with
	find /usr/local -xtype l -print0|xargs -0 rm
(be sure to first see whether you indeed get only stale links listed).

This works by copying the directory hierarchy of $prefix to $symlinkprefix (not copying or descending to any directories of the name git* matched case-insensitively), then linking all the rest.

Signed-off-by: David Kastrup <dak@gnu.org>
---
 Makefile |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 73b487f..7e53378 100644
--- a/Makefile
+++ b/Makefile
@@ -142,6 +142,7 @@ ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip
 
 prefix = $(HOME)
+symlinkprefix = /usr/local
 bindir = $(prefix)/bin
 gitexecdir = $(bindir)
 sharedir = $(prefix)/share
@@ -996,7 +997,13 @@ install-doc:
 quick-install-doc:
 	$(MAKE) -C Documentation quick-install
 
-
+# The somewhat strange looking lines start with an ignored $(MAKE) in
+# order to be executed also in make -n calls.
+install-symlinks:
+	@: $(MAKE) && cd '$(prefix_SQ)' && find . -type d ! \( -iname 'git*' -prune \) -exec echo $(INSTALL) -m 755 -d '$(symlinkprefix)/{}' \;
+	@cd '$(prefix_SQ)' && find . -type d ! \( -iname 'git*' -prune \) -exec $(INSTALL) -m 755 -d '$(symlinkprefix)/{}' \;
+	@: $(MAKE) && cd '$(prefix_SQ)' && find . \( -type d -iname 'git*' -prune -o ! -type d \) -exec echo $(RM) -r '$(symlinkprefix)/{}' \; -exec echo ln -s '$(prefix_SQ)/{}' '$(symlinkprefix)/{}' \;
+	@cd '$(prefix_SQ)' && find . \( -type d -iname 'git*' -prune -o ! -type d \) -exec $(RM) -r '$(symlinkprefix)/{}' \; -exec ln -s '$(prefix_SQ)/{}' '$(symlinkprefix)/{}' \;
 
 ### Maintainer's dist rules
 
-- 
1.5.3.rc2.41.gb47b1
Previous: David KastrupNext: David Kastrup
Message 7 of 8 in “Makefile: create an install-symlinks target”
  1. Makefile: create an install-symlinks targetDavid Kastrup, Jul 18, 2007
  2. David KastrupJul 18, 2007
  3. Johannes SchindelinJul 18, 2007
  4. Peter BaumannJul 18, 2007
  5. Alex RiesenJul 18, 2007
  6. David KastrupJul 18, 2007
  7. 1/2 Makefile: create an install-symlinks targetDavid Kastrup, Jul 18, 2007
  8. 2/2 Makefile: use $(FIND) instead of findDavid Kastrup, Jul 18, 2007

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.