blob: 4337666cc26a4a87ce0078cd2b78b65a2dffe43b [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
7
Rob Landley2bd3a5d2012-02-13 08:44:32 -06008source configure
9
Rob Landley1b7ad012012-02-23 21:03:18 -060010probeconfig()
Rob Landley28964802008-01-19 17:08:39 -060011{
Rob Landley27f57792012-02-03 23:16:28 -060012 # Probe for container support on target
13
14 echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
Rob Landleyf9fdd3c2012-03-19 20:15:08 -050015 ${CROSS_COMPILE}${CC} -xc -o /dev/null - 2>/dev/null << EOF
Georgi Chorbadzhiyski2c27fcf2012-03-04 01:24:06 -060016 #include <linux/sched.h>
Rob Landley27f57792012-02-03 23:16:28 -060017 int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
Rob Landleyf9fdd3c2012-03-19 20:15:08 -050018
19 int main(int argc, char *argv[]) { return unshare(x); }
Rob Landley27f57792012-02-03 23:16:28 -060020EOF
21 [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
Rob Landleyf9fdd3c2012-03-19 20:15:08 -050022 rm a.out 2>/dev/null
Rob Landley27f57792012-02-03 23:16:28 -060023 echo -e "\tdefault $DEFAULT\n" || return 1
Rob Landley1b7ad012012-02-23 21:03:18 -060024}
Rob Landleyf9fdd3c2012-03-19 20:15:08 -050025
Rob Landley1b7ad012012-02-23 21:03:18 -060026genconfig()
27{
Rob Landley3a9241a2012-08-25 14:25:22 -050028 # I could query the directory here, but I want to control the order
29 # and capitalization in the menu
Rob Landleyaa777fe2012-12-08 21:10:10 -060030 for j in toys/*/README
Rob Landley28964802008-01-19 17:08:39 -060031 do
Rob Landleyaa777fe2012-12-08 21:10:10 -060032 echo "menu \"$(head -n 1 $j)\""
Rob Landley28964802008-01-19 17:08:39 -060033 echo
Rob Landley3a9241a2012-08-25 14:25:22 -050034
Rob Landleyaa777fe2012-12-08 21:10:10 -060035 DIR="$(dirname "$j")"
Rob Landley3a9241a2012-08-25 14:25:22 -050036
37 # extract config stanzas from each source file, in alphabetical order
Rob Landleyaa777fe2012-12-08 21:10:10 -060038 for i in $(ls -1 $DIR/*.c)
Rob Landley3a9241a2012-08-25 14:25:22 -050039 do
40 # Grab the config block for Config.in
41 echo "# $i"
42 sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1
43 echo
44 done
45
46 echo endmenu
Rob Landley28964802008-01-19 17:08:39 -060047 done
48}
49
Rob Landley1b7ad012012-02-23 21:03:18 -060050probeconfig > generated/Config.probed || rm generated/Config.probed
51genconfig > generated/Config.in || rm generated/Config.in