1REM This script installs R-devel from SVN trunk on Windows. 2REM 3REM This script assumes you have 'wget' on your path, as it 4REM is used to download. You can find a binary here: 5REM 6REM https://eternallybored.org/misc/wget/wget64.exe 7REM 8REM We use SVN to checkout R trunk from SVN. 9REM If you need a Windows SVN client, you can download SlikSVN here: 10REM 11REM https://sliksvn.com/download/ 12REM 13REM Be sure to place the installed binary directory on your PATH. 14REM 15REM If you modify the configuration below, be sure to use 16REM a directory _within the %USERPROFILE%; ie, your user 17REM directory; otherwise you will almost certainly run into 18REM very bizarre permission issues on build. 19 20REM --------------------------------- 21REM - BEGIN CONFIGURATION VARIABLES - 22REM --------------------------------- 23 24REM Set to 32 for a 32bit build. 25REM TODO Build both in one go. 26SET "WIN=64" 27 28IF NOT DEFINED WGET ( 29 where /q wget && ( 30 SET "WGET=wget" 31 ) || ( 32 where /q wget && ( 33 SET "WGET=wget64" 34 ) 35 ) 36) 37 38IF NOT DEFINED SVN ( 39 SET "SVN=svn" 40) 41 42IF NOT DEFINED ROOT_DIR ( 43 SET "ROOT_DIR=%USERPROFILE%\R-src" 44) 45 46if NOT DEFINED RTOOLS_DIR ( 47 SET "RTOOLS_DIR=C:\Rtools" 48) 49 50IF NOT DEFINED RTOOLS_BIN_DIR ( 51 SET "RTOOLS_BIN_DIR=C:\Rtools\bin" 52) 53 54IF NOT DEFINED TMPDIR ( 55 SET "TMPDIR=%USERPROFILE%\tmp" 56) 57 58REM ------------------------------- 59REM - END CONFIGURATION VARIABLES - 60REM ------------------------------- 61 62REM Set some variables both for cleanup + download of 63REM required tools. 64SET "OLDDIR=%CD%" 65SET "CRAN=http://cran.r-project.org" 66SET "RTOOLS_VERSION=33" 67SET "R_HOME=%ROOT_DIR%\trunk" 68 69REM Ensure that some essential tools are on the PATH. 70where /Q %WGET% || ( 71 ECHO wget [%WGET%] not found on PATH; exiting 72 exit /b 73) 74 75where /Q %SVN% || ( 76 ECHO svn [%SVN%] not found on PATH; exiting 77 exit /b 78) 79 80REM Set the current directory. 81if not exist "%ROOT_DIR%" ( 82 mkdir "%ROOT_DIR%" 83) 84cd "%ROOT_DIR%" 85SET "OLDPATH=%PATH%" 86 87REM URI to RTools.exe 88SET "RTOOLS_URL=%CRAN%/bin/windows/Rtools/Rtools%RTOOLS_VERSION%.exe" 89 90REM URI to updated toolchains. 91REM TODO Remove this once Rtools stabilized. 92SET "TOOLCHAIN_BASE=http://www.stats.uwo.ca/faculty/murdoch/temp" 93SET "TOOLCHAIN_32BIT=%TOOLCHAIN_BASE%/mingw32mingw32_gcc-4.9.2.toolchain.tar.gz" 94SET "TOOLCHAIN_64BIT=%TOOLCHAIN_BASE%/mingw32mingw64_gcc-4.9.2.toolchain.tar.gz" 95 96REM Download Rtools, and the updated toolchains. 97REM TODO: Downloading the upgraded toolchains will not be necessary 98REM once RTOOLS has been fully stabilized. 99wget -c %RTOOLS_URL% 100wget -c %TOOLCHAIN_32BIT% 101wget -c %TOOLCHAIN_64BIT% 102 103REM Install Rtools. 104SET "RTOOLS_INSTALLER=.\Rtools%RTOOLS_VERSION%.exe" 105"%RTOOLS_INSTALLER%" /VERYSILENT 106 107REM Put Rtools on the path. 108SET "PATH=%RTOOLS_BIN_DIR%;%PATH%" 109 110REM Overwrite the toolchain paths with our own. 111rmdir /S /Q %RTOOLS_DIR%\gcc492_32 112rmdir /S /Q %RTOOLS_DIR%\gcc492_64 113 114REM Untar the downloaded toolchains and move them. 115tar -zxvf mingw32mingw32_gcc-4.9.2.toolchain.tar.gz 116move mingw32 %RTOOLS_DIR%\gcc492_32 117 118tar -zxvf mingw32mingw64_gcc-4.9.2.toolchain.tar.gz 119move mingw64 %RTOOLS_DIR%\gcc492_64 120 121REM Download the R sources. Get the latest R-devel sources using SVN. 122svn checkout https://svn.r-project.org/R/trunk/ 123cd trunk 124 125REM Copy in the 'extras' for a 64bit build. This includes tcltk 126REM plus some other libraries. Note that the R64 directory should 127REM have been populated by the RTools installation. 128REM xcopy /E /Y C:\R %R_HOME%\trunk\ 129rmdir /S /Q %R_HOME%\Tcl 130xcopy /E /Y C:\R64 %R_HOME%\ 131 132REM Ensure the temporary directory exists. 133if not exist "%TMPDIR%" ( 134 mkdir "%TMPDIR%" 135) 136 137REM Create the binary directories that will eventually 138REM be populated ourselves, rather than letting the 139REM bundled cygwin toolkit do it. The RTools 'mkdir' 140REM apparently can build directories without read 141REM permissions, which will cause any attempt to link 142REM to DLLs within those folders to fail. 143rmdir /S /Q bin 144mkdir bin\i386 145mkdir bin\x64 146 147REM Move into the root directory for 'Windows' builds. 148cd src\gnuwin32 149 150REM Since we're building from source, we need to get Recommended packages. 151make rsync-recommended 152 153REM Download external software -- libpng, libgsl, and so on. 154make rsync-extsoft 155 156REM Look at MkRules.dist and if settings need to be altered, copy it to 157REM MkRules.local and edit the settings there. 158if exist MkRules.local ( 159 rm MkRules.local 160) 161cp MkRules.dist MkRules.local 162 163REM Don't use MIKTEX. 164sed -i 's/^MIKTEX = TRUE//g' MkRules.local 165 166REM Ensure that the make rules are properly set -- need to 167REM point to 'extsoft'. 168sed -i 's/^# LOCAL_SOFT/LOCAL_SOFT/g' MkRules.local 169sed -i 's/^# EXT_LIBS/EXT_LIBS/g' MkRules.local 170 171REM Attempt to fix up permissions before the build. 172cacls %R_HOME% /T /E /G BUILTIN\Users:R > NUL 173cacls %TMPDIR% /T /E /G BUILTIN\Users:R > NUL 174 175REM Make it! 176REM For this part, we ensure only Rtools is on the PATH. This 177REM is important as if the wrong command line utilites are picked 178REM up things can fail for strange reason. In particular, we 179REM _must_ use the Rtools 'sort', _not_ the Windows 'sort', or 180REM else we will get strange errors from 'comm' when attempting 181REM to compare sorted files. Probably just placing Rtools first 182REM on the PATH is sufficient, but this is fine too. 183SET "PATH=C:\Rtools\bin" 184make distclean 185 186REM Now we should be able to build R + recommended packages. 187make WIN=%WIN% all recommended 188 189REM Clean up. 190SET "PATH=%OLDPATH%" 191cd %OLDDIR% 192