realpath() is not available for mingw32. Use _fullpath instead.
[fw/sdcc] / as / mcs51 / lklibr.c
index 07028e7995395972584a98ba059407dcfe371ac3..881a2bc58335b8a6a3bc462aafa313140d49af1b 100644 (file)
@@ -661,6 +661,7 @@ int fndsym( char *name )
        
        /* Iterate through all library object files */
        ThisLibr = libr.next;
+    FirstFound = libr.next; /*So gcc stops whining*/
        while (ThisLibr)
     {
                /* Iterate through all symbols in an object file */
@@ -720,8 +721,20 @@ int fndsym( char *name )
                 }
                 else
                 {
-                    if( !( EQ(FirstFound->libspc, ThisLibr->libspc) && 
-                           EQ(FirstFound->relfil, ThisLibr->relfil) ) )
+                    char absPath1[PATH_MAX];
+                    char absPath2[PATH_MAX];
+#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
+                    int j;
+
+                    _fullpath(absPath1, FirstFound->libspc, PATH_MAX);
+                    _fullpath(absPath2, ThisLibr->libspc, PATH_MAX);
+                    for(j=0; absPath1[j]!=0; j++) absPath1[j]=tolower(absPath1[j]);
+                    for(j=0; absPath2[j]!=0; j++) absPath2[j]=tolower(absPath2[j]);
+#else
+                    realpath(FirstFound->libspc, absPath1);
+                    realpath(ThisLibr->libspc, absPath2);
+#endif
+                    if( !( EQ(absPath1, absPath2) && EQ(FirstFound->relfil, ThisLibr->relfil) ) )
                     {
                         if(numfound==1)
                         {
@@ -915,7 +928,7 @@ int buildlibraryindex(void)
                                strcat(str,relfil);
                        }
 
-            if(strchr(str, FSEPX) == NULL)
+            if(strchr(relfil, FSEPX) == NULL)
             {
                                sprintf(&str[strlen(str)], "%crel", FSEPX);
                        }