diff options
author | Dan Gudmundsson <dgud@erlang.org> | 2020-01-08 12:36:02 +0100 |
---|---|---|
committer | Dan Gudmundsson <dgud@erlang.org> | 2020-01-08 12:36:02 +0100 |
commit | 8ff0284174252788bafb6b616d0fa09ef51a1ed6 (patch) | |
tree | 67e68124b6a6b6bea84fa22964facf6a6e221ae3 | |
parent | 83c68a5e9cebdd00d00bbf8e5de20ce928e0172f (diff) | |
parent | 9249a4479ce4c7956eea6bfba731b6a2af7fc123 (diff) | |
download | erlang-8ff0284174252788bafb6b616d0fa09ef51a1ed6.tar.gz |
Merge branch 'dgud/build-WSL'
* dgud/build-WSL:
Add missing files to gitignore
Make build installer work from WSL
Fix deps generation on Windows
Support ssl-1.1.1 on windows when building crypto
Setup VC env in otp_build
Add wsl config as an environment to otp build tools
25 files changed, 1742 insertions, 78 deletions
diff --git a/.gitignore b/.gitignore index 30f89872ea..4528cd6cdb 100644 --- a/.gitignore +++ b/.gitignore @@ -56,8 +56,10 @@ a.out.dSYM/ # Windows *.pdb +local.static.config.cache tcltk85_win32_bin.tar.gz erts/autoconf/win32.config.cache +erts/autoconf/win64.config.cache erts/emulator/obj/ erts/emulator/pcre/obj/ erts/emulator/pcre/win32/ @@ -68,6 +70,9 @@ erts/epmd/src/win32/ erts/etc/common/Install.ini erts/etc/common/win32/ erts/etc/win32/cygwin_tools/vc/coffix.exe +erts/etc/win32/wsl_tools/vc/coffix.exe +erts/etc/win32/nsis/helper.* +erts/etc/win32/nsis/hello.* erts/include/internal/win32/ erts/include/win32/ erts/lib/internal/win32/ diff --git a/erts/aclocal.m4 b/erts/aclocal.m4 index a0df305686..41b35459d5 100644 --- a/erts/aclocal.m4 +++ b/erts/aclocal.m4 @@ -127,13 +127,14 @@ if test "X$windows_environment_" != "Xchecked"; then windows_environment_=checked MIXED_CYGWIN=no MIXED_MSYS=no +MIXED_VSL=no dnl MIXED_VC is Microsoft Visual C++ used as standard compiler MIXED_VC=no dnl MIXED_MINGW is mingw(32|64) used as standard compiler MIXED_MINGW=no -AC_MSG_CHECKING(for mixed cygwin or msys and native VC++ environment) +AC_MSG_CHECKING(for mixed mingw-gcc and native VC++ environment) if test "X$host" = "Xwin32" -a "x$GCC" != "xyes"; then if test -x /usr/bin/msys-?.0.dll; then CFLAGS="$CFLAGS -O2" @@ -147,9 +148,15 @@ if test "X$host" = "Xwin32" -a "x$GCC" != "xyes"; then AC_MSG_RESULT([Cygwin and VC]) MIXED_VC=yes CPPFLAGS="$CPPFLAGS -DERTS_MIXED_VC" + elif test -x /bin/wslpath; then + CFLAGS="$CFLAGS -O2" + MIXED_WSL=yes + AC_MSG_RESULT([WSL and VC]) + MIXED_VC=yes + CPPFLAGS="$CPPFLAGS -DERTS_MIXED_VC" else AC_MSG_RESULT([undeterminable]) - AC_MSG_ERROR(Seems to be mixed windows but not with cygwin, cannot handle this!) + AC_MSG_ERROR(Seems to be mixed windows but not within any known env, cannot handle this!) fi else AC_MSG_RESULT([no]) @@ -204,6 +211,13 @@ else AC_MSG_RESULT([no]) fi +AC_MSG_CHECKING(if we mix WSL with another native compiler) +if test "X$MIXED_WSL" = "Xyes" ; then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + fi ]) diff --git a/erts/etc/win32/nsis/Makefile b/erts/etc/win32/nsis/Makefile index c541d2b293..4c5e5325b3 100644 --- a/erts/etc/win32/nsis/Makefile +++ b/erts/etc/win32/nsis/Makefile @@ -23,7 +23,7 @@ include $(ERL_TOP)/make/$(TARGET)/otp.mk include $(ERL_TOP)/erts/vsn.mk VERSION_HEADER = erlang.nsh -MAKENSIS = makensis +MAKENSIS = makensis.exe MAKENSISFLAGS = /V2 CUSTOM_MODERN=custom_modern.exe @@ -53,19 +53,23 @@ WTARGET_DIR=$(shell (w32_path.sh -d "$(TARGET_DIR)")) ifeq ($(CONFIG_SUBTYPE),win64) WINTYPE=win64 + REDIST_TARGET=vcredist_x64.exe else WINTYPE=win32 + REDIST_TARGET=vcredist_x86.exe endif -REDIST_FILE=$(shell (sh ./find_redist.sh || echo "")) -NICEREDISTFILE=$(shell (w32_path.sh -d "$(REDIST_FILE)" 2>/dev/null || echo "")) - -REDIST_TARGET=$(shell (sh ./find_redist.sh -n || echo "")) -REDIST_DLL_VERSION=$(shell (sh ./dll_version_helper.sh $(NICEREDISTFILE) || echo "")) -REDIST_DLL_NAME=$(shell (sh ./dll_version_helper.sh -n $(NICEREDISTFILE) || echo "")) +REDIST_FILE=$(shell (sh ./find_redist.sh $(WINTYPE) || echo "")) +NICEREDISTFILE=$(shell (w32_path.sh -m "$(REDIST_FILE)" 2>/dev/null || echo "NOTFOUND")) +# $(info $$NICEREDISTFILE = [${NICEREDISTFILE}]) +REDIST_DLL_VERSION=$(shell (sh ./dll_version_helper.sh "$(NICEREDISTFILE)" || echo "")) +REDIST_DLL_NAME=$(shell (sh ./dll_version_helper.sh -n "$(NICEREDISTFILE)" || echo "")) +# $(info $$REDIST_DLL_VERSION = [${REDIST_DLL_VERSION}]) +# $(info $$REDIST_DLL_NAME = [${REDIST_DLL_NAME}]) +# $(info $$REDIST_FILE = [${REDIST_FILE}]) release_spec: - @NSIS_VER=`makensis /hdrinfo | head -1 | awk '{print $$2}'`; \ + @NSIS_VER=`makensis.exe -version`; \ case $$NSIS_VER in \ v2.0b*) \ echo '!define MUI_VERSION "$(SYSTEM_VSN)"' > $(VERSION_HEADER);\ @@ -77,7 +81,7 @@ release_spec: echo '!define HAVE_DOCS 1' >> $(VERSION_HEADER); \ fi;\ $(MAKENSIS) erlang.nsi;;\ - v2.*) \ + v2.* | v3.*) \ echo '!define OTP_VERSION "$(SYSTEM_VSN)"' > $(VERSION_HEADER);\ echo '!define ERTS_VERSION "$(VSN)"' >> $(VERSION_HEADER);\ echo '!define TESTROOT "$(WTESTROOT)"' >> $(VERSION_HEADER);\ @@ -89,7 +93,7 @@ release_spec: fi;\ if [ '!' -z "$(REDIST_FILE)" -a '!' -z "$(REDIST_DLL_VERSION)" ];\ then \ - cp $(REDIST_FILE) "$(RELEASE_PATH)/$(REDIST_TARGET)";\ + cp "$(REDIST_FILE)" "$(RELEASE_PATH)/$(REDIST_TARGET)";\ echo '!define HAVE_REDIST_FILE 1' >> $(VERSION_HEADER); \ echo '!define REDIST_DLL_VERSION "$(REDIST_DLL_VERSION)"' >> $(VERSION_HEADER);\ echo '!define REDIST_DLL_NAME "$(REDIST_DLL_NAME)"' >> $(VERSION_HEADER);\ @@ -102,7 +106,7 @@ release_spec: echo "Running $(MAKENSIS) $(MAKENSISFLAGS) erlang20.nsi";\ $(MAKENSIS) $(MAKENSISFLAGS) erlang20.nsi;;\ *) \ - echo 'Unsupported NSIS version';;\ + echo "Unsupported NSIS version: $$NSIS_VER";;\ esac release_docs release_docs_spec docs: diff --git a/erts/etc/win32/nsis/dll_version_helper.sh b/erts/etc/win32/nsis/dll_version_helper.sh index 9eafb6ce0e..1b295aa89a 100755 --- a/erts/etc/win32/nsis/dll_version_helper.sh +++ b/erts/etc/win32/nsis/dll_version_helper.sh @@ -44,12 +44,16 @@ int main(void) } EOF -cl -MD hello.c > /dev/null 2>&1 +cl.exe -MD hello.c > /dev/null 2>&1 if [ '!' -f hello.exe.manifest ]; then # Gah - VC 2010 changes the way it handles DLL's and manifests... Again... # need another way of getting the version DLLNAME=`dumpbin.exe -imports hello.exe | egrep MSVCR.*dll` DLLNAME=`echo $DLLNAME` + if [ -z "$DLLNAME" ]; then + DLLNAME=`dumpbin.exe -imports hello.exe | egrep VCRUNTIME.*dll` + DLLNAME=`echo $DLLNAME` + fi if [ '!' -z "$1" ]; then FILETOLOOKIN=$1 else @@ -92,22 +96,25 @@ int main(void) for(i=0; i < n; ++i) { sprintf(buff,"\\\\StringFileInfo\\\\%04x%04x\\\\FileVersion", translate[i*2],translate[i*2+1]); - if (VerQueryValue(versinfo,buff,&vs_verinfo,&vs_ver_size)) { - printf("%s\n",(char *) vs_verinfo); - return 0; + if (VerQueryValue(versinfo,buff,&vs_verinfo,&vs_ver_size) && vs_ver_size > 2) { + if(vs_verinfo[1] == 0) // Wide char (depends on compiler version!!) + printf("%S\n",(unsigned short *) vs_verinfo); + else + printf("%s\n",(char *) vs_verinfo); + return 0; } } fprintf(stderr,"Failed to find file version of %s\n",REQ_MODULE); return 0; } EOF - cl -MD helper.c version.lib > /dev/null 2>&1 + cl.exe -MD helper.c version.lib > /dev/null 2>&1 if [ '!' -f helper.exe ]; then echo "Failed to build helper program." >&2 exit 1 fi NAME=$DLLNAME - VERSION=`./helper` + VERSION=`./helper.exe` else VERSION=`grep '<assemblyIdentity' hello.exe.manifest | sed 's,.*version=.\([0-9\.]*\).*,\1,g' | grep -v '<'` NAME=`grep '<assemblyIdentity' hello.exe.manifest | sed 's,.*name=.[A-Za-z\.]*\([0-9]*\).*,msvcr\1.dll,g' | grep -v '<'` diff --git a/erts/etc/win32/nsis/find_redist.sh b/erts/etc/win32/nsis/find_redist.sh index c070ad469a..deb5480e1a 100755 --- a/erts/etc/win32/nsis/find_redist.sh +++ b/erts/etc/win32/nsis/find_redist.sh @@ -26,17 +26,9 @@ lookup_prog_in_path () save_ifs=$IFS IFS=: for p in $PATH; do - # In cygwin the programs are not always executable and have .exe suffix... - if [ "X$TARGET" = "Xwin32" ]; then - if [ -f $p/$PROG.exe ]; then - echo $p/$PROG - break; - fi - else - if [ -x $p/$PROG ]; then - echo $p/$PROG - break; - fi + if [ -f $p/$PROG.exe ]; then + echo $p/$PROG + break; fi done IFS=$save_ifs @@ -89,36 +81,38 @@ add_path_element() echo "$PA" } - -CLPATH=`lookup_prog_in_path cl` - -if [ -z "$CLPATH" ]; then - echo "Can not locate cl.exe and vcredist_x86/x64.exe - OK if using mingw" >&2 - exit 1 -fi - # Look to see if it's 64bit -XX=`remove_path_element cl "$CLPATH"` -YY=`remove_path_element amd64 "$XX"` -if [ "$YY" != "$XX" ]; then +if [ "$1" = "win64" ]; then AMD64DIR=true VCREDIST=vcredist_x64 COMPONENTS="cl amd64 bin vc" -else +elif [ "$1" = "win32" ]; then AMD64DIR=false VCREDIST=vcredist_x86 COMPONENTS="cl bin vc" +else + echo "TARGET argument should win32 or win64" + exit 2 fi -if [ X"$1" = X"-n" ]; then - echo $VCREDIST.exe - exit 0 +if [ x"$VCToolsRedistDir" != x"" ]; then + File="$VCToolsRedistDir/$VCREDIST.exe" + if [ -r "$File" ]; then + echo "$File" + exit 0 + fi +fi + +CLPATH=`lookup_prog_in_path cl` +if [ -z "$CLPATH" ]; then + echo "Can not locate cl.exe and vcredist_x86/x64.exe - OK if using mingw" >&2 + exit 1 fi -# echo $CLPATH +echo $CLPATH BPATH=$CLPATH for x in $COMPONENTS; do - # echo $x + #echo $x NBPATH=`remove_path_element $x "$BPATH"` if [ "$NBPATH" = "$BPATH" ]; then echo "Failed to locate $VCREDIST.exe because cl.exe was in an unexpected location" >&2 diff --git a/erts/etc/win32/wsl_tools/SetupWSLcross.bat b/erts/etc/win32/wsl_tools/SetupWSLcross.bat new file mode 100644 index 0000000000..d29400f133 --- /dev/null +++ b/erts/etc/win32/wsl_tools/SetupWSLcross.bat @@ -0,0 +1,60 @@ +@echo off +rem Setup MCL and echo the environment +rem Usage: eval `cmd.exe /c SetupWSLcross.bat x64` + +IF "%~1"=="x86" GOTO search +IF "%~1"=="x64" GOTO search + +GOTO badarg + +:search +IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat". ( + call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %~1 > nul + goto continue +) + +IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat". ( + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" %~1 > nul + goto continue +) + +IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat". ( + call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" %~1 > nul + goto continue +) + +IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat". ( + call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %~1 > nul + goto continue +) + +GOTO no_vcvars + +:continue + +FOR /F "delims==" %%F IN ('where cl.exe') DO SET _cl_exec_=%%F +FOR %%F IN ("%_cl_exec_%") DO SET CL_PATH=%%~dpF + +FOR /F "delims==" %%F IN ('where rc.exe') DO SET _rc_exec_=%%F +FOR %%F IN ("%_rc_exec_%") DO SET RC_PATH=%%~dpF + +rem Order is important for some unknown reason +set WSLENV=VCToolsRedistDir/up:CL_PATH/up:RC_PATH/up:LIBPATH/ul:LIB/ul:INCLUDE/ul +wsl.exe echo INCLUDE=\"$INCLUDE\"; +wsl.exe echo LIB=\"$LIB\"; +wsl.exe echo LIBPATH=\"$LIBPATH\"; +wsl.exe echo VCToolsRedistDir=\"$VCToolsRedistDir\"; +wsl.exe echo PATH=\"$CL_PATH\":\"$RC_PATH\":'$PATH'; +wsl.exe echo WSLENV='$WSLENV:LIBPATH/l:LIB/l:INCLUDE/l'; +rem wsl.exe echo export 'INCLUDE LIB LIBPATH VCToolsRedistDir WSLENV PATH'; +wsl.exe echo "# Eval this file eval \`cmd.exe /c SetupWSLcross.bat\`" + +exit + +:badarg +echo "Bad TARGET or not specified: %~1 expected x86 or x64" +exit + +:no_vcvars +echo "Error: SetupWSLcross.bat: Could not find vcvarsall.bat" +exit diff --git a/erts/etc/win32/wsl_tools/erl b/erts/etc/win32/wsl_tools/erl new file mode 100755 index 0000000000..db24f6b4fe --- /dev/null +++ b/erts/etc/win32/wsl_tools/erl @@ -0,0 +1,45 @@ +#! /bin/sh +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +# Note! This shellscript expects to be run in a wsl environment, +# it converts erlc command lines to native windows erlc commands, which +# basically means running the command wslpath on whatever is a path... + +CMD="" +for x in "$@"; do + case "$x" in + -I/*|-o/*) + y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; + z=`echo $x | sed 's,^-\([Io]\)\(/.*\),\1,g'`; + MPATH=`wslpath -m $y`; + CMD="$CMD -$z\"$MPATH\"";; + /*) + MPATH=`wslpath -m $x`; + CMD="$CMD \"$MPATH\"";; + *) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD \"$y\"";; + esac +done +ERL_TOP=`wslpath -m $ERL_TOP` +WSLENV="ERL_TOP/w:$WSLENV" +export WSLENV +export ERL_TOP +eval erl.exe $CMD diff --git a/erts/etc/win32/wsl_tools/erlc b/erts/etc/win32/wsl_tools/erlc new file mode 100755 index 0000000000..956ac19abd --- /dev/null +++ b/erts/etc/win32/wsl_tools/erlc @@ -0,0 +1,60 @@ +#! /bin/sh +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# + + +CMD="" +ECHO_ONLY=false +for x in "$@"; do + case "$x" in + --echo_only) + ECHO_ONLY=true;; + -I/*|-o/*) + y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; + z=`echo $x | sed 's,^-\([Io]\)\(/.*\),\1,g'`; + MPATH=`wslpath -m $y`; + CMD="$CMD -$z$MPATH";; + -pa/*) + y=`echo $x | sed 's,^-pa\(/.*\),\1,g'`; + MPATH=`wslpath -m $y`; + CMD="$CMD -pa $MPATH";; + /*) + MPATH=`wslpath -m $x`; + CMD="$CMD \"$MPATH\"";; +# Needed for +'{preproc_flags,whatever}' + +{preproc_flags,*}) + y=`echo $x | sed 's,^+{preproc_flags\,"\(.*\)"},\1,g'`; + z=`eval $0 --echo_only $y`; + case "$z" in # Dont "doubledoublequote" + \"*\") + CMD="$CMD +'{preproc_flags,$z}'";; + *) + CMD="$CMD +'{preproc_flags,\"$z\"}'";; + esac;; + *) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD \"$y\"";; + esac +done +if [ $ECHO_ONLY = true ]; then + echo $CMD +else + eval erlc.exe $CMD +fi diff --git a/erts/etc/win32/wsl_tools/javac.sh b/erts/etc/win32/wsl_tools/javac.sh new file mode 100755 index 0000000000..a37dc9450d --- /dev/null +++ b/erts/etc/win32/wsl_tools/javac.sh @@ -0,0 +1,66 @@ +#! /bin/sh +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +# Note! This shellscript expects to be run in a WSL environment, +# it converts erlc command lines to native windows erlc commands, which +# basically means running the command wslpath on whatever is a path... + +CMD="" +save_IFS=$IFS +IFS=":" +NEWCLASSPATH="" +for x in $CLASSPATH; do + TMP=`wslpath -m $x` + if [ -z "$NEWCLASSPATH" ]; then + NEWCLASSPATH="$TMP" + else + NEWCLASSPATH="$NEWCLASSPATH;$TMP" + fi +done +IFS=$save_IFS +CLASSPATH="$NEWCLASSPATH" +export CLASSPATH +#echo "CLASSPATH=$CLASSPATH" +SAVE="$@" +while test -n "$1" ; do + x="$1" + case "$x" in + -I/*|-o/*|-d/*) + y=`echo $x | sed 's,^-[Iod]\(/.*\),\1,g'`; + z=`echo $x | sed 's,^-\([Iod]\)\(/.*\),\1,g'`; + #echo "Foooo:$z" + MPATH=`wslpath -m $y`; + CMD="$CMD -$z\"$MPATH\"";; + -d|-I|-o) + shift; + MPATH=`wslpath -m $1`; + CMD="$CMD $x $MPATH";; + /*) + #echo "absolute:"$x; + MPATH=`wslpath -m $x`; + CMD="$CMD \"$MPATH\"";; + *) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD \"$y\"";; + esac + shift +done +#echo javac.exe "$CMD" +eval javac.exe "$CMD" diff --git a/erts/etc/win32/wsl_tools/make_bootstrap_ini.sh b/erts/etc/win32/wsl_tools/make_bootstrap_ini.sh new file mode 100755 index 0000000000..c33d328ea0 --- /dev/null +++ b/erts/etc/win32/wsl_tools/make_bootstrap_ini.sh @@ -0,0 +1,43 @@ +#! /bin/bash +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2003-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +# Create a local init-file for erlang in the build environment. +if [ -z "$1" ]; then + echo "error: $0: No rootdir given" + exit 1 +else + RDIR=$1 +fi +if [ -z "$2" ]; then + echo "error: $0: No bindir given" + exit 1 +else + BDIR=$2 +fi + +DRDIR=`w32_path.sh -d $RDIR` +DBDIR=`w32_path.sh -d $BDIR` + +cat > $RDIR/bin/erl.ini <<EOF +[erlang] +Bindir=$DBDIR +Progname=erl +Rootdir=$DRDIR +EOF diff --git a/erts/etc/win32/wsl_tools/make_local_ini.sh b/erts/etc/win32/wsl_tools/make_local_ini.sh new file mode 100755 index 0000000000..85ec4e40aa --- /dev/null +++ b/erts/etc/win32/wsl_tools/make_local_ini.sh @@ -0,0 +1,40 @@ +#! /bin/bash +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2003-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +# Create a local init-file for erlang in the build environment. +if [ -z "$1" ]; then + if [ -z $ERL_TOP ]; then + echo "error: $0: No rootdir available" + exit 1 + else + RDIR=$ERL_TOP + fi +else + RDIR=$1 +fi + +DDIR=`w32_path.sh -d $RDIR` + +cat > $RDIR/bin/erl.ini <<EOF +[erlang] +Bindir=$DDIR\\\\bin\\\\win32 +Progname=erl +Rootdir=$DDIR +EOF diff --git a/erts/etc/win32/wsl_tools/reg_query.sh b/erts/etc/win32/wsl_tools/reg_query.sh new file mode 100755 index 0000000000..c05f00dfa1 --- /dev/null +++ b/erts/etc/win32/wsl_tools/reg_query.sh @@ -0,0 +1,19 @@ +#! /bin/sh + +mkdir -p $ERL_TOP/tmp +BAT_FILE=$ERL_TOP/tmp/w$$.bat +if [ -z "$1" -o -z "$2" ]; then + echo "Usage:" "$0" '<key> <valuename>' + exit 1 +fi +BACKED=`echo "$1" | sed 's,/,\\\\,g'` + +if [ $CONFIG_SUBTYPE = "win64" ]; then + REG_OPT=" /reg:64" +else + REG_OPT=" /reg:32" +fi + +WIN_BAT_FILE=`w32_path.sh -w $BAT_FILE` +RESULT=`reg.exe query "$BACKED" /v "$2" $REG_OPT | sed 's@\\\@/@g' | tr -d '\r\n'` +echo "$RESULT" | sed "s,.*REG_[^ ]* *,,g" diff --git a/erts/etc/win32/wsl_tools/vc/ar.sh b/erts/etc/win32/wsl_tools/vc/ar.sh new file mode 100755 index 0000000000..4d3b8ffdb5 --- /dev/null +++ b/erts/etc/win32/wsl_tools/vc/ar.sh @@ -0,0 +1,48 @@ +#! /bin/sh +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +CMD="" +while test -n "$1" ; do + x="$1" + case "$x" in + -out:) + shift + case "$1" in + /*) + MPATH=`w32_path.sh -d $1`;; + *) + MPATH=$1;; + esac + CMD="$CMD -out:\"$MPATH\"";; + -out:/*) + y=`echo $x | sed 's,^-out:\(/.*\),\1,g'`; + MPATH=`w32_path.sh -d $y`; + CMD="$CMD -out:\"$MPATH\"";; + /*) + MPATH=`w32_path.sh -d $x`; + CMD="$CMD \"$MPATH\"";; + *) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD \"$y\"";; + esac + shift +done + +eval lib.exe /nologo $CMD diff --git a/erts/etc/win32/wsl_tools/vc/cc.sh b/erts/etc/win32/wsl_tools/vc/cc.sh new file mode 100755 index 0000000000..036e00681c --- /dev/null +++ b/erts/etc/win32/wsl_tools/vc/cc.sh @@ -0,0 +1,382 @@ +#! /bin/sh +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +# Icky cl wrapper that does it's best to behave like a Unixish cc. +# Made to work for Erlang builds and to make configure happy, not really +# general I suspect. +# set -x +# Save the command line for debug outputs + +SAVE="$@" + +# Constants +COMMON_CFLAGS="-nologo -D__WIN32__ -DWIN32 -DWINDOWS -D_WIN32 -DNT -D_CRT_SECURE_NO_DEPRECATE" + +# Variables +# The stdout and stderr for the compiler +MSG_FILE=/tmp/cl.exe.$$.1 +ERR_FILE=/tmp/cl.exe.$$.2 + +# "Booleans" determined during "command line parsing" +# If the stdlib option is explicitly passed to this program +MD_FORCED=false +# If we're preprocession (only) i.e. -E +PREPROCESSING=false +# If we're generating dependencies (implies preprocesing) +DEPENDENCIES=false +# If this is supposed to be a debug build +DEBUG_BUILD=false +# If this is supposed to be an optimized build (there can only be one...) +OPTIMIZED_BUILD=false +# If we're linking or only compiling +LINKING=true + +# This data is accumulated during command line "parsing" +# The stdlibrary option, default multithreaded dynamic +MD=-MD +# Flags for debug compilation +DEBUG_FLAGS="" +# Flags for optimization +OPTIMIZE_FLAGS="" +# The specified output filename (if any), may be either object or exe. +OUTFILE="" +# Unspecified command line options for the compiler +CMD="" +# All the c source files, in unix style +SOURCES="" +# All the options to pass to the linker, kept in Unix style +LINKCMD="" + + +# Loop through the parameters and set the above variables accordingly +# Also convert some filenames to "windows style" +# except for anything passed to the linker, that script +# handles those and the sources, which are also kept unixish for now + +# If we are in "unix" directory we can't use relative paths +# since cl.exe can't find that path +WINCHECK=`w32_path.sh -m $PWD` +case $WINCHECK in + //wsl$/*) + USEABSPATH=true + ;; + *) + USEABSPATH=false + ;; +esac + +while test -n "$1" ; do + x="$1" + case "$x" in + -Wall) + ;; + -c) + LINKING=false;; + #CMD="$CMD -c";; + -MM) + PREPROCESSING=true; + LINKING=false; + DEPENDENCIES=true;; + -E) + PREPROCESSING=true; + LINKING=false;; # Obviously... + #CMD="$CMD -E";; + -Owx) + # Optimization hardcoded of wxErlang + OPTIMIZE_FLAGS="-Ob2ity -Gs -Z7"; + DEBUG_FLAGS=""; + DEBUG_BUILD=false; + if [ $MD_FORCED = false ]; then + MD=-MD; + fi + OPTIMIZED_BUILD=true;; + -O*) + # Optimization hardcoded + OPTIMIZE_FLAGS="-Ox -Z7"; + DEBUG_FLAGS=""; + DEBUG_BUILD=false; + if [ $MD_FORCED = false ]; then + MD=-MD; + fi + OPTIMIZED_BUILD=true;; + -g|-ggdb) + if [ $OPTIMIZED_BUILD = false ];then + # Hardcoded windows debug flags + DEBUG_FLAGS="-Z7"; + if [ $MD_FORCED = false ]; then + MD=-MDd; + fi + LINKCMD="$LINKCMD -g"; + DEBUG_BUILD=true; + fi;; + # Allow forcing of stdlib + -mt|-MT) + MD="-MT"; + MD_FORCED=true;; + -md|-MD) + MD="-MD"; + MD_FORCED=true;; + -ml|-ML) + MD="-ML"; + MD_FORCED=true;; + -mdd|-MDD|-MDd) + MD="-MDd"; + MD_FORCED=true;; + -mtd|-MTD|-MTd) + MD="-MTd"; + MD_FORCED=true;; + -mld|-MLD|-MLd) + MD="-MLd"; + MD_FORCED=true;; + -o) + shift; + OUTFILE="$1";; + -o*) + y=`echo $x | sed 's,^-[Io]\(.*\),\1,g'`; + OUTFILE="$y";; + -I/*) + y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; + z=`echo $x | sed 's,^-\([Io]\)\(/.*\),\1,g'`; + MPATH=`w32_path.sh -d "$y"`; + CMD="$CMD -$z\"$MPATH\"";; + -I\"/*) + y=`echo $x | sed 's,^\"-[Io]\(/.*\)\",\1,g'`; + z=`echo $x | sed 's,^\"-\([Io]\)\(/.*\)\",\1,g'`; + MPATH=`w32_path.sh -d "$y"`; + CMD="$CMD -$z\"$MPATH\"";; + -I*) + if [ $USEABSPATH = true ]; then + y=`echo $x | sed 's,^-[Io]\(.*\),\1,g'`; + z=`echo $x | sed 's,^-\([Io]\)\(.*\),\1,g'`; + MPATH=`w32_path.sh -a -d "$y"`; + CMD="$CMD -$z$MPATH"; + else + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD $y" + fi;; + -D*) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD $y";; + -EH*) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD $y";; + -TP|-Tp) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD $y";; + -l*) + y=`echo $x | sed 's,^-l\(.*\),\1,g'`; + LINKCMD="$LINKCMD $x";; + /*.c) + SOURCES="$SOURCES $x";; + *.c) + SOURCES="$SOURCES $x";; + /*.cc) + SOURCES="$SOURCES $x";; + *.cc) + SOURCES="$SOURCES $x";; + /*.cpp) + SOURCES="$SOURCES $x";; + *.cpp) + SOURCES="$SOURCES $x";; + /*.o) + LINKCMD="$LINKCMD $x";; + *.o) + LINKCMD="$LINKCMD $x";; + *) + # Try to quote uninterpreted options + y=`echo $x | sed 's,",\\\",g'`; + LINKCMD="$LINKCMD $y";; + esac + shift +done + +#Return code from compiler, linker.sh and finally this script... +RES=0 + +# Accumulated object names +ACCUM_OBJECTS="" + +# A temporary object file location +TMPOBJDIR=$ERL_TOP/tmpobj$$ +mkdir $TMPOBJDIR + +WINTMPDIR=`w32_path.sh -w $TMPOBJDIR` + +# Sometimes the file server doesn't keep up (paralell file creation) +while true ; do + DIR_EXISTS=$(cd /mnt/c; cmd.exe /C "IF EXIST $WINTMPDIR (echo yes) ELSE (echo no)") + case $DIR_EXISTS in # Contains trash in the end of string + yes*) + break + ;; + *) + if [ "X$CC_SH_DEBUG_LOG" != "X" ]; then + echo "sleep 1" >> $CC_SH_DEBUG_LOG + fi; + echo sleep $WINTMPDIR does not exist >&2 + sleep 1 + esac +done + +# Compile +for x in $SOURCES; do + # Compile each source + if [ $LINKING = false ]; then + # We should have an output defined, which is a directory + # or an object file + case $OUTFILE in + /*.o) + # Simple output, SOURCES should be one single + n=`echo $SOURCES | wc -w`; + if [ $n -gt 1 ]; then + echo "cc.sh:Error, multiple sources, one object output."; + exit 1; + else + output_filename=`echo $OUTFILE`; + fi;; + *.o) + # Relative path needs no translation + n=`echo $SOURCES | wc -w` + if [ $n -gt 1 ]; then + echo "cc.sh:Error, multiple sources, one object output." + exit 1 + else + output_filename=$OUTFILE + fi;; + /*) + # Absolute directory + o=`echo $x | sed 's,.*/,,' | sed 's,\.c$,.o,'` + output_filename=`echo $OUTFILE` + output_filename="$output_filename/${o}";; + *) + # Relative_directory or empty string (.//x.o is valid) + o=`echo $x | sed 's,.*/,,' | sed 's,\.cp*$,.o,'` + output_filename="./${OUTFILE}/${o}";; + esac + else + # We are linking, which means we build objects in a temporary + # directory and link from there. We should retain the basename + # of each source to make examining the exe easier... + o=`echo $x | sed 's,.*/,,' | sed 's,\.c$,.o,'` + output_filename=$TMPOBJDIR/$o + ACCUM_OBJECTS="$ACCUM_OBJECTS $output_filename" + fi + # Now we know enough, lets try a compilation... + if [ $USEABSPATH = true ]; then + MPATH=`w32_path.sh -a -d $x` + else + MPATH=`w32_path.sh -d $x` + fi + if [ $PREPROCESSING = true ]; then + output_flag="-E" + else + output_flag="/FS -c -Fo`w32_path.sh -a -d ${output_filename}`" + fi + params="$COMMON_CFLAGS $MD $DEBUG_FLAGS $OPTIMIZE_FLAGS \ + $CMD ${output_flag} $MPATH" + if [ "X$CC_SH_DEBUG_LOG" != "X" ]; then + echo cc.sh "$SAVE" >>$CC_SH_DEBUG_LOG + echo cl.exe $params >>$CC_SH_DEBUG_LOG + fi + eval cl.exe $params >$MSG_FILE 2>$ERR_FILE + RES=$? + if test $PREPROCESSING = false; then + cat $ERR_FILE >&2 + tail -n +2 $MSG_FILE + else + tail -n +2 $ERR_FILE >&2 + if test $DEPENDENCIES = true; then + perl -e ' +my $file = "'$x'"; +while (<>) { + next unless /^#line/; + next if /$file/o; + (undef,$_) = split(/\"/); + next if / /; + $all{$_} = 1; +} +foreach (sort keys %all) { + my $w_file; + ($w_file) = split("\n",`(w32_path.sh -u $_)`); + push @f, "\\\n $w_file "; +} +if (@f) { + my $oname = $file; + $oname =~ s@.*/@@; + $oname =~ s@[.]cp*@.o@; + print $oname, ":", @f; + print "\n\n"; + print STDERR "Made dependencies for $file\n"; +}' $MSG_FILE + else + cat $MSG_FILE + fi + fi + rm -f $ERR_FILE $MSG_FILE + if [ $RES != 0 ]; then + echo Failed: cl.exe $params + rm -rf $TMPOBJDIR + exit $RES + fi +done + +# If we got here, we succeeded in compiling (if there were anything to compile) +# The output filename should name an executable if we're linking +if [ $LINKING = true ]; then + case $OUTFILE in + "") + # Use the first source name to name the executable + first_source="" + for x in $SOURCES; do first_source=$x; break; done; + if [ -n "$first_source" ]; then + e=`echo $x | sed 's,.*/,,' | sed 's,\.c$,.exe,'`; + out_spec="-o $e"; + else + out_spec=""; + fi;; + *) + out_spec="-o $OUTFILE";; + esac + # Descide which standard library to link against + case $MD in + -ML) + stdlib="-lLIBC";; + -MLd) + stdlib="-lLIBCD";; + -MD) + stdlib="-lMSVCRT";; + -MDd) + stdlib="-lMSVCRTD";; + -MT) + stdlib="-lLIBCMT";; + -MTd) + stdlib="-lLIBMTD";; + esac + # And finally call the next script to do the linking... + params="$out_spec $LINKCMD $stdlib" + if [ "X$CC_SH_DEBUG_LOG" != "X" ]; then + echo ld.sh $ACCUM_OBJECTS $params >>$CC_SH_DEBUG_LOG + fi + eval ld.sh $ACCUM_OBJECTS $params + RES=$? +fi +rm -rf $TMPOBJDIR + +exit $RES diff --git a/erts/etc/win32/wsl_tools/vc/coffix.c b/erts/etc/win32/wsl_tools/vc/coffix.c new file mode 100755 index 0000000000..7428f9cd41 --- /dev/null +++ b/erts/etc/win32/wsl_tools/vc/coffix.c @@ -0,0 +1,161 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1999-2016. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * %CopyrightEnd% + */ +/* +** This mini tool fixes an incompatibility between +** Microsoft's tools, who dont like the virtual size being put in +** the physical address field, but rely on the raw size field for +** sizing the ".bss" section. +** This fixes some of the problems with linking gcc compiled objects +** together with MSVC dito. +** +** Courtesy DJ Delorie for describing the COFF file format on +** http://www.delorie.com/djgpp/doc/coff/ +** The coff structures are fetched from Microsofts headers though. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> + +#include <windows.h> +#include <winnt.h> /* Structure definitions for PE (COFF) */ + +static int dump_edit(char *filename, int edit); +static int v_printf(char *format, ...); + + +char *progname; +int verbouse = 0; + +int main(int argc, char **argv) +{ + int findex = 1; + int edit = 0; + int ret; + + progname = argv[0]; + if (argc == 1) { + fprintf(stderr,"Format : %s [-e] [-v] <filename>\n", progname); + return 1; + } + for (findex = 1; + findex < argc && (*argv[findex] == '-' || *argv[findex] == '/'); + ++findex) + switch (argv[findex][1]) { + case 'e': + case 'E': + edit = 1; + break; + case 'v': + case 'V': + verbouse = 1; + default: + fprintf(stderr, "%s: unknown option %s\n", progname, argv[findex]); + break; + } + if (findex == argc) { + fprintf(stderr,"%s: No filenames given.\n", progname); + return 1; + } + for(; findex < argc; ++findex) + if ((ret = dump_edit(argv[findex],edit)) != 0) + return ret; + return 0; +} + +int dump_edit(char *filename, int edit) +{ + FILE *f = fopen(filename, (edit) ? "r+b" : "rb"); + IMAGE_FILE_HEADER filhdr; + IMAGE_SECTION_HEADER scnhdr; + int i; + + if (f == NULL) { + fprintf(stderr, "%s: cannot open %s.\n", progname, filename); + return 1; + } + + if (fread(&filhdr, sizeof(filhdr), 1, f) == 0) { + fprintf(stderr,"%s: Could not read COFF header from %s," + " is this a PE (COFF) file?\n", progname, filename); + fclose(f); + return 1; + } + v_printf("File: %s\n", filename); + v_printf("Magic number: 0x%08x\n", filhdr.Machine); + v_printf("Number of sections: %d\n",filhdr.NumberOfSections); + + if (fseek(f, (long) filhdr.SizeOfOptionalHeader, SEEK_CUR) != 0) { + fprintf(stderr,"%s: Could not read COFF optional header from %s," + " is this a PE (COFF) file?\n", progname, filename); + fclose(f); + return 1; + } + + for (i = 0; i < filhdr.NumberOfSections; ++i) { + if (fread(&scnhdr, sizeof(scnhdr), 1, f) == 0) { + fprintf(stderr,"%s: Could not read section header from %s," + " is this a PE (COFF) file?\n", progname, filename); + fclose(f); + return 1; + } + v_printf("Section %s:\n", scnhdr.Name); + v_printf("Physical address: 0x%08x\n", scnhdr.Misc.PhysicalAddress); + v_printf("Size: 0x%08x\n", scnhdr.SizeOfRawData); + if (scnhdr.Misc.PhysicalAddress != 0 && + scnhdr.SizeOfRawData == 0) { + printf("Section header %s in file %s will confuse MSC linker, " + "virtual size is 0x%08x and raw size is 0\n", + scnhdr.Name, filename, scnhdr.Misc.PhysicalAddress, + scnhdr.SizeOfRawData); + if (edit) { + scnhdr.SizeOfRawData = scnhdr.Misc.PhysicalAddress; + scnhdr.Misc.PhysicalAddress = 0; + if (fseek(f, (long) -((long)sizeof(scnhdr)), SEEK_CUR) != 0 || + fwrite(&scnhdr, sizeof(scnhdr), 1, f) == 0) { + fprintf(stderr,"%s: could not edit file %s.\n", + progname, filename); + fclose(f); + return 1; + } + printf("Edited object, virtual size is now 0, and " + "raw size is 0x%08x.\n", scnhdr.SizeOfRawData); + } else { + printf("Specify option '-e' to correct the problem.\n"); + } + } + } + fclose(f); + return 0; +} + + +static int v_printf(char *format, ...) +{ + va_list ap; + int ret = 0; + if (verbouse) { + va_start(ap, format); + ret = vfprintf(stdout, format, ap); + va_end(ap); + } + return ret; +} diff --git a/erts/etc/win32/wsl_tools/vc/emu_cc.sh b/erts/etc/win32/wsl_tools/vc/emu_cc.sh new file mode 100755 index 0000000000..00b8555d2b --- /dev/null +++ b/erts/etc/win32/wsl_tools/vc/emu_cc.sh @@ -0,0 +1,100 @@ +#! /bin/sh +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# + +# sudo apt-get install gcc-mingw-w64 on (wsl ubuntu) + +if [ X"$CONFIG_SUBTYPE" = X"win64" ]; then + GCC="x86_64-w64-mingw32-gcc -m64" +else + GCC="x86_64-w64-mingw32-gcc -m32" +fi +TOOLDIR=$ERL_TOP/erts/etc/win32/wsl_tools/vc +COFFIX=$TOOLDIR/coffix +WTOOLDIR=`w32_path.sh -d "$TOOLDIR"` +# Do primitive 'make' +newer_exe=`find $TOOLDIR -newer $COFFIX.c -name coffix.exe -print` + +if [ -z $newer_exe ]; then + echo recompiling $COFFIX.exe + cl.exe -Fe${WTOOLDIR}/coffix.exe ${WTOOLDIR}/coffix.c + rm -f $COFFIX.obj coffix.obj $COFFIX.pdb coffix.pdb +fi + +# Try to find out the output filename and remove it from command line +CMD="" +OUTFILE="" +INFILE="" +SKIP_COFFIX=false +while test -n "$1" ; do + x="$1" + case "$x" in + -o/*) + OUTFILE=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`;; + -o) + shift + OUTFILE=$1;; + -MM) + SKIP_COFFIX=true + CMD="$CMD \"$x\"";; + *.c) + INFILE="$INFILE $x"; + CMD="$CMD \"$x\"";; + *) + CMD="$CMD \"$x\"";; + esac + shift +done +if [ -z "$INFILE" ]; then + echo 'emu_cc.sh: please give an input filename for the compiler' >&2 + exit 1 +fi +if [ -z "$OUTFILE" ]; then + OUTFILE=`echo $INFILE | sed 's,\.c$,.o,'` +fi + +if [ $SKIP_COFFIX = false ]; then + n=`echo $INFILE | wc -w`; + if [ $n -gt 1 ]; then + echo "emu_cc.sh:Error, multiple sources, one object output."; + exit 1; + fi + mkdir -p $ERL_TOP/tmp + TEMPFILE=$ERL_TOP/tmp/tmp_emu_cc$$.o + if [ "X$EMU_CC_SH_DEBUG_LOG" != "X" ]; then + echo "$GCC -o $TEMPFILE -D__WIN32__ -DWIN32 -DWINDOWS -fomit-frame-pointer $CMD" >> $EMU_CC_SH_DEBUG_LOG 2>&1 + fi + eval $GCC -o $TEMPFILE -D__WIN32__ -DWIN32 -DWINDOWS -fomit-frame-pointer $CMD + RES=$? + if [ $RES = 0 ]; then + $COFFIX.exe -e `w32_path.sh -w $TEMPFILE` + RES=$? + if [ $RES = 0 ]; then + cp $TEMPFILE $OUTFILE + else + echo "emu_cc.sh: fatal: coffix failed!" >&2 + fi + fi + rm -f $TEMPFILE + exit $RES +else + eval $GCC -D__WIN32__ -DWIN32 -DWINDOWS -fomit-frame-pointer -fno-tree-copyrename $CMD 2>/dev/null + exit $? +fi diff --git a/erts/etc/win32/wsl_tools/vc/ld.sh b/erts/etc/win32/wsl_tools/vc/ld.sh new file mode 100755 index 0000000000..fc115bec8c --- /dev/null +++ b/erts/etc/win32/wsl_tools/vc/ld.sh @@ -0,0 +1,210 @@ +#! /bin/sh +# set -x +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +# Save the command line for debug outputs + +SAVE="$@" +kernel_libs="kernel32.lib advapi32.lib" +gdi_libs="gdi32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib" +DEFAULT_LIBRARIES="$kernel_libs $gdi_libs" + +CMD="" +STDLIB=MSVCRT.LIB +DEBUG_BUILD=false +STDLIB_FORCED=false +BUILD_DLL=false +OUTPUT_FILENAME="" + +while test -n "$1" ; do + x="$1" + case "$x" in + -dll| -DLL) + BUILD_DLL=true;; + -L/*|-L.*) + y=`echo $x | sed 's,^-L\(.*\),\1,g'`; + MPATH=`w32_path.sh -d $y`; + CMD="$CMD -libpath:\"$MPATH\"";; + -lMSVCRT|-lmsvcrt) + STDLIB_FORCED=true; + STDLIB=MSVCRT.LIB;; + -lMSVCRTD|-lmsvcrtd) + STDLIB_FORCED=true; + STDLIB=MSVCRTD.LIB;; + -lLIBCMT|-llibcmt) + STDLIB_FORCED=true; + STDLIB=LIBCMT.LIB;; + -lLIBCMTD|-llibcmtd) + STDLIB_FORCED=true; + STDLIB=LIBCMTD.LIB;; + -lsocket) + DEFAULT_LIBRARIES="$DEFAULT_LIBRARIES WS2_32.LIB IPHLPAPI.LIB";; + -l*) + y=`echo $x | sed 's,^-l\(.*\),\1,g'`; + MPATH=`w32_path.sh -d $y`; + CMD="$CMD \"${MPATH}.lib\"";; + -g) + DEBUG_BUILD=true;; + -pdb:none|-incremental:no) + ;; + -implib:*) + y=`echo $x | sed 's,^-implib:\(.*\),\1,g'`; + MPATH=`w32_path.sh -d $y`; + CMD="$CMD -implib:\"${MPATH}\"";; + -def:*) + y=`echo $x | sed 's,^-def:\(.*\),\1,g'`; + MPATH=`w32_path.sh -d $y`; + CMD="$CMD -def:\"${MPATH}\"";; + -o) + shift + MPATH=`w32_path.sh -a -d $1`; + OUTPUT_FILENAME="$MPATH";; + -o/*) + y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; + MPATH=`w32_path.sh -a -d $y`; + OUTPUT_FILENAME="$MPATH";; + /*) + MPATH=`w32_path.sh -d $x`; + CMD="$CMD \"$MPATH\"";; + *) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD \"$y\"";; + esac + shift +done +if [ $DEBUG_BUILD = true ]; then + linktype="-debug -pdb:none" + if [ $STDLIB_FORCED = false ]; then + STDLIB=MSVCRTD.LIB + fi +fi +# Generate a PDB +linkadd_pdb="" +case "$OUTPUT_FILENAME" in + *.exe|*.EXE) + fn=`echo "$OUTPUT_FILENAME" | sed 's,[eE][xX][eE]$,,g'`; + # fn=`w32_path.sh -a -d $fn0` + # echo EXE "$OUTPUT_FILENAME" $fn + linkadd_pdb="-pdb:\"${fn}pdb\"";; + *.dll|*.DLL) + fn=`echo "$OUTPUT_FILENAME" | sed 's,[dD][lL][lL]$,,g'`; + # fn=`w32_path.sh -a -d $fn0` + # echo DLL "$OUTPUT_FILENAME" $fn + linkadd_pdb="-pdb:\"${fn}pdb\"";; + "") + linkadd_pdb="-pdb:\"a.pdb\"";; + *) + fn="$OUTPUT_FILENAME" + # fn=`w32_path.sh -a -d $OUTPUT_FILENAME` + # echo * "$OUTPUT_FILENAME" $fn + linkadd_pdb="-pdb:\"${fn}.pdb\"";; +esac + +linktype="-debug $linkadd_pdb" + +CHMOD_FILE="" + +if [ $BUILD_DLL = true ];then + case "$OUTPUT_FILENAME" in + *.exe|*.EXE) + echo "Warning, output set to .exe when building DLL" >&2 + CHMOD_FILE="$OUTPUT_FILENAME"; + CMD="-dll -out:\"$OUTPUT_FILENAME\" $CMD"; + OUTPUTRES="${OUTPUT_FILENAME}\;2"; + MANIFEST="${OUTPUT_FILENAME}.manifest";; + *.dll|*.DLL) + CMD="-dll -out:\"$OUTPUT_FILENAME\" $CMD"; + OUTPUTRES="${OUTPUT_FILENAME}\;2"; + MANIFEST="${OUTPUT_FILENAME}.manifest";; + "") + CMD="-dll -out:\"a.dll\" $CMD"; + OUTPUTRES="a.dll\;2"; + MANIFEST="a.dll.manifest";; + *) + CMD="-dll -out:\"${OUTPUT_FILENAME}.dll\" $CMD"; + OUTPUTRES="${OUTPUT_FILENAME}.dll\;2"; + MANIFEST="${OUTPUT_FILENAME}.dll.manifest";; + esac +else + case "$OUTPUT_FILENAME" in + *.exe|*.EXE) + CHMOD_FILE="$OUTPUT_FILENAME"; + CMD="-out:\"$OUTPUT_FILENAME\" $CMD"; + OUTPUTRES="${OUTPUT_FILENAME}\;1" + MANIFEST="${OUTPUT_FILENAME}.manifest";; + *.dll|*.DLL) + echo "Warning, output set to .dll when building EXE" >&2 + CMD="-out:\"$OUTPUT_FILENAME\" $CMD"; + OUTPUTRES="${OUTPUT_FILENAME}\;1"; + MANIFEST="${OUTPUT_FILENAME}.manifest";; + "") + CHMOD_FILE="a.exe"; + CMD="-out:\"a.exe\" $CMD"; + OUTPUTRES="a.exe\;1"; + MANIFEST="a.exe.manifest";; + *) + CMD="-out:\"${OUTPUT_FILENAME}.exe\" $CMD"; + OUTPUTRES="${OUTPUT_FILENAME}.exe\;1"; + MANIFEST="${OUTPUT_FILENAME}.exe.manifest";; + esac +fi + +p=$$ +CMD="$linktype -nologo -incremental:no $CMD $STDLIB $DEFAULT_LIBRARIES" +if [ "X$LD_SH_DEBUG_LOG" != "X" ]; then + echo ld.sh "$SAVE" >>$LD_SH_DEBUG_LOG + echo link.exe $CMD >>$LD_SH_DEBUG_LOG +fi +eval link.exe "$CMD" >/tmp/link.exe.${p}.1 2>/tmp/link.exe.${p}.2 +RES=$? + +CMANIFEST=`w32_path.sh -u $MANIFEST` + +if [ "$RES" = "0" -a -f "$CMANIFEST" ]; then + # Add stuff to manifest to turn off "virtualization" + sed -n -i '1h;1!H;${;g;s,<trustInfo.*</trustInfo>.,,g;p;}' $CMANIFEST 2>/dev/null + sed -i "s/<\/assembly>/ <ms_asmv2:trustInfo xmlns:ms_asmv2=\"urn:schemas-microsoft-com:asm.v2\">\n <ms_asmv2:security>\n <ms_asmv2:requestedPrivileges>\n <ms_asmv2:requestedExecutionLevel level=\"AsInvoker\" uiAccess=\"false\"\/>\n <\/ms_asmv2:requestedPrivileges>\n <\/ms_asmv2:security>\n <\/ms_asmv2:trustInfo>\n<\/assembly>/" $CMANIFEST 2>/dev/null + + eval mt.exe -nologo -manifest "$MANIFEST" -outputresource:"$OUTPUTRES" >>/tmp/link.exe.${p}.1 2>>/tmp/link.exe.${p}.2 + RES=$? + if [ "$RES" != "0" ]; then + REMOVE=`echo "$OUTPUTRES" | sed 's,\\\;[12]$,,g'` + CREMOVE=`wslpath -u $REMOVE` + ## If Defender or Search are enabled, they will lock just created files + ## and then mt will fail :/ + echo "If you get this error, make sure Windows Defender AND Windows Search is disabled">>/tmp/link.exe.${p}.1 + rm -f "$CREMOVE" + fi + rm -f "$CMANIFEST" +fi + +# This works around some strange behaviour +# in cygwin 1.7 Beta on Windows 7 with samba drive. +# Configure will think the compiler failed if test -x fails, +# which it might do as we might not be the owner of the +# file. +if [ '!' -z "$CHMOD_FILE" -a -s "$CHMOD_FILE" -a '!' -x "$CHMOD_FILE" ]; then + chmod +x $CHMOD_FILE +fi + +tail -n +2 /tmp/link.exe.${p}.2 >&2 +cat /tmp/link.exe.${p}.1 +rm -f /tmp/link.exe.${p}.2 /tmp/link.exe.${p}.1 +exit $RES diff --git a/erts/etc/win32/wsl_tools/vc/mc.sh b/erts/etc/win32/wsl_tools/vc/mc.sh new file mode 100755 index 0000000000..4ed7e7e2a3 --- /dev/null +++ b/erts/etc/win32/wsl_tools/vc/mc.sh @@ -0,0 +1,96 @@ +#! /bin/sh +# set -x +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +# Save the command line for debug outputs +SAVE="$@" +CMD="" +OUTPUT_DIRNAME="" + +# Find the correct mc.exe. This could be done by the configure script, +# But as we seldom use the message compiler, it might as well be done here... +MCC="" +save_ifs=$IFS +IFS=: +for p in $PATH; do + if [ -f $p/mc.exe ]; then + if [ -n "`$p/mc.exe -? 2>&1 >/dev/null </dev/null \ + | grep -i \"message compiler\"`" ]; then + MCC=`echo "mc.exe" | sed 's/ /\\\\ /g'` + break + else + echo "Bad mc.exe in path" >&2 + exit 1 + fi + fi +done +IFS=$save_ifs + +if [ -z "$MCC" ]; then + echo 'mc.exe not found!' >&2 + exit 1 +fi + +while test -n "$1" ; do + x="$1" + case "$x" in + -o) + shift + OUTPUT_DIRNAME="$1";; + -o/*) + y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; + OUTPUT_DIRNAME="$y";; + -I) + shift + MPATH=`w32_path.sh -d $1`; + CMD="$CMD -I\"$MPATH\"";; + -I/*) + y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; + MPATH=`w32_path.sh -d $y`; + CMD="$CMD -I\"$MPATH\"";; + *) + MPATH=`w32_path.sh -d -a $x`; + CMD="$CMD \"$MPATH\"";; + esac + shift +done +p=$$ +if [ "X$MC_SH_DEBUG_LOG" != "X" ]; then + echo mc.sh "$SAVE" >>$MC_SH_DEBUG_LOG + echo mc.exe $CMD >>$MC_SH_DEBUG_LOG +fi +if [ -n "$OUTPUT_DIRNAME" ]; then + cd $OUTPUT_DIRNAME + RES=$? + if [ "$RES" != "0" ]; then + echo "mc.sh: Error: could not cd to $OUTPUT_DIRNAME">&2 + exit $RES + fi +fi + +eval $MCC "$CMD" >/tmp/mc.exe.${p}.1 2>/tmp/mc.exe.${p}.2 +RES=$? +if [ $RES != 0 ]; then + echo Failed: $MCC "$CMD" +fi +tail -n +2 /tmp/mc.exe.${p}.2 >&2 +cat /tmp/mc.exe.${p}.1 +rm -f /tmp/mc.exe.${p}.2 /tmp/mc.exe.${p}.1 +exit $RES diff --git a/erts/etc/win32/wsl_tools/vc/rc.sh b/erts/etc/win32/wsl_tools/vc/rc.sh new file mode 100755 index 0000000000..bbd5c9a773 --- /dev/null +++ b/erts/etc/win32/wsl_tools/vc/rc.sh @@ -0,0 +1,94 @@ +#! /bin/sh +# set -x +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 2002-2016. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# +# Save the command line for debug outputs +SAVE="$@" +CMD="" +OUTPUT_FILENAME="" + +# Find the correct rc.exe. This could be done by the configure script, +# But as we seldom use the resource compiler, it might as well be done here... +RCC="" +save_ifs=$IFS +IFS=: +for p in $PATH; do + if [ -f $p/rc.exe ]; then + if [ -n "`$p/rc.exe -? 2>&1 | grep -i "resource compiler"`" ]; then + RCC="rc.exe /nologo" + break + else + echo "Bad rc.exe in path" >&2 + exit 1 + fi + fi +done +IFS=$save_ifs + +if [ -z "$RCC" ]; then + echo 'rc.exe not found!' >&2 + exit 1 +fi + +while test -n "$1" ; do + x="$1" + case "$x" in + -o) + shift + MPATH=`w32_path.sh -d $1`; + OUTPUT_FILENAME="$MPATH";; + -o/*) + y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; + MPATH=`w32_path.sh -d $y`; + OUTPUT_FILENAME="$MPATH";; + -I) + shift + MPATH=`w32_path.sh -d $1`; + CMD="$CMD -I\"$MPATH\"";; + -I/*) + y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; + MPATH=`w32_path.sh -d $y`; + CMD="$CMD -I\"$MPATH\"";; + /*) + MPATH=`w32_path.sh -d $x`; + CMD="$CMD \"$MPATH\"";; + *) + y=`echo $x | sed 's,",\\\",g'`; + CMD="$CMD \"$y\"";; + esac + shift +done +p=$$ +if [ -n "$OUTPUT_FILENAME" ]; then + CMD="-Fo$OUTPUT_FILENAME $CMD" +fi +if [ "X$RC_SH_DEBUG_LOG" != "X" ]; then + echo rc.sh "$SAVE" >>$RC_SH_DEBUG_LOG + echo rc.exe /nologo $CMD >>$RC_SH_DEBUG_LOG +fi +eval $RCC "$CMD" >/tmp/rc.exe.${p}.1 2>/tmp/rc.exe.${p}.2 +RES=$? +if [ $RES != 0 ]; then + echo Failed: $RCC "$CMD" +fi +tail -n +2 /tmp/rc.exe.${p}.2 >&2 +cat /tmp/rc.exe.${p}.1 +rm -f /tmp/rc.exe.${p}.2 /tmp/rc.exe.${p}.1 +exit $RES diff --git a/erts/etc/win32/wsl_tools/w32_path.sh b/erts/etc/win32/wsl_tools/w32_path.sh new file mode 100755 index 0000000000..55fbd76174 --- /dev/null +++ b/erts/etc/win32/wsl_tools/w32_path.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +WIN32=false +SEPARATOR="" +ABSOLUTE="" +UNIX=false +done=false +while [ $done = false ]; do + case "$1" in + -w) + WIN32=true; + SEPARATOR=backslash; + shift;; + -d) + WIN32=true; + SEPARATOR=double; + shift;; + -m) + WIN32=true; + SEPARATOR=slash; + shift;; + -u) + UNIX=true; + shift;; + -a) + ABSOLUTE="-a"; + shift;; + + *) + done=true;; + esac +done + +if [ $WIN32 = false -a $UNIX = false ]; then + echo "Usage: $0 -m|-w|-d|-u [-a] <path>" >&2 + exit 1; +fi + +if [ -z "$1" ]; then + echo "Usage: $0 -m|-w|-u [-a] <path>" >&2 + exit 1; +fi + +if [ $UNIX = true ]; then + # cl.exe loses //// in the beginning which make dependencies fail + # and sometimes lowercases the path + case $1 in + \\*wsl$\\*) + y=`echo $1 | sed 's,\\\\\+,/,g'`; + z=`echo $y | sed 's,^/wsl$/[^/]*\(.*\),\1,g' | sed 's, ,\\ ,g'`; + echo "$z"; + ;; + *) + echo `wslpath -u $ABSOLUTE "$1" | sed 's, ,\\ ,g'` + ;; + esac +else + case "$SEPARATOR" in + slash) + echo `wslpath -m $ABSOLUTE "$1"`; + ;; + backslash) + echo `wslpath -w $ABSOLUTE "$1"`; + ;; + double) + DOUBLE=`wslpath -w $ABSOLUTE "$1" | sed 's,\\\\,\\\\\\\\,g'`; + echo $DOUBLE + ;; + esac +fi diff --git a/lib/crypto/c_src/Makefile.in b/lib/crypto/c_src/Makefile.in index f922c3fb9b..20c32cb8d6 100644 --- a/lib/crypto/c_src/Makefile.in +++ b/lib/crypto/c_src/Makefile.in @@ -37,13 +37,14 @@ LIBS = @DED_LIBS@ LDFLAGS += @DED_LDFLAGS@ CFLAGS = @DED_CFLAGS@ @SSL_FLAGS@ -# From erts/configure +# From configure SSL_LIBDIR = @SSL_LIBDIR@ SSL_INCLUDE = @SSL_INCLUDE@ SSL_CRYPTO_LIBNAME = @SSL_CRYPTO_LIBNAME@ SSL_SSL_LIBNAME = @SSL_SSL_LIBNAME@ INCLUDES = $(SSL_INCLUDE) @DED_INCLUDE@ +SSL_EXTRA_LIBS=@SSL_EXTRA_LIBS@ ifeq ($(TYPE),debug) TYPEMARKER = .debug @@ -164,7 +165,7 @@ $(LIBDIR)/otp_test_engine$(TYPEMARKER).so: $(TEST_ENGINE_OBJS) $(LIBDIR)/otp_test_engine$(TYPEMARKER).dll: $(TEST_ENGINE_OBJS) $(V_at)$(INSTALL_DIR) $(LIBDIR) - $(V_LD) $(LDFLAGS) -o $@ $(SSL_DED_LD_RUNTIME_LIBRARY_PATH) -L$(SSL_LIBDIR) $(TEST_ENGINE_OBJS) -l$(SSL_CRYPTO_LIBNAME) -l$(SSL_SSL_LIBNAME) + $(V_LD) $(LDFLAGS) -o $@ $(SSL_DED_LD_RUNTIME_LIBRARY_PATH) -L$(SSL_LIBDIR) $(TEST_ENGINE_OBJS) -l$(SSL_CRYPTO_LIBNAME) -l$(SSL_SSL_LIBNAME) $(SSL_EXTRA_LIBS) $(OBJDIR)/%$(TYPEMARKER).o: %.c $(V_at)$(INSTALL_DIR) $(OBJDIR) @@ -184,7 +185,7 @@ $(LIBDIR)/crypto$(TYPEMARKER).a: $(CRYPTO_STATIC_OBJS) $(LIBDIR)/crypto$(TYPEMARKER).dll: $(CRYPTO_OBJS) $(V_at)$(INSTALL_DIR) $(LIBDIR) - $(V_LD) $(LDFLAGS) -o $@ $(SSL_DED_LD_RUNTIME_LIBRARY_PATH) -L$(SSL_LIBDIR) $(CRYPTO_OBJS) -l$(SSL_CRYPTO_LIBNAME) -l$(SSL_SSL_LIBNAME) + $(V_LD) $(LDFLAGS) -o $@ $(SSL_DED_LD_RUNTIME_LIBRARY_PATH) -L$(SSL_LIBDIR) $(CRYPTO_OBJS) -l$(SSL_CRYPTO_LIBNAME) -l$(SSL_SSL_LIBNAME) $(SSL_EXTRA_LIBS) ifeq ($(DYNAMIC_CRYPTO_LIB),yes) $(LIBDIR)/crypto_callback$(TYPEMARKER).so: $(CALLBACK_OBJS) diff --git a/lib/crypto/configure.in b/lib/crypto/configure.in index 5f270e8ffb..1c36357ebd 100644 --- a/lib/crypto/configure.in +++ b/lib/crypto/configure.in @@ -227,7 +227,7 @@ case "$erl_xcomp_without_sysroot-$with_ssl" in key="Inno Setup: App Path" if "$ac_cv_prog_REGTOOL" "$rp" "$key" > /dev/null; then ssl_install_dir=`"$ac_cv_prog_REGTOOL" "$rp" "$key"` - extra_dir=`win32_path.sh "$ssl_install_dir"` + extra_dir=`w32_path.sh -u "$ssl_install_dir"` fi fi fi @@ -238,12 +238,15 @@ case "$erl_xcomp_without_sysroot-$with_ssl" in SSL_CRYPTO_LIBNAME=crypto SSL_SSL_LIBNAME=ssl + SSL_EXTRA_LIBS="" if test "$host_os" = "win32" ; then if test "x$ac_cv_sizeof_void_p" = "x8"; then - std_win_ssl_locations="/cygdrive/c/OpenSSL-Win64 /c/OpenSSL-Win64 /opt/local64/pgm/OpenSSL" + std_win_ssl_locations="/mnt/c/OpenSSL-Win64 /c/OpenSSL-Win64 /mnt/c/opt/local64/pgm/OpenSSL /opt/local64/pgm/OpenSSL /cygdrive/c/OpenSSL-Win64" + lib_bits=64 else - std_win_ssl_locations="/cygdrive/c/OpenSSL-Win32 /c/OpenSSL-Win32 /cygdrive/c/OpenSSL /c/OpenSSL /opt/local/pgm/OpenSSL" + std_win_ssl_locations="/mnt/c/OpenSSL-Win32 /c/OpenSSL-Win32 /mnt/c/OpenSSL /c/OpenSSL /cygdrive/c/OpenSSL /opt/local/pgm/OpenSSL /opt/local32/pgm/OpenSSL /mnt/c/opt/local/pgm/OpenSSL /mnt/c/opt/local32/pgm/OpenSSL /cygdrive/c/OpenSSL-Win32" + lib_bits=32 fi else std_win_ssl_locations="" @@ -251,7 +254,7 @@ case "$erl_xcomp_without_sysroot-$with_ssl" in AC_MSG_CHECKING(for OpenSSL >= 0.9.8c in standard locations) - for rdir in $extra_dir $std_win_ssl_locations $std_ssl_locations; do + for rdir in "$extra_dir" $std_win_ssl_locations $std_ssl_locations; do dir="$erl_xcomp_sysroot$rdir" if test -f "$erl_xcomp_isysroot$rdir/include/openssl/opensslv.h"; then is_real_ssl=yes @@ -265,11 +268,11 @@ case "$erl_xcomp_without_sysroot-$with_ssl" in elif test -f "$dir/lib/VC/openssl.lib"; then SSL_RUNTIME_LIBDIR="$rdir/lib/VC" SSL_LIBDIR="$dir/lib/VC" - elif test -f $dir/lib/VC/libeay32MD.lib; then + elif test -f "$dir/lib/VC/libeay32MD.lib"; then SSL_CRYPTO_LIBNAME=libeay32MD SSL_SSL_LIBNAME=ssleay32MD if test "x$enable_dynamic_ssl" = "xno" && \ - test -f $dir/lib/VC/static/libeay32MD.lib; then + test -f "$dir/lib/VC/static/libeay32MD.lib"; then SSL_RUNTIME_LIBDIR="$rdir/lib/VC/static" SSL_LIBDIR="$dir/lib/VC/static" else @@ -281,6 +284,19 @@ case "$erl_xcomp_without_sysroot-$with_ssl" in SSL_LIBDIR="$dir/lib" SSL_CRYPTO_LIBNAME=libeay32 SSL_SSL_LIBNAME=ssleay32 + elif test -f "$dir/lib/VC/libcrypto${lib_bits}MD.lib"; then + SSL_CRYPTO_LIBNAME=libcrypto${lib_bits}MD + # NOTE: Additional ugly extra libs at the end + SSL_SSL_LIBNAME="libssl${lib_bits}MD" + if test "x$enable_dynamic_ssl" = "xno" && \ + test -f "$dir/lib/VC/static/$SSL_CRYPTO_LIBNAME.lib"; then + SSL_EXTRA_LIBS="-lCRYPT32 -lWS2_32" + SSL_RUNTIME_LIBDIR="$rdir/lib/VC/static" + SSL_LIBDIR="$dir/lib/VC/static" + else + SSL_RUNTIME_LIBDIR="$rdir/lib/VC" + SSL_LIBDIR="$dir/lib/VC" + fi elif test -f "$dir/lib/openssl.lib"; then SSL_RUNTIME_LIBDIR="$rdir/lib" SSL_LIBDIR="$dir/lib" @@ -324,7 +340,7 @@ case "$erl_xcomp_without_sysroot-$with_ssl" in SSL_INCLUDE="-I$dir/include" old_CPPFLAGS=$CPPFLAGS CPPFLAGS=$SSL_INCLUDE - AC_EGREP_CPP(^yes$,[ + AC_EGREP_CPP(^yes.?$,[ #include <openssl/opensslv.h> #if OPENSSL_VERSION_NUMBER >= 0x0090803fL yes @@ -457,6 +473,7 @@ dnl so it is - be adoptable SSL_INCDIR="$with_ssl_incl" SSL_CRYPTO_LIBNAME=crypto SSL_SSL_LIBNAME=ssl + SSL_EXTRA_LIBS="" if test "x$host_os" = "xwin32" && test -d "$with_ssl/lib/VC"; then if test -f "$with_ssl/lib/VC/libeay32.lib"; then SSL_LIBDIR="$with_ssl/lib/VC" @@ -472,15 +489,33 @@ dnl so it is - be adoptable SSL_LIBDIR="$with_ssl/lib/VC/static" else SSL_LIBDIR="$with_ssl/lib/VC" - fi + fi + elif test -f "$dir/lib/VC/libcrypto${lib_bits}MD.lib"; then + SSL_CRYPTO_LIBNAME=libcrypto${lib_bits}MD + # NOTE: Additional ugly extra libs at the end + SSL_SSL_LIBNAME="libssl${lib_bits}MD" + if test "x$enable_dynamic_ssl" = "xno" && \ + test -f "$dir/lib/VC/static/$SSL_CRYPTO_LIBNAME.lib"; then + SSL_EXTRA_LIBS="-lCRYPT32 -lWS2_32" + SSL_RUNTIME_LIBDIR="$rdir/lib/VC/static" + SSL_LIBDIR="$dir/lib/VC/static" + else + SSL_RUNTIME_LIBDIR="$rdir/lib/VC" + SSL_LIBDIR="$dir/lib/VC" + fi elif test -f "$with_ssl/lib/libeay32.lib"; then SSL_LIBDIR="$with_ssl/lib" SSL_CRYPTO_LIBNAME=libeay32 SSL_SSL_LIBNAME=ssleay32 + elif test -f "$dir/lib/openssl.lib"; then + SSL_RUNTIME_LIBDIR="$rdir/lib" + SSL_LIBDIR="$dir/lib" + SSL_CRYPTO_LIBNAME=libcrypto + SSL_SSL_LIBNAME=openssl else # This probably wont work, but that's what the user said, so... SSL_LIBDIR="$with_ssl/lib" - fi + fi elif test -f "$dir/lib/powerpc/libsslcrypto.a"; then SSL_CRYPTO_LIBNAME=sslcrypto SSL_LIBDIR="$with_ssl/lib/powerpc/" @@ -502,7 +537,7 @@ dnl so it is - be adoptable if test '!' -f "${SSL_LIBDIR}/lib${SSL_CRYPTO_LIBNAME}.a"; then SSL_DYNAMIC_ONLY=yes elif test '!' -f ${SSL_LIBDIR}/lib${SSL_CRYPTO_LIBNAME}.so -a '!' -f "$SSL_LIBDIR/lib${SSL_CRYPTO_LIBNAME}.dylib"; then - SSL_STATIC_ONLY=yes + SSL_STATIC_ONLY=yes fi SSL_INCLUDE="-I$with_ssl_incl/include" SSL_APP=ssl @@ -736,6 +771,7 @@ AC_SUBST(SSL_LIBDIR) AC_SUBST(SSL_FLAGS) AC_SUBST(SSL_CRYPTO_LIBNAME) AC_SUBST(SSL_SSL_LIBNAME) +AC_SUBST(SSL_EXTRA_LIBS) AC_SUBST(SSL_DED_LD_RUNTIME_LIBRARY_PATH) AC_SUBST(SSL_DYNAMIC_ONLY) AC_SUBST(SSL_LINK_WITH_KERBEROS) diff --git a/lib/ssl/src/Makefile b/lib/ssl/src/Makefile index e961f05b37..cc43a3c1cc 100644 --- a/lib/ssl/src/Makefile +++ b/lib/ssl/src/Makefile @@ -142,6 +142,13 @@ DEPDIR=$(ERL_TOP)/lib/ssl/src/deps DEP_FILE=$(DEPDIR)/ssl.d $(shell mkdir -p $(dir $(DEP_FILE)) >/dev/null) +ifeq ($(TARGET), win32) + # Native path without C: ignore driveletter case + ERL_TOP_NATIVE = $(shell w32_path.sh -m $(ERL_TOP) | sed "s@[a-zA-Z]:@:@") +else + ERL_TOP_NATIVE = $(ERL_TOP) +endif + # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- @@ -151,7 +158,6 @@ ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/kernel/src \ -pz $(ERL_TOP)/lib/public_key/ebin \ $(EXTRA_ERLC_FLAGS) - # ---------------------------------------------------- # Targets # ---------------------------------------------------- @@ -159,8 +165,9 @@ ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/kernel/src \ $(TARGET_FILES): $(BEHAVIOUR_TARGET_FILES) $(DEP_FILE): $(ERL_FILES) + @echo SED $(TARGET) $(ERL_TOP_NATIVE) $(gen_verbose)erlc -M $(ERL_FILES) \ - | sed "s@$(ERL_TOP)@../../..@g" \ + | sed "s@[a-zA-Z]\?$(ERL_TOP_NATIVE)@../../..@g" \ | sed "s/\.$(EMULATOR)/\.$$\(EMULATOR\)/" \ | sed 's@^dtls_@$$(EBIN)/dtls_@' \ | sed 's@^inet_@$$(EBIN)/inet_@' \ diff --git a/lib/wx/configure.in b/lib/wx/configure.in index 9e62d81c5f..5a69738544 100644 --- a/lib/wx/configure.in +++ b/lib/wx/configure.in @@ -392,7 +392,7 @@ define(wx_warn_text,[ fi else AC_MSG_CHECKING(for wxWidgets in standard locations) - + echo # Check whether --with-wxdir was given. AC_MSG_NOTICE(OptionCheck: [$with_wxdir $with_wx_prefix]) @@ -403,7 +403,6 @@ else if test "${with_wx_prefix+set}" = set; then : withval=$with_wx_prefix; CWXWIN0=$withval else - echo Setting it empty CWXWIN0="" fi fi @@ -413,7 +412,7 @@ else CWXWIN2=`dirname $CWXWIN1 2>/dev/null` if test -z "$PROGRAMFILES" ; then - PROGRAMFILES="c:/Program\ Files" + PROGRAMFILES="c:/Program Files" fi CWXWIN_PROG=`win32_path.sh -u "$PROGRAMFILES" 2>/dev/null` @@ -421,18 +420,23 @@ else CWXWIN3="$CWXWIN_PROG/wxWidgets-3.*.* $CWXWIN_PROG/wxWidgets-2.*.*" CWXWIN4="$CWXWIN_PROG/wxMSW-3.*.* $CWXWIN_PROG/wxMSW-2.*.*" - DOC_OPT=/opt/local/pgm - CWX_DOCUMENTED="$DOC_OPT/wxWidgets-2.*.* $DOC_OPT/wxMSW-2.*.*" - CWX_DOCUMENTED="$DOC_OPT/wxWidgets-3.*.* $DOC_OPT/wxMSW-3.*.* $CWX_DOCUMENTED" + DOC_OPT1=/opt/local/pgm + DOC_OPT2=/mnt/c/opt/local/pgm + CWX_DOCUMENTED="$DOC_OPT1/wxWidgets-3.*.* $DOC_OPT1/wxMSW-3.*.*" + CWX_DOCUMENTED="$DOC_OPT2/wxWidgets-3.*.* $DOC_OPT2/wxMSW-3.*.* $CWX_DOCUMENTED" case $ac_cv_sizeof_void_p in 8) - DOC_OPT64=/opt/local64/pgm - CWX_DOCUMENTED="$DOC_OPT64/wxWidgets-2.*.* $DOC_OPT64/wxMSW-2.*.* $CWX_DOCUMENTED" - CWX_DOCUMENTED="$DOC_OPT64/wxWidgets-3.*.* $DOC_OPT64/wxMSW-3.*.* $CWX_DOCUMENTED" + DOC_OPT64_1=/opt/local64/pgm + DOC_OPT64_2=/mnt/c/opt/local64/pgm + CWX_DOCUMENTED="$DOC_OPT64_1/wxWidgets-3.*.* $DOC_OPT64_1/wxMSW-3.*.* $CWX_DOCUMENTED" + CWX_DOCUMENTED="$DOC_OPT64_2/wxWidgets-3.*.* $DOC_OPT64_2/wxMSW-3.*.* $CWX_DOCUMENTED" ;; *) - true + DOC_OPT3=/opt/local32/pgm + DOC_OPT4=/mnt/c/opt/local32/pgm + CWX_DOCUMENTED="$DOC_OPT3/wxWidgets-3.*.* $DOC_OPT3/wxMSW-3.*.* $CWX_DOCUMENTED" + CWX_DOCUMENTED="$DOC_OPT4/wxWidgets-3.*.* $DOC_OPT4/wxMSW-3.*.* $CWX_DOCUMENTED" ;; esac @@ -451,7 +455,7 @@ else WX_RESCOMP="rc.sh -I$WXINCLUDE_PLAIN -D __WIN32__" RC_FILE_TYPE=res for lib in $WX_LIBDIR $WX_LIBDIR64; do - maybe=`ls $lib/wxbase*.lib | egrep 'wxbase[[0-9]]*u\.lib'` + maybe=`ls $lib/wxbase*.lib 2> /dev/null | egrep 'wxbase[[0-9]]*u\.lib'` if test '!' -z "$maybe"; then corelib_number=`echo $maybe | sed 's,.*\([[0-9]].\)u\.lib,\1,'` WX_LIBDIR=$lib @@ -493,7 +497,36 @@ if test "$WXERL_CAN_BUILD_DRIVER" != "false"; then AC_SUBST(WX_HAVE_STATIC_LIBS) AC_SUBST(RC_FILE_TYPE) -AC_MSG_CHECKING(if wxwidgets have opengl support) +AC_MSG_CHECKING(for wxwidgets 2.8 compatibility ) +AC_LANG_PUSH(C++) +saved_CXXFLAGS=$CXXFLAGS +CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS" + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #ifdef WIN32 + # include <windows.h> + #endif + #include "wx/wx.h" + ]], [[ + #if wxMAJOR_VERSION > 2 && WXWIN_COMPATIBILITY_2_8 == 1 + ; + #else + #error barf + #endif + ]])], + HAVE_COMPAT28_SUPPORT=yes, HAVE_COMPAT28_SUPPORT=no) + +CXXFLAGS=$saved_CXXFLAGS +AC_LANG_POP(C++) +AC_MSG_RESULT($HAVE_COMPAT28_SUPPORT) + +if test X"$HAVE_COMPAT28_SUPPORT" != X"yes" ; then + echo "wxWidgets was not compiled with --enable-compat28, wx will NOT be useable" >> ./CONF_INFO + WXERL_CAN_BUILD_DRIVER=false +fi + +AC_MSG_CHECKING(for wxwidgets opengl support) AC_LANG_PUSH(C++) saved_CXXFLAGS=$CXXFLAGS CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS" @@ -754,6 +754,66 @@ echo_env_msys () echo_envinfo } +echo_env_wsl () +{ + X64=$1 + #echo_envinfo + if [ X"$SHELL" = X"" ]; then + echo "You need to export the shell variable first," \ + "for bourne-like shells, type:" >&2 + echo 'export SHELL' >&2 + echo "and for csh-like shells, type:" >&2 + echo 'setenv SHELL $SHELL' >&2 + echo " - then try again." >&2 + exit 1 + fi + echo_env_erltop + + WIN32_WRAPPER_PATH="$ERL_TOP/erts/etc/win32/wsl_tools/vc:$ERL_TOP/erts/etc/win32/wsl_tools" + + if [ ! -n "`lookup_prog_in_path cl`" ]; then + if [ X"$X64" = X"true" ]; then + setup_win32_cl_env "x64" `wslpath -a -m erts/etc/win32/wsl_tools/SetupWSLcross.bat` + else + setup_win32_cl_env "x86" `wslpath -a -m erts/etc/win32/wsl_tools/SetupWSLcross.bat` + fi + fi + echo_setenv OVERRIDE_TARGET win32 ';' + if [ X"$X64" = X"true" ]; then + echo_setenv CONFIG_SUBTYPE win64 ';' + fi + echo_setenv WSLcross true ';' + echo_setenv CC cc.sh ';' + echo_setenv CXX cc.sh ';' + echo_setenv AR ar.sh ';' + echo_setenv RANLIB true ';' + if [ X"$X64" = X"true" ]; then + if [ -f "$ERL_TOP/erts/autoconf/win64.config.cache.static" ]; then + echo_setenv OVERRIDE_CONFIG_CACHE_STATIC "$ERL_TOP/erts/autoconf/win64.config.cache.static" ';' + fi + echo_setenv OVERRIDE_CONFIG_CACHE "$ERL_TOP/erts/autoconf/win64.config.cache" ';' + else + if [ -f "$ERL_TOP/erts/autoconf/win32.config.cache.static" ]; then + echo_setenv OVERRIDE_CONFIG_CACHE_STATIC "$ERL_TOP/erts/autoconf/win32.config.cache.static" ';' + fi + echo_setenv OVERRIDE_CONFIG_CACHE "$ERL_TOP/erts/autoconf/win32.config.cache" ';' + fi + echo_setenv WIN32_WRAPPER_PATH "$WIN32_WRAPPER_PATH" ';' + echo_setenv PATH "$WIN32_WRAPPER_PATH:$PATH" ';' + echo_envinfo +} + + +setup_win32_cl_env () +{ + eval `cmd.exe /c $2 $1` + echo_setenv INCLUDE "$INCLUDE" ';' + echo_setenv LIB "$LIB" ';' + echo_setenv LIBPATH "$LIBPATH" ';' + echo_setenv VCToolsRedistDir "$VCToolsRedistDir" ';' + echo_setenv WSLENV "$WSLENV" ';' +} + lookup_prog_in_path () { PROG=$1 @@ -1044,8 +1104,13 @@ case $TARGET in 'the command' exit 1 fi;; - *) - ;; + *) + if [ -x /bin/wslpath -a X"$OVERRIDE_TARGET" = X"" \ + -a X"$1" != X"env_win32" -a X"$1" != X"env_msys32" -a X"$1" != X"env_msys64" ]; then + echo "Building linux binary; if you intended to cross build for win32 use" >&2 + echo ' eval `./otp_build env_win32`\n' >&2 + fi + ;; esac if [ ! -z "$OVERRIDE_TARGET" ]; then @@ -1162,7 +1227,9 @@ case "$1" in if [ x"$2" = x"x64" -o x"$2" = x"amd64" ]; then ISX64=true fi - if [ -x /usr/bin/msys-?.0.dll ]; then + if [ -x /bin/wslpath ]; then + echo_env_wsl $ISX64 + elif [ -x /usr/bin/msys-?.0.dll ]; then echo_env_msys $ISX64 else echo_env_cygwin $ISX64 @@ -1170,7 +1237,9 @@ case "$1" in env_mingw32) echo_env_mingw32;; env_win64) - if [ -x /usr/bin/msys-?.0.dll ]; then + if [ -x /bin/wslpath ]; then + echo_env_wsl true + elif [ -x /usr/bin/msys-?.0.dll ]; then echo_env_msys true else echo_env_cygwin true |