diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.IMA | 4 | ||||
-rw-r--r-- | scripts/basic/fixdep.c | 2 | ||||
-rwxr-xr-x | scripts/bloat-o-meter | 4 | ||||
-rwxr-xr-x | scripts/cleanup_printf2puts | 2 | ||||
-rwxr-xr-x | scripts/gen_build_files.sh | 103 | ||||
-rwxr-xr-x | scripts/individual | 129 | ||||
-rwxr-xr-x | scripts/mkdiff_obj | 27 | ||||
-rwxr-xr-x | scripts/randomtest.loop | 2 |
8 files changed, 75 insertions, 198 deletions
diff --git a/scripts/Makefile.IMA b/scripts/Makefile.IMA index 11ae39eae..a62618ae0 100644 --- a/scripts/Makefile.IMA +++ b/scripts/Makefile.IMA | |||
@@ -85,8 +85,8 @@ lib-y:= | |||
85 | include archival/Kbuild | 85 | include archival/Kbuild |
86 | lib-all-y += $(patsubst %,archival/%,$(sort $(lib-y))) | 86 | lib-all-y += $(patsubst %,archival/%,$(sort $(lib-y))) |
87 | lib-y:= | 87 | lib-y:= |
88 | include archival/libunarchive/Kbuild | 88 | include archival/libarchive/Kbuild |
89 | lib-all-y += $(patsubst %,archival/libunarchive/%,$(sort $(lib-y))) | 89 | lib-all-y += $(patsubst %,archival/libarchive/%,$(sort $(lib-y))) |
90 | lib-y:= | 90 | lib-y:= |
91 | include applets/Kbuild | 91 | include applets/Kbuild |
92 | lib-all-y += $(patsubst %,applets/%,$(sort $(lib-y))) | 92 | lib-all-y += $(patsubst %,applets/%,$(sort $(lib-y))) |
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 1a5b10f84..f27a17984 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
@@ -329,7 +329,7 @@ void parse_dep_file(void *map, size_t len) | |||
329 | clear_config(); | 329 | clear_config(); |
330 | 330 | ||
331 | while (m < end) { | 331 | while (m < end) { |
332 | while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) | 332 | while (m < end && (*m == ' ' || *m == '\\' || *m == '\n' || *m == '\r')) |
333 | m++; | 333 | m++; |
334 | p = m; | 334 | p = m; |
335 | while (p < end && *p != ' ') p++; | 335 | while (p < end && *p != ' ') p++; |
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index 95cbbe6b8..91374c1ca 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter | |||
@@ -63,7 +63,7 @@ def getsizes(file): | |||
63 | else: | 63 | else: |
64 | sym[name] = {"addr" : value, "size": size} | 64 | sym[name] = {"addr" : value, "size": size} |
65 | lut[(value, size)] = 0 | 65 | lut[(value, size)] = 0 |
66 | for addr, sz in alias.iterkeys(): | 66 | for addr, sz in iter(alias.keys()): |
67 | # If the non-GLOBAL sym has an implementation elsewhere then | 67 | # If the non-GLOBAL sym has an implementation elsewhere then |
68 | # it's an alias, disregard it. | 68 | # it's an alias, disregard it. |
69 | if not (addr, sz) in lut: | 69 | if not (addr, sz) in lut: |
@@ -92,7 +92,7 @@ if flag_timing: | |||
92 | grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0 | 92 | grow, shrink, add, remove, up, down = 0, 0, 0, 0, 0, 0 |
93 | delta, common = [], {} | 93 | delta, common = [], {} |
94 | 94 | ||
95 | for name in old.iterkeys(): | 95 | for name in iter(old.keys()): |
96 | if name in new: | 96 | if name in new: |
97 | common[name] = 1 | 97 | common[name] = 1 |
98 | 98 | ||
diff --git a/scripts/cleanup_printf2puts b/scripts/cleanup_printf2puts index 446152e12..00193a842 100755 --- a/scripts/cleanup_printf2puts +++ b/scripts/cleanup_printf2puts | |||
@@ -3,7 +3,7 @@ | |||
3 | # Processes current directory recursively: | 3 | # Processes current directory recursively: |
4 | # printf("abc\n") -> puts("abc"). Beware of fprintf etc... | 4 | # printf("abc\n") -> puts("abc"). Beware of fprintf etc... |
5 | 5 | ||
6 | # BTW, gcc 4.1.2 already does tha same! Can't believe it... | 6 | # BTW, gcc 4.1.2 already does the same! Can't believe it... |
7 | 7 | ||
8 | grep -lr 'printf\([^%%]*\\n"\)' . | grep '.[ch]$' | xargs -n1 \ | 8 | grep -lr 'printf\([^%%]*\\n"\)' . | grep '.[ch]$' | xargs -n1 \ |
9 | sed -e 's/\([^A-Za-z0-9_]\)printf(\( *"[^%]*\)\\n")/\1puts(\2")/' -i | 9 | sed -e 's/\([^A-Za-z0-9_]\)printf(\( *"[^%]*\)\\n")/\1puts(\2")/' -i |
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh index 09a95b507..03831f501 100755 --- a/scripts/gen_build_files.sh +++ b/scripts/gen_build_files.sh | |||
@@ -9,43 +9,58 @@ mkdir include 2>/dev/null | |||
9 | 9 | ||
10 | srctree="$1" | 10 | srctree="$1" |
11 | 11 | ||
12 | status() { printf ' %-8s%s\n' "$1" "$2"; } | ||
13 | gen() { status "GEN" "$@"; } | ||
14 | chk() { status "CHK" "$@"; } | ||
15 | |||
16 | generate() | ||
17 | { | ||
18 | local src="$1" dst="$2" header="$3" insert="$4" | ||
19 | #chk "${dst}" | ||
20 | ( | ||
21 | # Need to use printf: different shells have inconsistent | ||
22 | # rules re handling of "\n" in echo params, | ||
23 | # and ${insert} definitely contains "\n". | ||
24 | # Therefore, echo "${header}" would not work: | ||
25 | printf "%s\n" "${header}" | ||
26 | if grep -qs '^INSERT$' "${src}"; then | ||
27 | sed -n '1,/^INSERT$/p' "${src}" | ||
28 | printf "%s\n" "${insert}" | ||
29 | sed -n '/^INSERT$/,$p' "${src}" | ||
30 | else | ||
31 | if [ -n "${insert}" ]; then | ||
32 | printf "%s\n" "ERROR: INSERT line missing in: ${src}" 1>&2 | ||
33 | fi | ||
34 | cat "${src}" | ||
35 | fi | ||
36 | ) | sed '/^INSERT$/d' > "${dst}.tmp" | ||
37 | if ! cmp -s "${dst}" "${dst}.tmp"; then | ||
38 | gen "${dst}" | ||
39 | mv "${dst}.tmp" "${dst}" | ||
40 | else | ||
41 | rm -f "${dst}.tmp" | ||
42 | fi | ||
43 | } | ||
44 | |||
12 | # (Re)generate include/applets.h | 45 | # (Re)generate include/applets.h |
13 | src="$srctree/include/applets.src.h" | ||
14 | dst="include/applets.h" | ||
15 | s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` | 46 | s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` |
16 | old=`cat "$dst" 2>/dev/null` | 47 | generate \ |
17 | # Why "IFS='' read -r REPLY"?? | 48 | "$srctree/include/applets.src.h" \ |
18 | # This atrocity is needed to read lines without mangling. | 49 | "include/applets.h" \ |
19 | # IFS='' prevents whitespace trimming, | 50 | "/* DO NOT EDIT. This file is generated from applets.src.h */" \ |
20 | # -r suppresses backslash handling. | 51 | "${s}" |
21 | new=`echo "/* DO NOT EDIT. This file is generated from applets.src.h */" | ||
22 | while IFS='' read -r REPLY; do | ||
23 | test x"$REPLY" = x"INSERT" && REPLY="$s" | ||
24 | printf "%s\n" "$REPLY" | ||
25 | done <"$src"` | ||
26 | if test x"$new" != x"$old"; then | ||
27 | echo " GEN $dst" | ||
28 | printf "%s\n" "$new" >"$dst" | ||
29 | fi | ||
30 | 52 | ||
31 | # (Re)generate include/usage.h | 53 | # (Re)generate include/usage.h |
32 | src="$srctree/include/usage.src.h" | ||
33 | dst="include/usage.h" | ||
34 | # We add line continuation backslash after each line, | 54 | # We add line continuation backslash after each line, |
35 | # and insert empty line before each line which doesn't start | 55 | # and insert empty line before each line which doesn't start |
36 | # with space or tab | 56 | # with space or tab |
37 | # (note: we need to use \\\\ because of ``) | 57 | # (note: we need to use \\\\ because of ``) |
38 | s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` | 58 | s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` |
39 | old=`cat "$dst" 2>/dev/null` | 59 | generate \ |
40 | new=`echo "/* DO NOT EDIT. This file is generated from usage.src.h */" | 60 | "$srctree/include/usage.src.h" \ |
41 | while IFS='' read -r REPLY; do | 61 | "include/usage.h" \ |
42 | test x"$REPLY" = x"INSERT" && REPLY="$s" | 62 | "/* DO NOT EDIT. This file is generated from usage.src.h */" \ |
43 | printf "%s\n" "$REPLY" | 63 | "${s}" |
44 | done <"$src"` | ||
45 | if test x"$new" != x"$old"; then | ||
46 | echo " GEN $dst" | ||
47 | printf "%s\n" "$new" >"$dst" | ||
48 | fi | ||
49 | 64 | ||
50 | # (Re)generate */Kbuild and */Config.in | 65 | # (Re)generate */Kbuild and */Config.in |
51 | { cd -- "$srctree" && find . -type d; } | while read -r d; do | 66 | { cd -- "$srctree" && find . -type d; } | while read -r d; do |
@@ -55,40 +70,24 @@ fi | |||
55 | dst="$d/Kbuild" | 70 | dst="$d/Kbuild" |
56 | if test -f "$src"; then | 71 | if test -f "$src"; then |
57 | mkdir -p -- "$d" 2>/dev/null | 72 | mkdir -p -- "$d" 2>/dev/null |
58 | #echo " CHK $dst" | ||
59 | 73 | ||
60 | s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` | 74 | s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` |
61 | 75 | generate \ | |
62 | old=`cat "$dst" 2>/dev/null` | 76 | "${src}" "${dst}" \ |
63 | new=`echo "# DO NOT EDIT. This file is generated from Kbuild.src" | 77 | "# DO NOT EDIT. This file is generated from Kbuild.src" \ |
64 | while IFS='' read -r REPLY; do | 78 | "${s}" |
65 | test x"$REPLY" = x"INSERT" && REPLY="$s" | ||
66 | printf "%s\n" "$REPLY" | ||
67 | done <"$src"` | ||
68 | if test x"$new" != x"$old"; then | ||
69 | echo " GEN $dst" | ||
70 | printf "%s\n" "$new" >"$dst" | ||
71 | fi | ||
72 | fi | 79 | fi |
73 | 80 | ||
74 | src="$srctree/$d/Config.src" | 81 | src="$srctree/$d/Config.src" |
75 | dst="$d/Config.in" | 82 | dst="$d/Config.in" |
76 | if test -f "$src"; then | 83 | if test -f "$src"; then |
77 | mkdir -p -- "$d" 2>/dev/null | 84 | mkdir -p -- "$d" 2>/dev/null |
78 | #echo " CHK $dst" | ||
79 | 85 | ||
80 | s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` | 86 | s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` |
81 | 87 | generate \ | |
82 | old=`cat "$dst" 2>/dev/null` | 88 | "${src}" "${dst}" \ |
83 | new=`echo "# DO NOT EDIT. This file is generated from Config.src" | 89 | "# DO NOT EDIT. This file is generated from Config.src" \ |
84 | while IFS='' read -r REPLY; do | 90 | "${s}" |
85 | test x"$REPLY" = x"INSERT" && REPLY="$s" | ||
86 | printf "%s\n" "$REPLY" | ||
87 | done <"$src"` | ||
88 | if test x"$new" != x"$old"; then | ||
89 | echo " GEN $dst" | ||
90 | printf "%s\n" "$new" >"$dst" | ||
91 | fi | ||
92 | fi | 91 | fi |
93 | done | 92 | done |
94 | 93 | ||
diff --git a/scripts/individual b/scripts/individual deleted file mode 100755 index e93ca5552..000000000 --- a/scripts/individual +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Compile individual versions of each busybox applet. | ||
4 | |||
5 | if [ $# -eq 0 ] | ||
6 | then | ||
7 | |||
8 | # Clear out the build directory. (Make clean should do this instead of here.) | ||
9 | |||
10 | rm -rf build | ||
11 | mkdir build | ||
12 | |||
13 | # Make our prerequisites. | ||
14 | |||
15 | make busybox.links include/bb_config.h $(pwd)/{libbb/libbb.a,archival/libunarchive/libunarchive.a,coreutils/libcoreutils/libcoreutils.a,networking/libiproute/libiproute.a} | ||
16 | |||
17 | else | ||
18 | # Could very well be that we want to build an individual applet but have no | ||
19 | # 'build' dir yet.. | ||
20 | |||
21 | test -d ./build || mkdir build | ||
22 | |||
23 | fi | ||
24 | |||
25 | # About 3/5 of the applets build from one .c file (with the same name as the | ||
26 | # corresponding applet), and all it needs to link against. However, to build | ||
27 | # them all we need more than that. | ||
28 | |||
29 | # Figure out which applets need extra libraries added to their command line. | ||
30 | |||
31 | function substithing() | ||
32 | { | ||
33 | if [ "${1/ $3 //}" != "$1" ] | ||
34 | then | ||
35 | echo $2 | ||
36 | fi | ||
37 | } | ||
38 | |||
39 | function extra_libraries() | ||
40 | { | ||
41 | # gzip needs gunzip.c (when gunzip is enabled, anyway). | ||
42 | substithing " gzip " "archival/gunzip.c archival/uncompress.c" "$1" | ||
43 | |||
44 | # init needs init_shared.c | ||
45 | substithing " init " "init/init_shared.c" "$1" | ||
46 | |||
47 | # ifconfig needs interface.c | ||
48 | substithing " ifconfig " "networking/interface.c" "$1" | ||
49 | |||
50 | # Applets that need libunarchive.a | ||
51 | substithing " ar bunzip2 unlzma cpio dpkg gunzip rpm2cpio rpm tar uncompress unzip dpkg_deb gzip " "archival/libunarchive/libunarchive.a" "$1" | ||
52 | |||
53 | # Applets that need libcoreutils.a | ||
54 | substithing " cp mv " "coreutils/libcoreutils/libcoreutils.a" "$1" | ||
55 | |||
56 | # Applets that need libiproute.a | ||
57 | substithing " ip " "networking/libiproute/libiproute.a" "$1" | ||
58 | |||
59 | # What needs -libm? | ||
60 | substithing " awk dc " "-lm" "$1" | ||
61 | |||
62 | # What needs -lcrypt? | ||
63 | substithing " httpd vlock " "-lcrypt" "$1" | ||
64 | } | ||
65 | |||
66 | # Query applets.h to figure out which applets need special treatment | ||
67 | |||
68 | strange_names=`sed -rn -e 's/\#.*//' -e 's/.*APPLET_NOUSAGE\(([^,]*),([^,]*),.*/\1 \2/p' -e 's/.*APPLET_ODDNAME\(([^,]*),([^,]*),.*, *([^)]*).*/\1 \2@\3/p' include/applets.h` | ||
69 | |||
70 | function bonkname() | ||
71 | { | ||
72 | while [ $# -gt 0 ] | ||
73 | do | ||
74 | if [ "$APPLET" == "$1" ] | ||
75 | then | ||
76 | APPFILT="${2/@*/}" | ||
77 | if [ "${APPFILT}" == "$2" ] | ||
78 | then | ||
79 | HELPNAME='"nousage\n"' # These should be _fixed_. | ||
80 | else | ||
81 | HELPNAME="${2/*@/}"_full_usage | ||
82 | fi | ||
83 | break | ||
84 | fi | ||
85 | shift 2 | ||
86 | done | ||
87 | #echo APPLET=${APPLET} APPFILT=${APPFILT} HELPNAME=${HELPNAME} 2=${2} | ||
88 | } | ||
89 | |||
90 | # Iterate through every name in busybox.links | ||
91 | |||
92 | function buildit () | ||
93 | { | ||
94 | export APPLET="$1" | ||
95 | export APPFILT=${APPLET} | ||
96 | export HELPNAME=${APPLET}_full_usage | ||
97 | |||
98 | bonkname $strange_names | ||
99 | |||
100 | j=`find archival console-tools coreutils debianutils editors findutils init loginutils miscutils modutils networking procps shell sysklogd util-linux -name "${APPFILT}.c"` | ||
101 | if [ -z "$j" ] | ||
102 | then | ||
103 | echo no file for $APPLET | ||
104 | else | ||
105 | echo "Building $APPLET" | ||
106 | gcc -Os -o build/$APPLET applets/individual.c $j \ | ||
107 | `extra_libraries $APPFILT` libbb/libbb.a -Iinclude \ | ||
108 | -DBUILD_INDIVIDUAL \ | ||
109 | '-Drun_applet_and_exit(...)' '-Dfind_applet_by_name(...)=0' \ | ||
110 | -DAPPLET_main=${APPFILT}_main -DAPPLET_full_usage=${HELPNAME} | ||
111 | if [ $? -ne 0 ]; | ||
112 | then | ||
113 | echo "Failed $APPLET" | ||
114 | fi | ||
115 | fi | ||
116 | } | ||
117 | |||
118 | if [ $# -eq 0 ] | ||
119 | then | ||
120 | for APPLET in `sed 's .*/ ' busybox.links` | ||
121 | do | ||
122 | buildit "$APPLET" | ||
123 | done | ||
124 | else | ||
125 | buildit "$1" | ||
126 | fi | ||
127 | |||
128 | |||
129 | strip build/* | ||
diff --git a/scripts/mkdiff_obj b/scripts/mkdiff_obj index a6ec5e602..307474874 100755 --- a/scripts/mkdiff_obj +++ b/scripts/mkdiff_obj | |||
@@ -1,28 +1,35 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | usage() { | ||
4 | echo "Usage: ${0##*/} DIR1 DIR2" | ||
5 | echo | ||
6 | echo "Compares all object files recursivelty found in DIR1 and DIR2." | ||
7 | echo "Prints diff of their disassembly." | ||
8 | echo | ||
9 | exit $1 | ||
10 | } | ||
11 | |||
3 | filter() { | 12 | filter() { |
4 | # sed removes " address: " prefixes which mess up diff | 13 | # sed removes " address: " prefixes which mess up diff |
5 | sed $'s/^\\(\t*\\)[ ]*[0-9a-f][0-9a-f]*:[ \t]*/\\1/' \ | 14 | sed $'s/^\\(\t*\\)[ ]*[0-9a-f][0-9a-f]*:[ \t]*/\\1/' \ |
6 | | sed 's/__GI_//g' | 15 | | sed 's/__GI_//g' |
7 | } | 16 | } |
8 | 17 | ||
9 | test -d "$1" || exit 1 | 18 | test -d "$1" || usage 1 |
10 | test -d "$2" || exit 1 | 19 | test -d "$2" || usage 1 |
11 | 20 | ||
12 | { | 21 | { |
13 | ( | 22 | ( |
14 | cd "$1" || exit 1 | 23 | cd "$1" || exit 1 |
15 | find -name '*.o' -o -name '*.os' # -o -name '*.so' | 24 | find -name '*.o' # -o -name '*.os' # -o -name '*.so' |
16 | ) | 25 | ) |
17 | ( | 26 | ( |
18 | cd "$2" || exit 1 | 27 | cd "$2" || exit 1 |
19 | find -name '*.o' -o -name '*.os' # -o -name '*.so' | 28 | find -name '*.o' # -o -name '*.os' # -o -name '*.so' |
20 | ) | 29 | ) |
21 | } | sed 's:^\./::' | sort | uniq | \ | 30 | } | sed 's:^\./::' | sort | uniq | \ |
22 | tee LST | \ | ||
23 | ( | 31 | ( |
24 | IFS='' | 32 | while IFS='' read -r oname; do |
25 | while read -r oname; do | ||
26 | if ! test -f "$1/$oname"; then | 33 | if ! test -f "$1/$oname"; then |
27 | echo "Only $2/$oname" | 34 | echo "Only $2/$oname" |
28 | continue | 35 | continue |
@@ -32,8 +39,8 @@ while read -r oname; do | |||
32 | continue | 39 | continue |
33 | fi | 40 | fi |
34 | diff -q -- "$1/$oname" "$2/$oname" >/dev/null && continue | 41 | diff -q -- "$1/$oname" "$2/$oname" >/dev/null && continue |
35 | (cd "$1"; objdump -dr "$oname" | filter >"$oname.disasm") | 42 | (cd "$1" && { size "$oname"; objdump -dr "$oname" | filter; } >"$oname.disasm") |
36 | (cd "$2"; objdump -dr "$oname" | filter >"$oname.disasm") | 43 | (cd "$2" && { size "$oname"; objdump -dr "$oname" | filter; } >"$oname.disasm") |
37 | diff -u "$1/$oname.disasm" "$2/$oname.disasm" | 44 | diff -u -- "$1/$oname.disasm" "$2/$oname.disasm" |
38 | done | 45 | done |
39 | ) | 46 | ) |
diff --git a/scripts/randomtest.loop b/scripts/randomtest.loop index 311536df8..2c8a9bd35 100755 --- a/scripts/randomtest.loop +++ b/scripts/randomtest.loop | |||
@@ -4,7 +4,7 @@ test -d "$1" || { echo "'$1' is not a directory"; exit 1; } | |||
4 | test -x "$1/scripts/randomtest" || { echo "No scripts/randomtest in '$1'"; exit 1; } | 4 | test -x "$1/scripts/randomtest" || { echo "No scripts/randomtest in '$1'"; exit 1; } |
5 | 5 | ||
6 | export LIBC="uclibc" | 6 | export LIBC="uclibc" |
7 | export CROSS_COMPILER_PREFIX="i486-linux-uclibc-" | 7 | export CROSS_COMPILER_PREFIX="i686-" |
8 | export MAKEOPTS="-j9" | 8 | export MAKEOPTS="-j9" |
9 | 9 | ||
10 | cnt=0 | 10 | cnt=0 |