aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-04-13 19:58:41 -0500
committerRob Landley <rob@landley.net>2018-04-13 19:58:41 -0500
commit1e1684742dc26e62bbc2afbaab124fca58d60c8e (patch)
tree937b1f9a654af6b4d9d1829112fa2fb932f203db /scripts
parentb6427f1bfe7291d6dcb102660685a2fc3bfc5123 (diff)
downloadtoybox-1e1684742dc26e62bbc2afbaab124fca58d60c8e.tar.gz
Add getconf.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/make.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/make.sh b/scripts/make.sh
index 993bcd33..1119ed9d 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -262,6 +262,42 @@ then
generated/config2help Config.in $KCONFIG_CONFIG > generated/help.h || exit 1
fi
+mksysconf()
+{
+ echo "int ${1}_vals[] = {" &&
+
+ # Extract names, remove blank lines, filter, replace unknown #defines
+ # with UNKNOWN
+ sed -n "/char [*]${1}_names[[]/"',/^}/s/[^"]*"\([^"]*\) *",*/\1\n/pg' \
+ toys/posix/getconf.c | grep -v '^$' | $2 |
+ sed -e "$DEFINES" -e "t;d;a UNKNOWN" | xargs | tr ' ' ',' &&
+ echo '};'
+}
+
+if ! [ generated/getconf.h -nt toys/posix/getconf.c ]
+then
+ echo generated/getconf.h
+
+ # Dump #define list for limits.h and unistd.h, create sed expression to
+ # match known defines
+ DEFINES="$(echo -e '#include <limits.h>\n#include <unistd.h>' | \
+ gcc -E -dM - | \
+ sed -n 's@^#define[ \t][ \t]*\([^ \t(]*\)[ \t].*@s/^\1$/\&/@p' )"
+
+ # Extract limit names, compare against limits.h #defines, replace unknown
+ # ones with UNKNOWN
+
+ {
+ mksysconf sysconf \
+ sed\ 's/^_POSIX2/2/;s/^PTHREAD/THREAD/;s/^_POSIX_//;s/^_XOPEN_/XOPEN_/;s/^/_SC_/' &&
+ mksysconf confstr sed\ 's/.*/_CS_&/' &&
+ mksysconf limit cat
+ } > generated/getconf.h
+
+ unset HEADERS
+fi
+
+
[ ! -z "$NOBUILD" ] && exit 0
echo -n "Compile toybox"