Fix a long standing bug in Scilab.
Sylvestre Ledru [Wed, 16 Sep 2009 16:44:13 +0000 (18:44 +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.

The behaviour is now:
* check if we are in the source tree
* if not, check if it is the scilab binary (ie the tar.gz that we are providing on the website)
* if not, check if it is a scilab package (/usr/include/scilab)
* if not, display a warning message saying that the user should report a bug report

scilab/modules/dynamic_link/macros/ilib_compile.sci

index be8cf4b..9af3803 100644 (file)
@@ -76,17 +76,12 @@ function libn = ilib_compile(lib_name,makename,files, ..
     end
    
   else
-    //** ---------- Linux/MacOS/Unix section ---------------------  
+    //** ---------- Linux section ---------------------  
+       defaultModulesCHeader=[ "core", "mexlib","api_scilab","output_stream","localization" ];
+       defaultModulesFHeader=[ "core" ];
        
-       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
@@ -97,21 +92,27 @@ 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/") && ScilabTreeFound == %t then
-         cflags="-I"+SCI+"/../../include/scilab/ " + cflags
-         fflags="-I"+SCI+"/../../include/scilab/ " + fflags
-         ScilabTreeFound=%t
+       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
        end
 
        // System version (ie: /usr/include/scilab/)    
-       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");  
+       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
        end
 
       oldPath = pwd();