makefilejam

jamfile: copy files to different directories


SEARCH_SOURCE = $(DDODBC_LIB_DIR) ;
InstallBin [ FDirName $(TOP) $(BUILDDIR) lib ] : $(DDODBC_LIBS) ;
InstallBin [ FDirName $(TOP) $(BUILDDIR) datadirect V7 lib ] : $(DDODBC_LIBS) ;

Only in the second directory can I find the copied files from $(DDODBC_LIBS). Why they are not copied to the first directory by InstallBin?


Solution

  • The issue is that InstallBin respectively InstallInto need to define a target (per source file) which represents the installed file and which is made a dependency of the install pseudo target. They do that by simply using the source target name with the grist set to $(INSTALLGRIST). So the second InstallBin invocation defines the same target, resetting the target's location (LOCATE variable on the target). Hence the file is only installed to the second location.

    A simple, if not particularly elegant, work-around is to redefine INSTALLGRIST for one of the invocations of InstallBin.

    SEARCH_SOURCE = $(DDODBC_LIB_DIR) ;
    
    InstallBin [ FDirName $(TOP) $(BUILDDIR) lib ] : $(DDODBC_LIBS) ;
    
    oldInstallGrist = $(INSTALLGRIST) ;
    INSTALLGRIST = $(INSTALLGRIST)2 ;
    InstallBin [ FDirName $(TOP) $(BUILDDIR) datadirect V7 lib ] : $(DDODBC_LIBS) ;
    INSTALLGRIST = $(oldInstallGrist) ;
    

    In case you need to do that more often, a more elegant solution would be to create a wrapper rule that derives an INSTALLGRIST value from the installation directory:

    rule InstallBinSafe
    {
        local INSTALLGRIST = installed-$(1:G=) ;
        InstallBin $(1) : $(2) ;
    }
    

    And then simply use that rule instead of InstallBin.