]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/mcbsp-lld.git/blobdiff - build/buildlib.xs
NOTICE OF RELOCATION
[keystone-rtos/mcbsp-lld.git] / build / buildlib.xs
old mode 100644 (file)
new mode 100755 (executable)
index 75fb8c7..779aa9f
@@ -7,63 +7,9 @@
  *  This file contains common routines that are used by the various McBSP 
  *  driver components.
  *
- * Copyright (C) 2012, Texas Instruments, Inc.
+ * Copyright (C) 2011-2016, Texas Instruments, Inc.
  *****************************************************************************/
 
-/**************************************************************************
- * FUNCTION NAME : createMiniPkg
- **************************************************************************
- * DESCRIPTION   :
- *  The function is responsible for creating the mini tar package
- *  The MINI package has the following files:- 
- *      - Driver Source Files. 
- *      - Header files (exported and internal driver files) 
- *      - Simple Makefiles. 
- **************************************************************************/
-function createMiniPkg(pkgName)
-{
-    /* Get the package Name. */
-    var packageRepository = xdc.getPackageRepository(Pkg.name);
-    var packageBase       = xdc.getPackageBase(Pkg.name);
-    var packageName       = packageBase.substring(packageRepository.length + 1);
-
-    /* Convert the Package name by replacing back slashes with forward slashes. This is required because
-     * otherwise with long names the tar is unable to change directory. */
-    var newPkgName = new java.lang.String(packageRepository);
-    var newPkgRep  = newPkgName.replace('\\', '/');
-
-    /* Step1: Create the MINI Package and add the simple Big and Little Endian Makefiles to the package */
-    Pkg.makeEpilogue += "release: mini_pkg\n";
-    Pkg.makeEpilogue += "mini_pkg:\n";
-    Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -cf packages/" + pkgName + "_mini.tar " + packageName + "simpleC66LE.mak "  + packageName + "simpleC66BE.mak\n";
-
-    /* Step2: Add the exported header files to the package */
-    var includeFiles = libUtility.listAllFiles (".h", ".", false);
-    for (var k = 0 ; k < includeFiles.length; k++)
-        Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -rf packages/" + pkgName + "_mini.tar " + packageName + includeFiles[k] + "\n";
-
-    /* Step3: Add the internal header files to the package */
-    includeFiles = libUtility.listAllFiles (".h", "include", true);
-    for (var k = 0 ; k < includeFiles.length; k++)
-        Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -rf packages/" + pkgName + "_mini.tar " + packageName + includeFiles[k] + "\n";
-
-    includeFiles = libUtility.listAllFiles (".h", "device", true);
-    for (var k = 0 ; k < includeFiles.length; k++)
-        Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -rf packages/" + pkgName + "_mini.tar " + packageName + includeFiles[k] + "\n";
-
-    /* Step4: Add the device McBSP file (Example file) which illustrates McBSP device initialization. */
-    var deviceSrcFiles = libUtility.listAllFiles (".c", "device", true);
-    for (var k = 0 ; k < deviceSrcFiles.length; k++)
-        Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -rf packages/" + pkgName + "_mini.tar " + packageName + deviceSrcFiles[k] + "\n";
-
-    /* Step5: Add the driver source files to the package; the filter should have generated a source listing */
-    Pkg.makeEpilogue += "\t tar -C " + "\"" + newPkgRep + "\"" + " -T src.lst -rf packages/" + pkgName + "_mini.tar " + "\n";
-
-    /* Ensure that we clean up the mini package */
-    Pkg.makeEpilogue += "clean::\n";
-    Pkg.makeEpilogue += "\t $(RM) packages/" + pkgName + "_mini.tar\n";
-}
-
 /**************************************************************************
  * FUNCTION NAME : listAllFiles
  **************************************************************************
@@ -72,7 +18,7 @@ function createMiniPkg(pkgName)
  *  present in a directory and any directory inside it.
  **************************************************************************/
 function listAllFiles(ext, dir, recurse)
-{      
+{     
     var srcFile = [];
     var d;
 
@@ -81,9 +27,9 @@ function listAllFiles(ext, dir, recurse)
         recurse = true;
 
     if (dir == undefined) 
-           d = ".";
+          d = ".";
     else 
-       d = dir;
+      d = dir;
 
     /* Get access to the current directory. */
     var file = new java.io.File(d);
@@ -126,11 +72,13 @@ function listAllFiles(ext, dir, recurse)
                 }
             }
         }
+
         return srcFile;
     }
     return null;
 }
 
