}
check_cc() {
- if $CC $1 -shared -o /dev/null -xc /dev/null >/dev/null 2>&1; then
+ local tempname="/tmp/temp.$$.$RANDOM"
+ # Can use "-o /dev/null", but older gcc tend to *unlink it* on failure! :(
+ # "-xc": C language. "/dev/null" is an empty source file.
+ if $CC $1 -shared -xc /dev/null -o "$tempname".o >/dev/null 2>&1; then
echo "$1";
else
echo "$2";
fi
+ rm "$tempname".o 2>/dev/null
}
check_libc_is_glibc() {
- local tempname="/tmp/temp.$$.$RANDOM.c"
+ local tempname="/tmp/temp.$$.$RANDOM"
echo "\
#include <stdlib.h>
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
syntax error here
#endif
" >"$tempname"
- if $CC "$tempname" -c -o /dev/null >/dev/null 2>&1; then
+ if $CC "$tempname".c -c -o "$tempname".o >/dev/null 2>&1; then
echo "$2";
else
echo "$1";
fi
- rm "$tempname"
+ rm "$tempname".c "$tempname".o 2>/dev/null
}
EXE="$1"
CC="$2"
-LDFLAGS="$3"
-O_FILES="$4"
-A_FILES="$5"
-LDLIBS="$6"
+CFLAGS="$3"
+LDFLAGS="$4"
+O_FILES="$5"
+A_FILES="$6"
+LDLIBS="$7"
# The -Wl,--sort-section option is not supported by older versions of ld
SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""`
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
-try $CC $LDFLAGS \
+try $CC $CFLAGS $LDFLAGS \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
$debug && echo "Trying -l options: '$l_list'"
- try $CC $LDFLAGS \
+ try $CC $CFLAGS $LDFLAGS \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
# --verbose gives us gobs of info to stdout (e.g. linker script used)
if ! test -f busybox_ldscript; then
- try $CC $LDFLAGS \
+ try $CC $CFLAGS $LDFLAGS \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
# *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*)
# This will eliminate most of the padding (~3kb).
# Hmm, "ld --sort-section alignment" should do it too.
- try $CC $LDFLAGS \
+ try $CC $CFLAGS $LDFLAGS \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
ln -s "libbusybox.so.$BB_VER" "$sharedlib_dir"/libbusybox.so 2>/dev/null
EXE="$sharedlib_dir/libbusybox.so.${BB_VER}_unstripped"
- try $CC $LDFLAGS \
+ try $CC $CFLAGS $LDFLAGS \
-o $EXE \
-shared -fPIC \
-Wl,--enable-new-dtags \
if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then
EXE="$sharedlib_dir/busybox_unstripped"
- try $CC $LDFLAGS \
+ try $CC $CFLAGS $LDFLAGS \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \
" >"$sharedlib_dir/applet.c"
EXE="$sharedlib_dir/$name"
- try $CC $LDFLAGS "$sharedlib_dir/applet.c" \
+ try $CC $CFLAGS $LDFLAGS "$sharedlib_dir/applet.c" \
-o $EXE \
-Wl,--sort-common \
$SORT_SECTION \