#!/bin/sh # This file is a part of Julia. License is MIT: https://julialang.org/license # Script to compile Windows Julia, using binary dependencies from nightlies. # Should work in MSYS assuming 7zip is installed and on the path, # or Cygwin or Linux assuming make, curl, p7zip, and mingw64-$ARCH-gcc-g++ # are installed # Run in top-level Julia directory cd $[dirname $0]/../.. # Stop on error set -e # Make sure stdin exists (not true on appveyor msys2) exec < /dev/null setglobal curlflags = '"curl --retry 10 -k -L -y 5'" proc checksum_download { # checksum_download filename url setglobal f = $1 setglobal url = $2 if test -e $f { deps/tools/jlchecksum $f !2 > /dev/null && return echo "Checksum for '$f' changed, download again." > !2 } echo "Downloading '$f'" $curlflags -O $url deps/tools/jlchecksum $f } # If ARCH environment variable not set, choose based on uname -m if test -z $ARCH -a -z $XC_HOST { export ARCH=$[uname -m] } elif test -z $ARCH { setglobal ARCH = $[echo $XC_HOST | sed 's/-w64-mingw32//] } echo "" > Make.user echo "" > get-deps.log # set MARCH for consistency with how binaries get built if test $ARCH = x86_64 { setglobal bits = '64' setglobal archsuffix = '64' setglobal exc = 'seh' echo "override MARCH = x86-64" >> Make.user echo 'USE_BLAS64 = 1' >> Make.user echo 'LIBBLAS = -L$(JULIAHOME)/usr/bin -lopenblas64_' >> Make.user echo 'LIBBLASNAME = libopenblas64_' >> Make.user } else { setglobal bits = '32' setglobal archsuffix = '86' setglobal exc = 'sjlj' echo "override MARCH = pentium4" >> Make.user echo 'LIBBLAS = -L$(JULIAHOME)/usr/bin -lopenblas' >> Make.user echo 'LIBBLASNAME = libopenblas' >> Make.user } # Set XC_HOST if in Cygwin or Linux match $[uname] { with CYGWIN* if test -z $XC_HOST { setglobal XC_HOST = ""$ARCH-w64-mingw32"" echo "XC_HOST = $XC_HOST" >> Make.user } setglobal CROSS_COMPILE = ""$XC_HOST-"" # Set BUILD_MACHINE and HOSTCC in case we don't have Cygwin gcc installed echo "override BUILD_MACHINE = $ARCH-pc-cygwin" >> Make.user if test -z $[which gcc !2 >/dev/null] { echo 'override HOSTCC = $(CROSS_COMPILE)gcc' >> Make.user } setglobal SEVENZIP = '"7z'" with Linux if test -z $XC_HOST { setglobal XC_HOST = ""$ARCH-w64-mingw32"" echo "XC_HOST = $XC_HOST" >> Make.user } setglobal CROSS_COMPILE = ""$XC_HOST-"" make win-extras >> get-deps.log setglobal SEVENZIP = '"wine dist-extras/7z.exe'" with * setglobal CROSS_COMPILE = ''"" setglobal SEVENZIP = '"7z'" } # Download most recent Julia binary for dependencies if ! test -e julia-installer.exe { setglobal f = "julia-latest-win$bits.exe" echo "Downloading $f" $curlflags -O https://julialangnightlies-s3.julialang.org/bin/winnt/x$archsuffix/$f echo "Extracting $f" $SEVENZIP x -y $f >> get-deps.log } mkdir -p usr for i in [bin/*.dll] { $SEVENZIP e -y julia-installer.exe $i \ -ousr'\'$[dirname $i | sed -e 's|/julia||' -e 's|/|\\\\|g] >> get-deps.log } for i in [share/julia/base/pcre_h.jl] { $SEVENZIP e -y julia-installer.exe $i -obase >> get-deps.log } echo "override PCRE_INCL_PATH =" >> Make.user # Remove libjulia.dll if it was copied from downloaded binary rm -f usr/bin/libjulia.dll rm -f usr/bin/libjulia-debug.dll rm -f usr/bin/libgcc_s_s*-1.dll rm -f usr/bin/libgfortran-3.dll rm -f usr/bin/libquadmath-0.dll rm -f usr/bin/libssp-0.dll rm -f usr/bin/libstdc++-6.dll if test -z $USEMSVC { if test -z $[which $(CROSS_COMPILE)gcc !2 >/dev/null] { setglobal f = "$ARCH-4.9.2-release-win32-$exc-rt_v4-rev3.7z" checksum_download \ $f "https://bintray.com/artifact/download/tkelman/generic/$f" echo "Extracting $f" $SEVENZIP x -y $f >> get-deps.log export PATH=$PWD/mingw$bits/bin:$PATH # If there is a version of make.exe here, it is mingw32-make which won't work rm -f mingw$bits/bin/make.exe } export AR=$(CROSS_COMPILE)ar setglobal f = "llvm-3.9.1-$ARCH-w64-mingw32-juliadeps-r07.7z" } else { echo "override USEMSVC = 1" >> Make.user echo "override ARCH = $ARCH" >> Make.user echo "override XC_HOST = " >> Make.user export CC="$PWD/deps/srccache/libuv/compile cl -nologo -MD -Z7" export AR="$PWD/deps/srccache/libuv/ar-lib lib" export LD="$PWD/linkld link" echo "override CC = $CC" >> Make.user echo 'override CXX = $(CC) -EHsc' >> Make.user echo "override AR = $AR" >> Make.user echo "override LD = $LD -DEBUG" >> Make.user setglobal f = "llvm-3.3-$ARCH-msvc12-juliadeps.7z" } checksum_download \ $f "https://bintray.com/artifact/download/tkelman/generic/$f" echo "Extracting $f" $SEVENZIP x -y $f >> get-deps.log if test -z $[which make !2 >/dev/null] { if test -n $[uname | grep CYGWIN] { echo "Install the Cygwin package for 'make' and try again." exit 1 } setglobal f = '"/make/make-3.81-2/make-3.81-2-msys-1.0.11-bin.tar'" if ! test -e $[basename $f.lzma] { echo "Downloading $[basename $f]" $curlflags -O http://sourceforge.net/projects/mingw/files/MSYS/Base$f.lzma } $SEVENZIP x -y $[basename $f.lzma] >> get-deps.log tar -xf $[basename $f] export PATH=$PWD/bin:$PATH } if ! test -e usr/bin/busybox.exe { setglobal f = 'busybox-w32-FRP-875-gc6ec14a.exe' echo "Downloading $f" $curlflags -o usr/bin/busybox.exe http://frippery.org/files/busybox/$f } chmod +x usr/bin/* usr/tools/* for lib in [SUITESPARSE ARPACK BLAS LAPACK \ GMP MPFR PCRE LIBUNWIND] { echo "USE_SYSTEM_$lib = 1" >> Make.user } echo 'override LIBLAPACK = $(LIBBLAS)' >> Make.user echo 'override LIBLAPACKNAME = $(LIBBLASNAME)' >> Make.user # Remaining dependencies: # libuv since its static lib is no longer included in the binaries # openlibm since we need it as a static library to work properly # utf8proc since its headers are not in the binary download echo 'override DEP_LIBS = libuv utf8proc' >> Make.user if test -n $USEMSVC { # Openlibm doesn't build well with MSVC right now echo 'USE_SYSTEM_OPENLIBM = 1' >> Make.user # Since we don't have a static library for openlibm echo 'override UNTRUSTED_SYSTEM_LIBM = 0' >> Make.user # Compile libuv and utf8proc without -TP first, then add -TP make -C deps install-libuv install-utf8proc cp usr/lib/uv.lib usr/lib/libuv.a echo 'override CC += -TP' >> Make.user echo 'override DEP_LIBS += dsfmt' >> Make.user # Create a modified version of compile for wrapping link sed -e 's/-link//' -e 's/cl/link/g' -e 's/ -Fe/ -OUT:/' \ -e 's|$dir/$lib|$dir/lib$lib|g' deps/srccache/libuv/compile > linkld chmod +x linkld } else { echo 'override DEP_LIBS += openlibm' >> Make.user make check-whitespace make VERBOSE=1 -C base version_git.jl.phony echo 'NO_GIT = 1' >> Make.user } echo 'FORCE_ASSERTIONS = 1' >> Make.user cat Make.user make -j3 VERBOSE=1 all make -j3 VERBOSE=1 install make VERBOSE=1 -C examples cp usr/bin/busybox.exe julia-*/bin make build-stats