R: enable shared library and test

Added an option to build R with shared library. This is necessary for use with rpy2, RSruby or similar libraries that embed R, as well as possibly other R-related software such as IDEs like RStudio.

I also added a basic test that creates a very simple .R script and runs it using r and rscript.