Building R-3.1.1 on OS X 10.8 and 10.9 (via fink) gives some warnings during ./configure:
checking X11/Intrinsic.h usability... yes
checking X11/Intrinsic.h presence... no
configure: WARNING: X11/Intrinsic.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: X11/Intrinsic.h: proceeding with the compiler's result
checking for X11/Intrinsic.h... yes
and likewise for X11/Xmu/Atoms.h a few lines later. In config.log, I see the following different compiler calls used for those two consecutive checks:
configure:32347: flag-sort -r gcc -ffor-scope -c -g -O3 -fPIC -I/usr/X11R6/include -I/sw/include conftest.c >&5
configure:32347: $? = 0
configure:32347: result: yes
configure:32347: flag-sort -r gcc -ffor-scope -E -I/sw/include conftest.c
conftest.c:219:10: fatal error: 'X11/Intrinsic.h' file not found
The -I for x11 in the second case, which is required in order to find the x11 headers. The problem is that the standard autoconf segments for x11 propagate that flag via X_CFLAGS but R's own tests (m4/R.m4) for those specific headers pass it via CFLAGS. CFLAGS is only used for compiler, not for preprocessor. Instead, X_CFLAGS should be passed via CPPFLAGS, which is used for preprocessor (and therefore also compiler, because that is built on top of preprocessor).
The various Makefile.in, Makeconf.in, and TCLTK flag variables eventually do handle X_CFLAGS correctly (via their *_CPPFLAGS), it's just a few R.m4 tests that are incorrect. As the output notes, for now, there is no effect because autoconf winds up using what is correct for R in this case, but it's technically broken and may break in the future if autoconf changes how it handles this situation.
Created attachment 1666 [details]
Fix X_CFLAGS propagation in autoconf tests
Fixed in R-devel
Finally ported to 3.2.2 patched, having bitten again in 3.2.2.