Steve Dutky
2005-Feb-07 17:56 UTC
[Rd] Problems encountered/fixed making CrossCompileBuild
Dear All:
I encountered and apparently overcame problems following Yan
and Rossini?s procedure for "Building Microsoft Windows
Versions of R and R packages under Intel Linux"
(http://cran.r-project.org/doc/contrib/cross-build.pdf): I
have successfully cross-compiled R packages for Windows on a
FreeBSD 4.10 i386 system.
My revisions to Makefile-rcb (http://cran.r-
project.org/doc/contrib/Makefile-rcb ) follow here:
1. created makevar MAKE initialized to gmake. Replaced all
direct references to make with $(MAKE).
2. updated makevar MINGW_CROSS = mingw-cross4 to point to
http://www.stats.ox.ac.uk/pub/Rtools/mingw-cross4.tar.bz2 ,
replacing original reference to mingw-cross2.
3. updated MkRules HEADER=$(CROSSDIR)/i586-mingw32/include ,
replacing original reference to <snip>/mingw32/include.
4. reset LinuxFresh = YES
Yan and Rossini imply that linuxR: is an optional step if R
is already installed. I ran afoul of steps in
$(WINR)/<snip>/gnuwin32/MakePkg referencing symbols in the
tools package in the system's version of R. Happily, these
ran successfully against $(LINUXR)/R/bin/R.
I hope some of this turns useful to others attempting this.
Thanks, Steve Dutky
Sdutky@terpalum.umd.edu
Revised Makefile-rcb:
############################ -*- Mode: Makefile -*-
###########################
## Makefile-rcb --- Makefile for R cross-building
##
## Author : Jun Yan (University of Iowa)
<jyan@stat.uiowa.edu>
## A.J. Rossini (UW - Seattle)
<rossini@u.washington.edu>
## Last modified : 10/11/2004
## Provisionally revised 2/1/2004 S Dutky
<sdutky@terpalum.umd.edu>
##############################################################
#################
MAKE = /usr/local/bin/gmake
SHELL = /bin/sh
WGET = wget --passive-ftp
BINS = \*.so \*.dll \*.RData \*.rda \*.zip \*.rds \*.pdf \*.ps
#### define directories
## the current directory where all the following cross-
building happens
RCB := $(shell pwd)
## the directory where the downloaded sources are stored
DOWNDIR = $(RCB)/downloads
## the directory where the cross-tools are installed
CROSSDIR = $(RCB)/cross-tools
## the directory where R sources are unpacked for cross-
building
WINR = $(RCB)/WinR
## the dirECTOry where R for Linux will be compiled and
installed
LINUXR = $(RCB)/LinuxR
## the directory where package sources are stored
PKGDIR = $(RCB)/pkgsrc
## the directory where the built packages for windows are to
be stored
WINRLIBS = $(RCB)/WinRlibs
## current versions
R = R-2.0.0
## snapshot R is only available at
ftp://ftp.stat.math.ethz.ch/Software/R
ifeq ($(findstring devel, $(R)), devel)
RURL = ftp://ftp.stat.math.ethz.ch/Software/R
REXT = tar.gz
else
RURL = http://cran.us.r-project.org/src/base/R-2
REXT = tar.gz
endif
R_TCL_URL = http://www.murdoch-sutherland.com/Rtools/R_Tcl.zip
#MINGW_CROSS = mingw-cross2 now:
MINGW_CROSS = mingw-cross4
## R_EXE
LinuxFresh = YES
ifeq ($(strip $(LinuxFresh)),YES)
R_EXE = $(LINUXR)/R/bin/R
else
R_EXE = R
endif
default:
@echo "syntax:"
@echo "make <target>"
@echo "No <Target> Specified. Should be one of:"
@echo " "
@echo "-------------------"
@echo "down : downloads files"
@echo "xtools : unpack cross compilers"
@echo "prepsrc : unpack and prepare source code"
@echo "mkrules : patch source code for cross-compile"
@echo "R : cross-compile R"
@echo " "
@echo "(or to run all at once (trusting, aren't
you?))"
@echo " "
@echo "CrossCompileBuild"
@echo " "
@echo "(To build packages or bundles, steps above
have to be run"
@echo " first to get a working build of R, which is
required!)"
@echo " "
@echo "pkg-NAME_VER : cross-build package NAME_VER"
@echo "bundle-NAME_VER : cross-build packages in
bundle NAME_VER"
@echo " "
@echo "(For example, put geepack_0.2-7.tar.gz and
VR_7.1-10.tar.gz"
@echo " in subdirectory pkgsrc, then do"
@echo " "
@echo " make pkg-geepack_0.2-7"
@echo " make bundle-VR_7.1-10)"
@echo "-------------------"
@echo " "
buildR: clean prepsrc mkrules R
#### steps described in the document
down:
mkdir -p $(DOWNDIR); \
cd $(DOWNDIR); \
$(WGET) $(RURL)/$(R).$(REXT) -O $(R).tgz; \
$(WGET) $(R_TCL_URL); \
$(WGET) http://www.stats.ox.ac.uk/pub/Rtools/
$(MINGW_CROSS).tar.bz2; \
downR:
mkdir -p $(DOWNDIR); \
cd $(DOWNDIR); \
$(WGET) $(RURL)/$(R).$(REXT) -O $(R).tgz; \
downRTcl:
mkdir -p $(DOWNDIR); \
cd $(DOWNDIR); \
$(WGET) $(R_TCL_URL);\
downXtools:
mkdir -p $(DOWNDIR); \
cd $(DOWNDIR); \
$(WGET) http://www.stats.ox.ac.uk/pub/Rtools/
$(MINGW_CROSS).tar.bz2; \
linuxR:
mkdir -p $(LINUXR); \
cd $(LINUXR); \
tar zxf $(DOWNDIR)/$(R).tgz; \
cd $(LINUXR)/$(R); \
./configure; \
$(MAKE); \
$(MAKE) prefix=$(LINUXR)/R install; \
xtools:
mkdir -p $(RCB)/cross-tools; \
cd $(CROSSDIR); \
tar jxf $(DOWNDIR)/$(MINGW_CROSS).tar.bz2; \
prepsrc:
mkdir -p $(WINR); \
cd $(WINR); \
rm -rf $(R); \
tar zxf $(DOWNDIR)/$(R).tgz; \
cd $(WINR)/$(R); \
unzip $(DOWNDIR)/R_Tcl.zip
mkrules:
cd $(WINR)/$(R)/src/gnuwin32/; \
cp MkRules MkRules.orig; \
sed 's|^BUILD=MINGW|BUILD=CROSS|;
s|^HEADER=.*$$|HEADER=$(CROSSDIR)/i586-mingw32/include|;
s|^R_EXE=.*$$|R_EXE=$(R_EXE)|; s|# R_EXE=R|R_EXE=$(R_EXE)|'
MkRules.orig > MkRules
R:
export
PATH=$(CROSSDIR)/bin:$(CROSSDIR)/mingw32/bin:$(PATH); \
cd $(WINR)/$(R)/src/gnuwin32/; \
$(MAKE); \
cd $(RCB)/WinR; \
tar zcf Win-$(R).tgz $(R)
pkg-%:
export
PATH=$(CROSSDIR)/bin:$(CROSSDIR)/mingw32/bin:$(PATH); \
export mypkg=`echo $* | cut -d'_' -f1,1`; \
cd $(PKGDIR); \
rm -rf $$mypkg; \
tar zxf $*.tar.gz; \
echo -------$$mypkg------; \
cd $(WINR)/$(R)/src/gnuwin32/; \
$(MAKE) PKGDIR=$(PKGDIR) RLIB=$(WINRLIBS) STAMP=no
pkg-$$mypkg; \
mkdir -p $(WINRLIBS); \
cd $(WINRLIBS); \
rm -rf $$mypkg.zip; \
zip -rl $$mypkg.zip $$mypkg -x $(BINS);\
zip -r9 $$mypkg.zip $$mypkg -i $(BINS);\
rm -rf $$mypkg
#### this section no longer works as of R-2.0.0
# bundle-%:
# export
PATH=$(CROSSDIR)/bin:$(CROSSDIR)/mingw32/bin:$(PATH); \
# cd $(PKGDIR); \
# tar zxf $*.tar.gz; \
# export mybundle=`echo $* | cut -d'_' -f1,1`; \
# echo -------$$mybundle------; \
# cd $(WINR)/$(R)/src/gnuwin32/; \
# $(MAKE) PKGDIR=$(PKGDIR) RLIB=$(WINRLIBS) STAMP=no
bundle-$$mybundle; \
# mkdir -p $(WINRLIBS); \
# cd $(WINRLIBS); \
# ls $(PKGDIR)/$$mybundle/; \
# echo $(PKGDIR)/$$mybundle/DESCRIPTION; \
# grep "^Contains:" $(PKGDIR)/$$mybundle/DESCRIPTION |
sed -e 's/Contains: //'; \
# export incl=`grep "^Contains:" $(PKGDIR)/
$$mybundle/DESCRIPTION | sed -e 's/Contains: //'`; \
# echo ------$$incl------; \
# for pkg in $$incl; do \
# (rm -rf $$pkg.zip; \
# zip -rl $$pkg.zip $$pkg -x $(BINS); \
# zip -r9 $$pkg.zip $$pkg -i $(BINS); \
# rm -rf $$pkg); \
# done;
bundle-%:
export
PATH=$(CROSSDIR)/bin:$(CROSSDIR)/mingw32/bin:$(PATH); \
cd $(WINR)/$(R)/src/library;\
tar zxf $(PKGDIR)/$*.tar.gz; \
export mybundle=`echo $* | cut -d'_' -f1,1`; \
echo -------$$mybundle------; \
cd $(WINR)/$(R)/src/gnuwin32/; \
$(R_EXE) CMD perl XINSTALL --unsafe --
docs=normal ../library/$${mybundle} || exit 1; \
mkdir -p $(WINRLIBS); \
ls $(WINR)/$(R)/src/library/$$mybundle/; \
echo $(PKGDIR)/$$mybundle/DESCRIPTION; \
grep "^Contains:" $(WINR)/$(R)/src/library/
$$mybundle/DESCRIPTION | sed -e 's/Contains: //'; \
export incl=`grep "^Contains:" $(WINR)/
$(R)/src/library/$$mybundle/DESCRIPTION | sed -
e 's/Contains: //'`; \
echo ------$$incl------; \
cd $(WINR)/$(R)/library; \
for pkg in $$incl; do \
(rm -rf $$pkg.zip; \
zip -rl $(WINRLIBS)/$$pkg.zip $$pkg -x $(BINS); \
zip -r9 $(WINRLIBS)/$$pkg.zip $$pkg -i $(BINS); \
rm -rf $$pkg); \
done; \
rm -rf $(WINR)/$(R)/src/library/$${mybundle}; \
#### other targets that may be useful
pkgclean-%:
cd $(PKGDIR); \
rm -rf $*
recommended:
export
PATH=$(CROSSDIR)/bin:$(CROSSDIR)/mingw32/bin:$(PATH); \
cd $(WINR)/$(R)/src/gnuwin32/; \
$(MAKE) recommended
# dist-recommended:
# mkdir -p $(WINRLIBS); \
# cd $(WINR)/$(R)/src/gnuwin32/; \
# $(MAKE) dist-recommended; \
# mv Recommended.zip $(WINRLIBS)/
clean:
rm -rf $(WINR)
#### not tested
# rinstaller:
# export
PATH=$(CROSSDIR)/bin:$(CROSSDIR)/mingw32/bin:$(PATH); \
# cd $(WINR)/$(R)/src/gnuwin32/; \
# $(MAKE) rinstaller
CrossCompileBuild :
$(MAKE) down
$(MAKE) xtools
$(MAKE) prepsrc
$(MAKE) mkrules
$(MAKE) R
Jake Bowers
2005-Feb-07 22:11 UTC
[Rd] R-patched Make Check Fails on reg-tests-1.R on linux and OS X
Dear Developers, I've been playing around with compiling R on my Debian Linux machine (dual Athlon 1.4ghz) and my OS X machine (dual G5). I'm emailing now because reg-tests-1.R fails during make check on my debian machine using gcc-3.4, and on my OS X machine using gcc-3.3. I am using r-patched updated via svn today (Updated to revision 33075.) Here are some details: **Using gcc-3.4 on debian: gcc-3.4 (GCC) 3.4.4 20041218 (prerelease) (Debian 3.4.3-6) wes:/home/temp/R/r-patched/tests# tail reg-tests-1.Rout.fail> > ## automatic row.names can be number-like, MM, 2004-11-26 > d0 <- data.frame(x=1:3, y=pi*2:0) > row.names(d0)[3] <- c("01.00") > write.table(d0, (tf <- tempfile())) > d <- read.table(tf) > ## gave error ("duplicate row.names") in 2.0.1 > stopifnot(all.equal(d,d0)) > unlink(tf)**Using gcc-3.3 on debian works fine (passes all make check). gcc (GCC) 3.3.5 (Debian 1:3.3.5-5) **Using gcc-3.3 on OS X. gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1671) More info on my OS X build: ./configure --with-blas='-framework vecLib' --with-lapack --with-aqua --with-x --with-tcl-config=/Library/Frameworks/Tcl.framework/tclConfig.sh --with-tk-config=/Library/Frameworks/Tk.framework/tkConfig.sh --enable-R-shlib TCLTK_LIBS='-framework Tcl -framework Tk' TCLTK_CPPFLAGS='-I/Library/Frameworks/Tcl.Framework/Headers -I/Library/Frameworks/Tk.Framework/Headers' --with-recommended g77 is version 3.4 downloaded from hpc.sf.net. GNU Fortran (GCC) 3.4.2 echo $PATH /usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/sw/bin:/sw/sbin:/usr/local/pvm3/lib:/usr/local/pvm3/bin/DARWIN and, to prevent it from using stuff in the fink directory: CPPFLAGS='-I/usr/local/include' Here is the output where make check fails: running regression tests running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1 make[2]: *** [test-Reg] Error 2 make[1]: *** [test-all-basics] Error 1 make: *** [check-all] Error 2 sphere:~/TEMP/R/r-patched/tests jwbowers$ tail reg-tests-1.Rout.fail> > > ## automatic row.names can be number-like, MM, 2004-11-26 > d0 <- data.frame(x=1:3, y=pi*2:0) > row.names(d0)[3] <- c("01.00") > write.table(d0, (tf <- tempfile())) > d <- read.table(tf) > ## gave error ("duplicate row.names") in 2.0.1 > stopifnot(all.equal(d,d0)) > unlink(tf)Should I be very concerned about this? I tend to mostly use my OS X machine since the Linux box is about 4 years old. I hope this information is helpful --- I'm sorry if this is something obvious! (I found some posts from last summer about problems with gcc-3.4, which might explain the problems with gcc-3.4 on linux, but I didn't find anything obvious about gcc-3.3 on the Mac). Thanks so much for all of your work!! Best, Jake Jake Bowers Assistant Professor Dept of Political Science University of Michigan http://www.umich.edu/~jwbowers