Mercurial > hg > toybox
annotate scripts/genconfig.sh @ 1753:0f940c4f9658 draft
Promote runcon to android (and add an android menu).
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 23 Mar 2015 13:45:47 -0500 |
parents | c1715c752e89 |
children |
rev | line source |
---|---|
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 #!/bin/bash |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
239
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
3 # This has to be a separate file from scripts/make.sh so it can be called |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
4 # before menuconfig. (It's called again from scripts/make.sh just to be sure.) |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
5 |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 mkdir -p generated |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 |
454
8f5780dd6da4
The unshare test needs $CC defined, source configure to get it.
Rob Landley <rob@landley.net>
parents:
426
diff
changeset
|
8 source configure |
8f5780dd6da4
The unshare test needs $CC defined, source configure to get it.
Rob Landley <rob@landley.net>
parents:
426
diff
changeset
|
9 |
1260
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
10 # Probe for a single config symbol with a "compiles or not" test. |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
11 # Symbol name is first argument, flags second, feed C file to stdin |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
12 probesymbol() |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
13 { |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
14 ${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null $2 - 2>/dev/null |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
15 [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
16 rm a.out 2>/dev/null |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
17 echo -e "config $1\n\tbool" || exit 1 |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
18 echo -e "\tdefault $DEFAULT\n" || exit 1 |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
19 } |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
20 |
496
f0247cfc37f2
Don't mix the the probed symbols with the command symbols.
Rob Landley <rob@landley.net>
parents:
454
diff
changeset
|
21 probeconfig() |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 { |
426
8b0487639db9
Add autodetect for container support.
Rob Landley <rob@landley.net>
parents:
239
diff
changeset
|
23 # Probe for container support on target |
1260
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
24 probesymbol TOYBOX_CONTAINER << EOF |
519
c6b3bd689d0a
Fix build on slackware-current.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
512
diff
changeset
|
25 #include <linux/sched.h> |
426
8b0487639db9
Add autodetect for container support.
Rob Landley <rob@landley.net>
parents:
239
diff
changeset
|
26 int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET; |
552
7b85b0a0e9c0
Have probe for unshare test for actual unshare() function in libc.
Rob Landley <rob@landley.net>
parents:
519
diff
changeset
|
27 |
7b85b0a0e9c0
Have probe for unshare test for actual unshare() function in libc.
Rob Landley <rob@landley.net>
parents:
519
diff
changeset
|
28 int main(int argc, char *argv[]) { return unshare(x); } |
426
8b0487639db9
Add autodetect for container support.
Rob Landley <rob@landley.net>
parents:
239
diff
changeset
|
29 EOF |
1260
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
30 |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
31 probesymbol TOYBOX_FIFREEZE -c << EOF |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
32 #include <linux/fs.h> |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
33 #ifndef FIFREEZE |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
34 #error nope |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
35 #endif |
0ce03bb85ebd
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
Rob Landley <rob@landley.net>
parents:
1259
diff
changeset
|
36 EOF |
1266
a302299dbb98
As long as uClibc's still around and requires you to jump through hoops to get iconv(), probe and build defconfig without it if it's not there.
Rob Landley <rob@landley.net>
parents:
1260
diff
changeset
|
37 |
1368
8bd7e28a9eb8
Add fallocate probe for uClibc.
Rob Landley <rob@landley.net>
parents:
1267
diff
changeset
|
38 # Work around some uClibc limitations |
1266
a302299dbb98
As long as uClibc's still around and requires you to jump through hoops to get iconv(), probe and build defconfig without it if it's not there.
Rob Landley <rob@landley.net>
parents:
1260
diff
changeset
|
39 probesymbol TOYBOX_ICONV -c << EOF |
a302299dbb98
As long as uClibc's still around and requires you to jump through hoops to get iconv(), probe and build defconfig without it if it's not there.
Rob Landley <rob@landley.net>
parents:
1260
diff
changeset
|
40 #include "iconv.h" |
a302299dbb98
As long as uClibc's still around and requires you to jump through hoops to get iconv(), probe and build defconfig without it if it's not there.
Rob Landley <rob@landley.net>
parents:
1260
diff
changeset
|
41 EOF |
1368
8bd7e28a9eb8
Add fallocate probe for uClibc.
Rob Landley <rob@landley.net>
parents:
1267
diff
changeset
|
42 probesymbol TOYBOX_FALLOCATE << EOF |
8bd7e28a9eb8
Add fallocate probe for uClibc.
Rob Landley <rob@landley.net>
parents:
1267
diff
changeset
|
43 #include <fcntl.h> |
8bd7e28a9eb8
Add fallocate probe for uClibc.
Rob Landley <rob@landley.net>
parents:
1267
diff
changeset
|
44 |
8bd7e28a9eb8
Add fallocate probe for uClibc.
Rob Landley <rob@landley.net>
parents:
1267
diff
changeset
|
45 int main(int argc, char *argv[]) { return posix_fallocate(0,0,0); } |
8bd7e28a9eb8
Add fallocate probe for uClibc.
Rob Landley <rob@landley.net>
parents:
1267
diff
changeset
|
46 EOF |
1564
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
47 |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
48 # Android and some other platforms miss utmpx |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
49 probesymbol TOYBOX_UTMPX -c << EOF |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
50 #include <utmpx.h> |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
51 #ifndef BOOT_TIME |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
52 #error nope |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
53 #endif |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
54 int main(int argc, char *argv[]) { |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
55 struct utmpx *a; |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
56 if (0 != (a = getutxent())) return 0; |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
57 return 1; |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
58 } |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
59 EOF |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
60 |
1662
c1715c752e89
AOSP master has <pty.h> and builds netcat/nc.
Elliott Hughes <enh@google.com>
parents:
1565
diff
changeset
|
61 # Android is missing shadow.h |
1564
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
62 probesymbol TOYBOX_SHADOW -c << EOF |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
63 #include <shadow.h> |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
64 int main(int argc, char *argv[]) { |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
65 struct spwd *a = getspnam("root"); return 0; |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
66 } |
685a0da6ca59
probe for getspnam(), forkpty(), utmpx, replace sethostname()
Isaac Dunham <ibid.ag@gmail.com>
parents:
1368
diff
changeset
|
67 EOF |
496
f0247cfc37f2
Don't mix the the probed symbols with the command symbols.
Rob Landley <rob@landley.net>
parents:
454
diff
changeset
|
68 } |
552
7b85b0a0e9c0
Have probe for unshare test for actual unshare() function in libc.
Rob Landley <rob@landley.net>
parents:
519
diff
changeset
|
69 |
496
f0247cfc37f2
Don't mix the the probed symbols with the command symbols.
Rob Landley <rob@landley.net>
parents:
454
diff
changeset
|
70 genconfig() |
f0247cfc37f2
Don't mix the the probed symbols with the command symbols.
Rob Landley <rob@landley.net>
parents:
454
diff
changeset
|
71 { |
1267
dd2fd057111f
Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
1266
diff
changeset
|
72 # Reverse sort puts posix first, examples last. |
dd2fd057111f
Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
1266
diff
changeset
|
73 for j in $(ls toys/*/README | sort -r) |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
74 do |
747
68d6c1ce7bba
Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
740
diff
changeset
|
75 DIR="$(dirname "$j")" |
68d6c1ce7bba
Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
740
diff
changeset
|
76 |
68d6c1ce7bba
Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
740
diff
changeset
|
77 [ $(ls "$DIR" | wc -l) -lt 2 ] && continue |
68d6c1ce7bba
Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
740
diff
changeset
|
78 |
740
f5ef67700a26
Add README file to each toys/ directory, teach build infrastructure to get fancy name from that. This means adding new directories shouldn't require touching build scripts.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
79 echo "menu \"$(head -n 1 $j)\"" |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
80 echo |
653
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
81 |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
82 # extract config stanzas from each source file, in alphabetical order |
740
f5ef67700a26
Add README file to each toys/ directory, teach build infrastructure to get fancy name from that. This means adding new directories shouldn't require touching build scripts.
Rob Landley <rob@landley.net>
parents:
653
diff
changeset
|
83 for i in $(ls -1 $DIR/*.c) |
653
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
84 do |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
85 # Grab the config block for Config.in |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
86 echo "# $i" |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
87 sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1 |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
88 echo |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
89 done |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
90 |
2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
Rob Landley <rob@landley.net>
parents:
552
diff
changeset
|
91 echo endmenu |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
92 done |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
93 } |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
94 |
496
f0247cfc37f2
Don't mix the the probed symbols with the command symbols.
Rob Landley <rob@landley.net>
parents:
454
diff
changeset
|
95 probeconfig > generated/Config.probed || rm generated/Config.probed |
f0247cfc37f2
Don't mix the the probed symbols with the command symbols.
Rob Landley <rob@landley.net>
parents:
454
diff
changeset
|
96 genconfig > generated/Config.in || rm generated/Config.in |