Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Rob Landley | 7c04f01 | 2008-01-20 19:00:16 -0600 | [diff] [blame] | 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 | |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 6 | mkdir -p generated |
| 7 | |
Rob Landley | 2bd3a5d | 2012-02-13 08:44:32 -0600 | [diff] [blame] | 8 | source configure |
| 9 | |
Rob Landley | 76e1cb3 | 2014-04-16 07:49:32 -0500 | [diff] [blame] | 10 | # Probe for a single config symbol with a "compiles or not" test. |
| 11 | # Symbol name is first argument, flags second, feed C file to stdin |
| 12 | probesymbol() |
| 13 | { |
| 14 | ${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null $2 - 2>/dev/null |
| 15 | [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n |
| 16 | rm a.out 2>/dev/null |
| 17 | echo -e "config $1\n\tbool" || exit 1 |
| 18 | echo -e "\tdefault $DEFAULT\n" || exit 1 |
| 19 | } |
| 20 | |
Rob Landley | 1b7ad01 | 2012-02-23 21:03:18 -0600 | [diff] [blame] | 21 | probeconfig() |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 22 | { |
Rob Landley | 27f5779 | 2012-02-03 23:16:28 -0600 | [diff] [blame] | 23 | # Probe for container support on target |
Rob Landley | 76e1cb3 | 2014-04-16 07:49:32 -0500 | [diff] [blame] | 24 | probesymbol TOYBOX_CONTAINER << EOF |
Georgi Chorbadzhiyski | 2c27fcf | 2012-03-04 01:24:06 -0600 | [diff] [blame] | 25 | #include <linux/sched.h> |
Rob Landley | 27f5779 | 2012-02-03 23:16:28 -0600 | [diff] [blame] | 26 | int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET; |
Rob Landley | f9fdd3c | 2012-03-19 20:15:08 -0500 | [diff] [blame] | 27 | |
| 28 | int main(int argc, char *argv[]) { return unshare(x); } |
Rob Landley | 27f5779 | 2012-02-03 23:16:28 -0600 | [diff] [blame] | 29 | EOF |
Rob Landley | 76e1cb3 | 2014-04-16 07:49:32 -0500 | [diff] [blame] | 30 | |
| 31 | probesymbol TOYBOX_FIFREEZE -c << EOF |
| 32 | #include <linux/fs.h> |
| 33 | #ifndef FIFREEZE |
| 34 | #error nope |
| 35 | #endif |
| 36 | EOF |
Rob Landley | 5fe77cf | 2014-04-23 08:38:29 -0500 | [diff] [blame^] | 37 | |
| 38 | # Hard to come by in uClibc. |
| 39 | probesymbol TOYBOX_ICONV -c << EOF |
| 40 | #include "iconv.h" |
| 41 | EOF |
Rob Landley | 1b7ad01 | 2012-02-23 21:03:18 -0600 | [diff] [blame] | 42 | } |
Rob Landley | f9fdd3c | 2012-03-19 20:15:08 -0500 | [diff] [blame] | 43 | |
Rob Landley | 1b7ad01 | 2012-02-23 21:03:18 -0600 | [diff] [blame] | 44 | genconfig() |
| 45 | { |
Rob Landley | 3a9241a | 2012-08-25 14:25:22 -0500 | [diff] [blame] | 46 | # I could query the directory here, but I want to control the order |
| 47 | # and capitalization in the menu |
Rob Landley | aa777fe | 2012-12-08 21:10:10 -0600 | [diff] [blame] | 48 | for j in toys/*/README |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 49 | do |
Rob Landley | b1c002a | 2012-12-10 21:08:42 -0600 | [diff] [blame] | 50 | DIR="$(dirname "$j")" |
| 51 | |
| 52 | [ $(ls "$DIR" | wc -l) -lt 2 ] && continue |
| 53 | |
Rob Landley | aa777fe | 2012-12-08 21:10:10 -0600 | [diff] [blame] | 54 | echo "menu \"$(head -n 1 $j)\"" |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 55 | echo |
Rob Landley | 3a9241a | 2012-08-25 14:25:22 -0500 | [diff] [blame] | 56 | |
Rob Landley | 3a9241a | 2012-08-25 14:25:22 -0500 | [diff] [blame] | 57 | # extract config stanzas from each source file, in alphabetical order |
Rob Landley | aa777fe | 2012-12-08 21:10:10 -0600 | [diff] [blame] | 58 | for i in $(ls -1 $DIR/*.c) |
Rob Landley | 3a9241a | 2012-08-25 14:25:22 -0500 | [diff] [blame] | 59 | do |
| 60 | # Grab the config block for Config.in |
| 61 | echo "# $i" |
| 62 | sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1 |
| 63 | echo |
| 64 | done |
| 65 | |
| 66 | echo endmenu |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 67 | done |
| 68 | } |
| 69 | |
Rob Landley | 1b7ad01 | 2012-02-23 21:03:18 -0600 | [diff] [blame] | 70 | probeconfig > generated/Config.probed || rm generated/Config.probed |
| 71 | genconfig > generated/Config.in || rm generated/Config.in |