From bodenhofer at bioinf.jku.at  Tue Oct 11 08:39:33 2016
From: bodenhofer at bioinf.jku.at (Ulrich Bodenhofer)
Date: Tue, 11 Oct 2016 08:39:33 +0200
Subject: [Rd] PKG_LIBS in make child processes
Message-ID: <ca643a41-3710-5dba-de9a-a1875d22c2ad@bioinf.jku.at>

[cross-posted from bioc-devel list]

Hi all,

I have a subtle question related to how R CMD SHLIB handles variables in 
make child processes. In more detail: I am the maintainer of the 'msa' 
package which has been in Bioconductor since April 2015. This package 
integrates three open-source libraries for multiple sequence alignment. 
This is organized in the following way: in src/, there are three 
sub-directories, one for each of the libraries (plus another one for a 
garbage collector library, but that is not relevant at this point). 
src/Makevars is made such that the libraries are compiled individually 
to static libraries in their respective sub-directory, then these static 
libraries are copied to src/, and finally the static libraries are 
integrated into msa.so. The Makevars file looks as follows:

     PKG_LIBS=`${R_HOME}/bin${R_ARCH_BIN}/Rscript -e "if
     (Sys.info()['sysname'] == 'Darwin') cat('-Wl,-all_load ./libgc.a
     ./libClustalW.a ./libClustalOmega.a ./libMuscle.a') else
     cat('-Wl,--whole-archive ./libgc.a ./libClustalW.a
     ./libClustalOmega.a ./libMuscle.a  -Wl,--no-whole-archive')"`
     PKG_CXXFLAGS=-I"./gc-7.2/include" -I"./Muscle/" -I"./ClustalW/src"
     -I"./ClustalOmega/src"

     .PHONY: all mylibs

     all: $(SHLIB)
     $(SHLIB): mylibs

     mylibs: build_gc build_muscle build_clustalw build_clustalomega

     build_gc:
          make --file=msaMakefile --directory=gc-7.2
          @echo "----------------------------------------"
          @echo "------------------ GC  -----------------"
          @echo "----------------------------------------"
          @echo "--------- Compilation finished ---------"
          @echo "----------------------------------------"

     build_muscle:
          make --file=msaMakefile --directory=Muscle
          @echo "----------------------------------------"
          @echo "---------------- MUSCLE ----------------"
          @echo "----------------------------------------"
          @echo "--------- Compilation finished ---------"
          @echo "----------------------------------------"

     build_clustalw:
          make --file=msaMakefile --directory=ClustalW
          @echo "----------------------------------------"
          @echo "--------------- ClustalW ---------------"
          @echo "----------------------------------------"
          @echo "--------- Compilation finished ---------"
          @echo "----------------------------------------"

     build_clustalomega:
          make --file=msaMakefile --directory=ClustalOmega
          @echo "----------------------------------------"
          @echo "------------- ClustalOmega -------------"
          @echo "----------------------------------------"
          @echo "--------- Compilation finished ---------"
          @echo "----------------------------------------"

This has always worked on Linux and Mac OS so far. Now I have received 
an error report from a user who cannot install the package on a 64-bit 
openSUSE 13.1 system using R 3.3.1. It turned out that R CMD SHLIB as 
called in the make child processes (make target 'build_muscle' above) 
uses the value of PKG_LIBS defined in the first line of the top-level 
Makevars file shown above (which of course does not work and makes no 
sense), while this does not happen on any other Unix-like system I have 
tried so far (Ubuntu, CentOS, Mac OS). Maybe somebody can shed some 
light on how variables defined inside the Makevars file propagate to 
child processes. Thanks so much in advance!

Best regards,
Ulrich



[Rd] PKG_LIBS in make child processes
Ulrich Bodenhofer