diff --git a/autogen.sh b/autogen.sh index 3f0fcd4..5e586d7 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,21 +1,21 @@ -#!/usr/bin/env bash +#!/bin/sh # Run this to generate all the initial makefiles, etc. # Ripped off from GNOME macros version DIE=0 -srcdir=`dirname $0` +srcdir=`dirname "$0"` test -z "$srcdir" && srcdir=. if [ -n "$MONO_PATH" ]; then # from -> /mono/lib:/another/mono/lib # to -> /mono /another/mono - for i in `echo ${MONO_PATH} | tr ":" " "`; do - i=`dirname ${i}` - if [ -n "{i}" -a -d "${i}/share/aclocal" ]; then + for i in `echo "${MONO_PATH}" | tr ":" " "`; do + i=`dirname "${i}"` + if [ -n "${i}" ] && [ -d "${i}/share/aclocal" ]; then ACLOCAL_FLAGS="-I ${i}/share/aclocal $ACLOCAL_FLAGS" fi - if [ -n "{i}" -a -d "${i}/bin" ]; then + if [ -n "${i}" ] && [ -d "${i}/bin" ]; then PATH="${i}/bin:$PATH" fi done @@ -31,9 +31,9 @@ fi } if [ -z "$LIBTOOLIZE" ]; then - LIBTOOLIZE=`which glibtoolize 2>/dev/null` + LIBTOOLIZE=`command -v glibtoolize 2>/dev/null` if [ ! -x "$LIBTOOLIZE" ]; then - LIBTOOLIZE=`which libtoolize` + LIBTOOLIZE=`command -v libtoolize 2>/dev/null` fi fi @@ -109,24 +109,28 @@ has_ext_mod=false ext_mod_args='' has_disable_boehm=false for PARAM; do - if [[ $PARAM =~ "--enable-extension-module" ]] ; then - has_ext_mod=true - if [[ $PARAM =~ "=" ]] ; then - ext_mod_args=`echo $PARAM | cut -d= -f2` - fi - fi - if [[ $PARAM =~ "--disable-boehm" ]] ; then - has_disable_boehm=true - fi + case "$PARAM" in + --enable-extension-module) + has_ext_mod=true + ;; + --enable-extension-module=*) + has_ext_mod=true + ext_mod_args=${PARAM#*=} + ;; + --disable-boehm) + has_disable_boehm=true + ;; + esac done # # Plug in the extension module # -if test x$has_ext_mod = xtrue; then - pushd $top_srcdir../mono-extensions/scripts - sh ./prepare-repo.sh $ext_mod_args || exit 1 - popd +if test "x$has_ext_mod" = xtrue; then + ( + cd "$srcdir/../mono-extensions/scripts" && + sh ./prepare-repo.sh "$ext_mod_args" + ) || exit 1 else cat mono/mini/Makefile.am.in > mono/mini/Makefile.am fi @@ -156,12 +160,12 @@ autoconf || { echo "**Error**: autoconf failed."; exit 1; } # Update all submodules recursively to ensure everything is checked out if test -e $srcdir/scripts/update_submodules.sh; then - (cd $srcdir && scripts/update_submodules.sh) + (cd "$srcdir" && sh scripts/update_submodules.sh) fi -if test x$has_disable_boehm = xfalse -a -d $srcdir/external/bdwgc; then +if test "x$has_disable_boehm" = xfalse -a -d "$srcdir/external/bdwgc"; then echo Running external/bdwgc/autogen.sh ... - (cd $srcdir/external/bdwgc ; NOCONFIGURE=1 ./autogen.sh "$@") + (cd "$srcdir/external/bdwgc" ; NOCONFIGURE=1 ./autogen.sh "$@") echo Done running external/bdwgc/autogen.sh ... fi @@ -173,7 +177,15 @@ host_conf_flag= build_uname_all=`(uname -a) 2>/dev/null` case "$build_uname_all" in CYGWIN*) - if [[ "$@" != *"--host="* ]]; then + has_host_flag=false + for arg do + case "$arg" in + --host=*) + has_host_flag=true + ;; + esac + done + if test "$has_host_flag" != true; then echo "Missing --host parameter, configure using ./configure --host=i686-w64-mingw32 or --host=x86_64-w64-mingw32" echo "Falling back using --host=x86_64-w64-mingw32 as default." host_conf_flag="--host=x86_64-w64-mingw32" diff --git a/configure b/configure index a465a2f..328ca8f 100755 --- a/configure +++ b/configure @@ -18865,7 +18865,7 @@ fi # end dolt -export_ldflags=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh` +export_ldflags=`eval echo \\$export_dynamic_flag_spec` # Test whenever ld supports -version-script diff --git a/configure.ac b/configure.ac index ed6b6db..2629b10 100644 --- a/configure.ac +++ b/configure.ac @@ -678,7 +678,7 @@ AM_PROG_LIBTOOL # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building. DOLT -export_ldflags=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh` +export_ldflags=`eval echo \\$export_dynamic_flag_spec` AC_SUBST(export_ldflags) # Test whenever ld supports -version-script diff --git a/llvm/build_llvm_config.sh b/llvm/build_llvm_config.sh index 7880d84..de1d368 100755 --- a/llvm/build_llvm_config.sh +++ b/llvm/build_llvm_config.sh @@ -1,27 +1,38 @@ -#!/bin/bash +#!/bin/sh llvm_config=$1 llvm_codegen_libs="$2" -llvm_extra_libs="${@:3}" +shift 2 +llvm_extra_libs="$*" use_llvm_config=1 llvm_host_win32=0 llvm_host_win32_wsl=0 llvm_host_win32_cygwin=0 -function win32_format_path { - local formatted_path=$1 - if [[ $llvm_host_win32_wsl = 1 ]] && [[ $1 != "/mnt/"* ]]; then - # if path is not starting with /mnt under WSL it could be a windows path, convert using wslpath. - formatted_path="$(wslpath -a "$1")" - elif [[ $llvm_host_win32_cygwin = 1 ]] && [[ $1 != "/cygdrive/"* ]]; then - # if path is not starting with /cygdrive under CygWin it could be a windows path, convert using cygpath. - formatted_path="$(cygpath -a "$1")" - fi +win32_format_path() { + formatted_path=$1 + case "$llvm_host_win32_wsl:$1" in + 1:/mnt/*) + ;; + 1:*) + # If the path is not under /mnt on WSL it could already be a Windows path. + formatted_path="$(wslpath -a "$1")" + ;; + esac + case "$llvm_host_win32_cygwin:$formatted_path" in + 1:/cygdrive/*) + ;; + 1:*) + # If the path is not under /cygdrive on Cygwin it could already be a Windows path. + formatted_path="$(cygpath -a "$formatted_path")" + ;; + esac echo "$formatted_path" } -if [[ $llvm_config = *".exe" ]]; then +case "$llvm_config" in +*.exe) llvm_host_win32=1 # llvm-config is a windows binary. Check if we are running CygWin or WSL since then we might still be able to run llvm-config.exe host_uname="$(uname -a)" @@ -37,66 +48,67 @@ if [[ $llvm_config = *".exe" ]]; then *) use_llvm_config=0 esac -fi + ;; +esac -if [[ $llvm_host_win32 = 1 ]]; then +if [ "$llvm_host_win32" = 1 ]; then llvm_config=$(win32_format_path "$llvm_config") fi -if [[ $use_llvm_config = 1 ]]; then - llvm_api_version=`$llvm_config --mono-api-version` || "0" - with_llvm=`$llvm_config --prefix` - llvm_config_cflags=`$llvm_config --cflags` - llvm_system=`$llvm_config --system-libs` - llvm_core_components=`$llvm_config --libs analysis core bitwriter` - if [[ $llvm_api_version -lt 600 ]]; then - llvm_old_jit=`$llvm_config --libs mcjit jit 2>>/dev/null` +if [ "$use_llvm_config" = 1 ]; then + llvm_api_version=$("$llvm_config" --mono-api-version 2>/dev/null || printf '%s\n' 0) + with_llvm=$("$llvm_config" --prefix) + llvm_config_cflags=$("$llvm_config" --cflags) + llvm_system=$("$llvm_config" --system-libs) + llvm_core_components=$("$llvm_config" --libs analysis core bitwriter) + if [ "$llvm_api_version" -lt 600 ]; then + llvm_old_jit=$("$llvm_config" --libs mcjit jit 2>>/dev/null) else - llvm_old_jit=`$llvm_config --libs mcjit 2>>/dev/null` + llvm_old_jit=$("$llvm_config" --libs mcjit 2>>/dev/null) fi - llvm_new_jit=`$llvm_config --libs orcjit 2>>/dev/null` + llvm_new_jit=$("$llvm_config" --libs orcjit 2>>/dev/null) - if [[ ! -z $llvm_codegen_libs ]]; then - llvm_extra=`$llvm_config --libs $llvm_codegen_libs` + if [ -n "$llvm_codegen_libs" ]; then + llvm_extra=$("$llvm_config" --libs "$llvm_codegen_libs") fi # When building for Windows subsystem using WSL or CygWin the path returned from llvm-config.exe # could be a Windows style path, make sure to format it into a path usable for WSL/CygWin. - if [[ $llvm_host_win32 = 1 ]]; then + if [ "$llvm_host_win32" = 1 ]; then with_llvm=$(win32_format_path "$with_llvm") fi fi # When cross compiling for Windows on system not capable of running Windows binaries, llvm-config.exe can't be used to query for # LLVM parameters. In that scenario we will need to fallback to default values. -if [[ $llvm_host_win32 = 1 ]] && [[ $use_llvm_config = 0 ]]; then +if [ "$llvm_host_win32" = 1 ] && [ "$use_llvm_config" = 0 ]; then # Assume we have llvm-config sitting in llvm-install-root/bin directory, get llvm-install-root directory. with_llvm="$(dirname $llvm_config)" with_llvm="$(dirname $with_llvm)" llvm_config_path=$with_llvm/include/llvm/Config/llvm-config.h # llvm-config.exe --mono-api-version - llvm_api_version=`awk '/MONO_API_VERSION/ { print $3 }' $llvm_config_path` + llvm_api_version=$(awk '/MONO_API_VERSION/ { print $3 }' "$llvm_config_path") # llvm-config.exe --cflags, returned information currently not used. llvm_config_cflags= # llvm-config.exe --system-libs - if [[ $llvm_api_version -lt 600 ]]; then + if [ "$llvm_api_version" -lt 600 ]; then llvm_system="-limagehlp -lpsapi -lshell32" else llvm_system="-lpsapi -lshell32 -lole32 -luuid -ladvapi32" fi # llvm-config.exe --libs analysis core bitwriter - if [[ $llvm_api_version -lt 600 ]]; then + if [ "$llvm_api_version" -lt 600 ]; then llvm_core_components="-lLLVMBitWriter -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport" else llvm_core_components="-lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle" fi # llvm-config.exe --libs mcjit jit - if [[ $llvm_api_version -lt 600 ]]; then + if [ "$llvm_api_version" -lt 600 ]; then llvm_old_jit="-lLLVMJIT -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMMCJIT -lLLVMTarget -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMExecutionEngine -lLLVMMC -lLLVMCore -lLLVMSupport" else # Current build of LLVM 60 for cross Windows builds doesn't support LLVM JIT. @@ -110,7 +122,7 @@ if [[ $llvm_host_win32 = 1 ]] && [[ $use_llvm_config = 0 ]]; then case "$llvm_codegen_libs" in *x86codegen*) # llvm-config.exe --libs x86codegen - if [[ $llvm_api_version -lt 600 ]]; then + if [ "$llvm_api_version" -lt 600 ]; then llvm_extra="-lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMObject -lLLVMBitReader -lLLVMMCDisassembler -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport" else llvm_extra="-lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMX86Desc -lLLVMX86Info -lLLVMMCDisassembler -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle" @@ -118,7 +130,7 @@ if [[ $llvm_host_win32 = 1 ]] && [[ $use_llvm_config = 0 ]]; then ;; *armcodegen*) # llvm-config.exe --libs armcodegen - if [[ $llvm_api_version -lt 600 ]]; then + if [ "$llvm_api_version" -lt 600 ]; then llvm_extra="-lLLVMARMCodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMARMDesc -lLLVMMCDisassembler -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMMC -lLLVMSupport" else llvm_extra="-lLLVMARMCodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMARMDesc -lLLVMMCDisassembler -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMARMUtils -lLLVMMC -lLLVMSupport -lLLVMDemangle" @@ -126,7 +138,7 @@ if [[ $llvm_host_win32 = 1 ]] && [[ $use_llvm_config = 0 ]]; then ;; *aarch64codegen*) # llvm-config.exe --libs aarch64codegen - if [[ $llvm_api_version -lt 600 ]]; then + if [ "$llvm_api_version" -lt 600 ]; then llvm_extra="-lLLVMAArch64CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport" else llvm_extra="-lLLVMAArch64CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport -lLLVMDemangle" @@ -137,15 +149,19 @@ if [[ $llvm_host_win32 = 1 ]] && [[ $use_llvm_config = 0 ]]; then esac fi -if [[ $llvm_config_cflags = *"stdlib=libc++"* ]]; then +llvm_libc_link="" +case "$llvm_config_cflags" in + *stdlib=libc++*) llvm_libc_c="-stdlib=libc++" # llvm_libc_link="-lc++" -else + ;; +*) llvm_libc_c="" # llvm_libc_link="-lstdc++" -fi + ;; +esac -if [[ $llvm_host_win32 = 1 ]]; then +if [ "$llvm_host_win32" = 1 ]; then host_cxxflag_additions="-std=gnu++11" host_cflag_additions="-DNDEBUG" else @@ -153,7 +169,7 @@ else host_cflag_additions="" fi -if [[ ! -z $llvm_extra_libs ]]; then +if [ -n "$llvm_extra_libs" ]; then llvm_extra="$llvm_extra $llvm_extra_libs" fi diff --git a/mcs/build/start-compiler-server.sh b/mcs/build/start-compiler-server.sh index 8c74d4c..16bc874 100755 --- a/mcs/build/start-compiler-server.sh +++ b/mcs/build/start-compiler-server.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # usage: start-compiler-server.sh # ensure that VBCS_RUNTIME and VBCS_LOCATION environment variables are set. @@ -6,20 +6,19 @@ set -u set -e if [ -s "$VBCS_LOCATION" ]; then - CMD="RoslynCommandLineLogFile=$2 $VBCS_RUNTIME --gc-params=nursery-size=64m \"$VBCS_LOCATION\" -pipename:$3 &" echo "Log location set to $2" touch "$2" - echo "cd $1; bash -c \"$CMD\"" + echo "cd $1; RoslynCommandLineLogFile=$2 $VBCS_RUNTIME --gc-params=nursery-size=64m \"$VBCS_LOCATION\" -pipename:$3 &" cd "$1" - bash -c "$CMD" + RoslynCommandLineLogFile=$2 "$VBCS_RUNTIME" --gc-params=nursery-size=64m "$VBCS_LOCATION" -pipename:"$3" & RESULT=$? - if [ $RESULT -eq 0 ]; then + if [ "$RESULT" -eq 0 ]; then echo Compiler server started. else echo Failed to start compiler server. - fi; + fi else echo No compiler server found at path "$VBCS_LOCATION". Ensure that VBCS_LOCATION is set in config.make or passed as a parameter to make. echo Use ENABLE_COMPILER_SERVER=0 to disable the use of the compiler server and continue to build. exit 1 -fi; +fi diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index 85a5664..95286b8 100755 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -3030,7 +3030,7 @@ modules.exe: modules.cs modules-m1.netmodule $(TEST_DRIVER_DEPEND) patch-libtool: cp "../../libtool" . sed -e 's,build_libtool_libs=no,build_libtool_libs=yes,g' libtool > 2; mv 2 libtool - sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 && echo "LIBTOOL = bash ./libtool" > 1 && cat 1 2 > Makefile + sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 && echo "LIBTOOL = $(SHELL) ./libtool" > 1 && cat 1 2 > Makefile touch libtest.c diff --git a/mono/tests/Makefile.in b/mono/tests/Makefile.in index 3d5eebd..f245b27 100644 --- a/mono/tests/Makefile.in +++ b/mono/tests/Makefile.in @@ -3444,7 +3444,7 @@ modules.exe: modules.cs modules-m1.netmodule $(TEST_DRIVER_DEPEND) patch-libtool: cp "../../libtool" . sed -e 's,build_libtool_libs=no,build_libtool_libs=yes,g' libtool > 2; mv 2 libtool - sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 && echo "LIBTOOL = bash ./libtool" > 1 && cat 1 2 > Makefile + sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 && echo "LIBTOOL = $(SHELL) ./libtool" > 1 && cat 1 2 > Makefile touch libtest.c test-process-exit: @$(MCS) $(srcdir)/threadpool-in-processexit.cs -out:threadpool-in-processexit.exe diff --git a/support/Makefile.am b/support/Makefile.am index d660025..2c0e425 100644 --- a/support/Makefile.am +++ b/support/Makefile.am @@ -163,8 +163,8 @@ refresh: patch-libtool: cp "../libtool" . sed -e 's,build_libtool_libs=no,build_libtool_libs=yes,g' libtool > 2; mv 2 libtool - echo "LIBTOOL = bash ./libtool" > 1 - echo "LTCOMPILE = bash ./libtool --mode=compile $(COMPILE)" >> 1 + echo "LIBTOOL = $(SHELL) ./libtool" > 1 + echo "LTCOMPILE = $(SHELL) ./libtool --mode=compile $(COMPILE)" >> 1 sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 sed -e 's,LTCOMPILE =,LTCOMPILE2 =,g' 2 > 3 cat 1 3 > Makefile diff --git a/support/Makefile.in b/support/Makefile.in index a5c760c..23916c8 100644 --- a/support/Makefile.in +++ b/support/Makefile.in @@ -1080,8 +1080,8 @@ uninstall-am: uninstall-libLTLIBRARIES @ENABLE_MSVC_ONLY_FALSE@patch-libtool: @ENABLE_MSVC_ONLY_FALSE@ cp "../libtool" . @ENABLE_MSVC_ONLY_FALSE@ sed -e 's,build_libtool_libs=no,build_libtool_libs=yes,g' libtool > 2; mv 2 libtool -@ENABLE_MSVC_ONLY_FALSE@ echo "LIBTOOL = bash ./libtool" > 1 -@ENABLE_MSVC_ONLY_FALSE@ echo "LTCOMPILE = bash ./libtool --mode=compile $(COMPILE)" >> 1 +@ENABLE_MSVC_ONLY_FALSE@ echo "LIBTOOL = $(SHELL) ./libtool" > 1 +@ENABLE_MSVC_ONLY_FALSE@ echo "LTCOMPILE = $(SHELL) ./libtool --mode=compile $(COMPILE)" >> 1 @ENABLE_MSVC_ONLY_FALSE@ sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 @ENABLE_MSVC_ONLY_FALSE@ sed -e 's,LTCOMPILE =,LTCOMPILE2 =,g' 2 > 3 @ENABLE_MSVC_ONLY_FALSE@ cat 1 3 > Makefile