genconfig.sh revision 3a9241add947cb6d24b5de7a8927517426a78795
1#!/bin/bash 2 3# This has to be a separate file from scripts/make.sh so it can be called 4# before menuconfig. (It's called again from scripts/make.sh just to be sure.) 5 6mkdir -p generated 7OUTFILE=generated/Config.in 8 9source configure 10 11probeconfig() 12{ 13 # Probe for container support on target 14 15 echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1 16 ${CROSS_COMPILE}${CC} -xc -o /dev/null - 2>/dev/null << EOF 17 #include <linux/sched.h> 18 int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET; 19 20 int main(int argc, char *argv[]) { return unshare(x); } 21EOF 22 [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n 23 rm a.out 2>/dev/null 24 echo -e "\tdefault $DEFAULT\n" || return 1 25} 26 27genconfig() 28{ 29 # I could query the directory here, but I want to control the order 30 # and capitalization in the menu 31 for j in Posix LSB Other 32 do 33 echo "menu \"$j commands\"" 34 echo 35 36 DIR=$(echo $j | tr A-Z a-z) 37 38 # extract config stanzas from each source file, in alphabetical order 39 for i in $(ls -1 toys/$DIR/*.c) 40 do 41 # Grab the config block for Config.in 42 echo "# $i" 43 sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1 44 echo 45 done 46 47 echo endmenu 48 done 49} 50 51probeconfig > generated/Config.probed || rm generated/Config.probed 52genconfig > generated/Config.in || rm generated/Config.in 53