blob: 449ee1eaee4c8aac233c0de828ef3dbe46228922 [file] [log] [blame]
Rob Landley28964802008-01-19 17:08:39 -06001#!/bin/bash
2
Rob Landley7c04f012008-01-20 19:00:16 -06003# 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
Rob Landley28964802008-01-19 17:08:39 -06006mkdir -p generated
Rob Landley27f57792012-02-03 23:16:28 -06007OUTFILE=generated/Config.in
Rob Landley28964802008-01-19 17:08:39 -06008
Rob Landley2bd3a5d2012-02-13 08:44:32 -06009source configure
10
Rob Landley1b7ad012012-02-23 21:03:18 -060011probeconfig()
Rob Landley28964802008-01-19 17:08:39 -060012{
Rob Landley27f57792012-02-03 23:16:28 -060013 # Probe for container support on target
14
15 echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
Rob Landley344c2672012-03-03 10:56:11 -060016 ${CROSS_COMPILE}${CC} -c -xc -o /dev/null - 2>/dev/null << EOF
Rob Landley27f57792012-02-03 23:16:28 -060017 #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
Rob Landley1b7ad012012-02-23 21:03:18 -060022}
23genconfig()
24{
Rob Landley27f57792012-02-03 23:16:28 -060025 # extract config stanzas from each command source file, in alphabetical order
26
27 for i in $(ls -1 toys/*.c)
Rob Landley28964802008-01-19 17:08:39 -060028 do
29 # Grab the config block for Config.in
30 echo "# $i"
Rob Landley27f57792012-02-03 23:16:28 -060031 sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1
Rob Landley28964802008-01-19 17:08:39 -060032 echo
33 done
34}
35
Rob Landley1b7ad012012-02-23 21:03:18 -060036probeconfig > generated/Config.probed || rm generated/Config.probed
37genconfig > generated/Config.in || rm generated/Config.in