+
 function createMake(makefile)
 {
     /* Create the main make file */
@@ -162,11 +110,11 @@ function createMake(makefile)
 
       var file = xdc.module('xdc.services.io.File');
     
-      var xdcTargetType = java.lang.System.getenv("XDCTARGET");
-      var toolsBaseDir = java.lang.System.getenv("XDCCGROOT");   
       
       makefile.writeLine("\n# Output for prebuilt generated libraries");
       makefile.writeLine("export LIBDIR ?= ./lib");
+      /* use sectti.exe from path */
+      makefile.writeLine("export SECTTI ?= sectti");
 
       /* Create INCDIR from XDCPATH */
     
@@ -264,29 +212,56 @@ function createMake(makefile)
  return makefile;
 }
 
-function createLibMake(makelibname,targetname, objectPath)
+function createLibMake(device, makelibname,targetname, objectPath)
 {
    var tooldir;
+   var cmdprefix;
+   var targetDir;
    var stringname=String(targetname).replace("(xdc.bld.ITarget.Module)","");
-   if(stringname.match("ARM11"))
-   {
-     tooldir="TI_ARM11_GEN_INSTALL_PATH"; 
-   }
-   else
-   {
-     tooldir="C6X_GEN_INSTALL_PATH";
-   }
- print(targetname+" Added for Freon debug.");
+   
    switch(stringname)
    {
     case String(C66LE):
+      tooldir="C6X_GEN_INSTALL_PATH";
+      cmdprefix="";
+      targetDir="c66/release";
       targetname=C66LE;
       break;
     case String(C66BE):
+      tooldir="C6X_GEN_INSTALL_PATH";
+      cmdprefix="";
+      targetDir="c66/release";
       targetname=C66BE;
       break;
-case String(C67LE):
-      targetname=C67LE;
+    case String(A15LE):
+      tooldir="TOOLCHAIN_PATH_A15"; 
+      cmdprefix="CROSS_TOOL_PRFX";
+      targetDir="a15/release";
+      targetname=A15LE;
+      break;
+    case String(A9LE):
+      tooldir="TOOLCHAIN_PATH_A9";
+      cmdprefix="CROSS_TOOL_PRFX";
+      targetDir="a9/release";
+      targetname=A9LE;
+      break;
+    case String(A8LE):
+      tooldir="TOOLCHAIN_PATH_A8";
+      cmdprefix="CROSS_TOOL_PRFX";
+      targetDir="a8/release";
+      targetname=A8LE;
+      break;
+    case String(M4LE):
+      tooldir="TOOLCHAIN_PATH_M4";
+      cmdprefix="";
+      targetDir="m4/release";
+      targetname=M4LE;
+      break;
+    case String(C674LE):
+      tooldir="C6X_GEN_INSTALL_PATH";
+      cmdprefix="";
+      targetDir="c674/release";
+      targetname=C674LE;
       break;
 
    }
@@ -317,46 +292,82 @@ case String(C67LE):
     libmakefile.writeLine("#");
     libmakefile.writeLine("empty =");
     libmakefile.writeLine("space =$(empty) $(empty)");
-         
-    if(stringname.match("ti.targets"))
+  
+    if ((targetname.name == "A15F") || (targetname.name == "A9F") || (targetname.name == "A8F"))
     {
+    
+        if(stringname.match("gnu.targets"))
+        {
+            libmakefile.writeLine("CC = $("+tooldir+")/bin/$("+cmdprefix+")gcc");
+            libmakefile.writeLine("AC = $("+tooldir+")/bin/$("+cmdprefix+")as");    
+            libmakefile.writeLine("ARIN = $("+tooldir+")/bin/$("+cmdprefix+")ar");    
+            libmakefile.writeLine("LD = $("+tooldir+")/bin/$("+cmdprefix+")gcc");   
+        }
+        else
+        {
+            print("Error: Non-GNU targets are not currently supported ");
+            java.lang.System.exit(1);
 
-       var rtslibtemp = targetname.lnkOpts.suffix.toString().split("/");
-       var rtslib;
-       for(n=0;n<rtslibtemp.length;n++)
-       {
-          if(rtslibtemp[n].match(".lib"))
-          { 
-             rtslib=rtslibtemp[n];
-          }
-       }
-
-      libmakefile.writeLine("CC = $("+tooldir+")/bin/"+targetname.cc.cmd +" "+targetname.ccOpts.prefix+" "+targetname.cc.opts);
-      libmakefile.writeLine("AC = $("+tooldir+")/bin/"+targetname.asm.cmd +" "+targetname.asmOpts.prefix+" "+targetname.asm.opts);    
-      libmakefile.writeLine("ARIN = $("+tooldir+")/bin/"+targetname.ar.cmd +" "+targetname.ar.opts);    
-      libmakefile.writeLine("LD = $("+tooldir+")/bin/"+targetname.lnk.cmd +" "+targetname.lnk.opts);   
-      libmakefile.writeLine("RTSLIB = -l $("+tooldir+")/lib/"+rtslib);        
+        }
+       
+        libmakefile.writeLine("INCS = -I. -I$(strip $(subst ;, -I,$(subst $(space),\\$(space),$(INCDIR)))) -I$("+tooldir+")/include");
+        libmakefile.writeLine("OBJEXT = o"+targetname.suffix); 
+        libmakefile.writeLine("AOBJEXT = s"+targetname.suffix);     
+        libmakefile.writeLine("CFLAGS_INTERNAL = " +targetname.ccOpts.prefix+" "+targetname.cc.opts);
+        libmakefile.writeLine("ASFLAGS_INTERNAL = " +targetname.asmOpts.prefix+" "+targetname.asm.opts);
+        libmakefile.writeLine("ARFLAGS_INTERNAL = " +targetname.ar.opts);
+        libmakefile.writeLine("LNKFLAGS_INTERNAL = " +targetname.lnk.opts);
+        libmakefile.writeLine("INTERNALDEFS = -MD -MF $@.dep");
+        libmakefile.writeLine("INTERNALLINKDEFS = -o $@ -m $@.map");  /* TBD */
+        libmakefile.writeLine("OBJDIR =  ./obj/obj_" +targetname.suffix +"/" + device.toString() + "/" + targetDir +"/obj" + "/" + objExtDir); 
+    
     }
     else
     {
-      print("Error: Non-TI targets are not currently supported ");
-      java.lang.System.exit(1);
+  
+        if(stringname.match("ti.targets"))
+        {
 
-    }
+            var rtslibtemp = targetname.lnkOpts.suffix.toString().split("/");
+            var rtslib;
+            for(n=0;n<rtslibtemp.length;n++)
+            {
+                if(rtslibtemp[n].match(".lib"))
+                { 
+                    rtslib=rtslibtemp[n];
+                }
+            }
+
+            libmakefile.writeLine("CC = $("+tooldir+")/bin/"+targetname.cc.cmd);
+            libmakefile.writeLine("AC = $("+tooldir+")/bin/"+targetname.asm.cmd);    
+            libmakefile.writeLine("ARIN = $("+tooldir+")/bin/"+targetname.ar.cmd);    
+            libmakefile.writeLine("LD = $("+tooldir+")/bin/"+targetname.lnk.cmd);   
+            libmakefile.writeLine("RTSLIB = -l $("+tooldir+")/lib/"+rtslib);        
+        }
+        else
+        {
+            print("Error: Non-TI targets are not currently supported ");
+            java.lang.System.exit(1);
+        }
        
-    libmakefile.writeLine("INCS = -I. -I$(strip $(subst ;, -I,$(subst $(space),\\$(space),$(INCDIR))))");
-    libmakefile.writeLine("OBJEXT = o"+targetname.suffix); 
-    libmakefile.writeLine("AOBJEXT = s"+targetname.suffix);     
-    /* libmakefile.writeLine("INTERNALDEFS = -D"+stringname.replace(/\./g,"_")+" -Dxdc_target_types__=ti/targets/std.h -DMAKEFILE_BUILD -eo.$(OBJEXT) -ea.$(AOBJEXT) -fr=$(@D) -fs=$(@D) -ppa -ppd=$@.dep");*/
-    libmakefile.writeLine("INTERNALDEFS = -D"+stringname.replace(/\./g,"_")+"  -DMAKEFILE_BUILD -eo.$(OBJEXT) -ea.$(AOBJEXT) -fr=$(@D) -fs=$(@D) -ppa -ppd=$@.dep");
-    libmakefile.writeLine("INTERNALLINKDEFS = -o $@ -m $@.map");
-         libmakefile.writeLine("OBJDIR =  $(LIBDIR)");    
+        libmakefile.writeLine("INCS = -I. -I$(strip $(subst ;, -I,$(subst $(space),\\$(space),$(INCDIR)))) -I$("+tooldir+")/include");
+        libmakefile.writeLine("OBJEXT = o"+targetname.suffix); 
+        libmakefile.writeLine("AOBJEXT = s"+targetname.suffix);     
+        libmakefile.writeLine("CFLAGS_INTERNAL = " +targetname.ccOpts.prefix+" "+targetname.cc.opts);
+        libmakefile.writeLine("ASFLAGS_INTERNAL = " +targetname.asmOpts.prefix+" "+targetname.asm.opts);
+        libmakefile.writeLine("ARFLAGS_INTERNAL = " +targetname.ar.opts);
+        libmakefile.writeLine("LNKFLAGS_INTERNAL = " +targetname.lnk.opts);
+        /* libmakefile.writeLine("INTERNALDEFS = -D"+stringname.replace(/\./g,"_")+" -Dxdc_target_types__=ti/targets/std.h -DMAKEFILE_BUILD -eo.$(OBJEXT) -ea.$(AOBJEXT) -fr=$(@D) -fs=$(@D) -ppa -ppd=$@.dep");*/
+        libmakefile.writeLine("INTERNALDEFS = -D"+stringname.replace(/\./g,"_")+"  -DMAKEFILE_BUILD -eo.$(OBJEXT) -ea.$(AOBJEXT) -fr=$(@D) -fs=$(@D) -ppa -ppd=$@.dep");
+        libmakefile.writeLine("INTERNALLINKDEFS = -o $@ -m $@.map");
+        libmakefile.writeLine("OBJDIR =  ./obj/obj_" +targetname.suffix +"/" + device.toString() + "/" + targetDir +"/obj" + "/" + objExtDir); 
+    }
    
  return libmakefile;
 
 }
 
