genconfig.sh revision 1b7ad01f5e5ead83fbc06ff20248b085a15dc279
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  $CC -c -xc -o /dev/null - << EOF
17    #include <sched.h>
18    int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
19EOF
20  [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
21  echo -e "\tdefault $DEFAULT\n" || return 1
22}
23genconfig()
24{
25  # extract config stanzas from each command source file, in alphabetical order
26
27  for i in $(ls -1 toys/*.c)
28  do
29    # Grab the config block for Config.in
30    echo "# $i"
31    sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1
32    echo
33  done
34}
35
36probeconfig > generated/Config.probed || rm generated/Config.probed
37genconfig > generated/Config.in || rm generated/Config.in
38