changeset 1260:0ce03bb85ebd

Probe for the existence of FIFREEZE and make fsfreeze depend on it.
author Rob Landley <rob@landley.net>
date Wed, 16 Apr 2014 07:49:32 -0500
parents 565980862743
children 9e105bab92e5
files scripts/genconfig.sh toys/other/fsfreeze.c
diffstat 2 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/genconfig.sh	Tue Apr 15 21:59:42 2014 -0500
+++ b/scripts/genconfig.sh	Wed Apr 16 07:49:32 2014 -0500
@@ -7,20 +7,33 @@
 
 source configure
 
+# Probe for a single config symbol with a "compiles or not" test.
+# Symbol name is first argument, flags second, feed C file to stdin
+probesymbol()
+{
+  ${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null $2 - 2>/dev/null
+  [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
+  rm a.out 2>/dev/null
+  echo -e "config $1\n\tbool" || exit 1
+  echo -e "\tdefault $DEFAULT\n" || exit 1
+}
+
 probeconfig()
 {
   # Probe for container support on target
-
-  echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
-  ${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null - 2>/dev/null << EOF
+  probesymbol TOYBOX_CONTAINER << EOF
     #include <linux/sched.h>
     int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
 
     int main(int argc, char *argv[]) { return unshare(x); }
 EOF
-  [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
-  rm a.out 2>/dev/null
-  echo -e "\tdefault $DEFAULT\n" || return 1
+
+  probesymbol TOYBOX_FIFREEZE -c << EOF
+    #include <linux/fs.h>
+    #ifndef FIFREEZE
+    #error nope
+    #endif
+EOF
 }
 
 genconfig()
--- a/toys/other/fsfreeze.c	Tue Apr 15 21:59:42 2014 -0500
+++ b/toys/other/fsfreeze.c	Wed Apr 16 07:49:32 2014 -0500
@@ -7,6 +7,7 @@
 config FSFREEZE
   bool "fsfreeze"
   default y
+  depends on TOYBOX_FIFREEZE
   help
     usage: fsfreeze {-f | -u} MOUNTPOINT