blob: accf0dba8804ea8b8bc16414281c1b8a429fb3e1 [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 Landleyf9fdd3c2012-03-19 20:15:08 -050016 ${CROSS_COMPILE}${CC} -xc -o /dev/null - 2>/dev/null << EOF
Georgi Chorbadzhiyski2c27fcf2012-03-04 01:24:06 -060017 #include <linux/sched.h>
Rob Landley27f57792012-02-03 23:16:28 -060018 int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
Rob Landleyf9fdd3c2012-03-19 20:15:08 -050019
20 int main(int argc, char *argv[]) { return unshare(x); }
Rob Landley27f57792012-02-03 23:16:28 -060021EOF
22 [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
Rob Landleyf9fdd3c2012-03-19 20:15:08 -050023 rm a.out 2>/dev/null
Rob Landley27f57792012-02-03 23:16:28 -060024 echo -e "\tdefault $DEFAULT\n" || return 1
Rob Landley1b7ad012012-02-23 21:03:18 -060025}
Rob Landleyf9fdd3c2012-03-19 20:15:08 -050026
Rob Landley1b7ad012012-02-23 21:03:18 -060027genconfig()
28{
Rob Landley3a9241a2012-08-25 14:25:22 -050029 # 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
Rob Landley28964802008-01-19 17:08:39 -060032 do
Rob Landley3a9241a2012-08-25 14:25:22 -050033 echo "menu \"$j commands\""
Rob Landley28964802008-01-19 17:08:39 -060034 echo
Rob Landley3a9241a2012-08-25 14:25:22 -050035
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
Rob Landley28964802008-01-19 17:08:39 -060048 done
49}
50
Rob Landley1b7ad012012-02-23 21:03:18 -060051probeconfig > generated/Config.probed || rm generated/Config.probed
52genconfig > generated/Config.in || rm generated/Config.in