align buildlib to procsdk style
[keystone-rtos/mcbsp-lld.git] / build / buildlib.xs
old mode 100755 (executable)
new mode 100644 (file)
index fe03505..08c6ed7
@@ -110,8 +110,6 @@ 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");
@@ -157,7 +155,7 @@ function createMake(makefile)
       makefile.writeLine("export ROOTDIR := "+pkgroot);
     
       makefile.writeLine("\n# INCLUDE Directory");
-      makefile.writeLine("export INCDIR := "+getxdcpath+";$(ROOTDIR);$(C6X_GEN_INSTALL_PATH)/include");       
+      makefile.writeLine("export INCDIR := "+getxdcpath+";$(ROOTDIR)");       
     
       makefile.writeLine("\n# Common Macros used in make");  
       makefile.writeLine("\nifndef RM");     
@@ -217,24 +215,55 @@ function createMake(makefile)
 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";
-   }
+   
    switch(stringname)
    {
     case String(C66LE):
+      tooldir="C6X_GEN_INSTALL_PATH";
+      cmdprefix="";
+      targetDir="c66";
       targetname=C66LE;
       break;
     case String(C66BE):
+      tooldir="C6X_GEN_INSTALL_PATH";
+      cmdprefix="";
+      targetDir="c66";
       targetname=C66BE;
       break;
+    case String(A15LE):
+      tooldir="TOOLCHAIN_PATH_A15"; 
+      cmdprefix="CROSS_TOOL_PRFX";
+      targetDir="armv7";
+      targetname=A15LE;
+      break;
+    case String(A9LE):
+      tooldir="TOOLCHAIN_PATH_A9";
+      cmdprefix="CROSS_TOOL_PRFX";
+      targetDir="armv7";
+      targetname=A9LE;
+      break;
+    case String(A8LE):
+      tooldir="TOOLCHAIN_PATH_A8";
+      cmdprefix="CROSS_TOOL_PRFX";
+      targetDir="armv7";
+      targetname=A8LE;
+      break;
+    case String(M4LE):
+      tooldir="TOOLCHAIN_PATH_M4";
+      cmdprefix="";
+      targetDir="m4";
+      targetname=M4LE;
+      break;
+    case String(ARM11):
+      tooldir="TI_ARM11_GEN_INSTALL_PATH"; 
+      break;
     case String(C67LE):
+      tooldir="C6X_GEN_INSTALL_PATH";
+      cmdprefix="";
+      targetDir="c66";
       targetname=C67LE;
       break;
 
@@ -267,40 +296,75 @@ function createLibMake(device, makelibname,targetname, objectPath)
     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 =  $(LIBDIR)/" + device.toString() + "/" + targetDir +"/obj"); 
+    
     }
     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("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)/" + device.toString() + "/obj");
-    libmakefile.writeLine("DEVOBJDIR = $(LIBDIR)/" + device.toString() + "/obj");
+            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)))) -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 =  $(LIBDIR)/" + device.toString() + "/" + targetDir +"/obj"); 
+    }   
    
  return libmakefile;
 
@@ -355,21 +419,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+":");
@@ -494,7 +570,7 @@ function buildLibrary (socName, isSoc, libOptions, libName, target, libFiles)
     makefilelib.writeLine(librule);
     makefilelib.writeLine("\t@echo archiving $? into $@ ...");
     makefilelib.writeLine("\tif [ ! -d $(LIBDIR)/"+targetDir+" ]; then $(MKDIR) $(LIBDIR)/"+targetDir+" ; fi;"); 
-    makefilelib.writeLine("\t$(ARIN) $@ $?");
+    makefilelib.writeLine("\t$(ARIN) $(ARFLAGS_INTERNAL) $@ $?");
     makefilelib.close();   
 
     /* Create the Epilogue; which executes after all the builds are completed.