Skip to contentSkip to conversation

configure: Do not use 'sed -i'

PATCH Applied Pavel Borzenkov 3 participants 3 messages Nov 10, 2011 – Nov 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: Do not use 'sed -i'

'sed -i' is not defined in POSIX. It doesn't work on Mac OS X the way it's used in configure (without suffix argument). This patch implements Peter Maydell's idea of xattr.h detection.

---
 configure |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
configure +5 -1
index 401d9a6..d6103c0 100755
@@ -1962,13 +1962,17 @@ if test "$attr" != "no" ; then
   cat > $TMPC <<EOF
 #include <stdio.h>
 #include <sys/types.h>
+#ifdef CONFIG_LIBATTR
+#include <attr/xattr.h>
+#else
 #include <sys/xattr.h>
+#endif
 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
 EOF
   if compile_prog "" "" ; then
     attr=yes
   # Older distros have <attr/xattr.h>, and need -lattr:
-  elif sed -i s,sys/xattr,attr/xattr, $TMPC && compile_prog "" "-lattr" ; then
+  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
     attr=yes
     LIBS="-lattr $LIBS"
     libattr=yes
Signature · 1 line
1.7.5.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Pavel Borzenkov

'sed -i' is not defined in POSIX. It doesn't work on Mac OS X the way it's used in configure (without suffix argument). This patch implements Peter Maydell's idea of xattr.h detection.

(tested that we take the sys/xattr.h path, and that if you nobble that test we correctly fall back and detect attr/xattr.h+libattr.)

-- PMM

#2 lore raw
In reply to Pavel Borzenkov
Quoted 6 lines · Pavel Borzenkov

'sed -i' is not defined in POSIX. It doesn't work on Mac OS X the way it's used in configure (without suffix argument). This patch implements Peter Maydell's idea of xattr.h detection.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 27 lines
---
  configure |    6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)
configure +5 -1
index 401d9a6..d6103c0 100755
@@ -1962,13 +1962,17 @@ if test "$attr" != "no" ; then
    cat>  $TMPC<<EOF
  #include<stdio.h>
  #include<sys/types.h>
+#ifdef CONFIG_LIBATTR
+#include<attr/xattr.h>
+#else
  #include<sys/xattr.h>
+#endif
  int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
  EOF
    if compile_prog "" "" ; then
      attr=yes
    # Older distros have<attr/xattr.h>, and need -lattr:
-  elif sed -i s,sys/xattr,attr/xattr, $TMPC&&  compile_prog "" "-lattr" ; then
+  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
      attr=yes
      LIBS="-lattr $LIBS"
      libattr=yes