Last active
August 13, 2025 21:30
-
-
Save t-kalinowski/befefd1ecfa0c4716fcae168e16888a7 to your computer and use it in GitHub Desktop.
Build R from source locally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e # stop on error | |
| cd ~/github/r-devel/r-svn | |
| # reset | |
| # rm -rf cran.rstudio.com src/library/Recommended/* | |
| export R_CRAN_WEB="https://cran.rstudio.com" | |
| git reset --hard | |
| git clean -fdx | |
| git config --global --add safe.directory $PWD || true | |
| ./.github/scripts/wget-recommended.sh | |
| sed -i.bak 's|$(GIT) svn info|./.github/scripts/svn-info.sh|' Makefile.in | |
| ./.github/scripts/svn-info.sh | |
| export PKG_CONFIG_PATH="/opt/X11/lib/pkgconfig" | |
| # seems -O0 is prefered over -Og | |
| # LIBnn='lib' \ | |
| CFLAGS='-g -O0' \ | |
| CXXFLAGS='-g -O0' \ | |
| FFLAGS='-g -O0' \ | |
| CC=clang \ | |
| FC='/opt/gfortran/bin/gfortran' \ | |
| LDFLAGS='-L/opt/R/arm64/lib -L/opt/X11/lib -L/opt/homebrew/lib' \ | |
| CPPFLAGS='-I/opt/R/arm64/include -I/opt/X11/include -I/opt/homebrew/include' \ | |
| ./configure --prefix=$(realpath ../r-build) \ | |
| --enable-R-shlib | |
| # --with-blas --with-lapack --disable-java | |
| make -j9 | |
| rm -rf ./r-build | |
| rm -rf ../r-build | |
| mkdir ../r-build | |
| make install | |
| # make -j9 && rm -rf ./r-build && make install | |
| # # cd .. | |
| # ../r-build/bin/Rscript -e \ | |
| # 'install.packages(c("remotes", "rcmdcheck"), repos = "https://cran.rstudio.com/", Ncpus = 2L)' | |
| # ../r-build/bin/Rscript -e \ | |
| # 'remotes::install_local("../S7", dependencies = TRUE, Ncpus = 2L, force = TRUE)' | |
| # ../r-build/bin/Rscript -e \ | |
| # 'rcmdcheck::rcmdcheck("../S7", args = c("--no-manual", "--as-cran"), error_on = "warning")' | |
| make check-all | |
| # make -j9 && make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The above is just an ad-hoc script. Some more comprehensive approaches: