Mercurial > hg > toybox
comparison scripts/make.sh @ 237:7cb15eae1664
Zap toylist.h, moving contents of global structures into DEFINE_GLOBALS()
macros in each C file, and making generated/globals.h from that. Rename
"toy" to "this" along the way to avoid toy/toys confusion.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 20 Jan 2008 17:25:44 -0600 |
parents | 163498bf547b |
children | c3659856f120 |
comparison
equal
deleted
inserted
replaced
236:6b292ee780ab | 237:7cb15eae1664 |
---|---|
2 | 2 |
3 # Grab default values for $CFLAGS and such. | 3 # Grab default values for $CFLAGS and such. |
4 | 4 |
5 source ./configure | 5 source ./configure |
6 | 6 |
7 echo "Extract configuration information from toys/*.c files." | 7 echo "Extract configuration information from toys/*.c files..." |
8 scripts/genconfig.sh | 8 scripts/genconfig.sh |
9 | |
10 echo "Generate headers from toys/*.h..." | |
9 | 11 |
10 # Create a list of all the applets toybox can provide. Note that the first | 12 # Create a list of all the applets toybox can provide. Note that the first |
11 # entry is out of order on purpose (the toybox multiplexer applet must be the | 13 # entry is out of order on purpose (the toybox multiplexer applet must be the |
12 # first element of the array). The rest must be sorted in alphabetical order | 14 # first element of the array). The rest must be sorted in alphabetical order |
13 # for fast binary search. | 15 # for fast binary search. |
19 sed -n -e '1,/^config [A-Z]/s/^USE_/&/p' $i || exit 1 | 21 sed -n -e '1,/^config [A-Z]/s/^USE_/&/p' $i || exit 1 |
20 done | 22 done |
21 } | 23 } |
22 echo "NEWTOY(toybox, NULL, 0)" > generated/newtoys.h | 24 echo "NEWTOY(toybox, NULL, 0)" > generated/newtoys.h |
23 newtoys | sort >> generated/newtoys.h | 25 newtoys | sort >> generated/newtoys.h |
26 | |
27 # Extract global structure definitions from toys/*.c | |
28 | |
29 function getglobals() | |
30 { | |
31 for i in toys/*.c | |
32 do | |
33 NAME="$(echo $i | sed 's@toys/\(.*\)\.c@\1@')" | |
34 | |
35 echo -e "// $i\n" | |
36 sed -n -e '/^DEFINE_GLOBALS(/,/^)/b got;b;:got' \ | |
37 -e 's/^DEFINE_GLOBALS(/struct '"$NAME"'_data {/' \ | |
38 -e 's/^)/};/' -e 'p' $i | |
39 done | |
40 } | |
41 | |
42 GLOBSTRUCT="$(getglobals)" | |
43 ( | |
44 echo "$GLOBSTRUCT" | |
45 echo | |
46 echo "extern union global_union {" | |
47 echo "$GLOBSTRUCT" | sed -n 's/struct \(.*\)_data {/ struct \1_data \1;/p' | |
48 echo "} this;" | |
49 ) > generated/globals.h | |
24 | 50 |
25 # Only recreate generated/help.h if python is installed | 51 # Only recreate generated/help.h if python is installed |
26 if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ] | 52 if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ] |
27 then | 53 then |
28 echo "Extract help text from Config.in." | 54 echo "Extract help text from Config.in." |