Improved -l option.
authorjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 1 Oct 2006 03:47:36 +0000 (03:47 +0000)
committerjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 1 Oct 2006 03:47:36 +0000 (03:47 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4394 4a8a32a2-be11-0410-ad9d-d568d2c75423

support/librarian/sdcclib.c

index 95817b2e1bbd98915cac8423633234cc828baf2f..b6760c6d5c96554e49192ca09731d3f24674e000 100644 (file)
@@ -533,6 +533,10 @@ int fileexist(char * fname)
 void AddList(void)
 {
     FILE * list;
+    char *cc;
+    char *as;
+    char CmdLine[1024];
+    char SrcName[PATH_MAX];
 
     list=fopen(ListName, "r");
     if(list==NULL)
@@ -541,6 +545,9 @@ void AddList(void)
         return;
     }
 
+    cc = getenv("SDCCLIB_CC");
+    as = getenv("SDCCLIB_AS");
+
     action=OPT_ADD_REL;
     while(!feof(list))
     {
@@ -549,6 +556,34 @@ void AddList(void)
         CleanLine(RelName);
         if(strlen(RelName)>0) //Skip empty lines
         {
+            if((cc!=NULL)||(as!=NULL))
+            {
+                strcpy(SrcName, RelName);
+                if(strchr(SrcName,'.')==NULL)
+                    strcat(SrcName,".src");
+            }
+
+            if(cc!=NULL)
+            {
+                ChangeExtension(SrcName, "c");
+                if(fileexist(SrcName))
+                {
+                    sprintf(CmdLine, "%s %s", cc, SrcName);
+                    printf("%s\n", CmdLine);
+                    system(CmdLine);
+                }
+            }
+            else if(as!=NULL)
+            {
+                ChangeExtension(SrcName, "asm");
+                if(fileexist(SrcName))
+                {
+                    sprintf(CmdLine, "%s %s", as, SrcName);
+                    printf("%s\n", CmdLine);
+                    system(CmdLine);
+                }
+            }
+
             if(strchr(RelName,'.')==NULL)
             {
                 //Try adding the default sdcc extensions
@@ -556,6 +591,7 @@ void AddList(void)
                 if(!fileexist(RelName))
                     ChangeExtension(RelName, "rel");
             }
+
             printf("Adding: %s\n", RelName);
             AddRel();
         }