From khansen at stat.Berkeley.EDU  Tue Jul 10 05:26:56 2007
From: khansen at stat.Berkeley.EDU (Kasper Daniel Hansen)
Date: Mon, 9 Jul 2007 20:26:56 -0700
Subject: [Rd] cleanup and Makevars
Message-ID: <A153F980-E93F-4623-B097-E7635151386B@stat.berkeley.edu>

Hi

This is a question prompted by the mac version of R, but as I see it,  
it should have broader interest.

These days the CRAN Mac binary per default compiles every package for  
two architectures. First i386 and then ppc. In between the two  
compilation runs, any object files in pkgname/src is removed. This  
cleanup is necessary since otherwise Make would not recompile the  
object files under the next architecture.

I have a package which includes a large SDK which I have put in
   src/fusion_sdk
(and subdirectories). I take care of that by using a Makevars file  
with essentially (the whole Makevars file is reproduced below)

PKG_SOURCES = \
         fusion_sdk/calvin_files/data/src/CDFData.cpp

OBJS=$(PKG_SOURCES:.cpp=.o)

all: $(SHLIB)

However, this setup does not remove the object files in the  
fusion_sdk subdirectory. From a posting on R-sig-mac by Simon Urbanek  
I learned that I need to clean up these directories myself.

I have - per R extensions - attempted to do so using a pkgname/ 
cleanup script. While this works for cleaning up the sub directories  
when I do R CMD build, it seems as if this script is not being run  
between compilation runs (is this intentional btw.?).

So my question is now: how do I in a simple way clean up my  
subdirectories? I would prefer it to be as simple as possible because  
so far I have not really needed anything besides a Makevars file. In  
fact the impression I have right now from looking at the SHLIB and  
INSTALL scripts is that I might need a Makefile that removes the  
object files _before_ starting the compilation, as I don't really see  
any cleanup process (eg. making a target clean) - but this may very  
well be due to my limited understanding of these scripts.

Any help/hints on how to proceed? Especially if I want it to be  
portable?

Kasper

The full Makevars file:

MYCXXFLAGS=-O0

%.o: %.cpp
	$(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(MYCXXFLAGS) -c $< -o $@

PKG_CPPFLAGS=\
-imacros R_affx_constants.h\
-Ifusion_sdk/calvin_files/array/src\
-Ifusion_sdk/calvin_files/data/src\
-Ifusion_sdk/calvin_files/exception/src\
-Ifusion_sdk/calvin_files/fusion/src\
-Ifusion_sdk/calvin_files/fusion/src/GCOSAdapter\
-Ifusion_sdk/calvin_files/fusion/src/CalvinAdapter\
-Ifusion_sdk/calvin_files/parameter/src\
-Ifusion_sdk/calvin_files/parsers/src\
-Ifusion_sdk/calvin_files/portability/src\
-Ifusion_sdk/calvin_files/template/src\
-Ifusion_sdk/calvin_files/utils/src\
-Ifusion_sdk/calvin_files/writers/src\
-Ifusion_sdk/file\
-Ifusion_sdk/portability\
-D_USE_MEM_MAPPING_

PKG_SOURCES = \
	fusion_sdk/calvin_files/data/src/CDFData.cpp\
	fusion_sdk/calvin_files/data/src/CDFProbeGroupInformation.cpp\
	fusion_sdk/calvin_files/data/src/CDFProbeInformation.cpp\
	fusion_sdk/calvin_files/data/src/CDFProbeSetInformation.cpp\
	fusion_sdk/calvin_files/data/src/CDFQCProbeInformation.cpp\
	fusion_sdk/calvin_files/data/src/CDFQCProbeSetInformation.cpp\
	fusion_sdk/calvin_files/data/src/CELData.cpp\
	fusion_sdk/calvin_files/data/src/DataGroup.cpp\
	fusion_sdk/calvin_files/data/src/DataGroupHeader.cpp\
	fusion_sdk/calvin_files/data/src/DataSet.cpp\
	fusion_sdk/calvin_files/data/src/DataSetHeader.cpp\
	fusion_sdk/calvin_files/data/src/FileHeader.cpp\
	fusion_sdk/calvin_files/data/src/GenericData.cpp\
	fusion_sdk/calvin_files/data/src/GenericDataHeader.cpp\
	fusion_sdk/calvin_files/exception/src/ExceptionBase.cpp\
	fusion_sdk/calvin_files/fusion/src/CalvinAdapter/ 
CalvinCELDataAdapter.cpp\
	fusion_sdk/calvin_files/fusion/src/FusionBPMAPData.cpp\
	fusion_sdk/calvin_files/fusion/src/FusionCDFData.cpp\
	fusion_sdk/calvin_files/fusion/src/FusionCDFQCProbeSetNames.cpp\
	fusion_sdk/calvin_files/fusion/src/FusionCELData.cpp\
	fusion_sdk/calvin_files/fusion/src/GCOSAdapter/GCOSCELDataAdapter.cpp\
	fusion_sdk/calvin_files/parameter/src/ParameterNameValueType.cpp\
	fusion_sdk/calvin_files/parsers/src/CDFFileReader.cpp\
	fusion_sdk/calvin_files/parsers/src/CelFileReader.cpp\
	fusion_sdk/calvin_files/parsers/src/DataGroupHeaderReader.cpp\
	fusion_sdk/calvin_files/parsers/src/DataGroupReader.cpp\
	fusion_sdk/calvin_files/parsers/src/DataSetHeaderReader.cpp\
	fusion_sdk/calvin_files/parsers/src/DataSetReader.cpp\
	fusion_sdk/calvin_files/parsers/src/FileHeaderReader.cpp\
	fusion_sdk/calvin_files/parsers/src/FileInput.cpp\
	fusion_sdk/calvin_files/parsers/src/GenericDataHeaderReader.cpp\
	fusion_sdk/calvin_files/parsers/src/GenericFileReader.cpp\
	fusion_sdk/calvin_files/utils/src/AffymetrixGuid.cpp\
	fusion_sdk/calvin_files/utils/src/DateTime.cpp\
	fusion_sdk/calvin_files/utils/src/FileUtils.cpp\
	fusion_sdk/calvin_files/utils/src/StringUtils.cpp\
	fusion_sdk/calvin_files/utils/src/checksum.cpp\
	fusion_sdk/file/BPMAPFileData.cpp\
	fusion_sdk/file/BPMAPFileWriter.cpp\
	fusion_sdk/file/CDFFileData.cpp\
	fusion_sdk/file/CELFileData.cpp\
	fusion_sdk/file/FileIO.cpp\
	fusion_sdk/file/FileWriter.cpp\
	R_affx_cel_parser.cpp\
	R_affx_cdf_parser.cpp\
	R_affx_cdf_extras.cpp\
	R_affx_bpmap_parser.cpp

OBJS=$(PKG_SOURCES:.cpp=.o)

all: $(SHLIB)



[Rd] cleanup and Makevars
Kasper Daniel Hansen