[systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix

Michael Biebl mbiebl at gmail.com
Fri May 29 17:50:28 PDT 2015


2015-05-30 2:24 GMT+02:00 Daniel Mack <daniel at zonque.org>:
>
> Fine for me, just go ahead if you have an implementation in mind :)

I was lazy and just copied
ftp://ftp.tu-clausthal.de/pub/mirror/gnu/www/software/ac-archive/normpath.html
The resulting diff would look something like

diff --git a/configure.ac b/configure.ac
index 92654a6..815c8af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1397,11 +1397,13 @@ AC_ARG_WITH([zshcompletiondir],
 AC_ARG_WITH([rootprefix],
         AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory
prefix for config files and kernel modules]),
         [], [with_rootprefix=${ac_default_prefix}])
+adl_NORMALIZE_PATH([with_rootprefix])

 AC_ARG_WITH([rootlibdir],
         AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for
libraries necessary for boot]),
         [],
         [with_rootlibdir=${libdir}])
+adl_NORMALIZE_PATH([with_rootlibdir])

 AC_ARG_WITH([pamlibdir],
         AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]),
diff --git a/m4/normpath.m4 b/m4/normpath.m4
new file mode 100644
index 0000000..5b29488
--- /dev/null
+++ b/m4/normpath.m4
@@ -0,0 +1,15 @@
+AC_DEFUN([adl_NORMALIZE_PATH],
+[case ":[$]$1:" in
+# change empty paths to '.'
+  ::) $1='.' ;;
+# strip trailing slashes
+  :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;;
+  :*:) ;;
+esac
+# squeze repeated slashes
+case ifelse($2,,"[$]$1",$2) in
+# if the path contains any backslashes, turn slashes into backslashes
+ *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\,g'` ;;
+# if the path contains slashes, also turn backslashes into slashes
+ *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;;
+esac])


This would need to be extended all remaining dirs.

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?


More information about the systemd-devel mailing list