Browse Source

* check extension of library if it needs to be linked static

peter 21 years ago
parent
commit
e009b39d8b
1 changed files with 27 additions and 15 deletions
  1. 27 15
      compiler/scandir.pas

+ 27 - 15
compiler/scandir.pas

@@ -445,6 +445,7 @@ implementation
       var
       var
         s : string;
         s : string;
         quote : char;
         quote : char;
+        libext,
         libname,
         libname,
         linkmodestr : string;
         linkmodestr : string;
         p : longint;
         p : longint;
@@ -466,24 +467,14 @@ implementation
             else
             else
               libname:=TrimSpace(copy(s,1,p-1));
               libname:=TrimSpace(copy(s,1,p-1));
           end;
           end;
-
         if p=0 then
         if p=0 then
           linkmodeStr:=''
           linkmodeStr:=''
         else
         else
           linkmodeStr:=Upper(TrimSpace(copy(s,p+1,255)));
           linkmodeStr:=Upper(TrimSpace(copy(s,p+1,255)));
 
 
+
         if (libname='') or (libname='''''') or (libname='""') then
         if (libname='') or (libname='''''') or (libname='""') then
          exit;
          exit;
-        { get linkmode, default is shared linking }
-        if linkModeStr='STATIC' then
-         linkmode:=lm_static
-        else if (LinkModeStr='SHARED') or (LinkModeStr='') then
-         linkmode:=lm_shared
-        else
-         begin
-           Comment(V_Error,'Wrong link mode specified: "'+Linkmodestr+'"');
-           exit;
-         end;
         { create library name }
         { create library name }
         if libname[1] in ['''','"'] then
         if libname[1] in ['''','"'] then
          begin
          begin
@@ -493,11 +484,29 @@ implementation
            if p>0 then
            if p>0 then
             Delete(libname,p,1);
             Delete(libname,p,1);
          end;
          end;
-        { add to the list of libraries to link }
+        libname:=FixFileName(libname);
+
+        { get linkmode, default is to check the extension for
+          the static library, otherwise shared linking is assumed }
+        linkmode:=lm_shared;
+        if linkModeStr='' then
+         begin
+           libext:=SplitExtension(libname);
+           if libext=target_info.staticClibext then
+             linkMode:=lm_static;
+         end
+        else if linkModeStr='STATIC' then
+         linkmode:=lm_static
+        else if (LinkModeStr='SHARED') or (LinkModeStr='') then
+         linkmode:=lm_shared
+        else
+         Comment(V_Error,'Wrong link mode specified: "'+Linkmodestr+'"');
+
+        { add to the list of other libraries }
         if linkMode=lm_static then
         if linkMode=lm_static then
-         current_module.linkOtherStaticLibs.add(FixFileName(libname),link_allways)
+         current_module.linkOtherStaticLibs.add(libname,link_allways)
         else
         else
-         current_module.linkOtherSharedLibs.add(FixFileName(libname),link_allways);
+         current_module.linkOtherSharedLibs.add(libname,link_allways);
       end;
       end;
 
 
     procedure dir_localsymbols;
     procedure dir_localsymbols;
@@ -1138,7 +1147,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.46  2004-10-26 15:11:01  peter
+  Revision 1.47  2004-11-06 17:58:10  peter
+    * check extension of library if it needs to be linked static
+
+  Revision 1.46  2004/10/26 15:11:01  peter
     * -Ch for heapsize added again
     * -Ch for heapsize added again
     * __heapsize contains the heapsize
     * __heapsize contains the heapsize