summaryrefslogtreecommitdiff
path: root/lib/am
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2011-09-23 22:50:14 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2011-09-26 21:46:59 +0200
commiteae5cfa9b373ee19b2768957b53dbe53a586b69e (patch)
tree5e91f6e72b5f6785f631fa2996c156f4761abc65 /lib/am
parentb9fa1fc1eb50d7907764ec0972a674548a7bd8b3 (diff)
downloadautomake-eae5cfa9b373ee19b2768957b53dbe53a586b69e.tar.gz
uninstall: "make uninstall" before "make install" works
This change fixes automake bug#9578. * lib/am/inst-vars.am (am__uninstall_files_from_dir): New internal macro, that defines a shell code fragment to uninstall files from a given directory. * lib/am/data.am (uninstall-%DIR%%PRIMARY%): Use it, to reduce code duplication and improve consistency and correctness. * lib/am/libs.am (uninstall-%DIR%LIBRARIES): Likewise. * lib/am/lisp.am (uninstall-%DIR%LISP): Likewise. * lib/am/mans.am (uninstall-man%SECTION%): Likewise. * lib/am/python.am (uninstall-%DIR%LIBRARIES): Likewise. * lib/am/scripts.am (uninstall-%DIR%SCRIPTS): Likewise. * tests/uninstall-pr9578.test: New test. * tests/uninstall-fail.test: New test. * tests/Makefile.am (TESTS): Add them. * NEWS, THANKS: Update. Report by Nick Bowler.
Diffstat (limited to 'lib/am')
-rw-r--r--lib/am/Makefile.in10
-rw-r--r--lib/am/data.am4
-rw-r--r--lib/am/inst-vars.am18
-rw-r--r--lib/am/libs.am4
-rw-r--r--lib/am/lisp.am8
-rw-r--r--lib/am/mans.am8
-rw-r--r--lib/am/python.am15
-rw-r--r--lib/am/scripts.am4
8 files changed, 39 insertions, 32 deletions
diff --git a/lib/am/Makefile.in b/lib/am/Makefile.in
index 649c1bf29..194f1cba7 100644
--- a/lib/am/Makefile.in
+++ b/lib/am/Makefile.in
@@ -89,6 +89,12 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ cd "$$dir" && rm -f $$files; }; \
+ }
am__installdirs = "$(DESTDIR)$(amdir)"
DATA = $(dist_am_DATA)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -279,9 +285,7 @@ uninstall-dist_amDATA:
@$(NORMAL_UNINSTALL)
@list='$(dist_am_DATA)'; test -n "$(amdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(amdir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(amdir)" && rm -f $$files
+ dir='$(DESTDIR)$(amdir)'; $(am__uninstall_files_from_dir)
tags: TAGS
TAGS:
diff --git a/lib/am/data.am b/lib/am/data.am
index 36af717f0..1817447de 100644
--- a/lib/am/data.am
+++ b/lib/am/data.am
@@ -73,9 +73,7 @@ uninstall-%DIR%%PRIMARY%:
@list='$(%DIR%_%PRIMARY%)'; test -n "$(%NDIR%dir)" || list=; \
?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
?!BASE? $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files
+ dir='$(DESTDIR)$(%NDIR%dir)'; $(am__uninstall_files_from_dir)
endif %?INSTALL%
diff --git a/lib/am/inst-vars.am b/lib/am/inst-vars.am
index a49cfe934..477513ff8 100644
--- a/lib/am/inst-vars.am
+++ b/lib/am/inst-vars.am
@@ -15,6 +15,7 @@
## along with this program. If not, see <http://www.gnu.org/licenses/>.
if %?FIRST%
+
## These variables help stripping any $(VPATH) that some
## Make implementations prepend before VPATH-found files.
## The issue is discussed at length in distdir.am.
@@ -52,4 +53,21 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+
+## A shell code fragment to uninstall files from a given directory.
+## It expects the $dir and $files shell variables to be defined respectively
+## to the directory where the files to be removed are, and to the list of
+## such files.
+am__uninstall_files_from_dir = { \
+## Some rm implementations complain if `rm -f' is used without arguments.
+ test -z "$$files" \
+## At least Solaris /bin/sh still lacks `test -e', so we use the multiple
+## tests below instead. We expect $dir to be either non-existent or a
+## directory, so the failure we'll experience if it is a regular file
+## is indeed desired and welcome (better to fail loudly thasn silently).
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ cd "$$dir" && rm -f $$files; }; \
+ }
+
endif %?FIRST%
diff --git a/lib/am/libs.am b/lib/am/libs.am
index eec62a1f7..29f630b76 100644
--- a/lib/am/libs.am
+++ b/lib/am/libs.am
@@ -87,9 +87,7 @@ uninstall-%DIR%LIBRARIES:
@list='$(%DIR%_LIBRARIES)'; test -n "$(%NDIR%dir)" || list=; \
?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
?!BASE? $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f "$$files" )"; \
- cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files
+ dir='$(DESTDIR)$(%NDIR%dir)'; $(am__uninstall_files_from_dir)
endif %?INSTALL%
diff --git a/lib/am/lisp.am b/lib/am/lisp.am
index ab45b30e6..6ffcdbfcc 100644
--- a/lib/am/lisp.am
+++ b/lib/am/lisp.am
@@ -128,12 +128,8 @@ uninstall-%DIR%LISP:
list='$(%DIR%_LISP)'; \
?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
?!BASE? $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
- test -n "$$files" || exit 0; \
- filesc=`echo "$$files" | sed 's|$$|c|'`; \
- echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files || exit $$?; \
- echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$filesc ")"; \
- cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$filesc
+ files="$$files "`echo "$$files" | sed 's|$$|c|'`; \
+ dir='$(DESTDIR)$(%NDIR%dir)'; $(am__uninstall_files_from_dir)
endif %?INSTALL%
diff --git a/lib/am/mans.am b/lib/am/mans.am
index 66a6c7ee2..b41a94d18 100644
--- a/lib/am/mans.am
+++ b/lib/am/mans.am
@@ -119,9 +119,7 @@ if %?NOTRANS_MANS%
?HAVE_NOTRANS? sed -n '/\.%SECTION%[a-z]*$$/p'; \
## Extract basename of manpage, change the extension if needed.
} | sed 's,.*/,,;s,\.[^%SECTION%][0-9a-z]*$$,.%SECTION%,'`; \
- test -z "$$files" || { \
- echo " ( cd '$(DESTDIR)$(man%SECTION%dir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(man%SECTION%dir)" && rm -f $$files; }
+ dir='$(DESTDIR)$(man%SECTION%dir)'; $(am__uninstall_files_from_dir)
endif %?NOTRANS_MANS%
if %?TRANS_MANS%
## Handle MANS without notrans_ prefix
@@ -136,7 +134,5 @@ if %?TRANS_MANS%
## transform, and change the extension if needed.
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^%SECTION%][0-9a-z]*$$,%SECTION%,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
- test -z "$$files" || { \
- echo " ( cd '$(DESTDIR)$(man%SECTION%dir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(man%SECTION%dir)" && rm -f $$files; }
+ dir='$(DESTDIR)$(man%SECTION%dir)'; $(am__uninstall_files_from_dir)
endif %?TRANS_MANS%
diff --git a/lib/am/python.am b/lib/am/python.am
index 40aaa620d..427c95d0c 100644
--- a/lib/am/python.am
+++ b/lib/am/python.am
@@ -94,16 +94,15 @@ uninstall-%DIR%PYTHON:
?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
?!BASE? $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
test -n "$$files" || exit 0; \
+ dir='$(DESTDIR)$(%NDIR%dir)'; \
+## Also remove the .pyc and .pyo byte compiled versions.
filesc=`echo "$$files" | sed 's|$$|c|'`; \
fileso=`echo "$$files" | sed 's|$$|o|'`; \
- echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files || exit $$?; \
-## This is to remove the .pyc and .pyo byte compiled versions (a bit
-## of a hack).
- echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$filesc ")"; \
- cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$filesc || exit $$?; \
- echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$fileso ")"; \
- cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$fileso
+ st=0; \
+ for files in "$$files" "$$filesc" "$$fileso"; do \
+ $(am__uninstall_files_from_dir) || st=$$?; \
+ done; \
+ exit $$st
endif %?INSTALL%
diff --git a/lib/am/scripts.am b/lib/am/scripts.am
index 790cb649f..346f0d3b9 100644
--- a/lib/am/scripts.am
+++ b/lib/am/scripts.am
@@ -83,9 +83,7 @@ uninstall-%DIR%SCRIPTS:
?!BASE? $(am__nobase_strip_setup); \
?!BASE? files=`$(am__nobase_strip) \
?!BASE? -e 'h;s,.*/,,;$(transform);x;s|[^/]*$$||;G;s,\n,,'`; \
- test -n "$$list" || exit 0; \
- echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files
+ dir='$(DESTDIR)$(%NDIR%dir)'; $(am__uninstall_files_from_dir)
endif %?INSTALL%