Assar Westerlund writes: > b) just remove the directories that were created during `make install' If you `make install' twice then the second time the directories aren't created anymore, so the `make uninstall' would not attempt to remove them. Not good. > c) remove the last level of directory if it's empty That's not quite it either. If I install something into /opt/foo-0.99/{bin,lib,include} and then it only removes the bin, lib, and include parts, then it's arguably being less than helpful. > d) remove all the levels that are empty That would certainly be the easiest. Perhaps once could make provisions that certain "standard" directories (e.g., /usr/local) shouldn't be removed, although I don't see a reason for keeping them around. It was objected that other, badly packaged software might blindly assume that some standard directory exists, but how hard is it to `mkdir /usr/local' if you get `/usr/local: no such file or directory'? The added beauty of this approach would be that `rminstalldirs' would be to `rmdir -p' what `mkinstalldirs' is now to `mkdir -p'. A possible (though perhaps not perfect) implementation of rminstalldirs is attached for your perusal. -- Peter Eisentraut Sernanders väg 10:115 [EMAIL PROTECTED] 75262 Uppsala http://yi.org/peter-e/ Sweden
#! /bin/sh # rminstalldirs -- remove empty directory hierarchy # Author: Peter Eisentraut <[EMAIL PROTECTED]> # Created: 2000-05-15 # EXPERIMENTAL! errstatus=0 for arg in ${1+"$@"} ; do path=`echo "$arg" | sed -e 's,/$,,' | tr -s '/'` case "$path" in -* ) path="./$path" ;; esac while test -n "$path" && test x"$path" != x"." ; do if test -d "$path" ; then if test x"`ls -A "$path"`" = x ; then echo "rmdir $path" rmdir "$path" > /dev/null 2>&1 || errstatus=$? else # $path is not empty break fi else # not a directory errstatus=1 fi if test $errstatus -ne 0 ; then break; fi path=`echo "$path" | sed -e 's,/[^/]*$,,'` done done exit $errstatus