2008-01-19 15:08:39 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2008-01-20 17:00:16 -08:00
|
|
|
# This has to be a separate file from scripts/make.sh so it can be called
|
|
|
|
# before menuconfig. (It's called again from scripts/make.sh just to be sure.)
|
|
|
|
|
2008-01-19 15:08:39 -08:00
|
|
|
mkdir -p generated
|
|
|
|
|
2012-02-13 06:44:32 -08:00
|
|
|
source configure
|
|
|
|
|
2015-05-09 15:07:22 -07:00
|
|
|
probecc()
|
|
|
|
{
|
|
|
|
${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null $1 -
|
|
|
|
}
|
|
|
|
|
2014-04-16 05:49:32 -07:00
|
|
|
# Probe for a single config symbol with a "compiles or not" test.
|
|
|
|
# Symbol name is first argument, flags second, feed C file to stdin
|
|
|
|
probesymbol()
|
|
|
|
{
|
2015-05-09 15:07:22 -07:00
|
|
|
probecc $2 2>/dev/null && DEFAULT=y || DEFAULT=n
|
2014-04-16 05:49:32 -07:00
|
|
|
rm a.out 2>/dev/null
|
|
|
|
echo -e "config $1\n\tbool" || exit 1
|
|
|
|
echo -e "\tdefault $DEFAULT\n" || exit 1
|
|
|
|
}
|
|
|
|
|
2012-02-23 19:03:18 -08:00
|
|
|
probeconfig()
|
2008-01-19 15:08:39 -08:00
|
|
|
{
|
2015-05-09 15:07:22 -07:00
|
|
|
> generated/cflags
|
|
|
|
# llvm produces its own really stupid warnings about things that aren't wrong,
|
|
|
|
# and although you can turn the warning off, gcc reacts badly to command line
|
|
|
|
# arguments it doesn't understand. So probe.
|
|
|
|
[ -z "$(probecc -Wno-string-plus-int <<< \#warn warn 2>&1 | grep string-plus-int)" ] &&
|
|
|
|
echo -Wno-string-plus-int >> generated/cflags
|
|
|
|
|
2012-02-03 21:16:28 -08:00
|
|
|
# Probe for container support on target
|
2014-04-16 05:49:32 -07:00
|
|
|
probesymbol TOYBOX_CONTAINER << EOF
|
2012-03-03 23:24:06 -08:00
|
|
|
#include <linux/sched.h>
|
2012-02-03 21:16:28 -08:00
|
|
|
int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
|
2012-03-19 18:15:08 -07:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) { return unshare(x); }
|
2012-02-03 21:16:28 -08:00
|
|
|
EOF
|
2014-04-16 05:49:32 -07:00
|
|
|
|
|
|
|
probesymbol TOYBOX_FIFREEZE -c << EOF
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#ifndef FIFREEZE
|
|
|
|
#error nope
|
|
|
|
#endif
|
|
|
|
EOF
|
2014-04-23 06:38:29 -07:00
|
|
|
|
2014-06-28 18:16:11 -07:00
|
|
|
# Work around some uClibc limitations
|
2014-04-23 06:38:29 -07:00
|
|
|
probesymbol TOYBOX_ICONV -c << EOF
|
|
|
|
#include "iconv.h"
|
2014-06-28 18:16:11 -07:00
|
|
|
EOF
|
|
|
|
probesymbol TOYBOX_FALLOCATE << EOF
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) { return posix_fallocate(0,0,0); }
|
2014-04-23 06:38:29 -07:00
|
|
|
EOF
|
2014-11-19 14:38:46 -08:00
|
|
|
|
|
|
|
# Android and some other platforms miss utmpx
|
|
|
|
probesymbol TOYBOX_UTMPX -c << EOF
|
|
|
|
#include <utmpx.h>
|
|
|
|
#ifndef BOOT_TIME
|
|
|
|
#error nope
|
|
|
|
#endif
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
struct utmpx *a;
|
|
|
|
if (0 != (a = getutxent())) return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2015-01-16 11:49:23 -08:00
|
|
|
# Android is missing shadow.h
|
2014-11-19 14:38:46 -08:00
|
|
|
probesymbol TOYBOX_SHADOW -c << EOF
|
|
|
|
#include <shadow.h>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
struct spwd *a = getspnam("root"); return 0;
|
|
|
|
}
|
|
|
|
EOF
|
2015-04-19 19:50:51 -07:00
|
|
|
|
|
|
|
# Some commands are android-specific
|
|
|
|
probesymbol TOYBOX_ON_ANDROID -c << EOF
|
|
|
|
#ifndef __ANDROID__
|
|
|
|
#error nope
|
|
|
|
#endif
|
|
|
|
EOF
|
2015-07-03 13:17:25 -07:00
|
|
|
|
|
|
|
# nommu support
|
|
|
|
probesymbol TOYBOX_FORK << EOF
|
|
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char *argv[]) { return fork(); }
|
|
|
|
EOF
|
2015-08-29 20:12:56 -07:00
|
|
|
echo -e '\tdepends on !TOYBOX_MUSL_NOMMU_IS_BROKEN'
|
2012-02-23 19:03:18 -08:00
|
|
|
}
|
2012-03-19 18:15:08 -07:00
|
|
|
|
2012-02-23 19:03:18 -08:00
|
|
|
genconfig()
|
|
|
|
{
|
2014-04-23 15:23:09 -07:00
|
|
|
# Reverse sort puts posix first, examples last.
|
|
|
|
for j in $(ls toys/*/README | sort -r)
|
2008-01-19 15:08:39 -08:00
|
|
|
do
|
2012-12-10 19:08:42 -08:00
|
|
|
DIR="$(dirname "$j")"
|
|
|
|
|
|
|
|
[ $(ls "$DIR" | wc -l) -lt 2 ] && continue
|
|
|
|
|
2012-12-08 19:10:10 -08:00
|
|
|
echo "menu \"$(head -n 1 $j)\""
|
2008-01-19 15:08:39 -08:00
|
|
|
echo
|
2012-08-25 12:25:22 -07:00
|
|
|
|
|
|
|
# extract config stanzas from each source file, in alphabetical order
|
2012-12-08 19:10:10 -08:00
|
|
|
for i in $(ls -1 $DIR/*.c)
|
2012-08-25 12:25:22 -07:00
|
|
|
do
|
|
|
|
# Grab the config block for Config.in
|
|
|
|
echo "# $i"
|
|
|
|
sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
|
|
|
|
echo endmenu
|
2008-01-19 15:08:39 -08:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-02-23 19:03:18 -08:00
|
|
|
probeconfig > generated/Config.probed || rm generated/Config.probed
|
|
|
|
genconfig > generated/Config.in || rm generated/Config.in
|