Fix a long standing bug in Scilab.
Sylvestre Ledru [Wed, 16 Sep 2009 16:33:04 +0000 (18:33 +0200)]
In the 5.X familly, when Scilab packages were installed on the system
(for example debian/ubuntu packages), ilib_compile was adding
both sources tree as CFLAGS:
-I/my/dev/source/tree/of/scilab/modules/core/includes/
and also
-I/usr/include/scilab/core/

This was causing some important (and hard to find) issues when header files
were different/updated.

scilab/modules/dynamic_link/macros/ilib_compile.sci

index 9af3803..be8cf4b 100644 (file)
@@ -76,12 +76,17 @@ function libn = ilib_compile(lib_name,makename,files, ..
     end
    
   else
-    //** ---------- Linux section ---------------------  
-       defaultModulesCHeader=[ "core", "mexlib","api_scilab","output_stream","localization" ];
-       defaultModulesFHeader=[ "core" ];
+    //** ---------- Linux/MacOS/Unix section ---------------------  
        
+       ScilabTreeFound=%f
+
     // Source tree version
+       // Headers are dispatched in the source tree
        if isdir(SCI+"/modules/core/includes/") then
+         defaultModulesCHeader=[ "core", "mexlib","api_scilab","output_stream","localization" ];
+         defaultModulesFHeader=[ "core" ];
+         ScilabTreeFound=%t
+
          for x = defaultModulesCHeader(:)' 
              cflags=" -I"+SCI+"/modules/"+x+"/includes/ "+cflags;
          end
@@ -92,27 +97,21 @@ function libn = ilib_compile(lib_name,makename,files, ..
           end
        end
 
-       // Add MALLOC since that is this two cases, it is at the same place
-       defaultModulesCHeader=[ defaultModulesCHeader, "malloc" ]; 
-
        // Binary version
-       if isdir(SCI+"/../../include/scilab/core/") then
-         for x = defaultModulesCHeader(:)' 
-                 cflags="-I"+SCI+"/../../include/scilab/"+ x + "/ " + cflags
-         end
-         for x = defaultModulesFHeader(:)' 
-                 fflags="-I"+SCI+"/../../include/scilab/"+x+"/ "+fflags
-         end
+       if isdir(SCI+"/../../include/scilab/") && ScilabTreeFound == %t then
+         cflags="-I"+SCI+"/../../include/scilab/ " + cflags
+         fflags="-I"+SCI+"/../../include/scilab/ " + fflags
+         ScilabTreeFound=%t
        end
 
        // System version (ie: /usr/include/scilab/)    
-       if isdir("/usr/include/scilab/") then
-         for x = defaultModulesCHeader(:)' 
-                 cflags="-I/usr/include/scilab/"+x+"/ "+cflags
-         end
-         for x = defaultModulesFHeader(:)' 
-                 fflags="-I/usr/include/scilab/"+x+"/ "+fflags
-         end
+       if isdir("/usr/include/scilab/") && ScilabTreeFound == %t then
+          cflags="-I/usr/include/scilab/ "+cflags
+          fflags="-I/usr/include/scilab/ "+fflags
+       end
+
+       if ( ilib_verbose() <> 0 ) then
+          mprintf(gettext("%s: Warning: Scilab has not been able to find where the Scilab sources are. Please submit a bug report on http://bugzilla.scilab.org/\n"),"ilib_compile");  
        end
 
       oldPath = pwd();