[Rcpp-commits] r1863 - linkingto

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 16 13:59:23 CEST 2010


Author: romain
Date: 2010-07-16 13:59:23 +0200 (Fri, 16 Jul 2010)
New Revision: 1863

Modified:
   linkingto/linkingto-proposal.Rnw
Log:
some more

Modified: linkingto/linkingto-proposal.Rnw
===================================================================
--- linkingto/linkingto-proposal.Rnw	2010-07-16 10:27:51 UTC (rev 1862)
+++ linkingto/linkingto-proposal.Rnw	2010-07-16 11:59:23 UTC (rev 1863)
@@ -165,6 +165,79 @@
 \pkg{packB} package links against the appropriate library.
 
 
+\section{Implementation}
+
+To compile the content of the \texttt{src} directory, R invokes \texttt{make}
+with several source files as seen on this extract from the 
+\texttt{.shlib\_internal} function in \texttt{install.R} (in package \texttt{tools}). 
+
+<<eval=FALSE>>=
+site <- file.path(p0(R.home("etc"), rarch), "Makevars.site")
+makefiles <-
+    c(file.path(p0(R.home("etc"), rarch), "Makeconf"),
+      if(file.exists(site)) site,
+      file.path(R.home("share"), "make",
+                if (WINDOWS) "winshlib.mk" else "shlib.mk"))
+@
+               
+The \texttt{Makeconf} sets all the flags relevant for the current platform and
+sub architecture. 
+
+The \texttt{shlib.mk} file defines the target for the shared library of the package: 
+
+<<lang=make>>=
+## ${R_HOME}/share/make/shlib.mk
+
+all: $(SHLIB)
+
+$(SHLIB): $(OBJECTS)
+	@if test  "z$(OBJECTS)" != "z"; then \
+	  echo $(SHLIB_LINK) -o $@ $(OBJECTS) $(ALL_LIBS); \
+	  $(SHLIB_LINK) -o $@ $(OBJECTS) $(ALL_LIBS); \
+	fi
+
+.PHONY: all shlib-clean
+
+shlib-clean:
+	@rm -rf .libs _libs
+	@rm -f $(OBJECTS)
+@
+                        
+Similarly on windows, the \texttt{winshlib.mk} file : 
+
+<<lang=make>>=
+## ${R_HOME}/share/make/winshlib.mk
+
+all: $(SHLIB)
+
+BASE = $(shell basename $(SHLIB) .dll)
+
+## do it with explicit rules as packages might add dependencies to this target
+## (attempts to do this GNUishly failed for parallel makes,
+## but we do want the link targets echoed)
+$(SHLIB): $(OBJECTS)
+	@if test "z$(OBJECTS)" != "z"; then \
+	  if test -e "$(BASE)-win.def"; then \
+	    echo $(SHLIB_LD) -shared $(DLLFLAGS) -o $@ $(BASE)-win.def $(OBJECTS) $(ALL_LIBS); \
+	    $(SHLIB_LD) -shared $(DLLFLAGS) -o $@ $(BASE)-win.def $(OBJECTS) $(ALL_LIBS); \
+	  else \
+	    echo EXPORTS > tmp.def; \
+	    $(NM) $^ | $(SED) -n 's/^.* [BCDRT] _/ /p' >> tmp.def; \
+	    echo $(SHLIB_LD) -shared $(DLLFLAGS) -o $@ tmp.def $(OBJECTS) $(ALL_LIBS); \
+	    $(SHLIB_LD) -shared $(DLLFLAGS) -o $@ tmp.def $(OBJECTS) $(ALL_LIBS); \
+	    $(RM) tmp.def; \
+	  fi \
+	fi
+
+.PHONY: all shlib-clean
+shlib-clean:
+	@rm -f $(OBJECTS)
+@
+
+% so we need to provide modifications of these files so that they
+% build also a dynamic lib and a static lib
+
+
 \bibliographystyle{abbrvnat}
 \bibliography{Rcpp}
 



More information about the Rcpp-commits mailing list