aboutsummaryrefslogtreecommitdiff
path: root/scripts/make.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/make.sh')
-rwxr-xr-xscripts/make.sh28
1 files changed, 27 insertions, 1 deletions
diff --git a/scripts/make.sh b/scripts/make.sh
index b5300d38..08333959 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -4,9 +4,11 @@
source ./configure
-echo "Extract configuration information from toys/*.c files."
+echo "Extract configuration information from toys/*.c files..."
scripts/genconfig.sh
+echo "Generate headers from toys/*.h..."
+
# Create a list of all the applets toybox can provide. Note that the first
# entry is out of order on purpose (the toybox multiplexer applet must be the
# first element of the array). The rest must be sorted in alphabetical order
@@ -22,6 +24,30 @@ function newtoys()
echo "NEWTOY(toybox, NULL, 0)" > generated/newtoys.h
newtoys | sort >> generated/newtoys.h
+# Extract global structure definitions from toys/*.c
+
+function getglobals()
+{
+ for i in toys/*.c
+ do
+ NAME="$(echo $i | sed 's@toys/\(.*\)\.c@\1@')"
+
+ echo -e "// $i\n"
+ sed -n -e '/^DEFINE_GLOBALS(/,/^)/b got;b;:got' \
+ -e 's/^DEFINE_GLOBALS(/struct '"$NAME"'_data {/' \
+ -e 's/^)/};/' -e 'p' $i
+ done
+}
+
+GLOBSTRUCT="$(getglobals)"
+(
+ echo "$GLOBSTRUCT"
+ echo
+ echo "extern union global_union {"
+ echo "$GLOBSTRUCT" | sed -n 's/struct \(.*\)_data {/ struct \1_data \1;/p'
+ echo "} this;"
+) > generated/globals.h
+
# Only recreate generated/help.h if python is installed
if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ]
then