diff scripts/genconfig.sh @ 426:8b0487639db9

Add autodetect for container support.
author Rob Landley <rob@landley.net>
date Fri, 03 Feb 2012 23:16:28 -0600
parents 4f1ca01db000
children 8f5780dd6da4
line wrap: on
line diff
--- a/scripts/genconfig.sh	Fri Feb 03 22:39:55 2012 -0600
+++ b/scripts/genconfig.sh	Fri Feb 03 23:16:28 2012 -0600
@@ -4,16 +4,29 @@
 # before menuconfig.  (It's called again from scripts/make.sh just to be sure.)
 
 mkdir -p generated
+OUTFILE=generated/Config.in
 
-function genconfig()
+genconfig()
 {
-  for i in $(echo toys/*.c | sort)
+  # Probe for container support on target
+
+  echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
+  $CC -c -xc -o /dev/null - 2>/dev/null << EOF
+    #include <sched.h>
+    int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
+EOF
+  [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
+  echo -e "\tdefault $DEFAULT\n" || return 1
+
+  # extract config stanzas from each command source file, in alphabetical order
+
+  for i in $(ls -1 toys/*.c)
   do
     # Grab the config block for Config.in
     echo "# $i"
-    sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || exit 1
+    sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1
     echo
   done
 }
 
-genconfig > generated/Config.in
+genconfig > generated/Config.in || rm "$OUTFILE"