From: Russ Allbery Date: Sun, 17 Feb 2008 20:42:29 -0800 Subject: Add DESTDIR support Original patch taken from Joel Baker's Debian package. This adds DESTDIR where needed to the Unix makefile fragment. --- unix/unix.mak | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/unix/unix.mak b/unix/unix.mak index 60f1b18..944e0dd 100644 --- a/unix/unix.mak +++ b/unix/unix.mak @@ -87,15 +87,15 @@ TF tf$(X): $(OBJS) $(BUILDERS) $(PCRE) -test -z "$(STRIP)" || $(STRIP) tf$(X) || true PREFIXDIRS: - test -d "$(bindir)" || mkdir $(bindir) - test -d "$(datadir)" || mkdir $(datadir) + test -d "$(DESTDIR)$(bindir)" || mkdir $(DESTDIR)$(bindir) + test -d "$(DESTDIR)$(datadir)" || mkdir $(DESTDIR)$(datadir) install_TF $(TF): tf$(X) $(BUILDERS) - -@rm -f $(TF) - cp tf$(X) $(TF) - chmod $(MODE) $(TF) + -@rm -f $(DESTDIR)$(TF) + cp tf$(X) $(DESTDIR)$(TF) + chmod $(MODE) $(DESTDIR)$(TF) -SYMLINK $(SYMLINK): $(TF) +SYMLINK $(SYMLINK): $(DESTDIR)$(TF) test -z "$(SYMLINK)" || { rm -f $(SYMLINK) && ln -s $(TF) $(SYMLINK); } LIBRARY $(TF_LIBDIR): ../tf-lib/tf-help ../tf-lib/tf-help.idx @@ -103,30 +103,30 @@ LIBRARY $(TF_LIBDIR): ../tf-lib/tf-help ../tf-lib/tf-help.idx # @# Overly simplified shell commands, to avoid problems on ultrix -@test -n "$(TF_LIBDIR)" || echo "TF_LIBDIR is undefined." test -n "$(TF_LIBDIR)" - test -d "$(TF_LIBDIR)" || mkdir $(TF_LIBDIR) - -@test -d "$(TF_LIBDIR)" || echo "Can't make $(TF_LIBDIR) directory. See if" - -@test -d "$(TF_LIBDIR)" || echo "there is already a file with that name." - test -d "$(TF_LIBDIR)" + test -d "$(DESTDIR)$(TF_LIBDIR)" || mkdir $(DESTDIR)$(TF_LIBDIR) + -@test -d "$(DESTDIR)$(TF_LIBDIR)" || echo "Can't make $(TF_LIBDIR) directory. See if there is already a file with that name." + test -d "$(DESTDIR)$(TF_LIBDIR)" # # @#rm -f $(TF_LIBDIR)/*; # wrong: this would remove local.tf, etc. @echo '## Copying library files...' cd ../tf-lib; \ for f in *; do test -f $$f && files="$$files $$f"; done; \ - ( cd $(TF_LIBDIR); rm -f $$files tf.help tf.help.index; ); \ - cp $$files $(TF_LIBDIR); \ - cd $(TF_LIBDIR); \ + ( cd $(DESTDIR)$(TF_LIBDIR); rm -f $$files tf.help tf.help.index; ); \ + cp $$files $(DESTDIR)$(TF_LIBDIR); \ + cd $(DESTDIR)$(TF_LIBDIR); \ chmod $(MODE) $$files; chmod ugo-wx $$files - -rm -f $(TF_LIBDIR)/CHANGES - cp ../CHANGES $(TF_LIBDIR) - chmod $(MODE) $(TF_LIBDIR)/CHANGES; chmod ugo-wx $(TF_LIBDIR)/CHANGES - chmod $(MODE) $(TF_LIBDIR) - -@cd $(TF_LIBDIR); old=`ls replace.tf 2>/dev/null`; \ + -rm -f $(DESTDIR)$(TF_LIBDIR)/CHANGES + cp ../CHANGES $(DESTDIR)$(TF_LIBDIR) + chmod $(MODE) $(DESTDIR)$(TF_LIBDIR)/CHANGES; + chmod ugo-wx $(DESTDIR)$(TF_LIBDIR)/CHANGES + chmod $(MODE) $(DESTDIR)$(TF_LIBDIR) + -@cd $(DESTDIR)$(TF_LIBDIR); old=`ls replace.tf 2>/dev/null`; \ if [ -n "$$old" ]; then \ echo "## WARNING: Obsolete files found in $(TF_LIBDIR): $$old"; \ fi @echo '## Creating links so old library names still work...' # @# note: ln -sf isn't portable. - @cd $(TF_LIBDIR); \ + @cd $(DESTDIR)$(TF_LIBDIR); \ rm -f bind-bash.tf; ln -s kb-bash.tf bind-bash.tf; \ rm -f bind-emacs.tf; ln -s kb-emacs.tf bind-emacs.tf; \ rm -f completion.tf; ln -s complete.tf completion.tf; \