-function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, targetName)
+function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, targetName, objDir)
 {
   var  sourcestring = (srcString + fileExt).toString().toUpperCase();
   var  compileflagstring = sourcestring + "FLAGS";
@@ -391,8 +402,8 @@ function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, target
  makefilename.writeLine(compileflagstring+" = "+compileflags +" \n");     
  makefilename.writeLine("# Make Rule for the "+srcString+" Files");  
  
- makefilename.writeLine(objectliststring +" = $(patsubst %."+fileExt+", $(OBJDIR)/%.$(OBJEXT), $(" + sourcestring + "))"); 
- makefilename.writeLine("\n$("+objectliststring+"): $(OBJDIR)/%.$(OBJEXT): %."+fileExt);   
+ makefilename.writeLine(objectliststring +" = $(patsubst %."+fileExt+", "+objDir+"/%.$(OBJEXT), $(" + sourcestring + "))"); 
+ makefilename.writeLine("\n$("+objectliststring+"): "+objDir+"/%.$(OBJEXT): %."+fileExt);   
  if(fileExt == "c")
  { 
    makefilename.writeLine("\t-@echo cl"+targetName.suffix +" $< ...");     
@@ -405,21 +416,33 @@ function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, target
  
  if(fileExt == "c")
  {
-   makefilename.writeLine("\t$(RM) $@.dep");
-   makefilename.writeLine("\t$(CC) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) -fc $< ");
-   makefilename.writeLine("\t-@$(CP) $@.dep $@.pp; \\");
-   makefilename.writeLine("         $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\\\$$//' \\");
-   makefilename.writeLine("             -e '/^$$/ d' -e 's/$$/ :/' < $@.pp >> $@.dep; \\");
-   makefilename.writeLine("         $(RM) $@.pp ");
+   if ((targetName.name == "A15F") || (targetName.name == "A9F") || (targetName.name == "A8F"))
+   {
+    makefilename.writeLine("\t$(RM) $@.dep");
+    makefilename.writeLine("\t$(CC) $(CFLAGS_INTERNAL) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) $< -o $@");
+   /* 
+    TBD
+   */
+   }
+   else
+   {
+    makefilename.writeLine("\t$(RM) $@.dep");
+    makefilename.writeLine("\t$(CC) $(CFLAGS_INTERNAL) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) -fc $< ");
+    makefilename.writeLine("\t-@$(CP) $@.dep $@.pp; \\");
+    makefilename.writeLine("         $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\\\$$//' \\");
+    makefilename.writeLine("             -e '/^$$/ d' -e 's/$$/ :/' < $@.pp >> $@.dep; \\");
+    makefilename.writeLine("         $(RM) $@.pp ");
+   }
  }
  else if(fileExt == "asm")
  {
-   makefilename.writeLine("\t$(AC) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) -fa $< ");
+   makefilename.writeLine("\t$(AC) $(ASFLAGS_INTERNAL) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) -fa $< ");
  }
  else if(fileExt == "sa")
  {
-   makefilename.writeLine("\t$(AC) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) $< ");
+   makefilename.writeLine("\t$(AC) $(ASFLAGS_INTERNAL) $("+compileflagstring+") $(INTERNALDEFS) $(INCS) $< ");
  }
    makefilename.writeLine("\n#Create Empty rule for dependency");
    makefilename.writeLine("$("+objectliststring+"):"+makefilename.$private.fd);
    makefilename.writeLine(makefilename.$private.fd+":");
@@ -437,24 +460,64 @@ function makeAddObjects(srcString, makefilename, srcfiles, flags,fileExt, target
  *  Utility function which will build a specific library
  **************************************************************************/
 var makefilelocal;
-function buildLibrary (libOptions, libName, target, libFiles) 
+function buildLibrary (socName, isSoc, libOptions, libName, target, libFiles) 
 {
-    var lldFullLibraryPath = "./lib/" + libName;
-    var lldFullLibraryPathMake = "$(LIBDIR)/" + libName;
+    var targetDir;
+    var objExtDir;
+    
+    if (target.name == "A15F")
+    {
+        targetDir = "a15/release";
+    }
+    else if (target.name == "A9F")
+    {
+        targetDir = "a9/release";
+    }
+    else if (target.name == "A8F")
+    {
+        targetDir = "a8/release";
+    }
+    else if (target.name == "M4")
+    {
+        targetDir = "m4/release";
+    }
+       else if (target.name == "C674")
+    {
+        targetDir = "c674";
+    }
+    else
+    {
+        targetDir = "c66";
+    }
+    
+    /* Derive the operating system and soc names */
+    if (isSoc == "true") {
+        var libNameExp = libName+"."+socName;
+        targetDir = socName+"/"+targetDir;
+        objExtDir = "soc";
+    }
+    else  {
+        var libNameExp = libName;
+        objExtDir = "all";
+    }
+
+    var lldFullLibraryPath = "./lib/" + targetDir +"/" + libNameExp;
+    var lldFullBuildPath = "./build/" + targetDir +"/" + libNameExp;
+    var lldFullLibraryPathMake = "$(LIBDIR)/" + targetDir +"/" + libNameExp;
 
     /* Create Main make file in the root of package folder */
     makefilelocal = createMake(makefilelocal);
 
     /* Write the rule to make library in main makefile */
-    lib = lldFullLibraryPath+".a"+target.suffix;
+    lib = lldFullBuildPath+".a"+target.suffix;
     libMake = lldFullLibraryPathMake+".a"+target.suffix;
-    var objectPath= "./package/lib/"+lldFullLibraryPath;
+    var objectPath= "./package/"+lldFullBuildPath;
     makefilelocal.writeLine("\n\n# Make rule to create "+libMake+" library");
     makefilelocal.writeLine(".libraries: "+ libMake);
     makefilelocal.writeLine(libMake+": FORCE\n\t$(MAKE) -f "+lib+".mk $@");                                 
 
     /* Create Library make file in the lib folder */
-    var makefilelib= createLibMake(lib+".mk",target,objectPath);  
+    var makefilelib= createLibMake(socName, lib+".mk",target,objectPath);  
 
     /* Rule to clean library in main makefile */
     makefilelocal.writeLine("# Rule to clean "+libMake+" library");                                              
@@ -491,44 +554,60 @@ function buildLibrary (libOptions, libName, target, libFiles)
      }
     if(cfiles.length > 0)
     {                                                
-      makeAddObjects("COMMONSRC",makefilelib,cfiles,libOptions,"c",target);
+      makeAddObjects("COMMONSRC",makefilelib,cfiles,libOptions,"c",target, "$(OBJDIR)");
       librule += " $(COMMONSRCCOBJS)";                   
     }
     if(afiles.length > 0)
     {                                                
-      makeAddObjects("COMMONSRC",makefilelib,afiles,libOptions,"asm",target);
-      librule += " $(COMMONSRCSOBJS)";                   
+      makeAddObjects("COMMONSRC",makefilelib,afiles,libOptions,"asm",target, "$(OBJDIR)");
+      librule += " $(COMMONSRCASMOBJS)";                   
     }
     if(safiles.length > 0)
     {                                                
-      makeAddObjects("COMMONSRC",makefilelib,safiles,libOptions,"sa",target);
+      makeAddObjects("COMMONSRC",makefilelib,safiles,libOptions,"sa",target, "$(OBJDIR)");
       librule += " $(COMMONSRCSAOBJS)";                   
     }
 
     makefilelib.writeLine(librule);
     makefilelib.writeLine("\t@echo archiving $? into $@ ...");
-               makefilelib.writeLine("\t$(ARIN) $@ $?");
-               makefilelib.close();   
-
-    /* Create the library file and add all the objects to the file. */
-    var lib = Pkg.addLibrary(lldFullLibraryPath, target, libOptions);
-
-    lib.addObjects (libFiles);
+    makefilelib.writeLine("\tif [ ! -d $(LIBDIR)/"+targetDir+" ]; then $(MKDIR) $(LIBDIR)/"+targetDir+" ; fi;"); 
+    makefilelib.writeLine("\t$(ARIN) $(ARFLAGS_INTERNAL) $@ $?");
+    makefilelib.close();   
 
     /* Create the Epilogue; which executes after all the builds are completed. 
      * This is used to generate the benchmark information for the built library. 
      * Also add the benchmarking information file to the package. */
-    Pkg.makeEpilogue += ".libraries: benchmarking_" + target.suffix + "\n";
-    Pkg.makeEpilogue += "benchmarking_" + target.suffix + ":";
-    Pkg.makeEpilogue += "\n\t ofd6x.exe -x " + lldFullLibraryPath + ".a" + target.suffix + " > tmp.xml";
-    Pkg.makeEpilogue += "\n\t sectti.exe tmp.xml > " + lldFullLibraryPath + ".a" + target.suffix +  "_size.txt";
-    Pkg.makeEpilogue += "\n\t $(RM) tmp.xml\n\n";
+
+    /* Put the temp file in object directory since javascript doesn't have a built in tmpname, 
+     * and don't want --jobs=# with # > 1 to result in collisions */
+    var libFullName = lldFullLibraryPath + ".a" + target.suffix;
+    var tempFile = libFullName + ".xml";
+    Pkg.makeEpilogue += ".libraries: " + libFullName +  "_size.txt\n";
+    Pkg.makeEpilogue += libFullName +  "_size.txt: " + libFullName + "\n";
+    if ( java.lang.String(target.name).contains('66') )
+    {    
+        Pkg.makeEpilogue += "\n\t $(C6X_GEN_INSTALL_PATH)/bin/ofd6x -x " + libFullName + " > " + tempFile;
+        Pkg.makeEpilogue += "\n\t $(SECTTI) " + tempFile + " > " + libFullName +  "_size.txt";
+        Pkg.makeEpilogue += "\n\t $(RM) " + tempFile + "\n\n";
+    }   
+    else if (target.name == "M4")
+    {
+        Pkg.makeEpilogue += "\n\t $(TOOLCHAIN_PATH_M4)/bin/armofd -x " + libFullName + " > " + tempFile;
+        Pkg.makeEpilogue += "\n\t $(SECTTI) " + tempFile + " > " + libFullName +  "_size.txt";
+        Pkg.makeEpilogue += "\n\t $(RM) " + tempFile + "\n\n";
+    }
+    else
+    {
+        Pkg.makeEpilogue += "\n\t $(TOOLCHAIN_PATH_A15)/bin/$(CROSS_TOOL_PRFX)size " + libFullName + " > " + libFullName + "_size.txt";
+    }                
     Pkg.otherFiles[Pkg.otherFiles.length++] = lldFullLibraryPath + ".a" + target.suffix + "_size.txt";
-    Pkg.otherFiles[Pkg.otherFiles.length++] = lldFullLibraryPath + ".a" + target.suffix + ".mk";
+    Pkg.otherFiles[Pkg.otherFiles.length++] = lldFullBuildPath + ".a" + target.suffix + ".mk";
+    Pkg.otherFiles[Pkg.otherFiles.length++] = lldFullLibraryPath + ".a" + target.suffix;
 
     /* We need to clean after ourselves; extend the 'clean' target to take care of this. */
-    Pkg.makeEpilogue += "clean::\n\t";
-    Pkg.makeEpilogue += "$(RM) " + lldFullLibraryPath + ".a" + target.suffix + "_size.txt\n\n";
+    Pkg.makeEpilogue += "\nclean::\n";
+    Pkg.makeEpilogue += "\t$(RM) " + lldFullBuildPath + ".a" + target.suffix + "_size.txt\n";    
+    Pkg.makeEpilogue += "\t$(RMDIR) " + "$(LIBDIR)/" + targetDir + "/ \n\n";
 
     return lib;
 }