読者です 読者をやめる 読者になる 読者になる

メモ:Rが使うデフォルトのMakefileの場所

R Windows

r-pkgsには、

Generally, R packages should avoid a custom Makefile. Instead, use Makevars. Makevars is a make file that overrides the default make file generated by R (which is located at file.path(R.home("etc"), "Makeconf")).
(http://r-pkgs.had.co.nz/src.html#make)

と書いてあるけど、実はWindowsの場合は微妙にパスが違う。最新のRtoolsだと32bit版と64bit版に分かれていて、file.path(R.home("etc"), Sys.getenv("R_ARCH"), "Makeconf")になっている。

なんでかというと、Rtoolsはmultilibをサポートするのをあきらめたかららしい。

The new Rtools compiler for windows is based on GCC 4.9.3 and Mingw-W64 V3. It does not support multilib: instead we ship separate compilers targeting win32 and win64
(https://github.com/rwinlib/r-base#summary)

2つのファイルの差はこんな感じ。

$ diff /c/progra~1/R/R-3.2.2/etc/*/Makeconf
17,18c17,18
< ## Things which are substituted by fixed/Makefile (and also -O3 -> -O2)
< WIN = 32
---
> ## Things which are substituted by fixed/Makefile (and also -O2 -> -O2)
> WIN = 64
22,23c22,23
< SYMPAT = 's/^.* [BCDRT] _/ /p'
< IMPDIR = bin/i386
---
> SYMPAT = 's/^.* [BCDRT] / /p'
> IMPDIR = bin/x64
25,27c25,27
< M_ARCH = -m32
< DT_ARCH = -m i386 --as-flags --32
< RC_ARCH = -F pe-i386
---
> M_ARCH = -m64
> DT_ARCH = -m i386:x86-64 --as-flags --64
> RC_ARCH = -F pe-x86-64
31c31
< NM_FILTER =
---
> NM_FILTER = | sed -e '/.refptr./d'
70c70
< CFLAGS = -O3 -Wall $(DEBUGFLAG) -std=gnu99 -mtune=core2
---
> CFLAGS = -O2 -Wall $(DEBUGFLAG) -std=gnu99 -mtune=core2
90c90
< FCFLAGS = -O3 $(DEBUGFLAG) -mtune=core2
---
> FCFLAGS = -O2 $(DEBUGFLAG) -mtune=core2
95c95
< FFLAGS = -O3 $(DEBUGFLAG) -mtune=core2
---
> FFLAGS = -O2 $(DEBUGFLAG) -mtune=core2
131c131
< R_ARCH = /i386
---
> R_ARCH = /x64
133c133
< SAFE_FFLAGS = -O3 -ffloat-store
---
> SAFE_FFLAGS = -O2 -ffloat-store
161c161
< TCLTK_LIBS = -L"$(TCL_HOME)/bin" -ltcl$(TCL_VERSION) -ltk$(TCL_VERSION)
---
> TCLTK_LIBS = -L"$(TCL_HOME)/bin64" -ltcl$(TCL_VERSION) -ltk$(TCL_VERSION)