Changeset 135


Ignore:
Timestamp:
May 13, 2003, 5:57:49 PM (22 years ago)
Author:
bird
Message:

#416: Added library filename resolving similar to ld.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/emxomfld.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r134 r135  
    381381      list = list->next;
    382382    }
     383}
     384
     385
     386/* Put a list of library arguments on to the command line or into the
     387   response file. Filenames without path and extension will be 'resolved'
     388   using libdirs and the LIB environment variable and a '.lib' extension.
     389   If not found a search for a 'lib' prefixed filename is attempted, if
     390   still not found we'll let link386 do the complaining and pass filename
     391   unresolved to link386.
     392
     393   The motivation for doing this is to have the same behaviour of ld and
     394   emxomfld which allows us to lax the libsomething.lib to something.lib
     395   renaming and addapt to the gcc/unix library naming standards.
     396   (see Innotek Defect #416)
     397
     398   Note. make_env () *must* be called before this function is called. */
     399
     400static void put_lib_args(const name_list *list)
     401{
     402  const char *pszLib = getenv ("LIB");
     403  for (;list != NULL; list = list->next)
     404    {
     405      char  szFilename[260];
     406      int   fFound = 0;
     407
     408      if (!strpbrk (list->name, ":\\/."))
     409        { /* search for it */
     410          const char *psz, *pszEnd;
     411          for (psz = pszLib; !fFound && psz; psz = pszEnd + (pszEnd != NULL))
     412            {
     413              pszEnd = strchr(psz, ';');
     414              if (pszEnd > psz)
     415                {
     416                  int  cchPath = pszEnd - psz;
     417                  struct stat s;
     418
     419                  strncpy(szFilename, psz, pszEnd - psz);
     420                  if (   szFilename[cchPath-1] != '\\'
     421                      && szFilename[cchPath-1] != '/'
     422                      && szFilename[cchPath-1] != ':')
     423                    szFilename[cchPath++] = '\\';
     424
     425                  strcat(strcpy(szFilename + cchPath, list->name), ".lib");
     426                  fFound = !stat(szFilename, &s);
     427                  if (!fFound)
     428                    {
     429                      strcat(strcpy(strcpy(szFilename + cchPath, "lib") + 3, list->name), ".lib");
     430                      fFound = !stat(szFilename, &s);
     431                    }
     432                }
     433            } /* foreach path in $LIB */
     434        }
     435
     436      put_arg (fFound ? szFilename : list->name, TRUE, TRUE);
     437    } /* foreach list entry */
    383438}
    384439
     
    681736    linker_name = t;
    682737
     738  /* Build the environment for LINK386.
     739     This must be done before calling put_lib_args (). */
     740
     741  make_env ();
     742
    683743  /* Start building the LINK386 command line.  We can use a response
    684744     file if the command line gets too long. */
     
    795855  /* Put the library file names onto the command line. */
    796856
    797   put_args (lib_fnames, TRUE);
     857  put_lib_args (lib_fnames);
    798858  put_arg (",", FALSE, FALSE);
    799859
     
    803863  put_arg (";", FALSE, FALSE);
    804864  arg_end ();
    805 
    806   /* Build the environment for LINK386. */
    807 
    808   make_env ();
    809865
    810866  /* Call LINK386 via CMD.EXE (what a waste -- but I'm lazy) and abort
Note: See TracChangeset for help on using the changeset viewer.