aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build7
-rw-r--r--scripts/basic/docproc.c2
-rwxr-xr-xscripts/gen_build_files.sh55
-rwxr-xr-xscripts/randomtest14
-rwxr-xr-xscripts/test_make_O11
-rwxr-xr-xscripts/trylink38
6 files changed, 72 insertions, 55 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f343818b1..5685b5bcc 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -13,8 +13,13 @@ __build:
13include scripts/Kbuild.include 13include scripts/Kbuild.include
14 14
15# The filename Kbuild has precedence over Makefile 15# The filename Kbuild has precedence over Makefile
16# bbox: we also try to include Kbuild file in obj tree first
16kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) 17kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
17include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) 18include $(if $(wildcard $(src)/Kbuild), $(src)/Kbuild, \
19 $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, \
20 $(kbuild-dir)/Makefile \
21 ) \
22 )
18 23
19include scripts/Makefile.lib 24include scripts/Makefile.lib
20 25
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index ef5181226..50ef37157 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -86,7 +86,7 @@ void exec_kernel_doc(char **svec)
86 fflush(stdout); 86 fflush(stdout);
87 switch(pid=fork()) { 87 switch(pid=fork()) {
88 case -1: 88 case -1:
89 perror("fork"); 89 perror("vfork"+1);
90 exit(1); 90 exit(1);
91 case 0: 91 case 0:
92 rflen = strlen(getenv("SRCTREE")); 92 rflen = strlen(getenv("SRCTREE"));
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 647c7daf7..968158758 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -4,6 +4,8 @@ test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
4 4
5# cd to objtree 5# cd to objtree
6cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } 6cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
7# In separate objtree build, include/ might not exist yet
8mkdir include 2>/dev/null
7 9
8srctree="$1" 10srctree="$1"
9 11
@@ -11,20 +13,19 @@ srctree="$1"
11src="$srctree/include/applets.src.h" 13src="$srctree/include/applets.src.h"
12dst="include/applets.h" 14dst="include/applets.h"
13s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` 15s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
14echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp" 16old=`cat "$dst" 2>/dev/null`
15# Why "IFS='' read -r REPLY"?? 17# Why "IFS='' read -r REPLY"??
16# This atrocity is needed to read lines without mangling. 18# This atrocity is needed to read lines without mangling.
17# IFS='' prevents whitespace trimming, 19# IFS='' prevents whitespace trimming,
18# -r suppresses backslash handling. 20# -r suppresses backslash handling.
21new=`echo "/* DO NOT EDIT. This file is generated from applets.src.h */"
19while IFS='' read -r REPLY; do 22while IFS='' read -r REPLY; do
20 test x"$REPLY" = x"INSERT" && REPLY="$s" 23 test x"$REPLY" = x"INSERT" && REPLY="$s"
21 printf "%s\n" "$REPLY" 24 printf "%s\n" "$REPLY"
22done <"$src" >>"$dst.$$.tmp" 25done <"$src"`
23if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 26if test x"$new" != x"$old"; then
24 rm -- "$dst.$$.tmp"
25else
26 echo " GEN $dst" 27 echo " GEN $dst"
27 mv -- "$dst.$$.tmp" "$dst" 28 printf "%s\n" "$new" >"$dst"
28fi 29fi
29 30
30# (Re)generate include/usage.h 31# (Re)generate include/usage.h
@@ -35,62 +36,58 @@ dst="include/usage.h"
35# with space or tab 36# with space or tab
36# (note: we need to use \\\\ because of ``) 37# (note: we need to use \\\\ because of ``)
37s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` 38s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
38echo "/* DO NOT EDIT. This file is generated from usage.src.h */" >"$dst.$$.tmp" 39old=`cat "$dst" 2>/dev/null`
39# Why "IFS='' read -r REPLY"?? 40new=`echo "/* DO NOT EDIT. This file is generated from usage.src.h */"
40# This atrocity is needed to read lines without mangling.
41# IFS='' prevents whitespace trimming,
42# -r suppresses backslash handling.
43while IFS='' read -r REPLY; do 41while IFS='' read -r REPLY; do
44 test x"$REPLY" = x"INSERT" && REPLY="$s" 42 test x"$REPLY" = x"INSERT" && REPLY="$s"
45 printf "%s\n" "$REPLY" 43 printf "%s\n" "$REPLY"
46done <"$src" >>"$dst.$$.tmp" 44done <"$src"`
47if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 45if test x"$new" != x"$old"; then
48 rm -- "$dst.$$.tmp"
49else
50 echo " GEN $dst" 46 echo " GEN $dst"
51 mv -- "$dst.$$.tmp" "$dst" 47 printf "%s\n" "$new" >"$dst"
52fi 48fi
53 49
54# (Re)generate */Kbuild and */Config.in 50# (Re)generate */Kbuild and */Config.in
55find -type d | while read -r d; do 51{ cd -- "$srctree" && find -type d; } | while read -r d; do
56 d="${d#./}" 52 d="${d#./}"
53
57 src="$srctree/$d/Kbuild.src" 54 src="$srctree/$d/Kbuild.src"
58 dst="$d/Kbuild" 55 dst="$d/Kbuild"
56 mkdir -p -- "$d" 2>/dev/null
59 if test -f "$src"; then 57 if test -f "$src"; then
60 #echo " CHK $dst" 58 #echo " CHK $dst"
61 59
62 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` 60 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
63 61
64 echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp" 62 old=`cat "$dst" 2>/dev/null`
63 new=`echo "# DO NOT EDIT. This file is generated from Kbuild.src"
65 while IFS='' read -r REPLY; do 64 while IFS='' read -r REPLY; do
66 test x"$REPLY" = x"INSERT" && REPLY="$s" 65 test x"$REPLY" = x"INSERT" && REPLY="$s"
67 printf "%s\n" "$REPLY" 66 printf "%s\n" "$REPLY"
68 done <"$src" >>"$dst.$$.tmp" 67 done <"$src"`
69 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 68 if test x"$new" != x"$old"; then
70 rm -- "$dst.$$.tmp"
71 else
72 echo " GEN $dst" 69 echo " GEN $dst"
73 mv -- "$dst.$$.tmp" "$dst" 70 printf "%s\n" "$new" >"$dst"
74 fi 71 fi
75 fi 72 fi
76 73
77 src="$srctree/$d/Config.src" 74 src="$srctree/$d/Config.src"
78 dst="$d/Config.in" 75 dst="$d/Config.in"
76 mkdir -p -- "$d" 2>/dev/null
79 if test -f "$src"; then 77 if test -f "$src"; then
80 #echo " CHK $dst" 78 #echo " CHK $dst"
81 79
82 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` 80 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
83 81
84 echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp" 82 old=`cat "$dst" 2>/dev/null`
83 new=`echo "# DO NOT EDIT. This file is generated from Config.src"
85 while IFS='' read -r REPLY; do 84 while IFS='' read -r REPLY; do
86 test x"$REPLY" = x"INSERT" && REPLY="$s" 85 test x"$REPLY" = x"INSERT" && REPLY="$s"
87 printf "%s\n" "$REPLY" 86 printf "%s\n" "$REPLY"
88 done <"$src" >>"$dst.$$.tmp" 87 done <"$src"`
89 if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then 88 if test x"$new" != x"$old"; then
90 rm -- "$dst.$$.tmp"
91 else
92 echo " GEN $dst" 89 echo " GEN $dst"
93 mv -- "$dst.$$.tmp" "$dst" 90 printf "%s\n" "$new" >"$dst"
94 fi 91 fi
95 fi 92 fi
96done 93done
diff --git a/scripts/randomtest b/scripts/randomtest
index 8d0d79e64..a102593d3 100755
--- a/scripts/randomtest
+++ b/scripts/randomtest
@@ -43,6 +43,10 @@ mv .config.new .config
43echo '# CONFIG_DEBUG_PESSIMIZE is not set' >>.config 43echo '# CONFIG_DEBUG_PESSIMIZE is not set' >>.config
44echo '# CONFIG_WERROR is not set' >>.config 44echo '# CONFIG_WERROR is not set' >>.config
45echo "CONFIG_CROSS_COMPILER_PREFIX=\"${CROSS_COMPILER_PREFIX}\"" >>.config 45echo "CONFIG_CROSS_COMPILER_PREFIX=\"${CROSS_COMPILER_PREFIX}\"" >>.config
46echo '# CONFIG_SELINUX is not set' >>.config
47echo '# CONFIG_EFENCE is not set' >>.config
48echo '# CONFIG_DMALLOC is not set' >>.config
49echo '# CONFIG_RFKILL is not set' >>.config
46 50
47# If glibc, don't build static 51# If glibc, don't build static
48if test x"$LIBC" = x"glibc"; then 52if test x"$LIBC" = x"glibc"; then
@@ -53,18 +57,21 @@ if test x"$LIBC" = x"glibc"; then
53 echo '# CONFIG_STATIC is not set' >>.config 57 echo '# CONFIG_STATIC is not set' >>.config
54fi 58fi
55 59
56# If glibc, build static, and remove some things 60# If uclibc, build static, and remove some things
57# likely to not work on uclibc. 61# likely to not work on uclibc.
58if test x"$LIBC" = x"uclibc"; then 62if test x"$LIBC" = x"uclibc"; then
59 cat .config \ 63 cat .config \
60 | grep -v CONFIG_STATIC \ 64 | grep -v CONFIG_STATIC \
61 | grep -v CONFIG_BUILD_LIBBUSYBOX \ 65 | grep -v CONFIG_BUILD_LIBBUSYBOX \
62 | grep -v CONFIG_TASKSET \
63 | grep -v CONFIG_UNICODE_SUPPORT \
64 | grep -v CONFIG_PIE \ 66 | grep -v CONFIG_PIE \
67 \
68 | grep -v CONFIG_FEATURE_2_4_MODULES \
65 >.config.new 69 >.config.new
66 mv .config.new .config 70 mv .config.new .config
67 echo 'CONFIG_STATIC=y' >>.config 71 echo 'CONFIG_STATIC=y' >>.config
72 echo '# CONFIG_BUILD_LIBBUSYBOX is not set' >>.config
73 echo '# CONFIG_PIE is not set' >>.config
74 echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config
68fi 75fi
69 76
70# If STATIC, remove some things. 77# If STATIC, remove some things.
@@ -75,6 +82,7 @@ if grep -q "^CONFIG_STATIC=y" .config; then
75 | grep -v CONFIG_PAM \ 82 | grep -v CONFIG_PAM \
76 >.config.new 83 >.config.new
77 mv .config.new .config 84 mv .config.new .config
85 echo '# CONFIG_PAM is not set' >>.config
78fi 86fi
79 87
80# Regenerate .config with default answers for yanked-off options 88# Regenerate .config with default answers for yanked-off options
diff --git a/scripts/test_make_O b/scripts/test_make_O
new file mode 100755
index 000000000..a0ee6a868
--- /dev/null
+++ b/scripts/test_make_O
@@ -0,0 +1,11 @@
1#!/bin/sh
2
3b=`basename $PWD`
4test "${b#busybox}" != "$b" || { echo "Must be run in busybox tree"; exit 1; }
5
6rm -rf ../testdir_make_O.$$
7mkdir ../testdir_make_O.$$
8odir=`cd ../testdir_make_O.$$ && pwd`
9test -d "$odir" || exit 1
10
11make O="$odir" $MAKEOPTS "$@" defconfig busybox 2>&1 | tee test_make_O.log
diff --git a/scripts/trylink b/scripts/trylink
index 164f5274c..5994a757b 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -85,6 +85,10 @@ LDLIBS="$7"
85# The --sort-section option is not supported by older versions of ld 85# The --sort-section option is not supported by older versions of ld
86SORT_SECTION=`check_cc "-Wl,--sort-section,alignment" ""` 86SORT_SECTION=`check_cc "-Wl,--sort-section,alignment" ""`
87 87
88START_GROUP="-Wl,--start-group"
89END_GROUP="-Wl,--end-group"
90INFO_OPTS="-Wl,--warn-common -Wl,-Map,$EXE.map -Wl,--verbose"
91
88# gold may not support --sort-common (yet) 92# gold may not support --sort-common (yet)
89SORT_COMMON=`check_cc "-Wl,--sort-common" ""` 93SORT_COMMON=`check_cc "-Wl,--sort-common" ""`
90 94
@@ -114,13 +118,13 @@ LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs`
114echo "Trying libraries: $LDLIBS" 118echo "Trying libraries: $LDLIBS"
115# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" 119# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
116l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` 120l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
117test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" 121test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP"
118try $CC $CFLAGS $LDFLAGS \ 122try $CC $CFLAGS $LDFLAGS \
119 -o $EXE \ 123 -o $EXE \
120 $SORT_COMMON \ 124 $SORT_COMMON \
121 $SORT_SECTION \ 125 $SORT_SECTION \
122 $GC_SECTIONS \ 126 $GC_SECTIONS \
123 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ 127 $START_GROUP $O_FILES $A_FILES $END_GROUP \
124 $l_list \ 128 $l_list \
125|| { 129|| {
126 echo "Failed: $l_list" 130 echo "Failed: $l_list"
@@ -138,14 +142,14 @@ while test "$LDLIBS"; do
138 without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` 142 without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
139 # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" 143 # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
140 l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` 144 l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
141 test x"$l_list" != x"" && l_list="-Wl,--start-group $l_list -Wl,--end-group" 145 test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
142 $debug && echo "Trying -l options: '$l_list'" 146 $debug && echo "Trying -l options: '$l_list'"
143 try $CC $CFLAGS $LDFLAGS \ 147 try $CC $CFLAGS $LDFLAGS \
144 -o $EXE \ 148 -o $EXE \
145 $SORT_COMMON \ 149 $SORT_COMMON \
146 $SORT_SECTION \ 150 $SORT_SECTION \
147 $GC_SECTIONS \ 151 $GC_SECTIONS \
148 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ 152 $START_GROUP $O_FILES $A_FILES $END_GROUP \
149 $l_list 153 $l_list
150 if test $? = 0; then 154 if test $? = 0; then
151 echo " Library $one is not needed, excluding it" 155 echo " Library $one is not needed, excluding it"
@@ -169,7 +173,7 @@ done
169# Make the binary with final, minimal list of libs 173# Make the binary with final, minimal list of libs
170echo "Final link with: ${LDLIBS:-<none>}" 174echo "Final link with: ${LDLIBS:-<none>}"
171l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` 175l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
172test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" 176test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP"
173# --verbose gives us gobs of info to stdout (e.g. linker script used) 177# --verbose gives us gobs of info to stdout (e.g. linker script used)
174if ! test -f busybox_ldscript; then 178if ! test -f busybox_ldscript; then
175 try $CC $CFLAGS $LDFLAGS \ 179 try $CC $CFLAGS $LDFLAGS \
@@ -177,11 +181,9 @@ if ! test -f busybox_ldscript; then
177 $SORT_COMMON \ 181 $SORT_COMMON \
178 $SORT_SECTION \ 182 $SORT_SECTION \
179 $GC_SECTIONS \ 183 $GC_SECTIONS \
180 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ 184 $START_GROUP $O_FILES $A_FILES $END_GROUP \
181 $l_list \ 185 $l_list \
182 -Wl,--warn-common \ 186 $INFO_OPTS \
183 -Wl,-Map,$EXE.map \
184 -Wl,--verbose \
185 || { 187 || {
186 cat $EXE.out 188 cat $EXE.out
187 exit 1 189 exit 1
@@ -200,11 +202,9 @@ else
200 $SORT_SECTION \ 202 $SORT_SECTION \
201 $GC_SECTIONS \ 203 $GC_SECTIONS \
202 -Wl,-T,busybox_ldscript \ 204 -Wl,-T,busybox_ldscript \
203 -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ 205 $START_GROUP $O_FILES $A_FILES $END_GROUP \
204 $l_list \ 206 $l_list \
205 -Wl,--warn-common \ 207 $INFO_OPTS \
206 -Wl,-Map,$EXE.map \
207 -Wl,--verbose \
208 || { 208 || {
209 cat $EXE.out 209 cat $EXE.out
210 exit 1 210 exit 1
@@ -233,11 +233,9 @@ if test "$CONFIG_BUILD_LIBBUSYBOX" = y; then
233 -Wl,--undefined=lbb_main \ 233 -Wl,--undefined=lbb_main \
234 $SORT_COMMON \ 234 $SORT_COMMON \
235 $SORT_SECTION \ 235 $SORT_SECTION \
236 -Wl,--start-group $A_FILES -Wl,--end-group \ 236 $START_GROUP $A_FILES $END_GROUP \
237 $l_list \ 237 $l_list \
238 -Wl,--warn-common \ 238 $INFO_OPTS \
239 -Wl,-Map,$EXE.map \
240 -Wl,--verbose \
241 || { 239 || {
242 echo "Linking $EXE failed" 240 echo "Linking $EXE failed"
243 cat $EXE.out 241 cat $EXE.out
@@ -255,11 +253,9 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then
255 $SORT_COMMON \ 253 $SORT_COMMON \
256 $SORT_SECTION \ 254 $SORT_SECTION \
257 $GC_SECTIONS \ 255 $GC_SECTIONS \
258 -Wl,--start-group $O_FILES -Wl,--end-group \ 256 $START_GROUP $O_FILES $END_GROUP \
259 -L"$sharedlib_dir" -lbusybox \ 257 -L"$sharedlib_dir" -lbusybox \
260 -Wl,--warn-common \ 258 $INFO_OPTS \
261 -Wl,-Map,$EXE.map \
262 -Wl,--verbose \
263 || { 259 || {
264 echo "Linking $EXE failed" 260 echo "Linking $EXE failed"
265 cat $EXE.out 261 cat $EXE.out