From 27f5779a7a3d71cd26107d26330c67445341e879 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 3 Feb 2012 23:16:28 -0600 Subject: Add autodetect for container support. --- Makefile | 2 +- scripts/genconfig.sh | 21 +++++++++++++++++---- toys/unshare.c | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d42dd3f3..df24c513 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ toybox toybox_unstripped: .config *.[ch] lib/*.[ch] toys/*.[ch] scripts/*.sh include kconfig/Makefile $(KCONFIG_TOP): generated/Config.in -generated/Config.in: toys/*.c +generated/Config.in: toys/*.c scripts/genconfig.sh scripts/genconfig.sh HOSTCC:=cc diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh index 126e52ef..1911efc6 100755 --- a/scripts/genconfig.sh +++ b/scripts/genconfig.sh @@ -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 + 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" diff --git a/toys/unshare.c b/toys/unshare.c index c708ebe9..6485e334 100644 --- a/toys/unshare.c +++ b/toys/unshare.c @@ -11,6 +11,7 @@ USE_UNSHARE(NEWTOY(unshare, "<1^nium", TOYFLAG_USR|TOYFLAG_BIN)) config UNSHARE bool "unshare" default y + depends on TOYBOX_CONTAINER help usage: unshare [-muin] COMMAND... -- cgit v1.2.3