From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4618 invoked from network); 10 Oct 2020 18:52:03 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 10 Oct 2020 18:52:03 -0000 Received: (qmail 27912 invoked by uid 550); 10 Oct 2020 18:52:01 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 27882 invoked from network); 10 Oct 2020 18:52:00 -0000 Authentication-Results: spamfilter05.heinlein-hosting.de (amavisd-new); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=mailbox.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1602355907; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VeOz6cKCTVNnihswcIihksFoJba/MeIWxbhA4RgK+LM=; b=cK2st3DaPINLy870bvNdY1CdJ3Pc/57yJsj6QtQUvt3XIPWswNrZxVphJs51d6/gfMZaJL jjZkIIjwWVsKo2tjGgZffk7Vccdd6BMpPNxJCnil8ZiXOPFRPVvoz6c7TRWrOjNGOOSw57 YQ8MI9YA4xdnXiW6VV/nkVACFzyH5qDLGvgKTN19Om+W8JYrTerChWfuA+/4g6BO64w414 WYLqaHDmcg09zv/qo4VUBnvUrPnjVJwkCthe+tMoYiG5XZOviiGq/FkGTdzy/6XMZlCvzY y/PGGXxX0cXj+ZYGZf5a3/DIpHjJS4DGFXTh1oYd9Rn/6dxYCjfJZJyd1bDbGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mailbox.org; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from:received; s= mail20150812; t=1602355905; bh=SzjATMV6OKpJbUs9QNBVrrl4V54vJNR8n K7GUjBPmKw=; b=YLiFWU9uJqlTYQiyefZmimYdJvh8JXamUNCx+pfb0MN7ALQVa tax+6upeo3Oh/S2Q692kP7477E3f7WkbBVVP1MgznvwjJyDDgb3dJLUOLiHdFln9 i/kjOBC8GhTPIv3zwUIv3yTwBq0/Z4pnUzsnUrbx3oa0XWLHLfDQ9JujPCYLhPo0 nh5xF95j7SvE2mVNe/8RB1Hp/wgxEbfV+qAKY7wdPlrD9GPb1iJbNJNZzBWuHD9v n6CjTMeWN05EAWmKN/WNE7rq6SYsYpzRHR8WuKVcSq883SgWa6Z/LIrUSiLLdoEc x9hB9zlFBx1OuwFpsgRsBBod1f9A/ksG3Mseg== X-Virus-Scanned: amavisd-new at heinlein-support.de From: "Issam E. Maghni" To: musl@lists.openwall.com Cc: "Issam E. Maghni" Date: Sat, 10 Oct 2020 18:51:10 +0000 Message-Id: <20201010185110.748-2-issam.e.maghni@mailbox.org> In-Reply-To: <20201010185110.748-1-issam.e.maghni@mailbox.org> References: <20201010185110.748-1-issam.e.maghni@mailbox.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MBO-SPAM-Probability: X-Rspamd-Score: -0.53 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6FFA91696 X-Rspamd-UID: 49c80e Subject: [musl] [PATCH 2/2] configure: improve portability of test command > The two commands: > test "$1" > test ! "$1" > could not be used reliably on some historical systems. Unexpected results > would occur if such a string expression were used and $1 expanded to '!', '(', > or a known unary primary. Better constructs are: > test -n "$1" > test -z "$1" > respectively. > Historical systems have also been unreliable given the common construct: > test "$response" = "expected string" > One of the following is a more reliable form: > test "X$response" = "Xexpected string" > test "expected string" = "$response" https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128_16 Signed-off-by: Issam E. Maghni --- configure | 88 +++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/configure b/configure index a5231a0e..a57ae6e1 100755 --- a/configure +++ b/configure @@ -203,8 +203,8 @@ stripdir srcdir fi abs_builddir="$(pwd)" || fail "$0: cannot determine working directory" abs_srcdir="$(cd $srcdir && pwd)" || fail "$0: invalid source directory $srcdir" -test "$abs_srcdir" = "$abs_builddir" && srcdir=. -test "$srcdir" != "." && test -f Makefile && test ! -h Makefile && fail "$0: Makefile already exists in the working directory" +test "x${abs_srcdir}" = "x${abs_builddir}" && srcdir=. +test '.' != "$srcdir" && test -f Makefile && test ! -h Makefile && fail "$0: Makefile already exists in the working directory" # # Get a temp filename we can use @@ -214,7 +214,7 @@ set -C while : ; do i=$(($i+1)) tmpc="./conf$$-$PPID-$i.c" 2>|/dev/null > "$tmpc" && break -test "$i" -gt 50 && fail "$0: cannot create temporary file $tmpc" +test 50 -le "$i" && fail "$0: cannot create temporary file $tmpc" done set +C trap 'rm "$tmpc"' EXIT INT QUIT TERM HUP @@ -222,17 +222,17 @@ trap 'rm "$tmpc"' EXIT INT QUIT TERM HUP # # Check that the requested malloc implementation exists # -test -d "$srcdir/src/malloc/$malloc_dir" \ +test -d "${srcdir}/src/malloc/${malloc_dir}" \ || fail "$0: error: chosen malloc implementation '$malloc_dir' does not exist" # # Check whether we are cross-compiling, and set a default # CROSS_COMPILE prefix if none was provided. # -test "$target" && \ -test "$target" != "$build" && \ +test -n "$target" && \ +test "x${target}" != "x${build}" && \ test -z "$CROSS_COMPILE" && \ -CROSS_COMPILE="$target-" +CROSS_COMPILE="${target}-" # # Find a C compiler to use @@ -279,33 +279,33 @@ echo "$cc_family" # # Figure out toolchain wrapper to build # -if test "$wrapper" = auto || test "$wrapper" = detect ; then +if test 'auto' = "$wrapper" || test 'detect' = "$wrapper" ; then echo "#include " > "$tmpc" echo "#if ! __GLIBC__" >> "$tmpc" echo "#error no" >> "$tmpc" echo "#endif" >> "$tmpc" printf "checking for toolchain wrapper to build... " -if test "$wrapper" = auto && ! $CC -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then +if test 'auto' = "$wrapper" && ! $CC -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then echo "none" -elif test "$cc_family" = gcc ; then +elif test 'gcc' = "$cc_family" ; then gcc_wrapper=yes echo "gcc" -elif test "$cc_family" = clang ; then +elif test 'clang' = "$cc_family" ; then clang_wrapper=yes echo "clang" else echo "none" -if test "$wrapper" = detect ; then +if test 'detect' = "$wrapper" ; then fail "$0: could not find an appropriate toolchain wrapper" fi fi fi -if test "$gcc_wrapper" = yes ; then +if test 'yes' = "$gcc_wrapper" ; then tools="$tools obj/musl-gcc" tool_libs="$tool_libs lib/musl-gcc.specs" fi -if test "$clang_wrapper" = yes ; then +if test 'yes' = "$clang_wrapper" ; then tools="$tools obj/musl-clang obj/ld.musl-clang" fi @@ -350,7 +350,7 @@ tryflag CFLAGS_C99FSE -nostdinc tryflag CFLAGS_C99FSE -ffreestanding \ || tryflag CFLAGS_C99FSE -fno-builtin tryflag CFLAGS_C99FSE -fexcess-precision=standard \ -|| { test "$ARCH" = i386 && tryflag CFLAGS_C99FSE -ffloat-store ; } +|| { test 'i386' = "$ARCH" && tryflag CFLAGS_C99FSE -ffloat-store ; } tryflag CFLAGS_C99FSE -frounding-math # @@ -400,7 +400,7 @@ tryflag CFLAGS_MEMOPS -fno-tree-loop-distribute-patterns # # Enable debugging if requessted. # -test "$debug" = yes && CFLAGS_AUTO=-g +test 'yes' = "$debug" && CFLAGS_AUTO=-g # # Preprocess asm files to add extra debugging information if debug is @@ -409,7 +409,7 @@ test "$debug" = yes && CFLAGS_AUTO=-g # printf "checking whether we should preprocess assembly to add debugging information... " if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" && - test -f "tools/add-cfi.$ARCH.awk" && + test -f "tools/add-cfi.${ARCH}.awk" && printf ".file 1 \"srcfile.s\"\n.line 1\n.cfi_startproc\n.cfi_endproc" | $CC -g -x assembler -c -o /dev/null 2>/dev/null - then ADD_CFI=yes @@ -436,13 +436,13 @@ xno|x) printf "disabled\n" ; optimize=no ;; *) printf "custom\n" ;; esac -test "$optimize" = no || tryflag CFLAGS_AUTO -Os || tryflag CFLAGS_AUTO -O2 -test "$optimize" = yes && optimize="internal,malloc,string" +test 'no' = "$optimize" || tryflag CFLAGS_AUTO -Os || tryflag CFLAGS_AUTO -O2 +test 'yes' = "$optimize" && optimize="internal,malloc,string" if fnmatch 'no|size' "$optimize" ; then : else printf "components to be optimized for speed:" -while test "$optimize" ; do +while test -n "$optimize" ; do case "$optimize" in *,*) this=${optimize%%,*} optimize=${optimize#*,} ;; *) this=$optimize optimize= @@ -500,7 +500,7 @@ tryflag CFLAGS_AUTO -fdata-sections # Some build environments pass -march and -mtune options via CC, so # check both CC and CFLAGS. # -if test "$ARCH" = "i386" ; then +if test 'i386' = "$ARCH" ; then fnmatch '-march=*|*\ -march=*' "$CC $CFLAGS" || tryldflag CFLAGS_AUTO -march=i486 fnmatch '-mtune=*|*\ -mtune=*' "$CC $CFLAGS" || tryldflag CFLAGS_AUTO -mtune=generic fi @@ -511,7 +511,7 @@ fi # to start from a clean slate. So use -w if building with clang. Also # turn off a common on-by-default cast warning regardless of compiler. # -test "$cc_family" = clang && tryflag CFLAGS_AUTO -w +test 'clang' = "$cc_family" && tryflag CFLAGS_AUTO -w tryflag CFLAGS_AUTO -Wno-pointer-to-int-cast @@ -535,9 +535,9 @@ tryflag CFLAGS_AUTO -Werror=discarded-array-qualifiers # parameter to stop printing warnings about LDFLAGS passed during # compiling stage and CFLAGS passed during linking stage. # -test "$cc_family" = clang && tryflag CFLAGS_AUTO -Qunused-arguments +test 'clang' = "$cc_family" && tryflag CFLAGS_AUTO -Qunused-arguments -if test "x$warnings" = xyes ; then +if test 'yes' = "$warnings" ; then tryflag CFLAGS_AUTO -Waddress tryflag CFLAGS_AUTO -Warray-bounds tryflag CFLAGS_AUTO -Wchar-subscripts @@ -604,7 +604,7 @@ printf "using compiler runtime libraries: %s\n" "$LIBCC" SUBARCH= t="$CFLAGS_C99FSE $CPPFLAGS $CFLAGS" -if test "$ARCH" = "i386" ; then +if test 'i386' = "$ARCH" ; then printf "checking whether compiler can use ebx in PIC asm constraints... " cat > "$tmpc" < "$tmpc" if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then @@ -646,31 +646,31 @@ fi fi fi -if test "$ARCH" = "aarch64" ; then +if test 'aarch64' = "$ARCH" ; then trycppif __AARCH64EB__ "$t" && SUBARCH=${SUBARCH}_be fi -if test "$ARCH" = "m68k" ; then +if test 'm68k' = "$ARCH" ; then if trycppif "__HAVE_68881__" ; then : ; elif trycppif "__mcffpu__" ; then SUBARCH="-fp64" else SUBARCH="-sf" fi fi -if test "$ARCH" = "mips" ; then +if test 'mips' = "$ARCH" ; then trycppif "__mips_isa_rev >= 6" "$t" && SUBARCH=${SUBARCH}r6 trycppif "_MIPSEL || __MIPSEL || __MIPSEL__" "$t" && SUBARCH=${SUBARCH}el trycppif __mips_soft_float "$t" && SUBARCH=${SUBARCH}-sf fi -if test "$ARCH" = "mips64" ; then +if test 'mips64' = "$ARCH" ; then trycppif "_MIPS_SIM != _ABI64" "$t" && ARCH=mipsn32 trycppif "__mips_isa_rev >= 6" "$t" && SUBARCH=${SUBARCH}r6 trycppif "_MIPSEL || __MIPSEL || __MIPSEL__" "$t" && SUBARCH=${SUBARCH}el trycppif __mips_soft_float "$t" && SUBARCH=${SUBARCH}-sf fi -if test "$ARCH" = "powerpc" ; then +if test 'powerpc' = "$ARCH" ; then trycppif "__NO_FPRS__ && !_SOFT_FLOAT" "$t" && fail \ "$0: error: compiler's floating point configuration is unsupported" trycppif _SOFT_FLOAT "$t" && SUBARCH=${SUBARCH}-sf @@ -685,21 +685,21 @@ CFLAGS_AUTO="${CFLAGS_AUTO# }" fi fi -test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \ +test 'microblaze' = "$ARCH" && trycppif __MICROBLAZEEL__ "$t" \ && SUBARCH=${SUBARCH}el -if test "$ARCH" = "powerpc64" ; then +if test 'powerpc64' = "$ARCH" ; then trycppif "_CALL_ELF == 2" "$t" || fail "$0: error: unsupported powerpc64 ABI" trycppif __LITTLE_ENDIAN__ "$t" && SUBARCH=${SUBARCH}le trycppif _SOFT_FLOAT "$t" && fail "$0: error: soft-float not supported on powerpc64" fi -if test "$ARCH" = "riscv64" ; then +if test 'riscv64' = "$ARCH" ; then trycppif __riscv_float_abi_soft "$t" && SUBARCH=${SUBARCH}-sf trycppif __riscv_float_abi_single "$t" && SUBARCH=${SUBARCH}-sp fi -if test "$ARCH" = "sh" ; then +if test 'sh' = "$ARCH" ; then tryflag CFLAGS_AUTO -Wa,--isa=any trycppif __BIG_ENDIAN__ "$t" && SUBARCH=${SUBARCH}eb if trycppif "__SH_FPU_ANY__ || __SH4__" "$t" ; then @@ -722,7 +722,7 @@ SUBARCH=${SUBARCH}-fdpic fi fi -test "$SUBARCH" \ +test -n "$SUBARCH" \ && printf "configured for %s variant: %s\n" "$ARCH" "$ARCH$SUBARCH" case "$ARCH$SUBARCH" in @@ -802,13 +802,13 @@ TOOL_LIBS = $tool_libs ADD_CFI = $ADD_CFI MALLOC_DIR = $malloc_dir EOF -test "x$static" = xno && echo "STATIC_LIBS =" -test "x$shared" = xno && echo "SHARED_LIBS =" -test "x$cc_family" = xgcc && echo 'WRAPCC_GCC = $(CC)' -test "x$cc_family" = xclang && echo 'WRAPCC_CLANG = $(CC)' -test "x$pic_default" = xyes && echo 'AOBJS = $(LOBJS)' +test 'no' = "$static" && echo "STATIC_LIBS =" +test 'no' = "$shared" && echo "SHARED_LIBS =" +test 'gcc' = "$cc_family" && echo 'WRAPCC_GCC = $(CC)' +test 'clang' = "$cc_family" && echo 'WRAPCC_CLANG = $(CC)' +test 'yes' = "$pic_default" && echo 'AOBJS = $(LOBJS)' exec 1>&3 3>&- -test "$srcdir" = "." || ln -sf $srcdir/Makefile . +test '.' = "$srcdir" || ln -sf $srcdir/Makefile . printf "done\n" -- 2.28.0