*Missing file dyn link
Sylvestre Ledru [Mon, 18 Feb 2008 17:22:39 +0000 (17:22 +0000)]
* more stuff to manage flags

scilab/modules/dynamic_link/macros/ilib_build.sci
scilab/modules/dynamic_link/macros/ilib_compile.sci
scilab/modules/dynamic_link/macros/ilib_gen_Make.sci
scilab/modules/dynamic_link/macros/ilib_gen_Make_unix.sci [new file with mode: 0644]

index c4c4e93..df74466 100644 (file)
@@ -9,7 +9,7 @@
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
 //==========================================
-function ilib_build(ilib_name,table,files,libs,makename,ldflags,cflags,fflags,ismex)
+function ilib_build(ilib_name,table,files,libs,makename,ldflags,cflags,fflags,ismex,cc)
 
   if ~haveacompiler() then
        error(_("A Fortran or C compiler is required."))  
@@ -28,6 +28,7 @@ function ilib_build(ilib_name,table,files,libs,makename,ldflags,cflags,fflags,is
   if rhs <= 6 then cflags  = ''; end 
   if rhs <= 7 then fflags  = ''; end 
   if rhs <= 8 then ismex  = %f; end 
+  if rhs <= 9 then cc  = ''; end 
   
   warningmode = warning('query');
   
@@ -55,7 +56,7 @@ function ilib_build(ilib_name,table,files,libs,makename,ldflags,cflags,fflags,is
          write(%io(2),sprintf(_("   Generate a Makefile")));
        end
   end
-  ilib_gen_Make(ilib_name,table,files,libs,makename,%t,ldflags,cflags,fflags);
+  ilib_gen_Make(ilib_name,table,files,libs,makename,%t,ldflags,cflags,fflags,cc);
   
   // we call make
   if (warningmode == 'on') then
index 219844b..f2429c4 100644 (file)
@@ -1,7 +1,12 @@
 //==========================================
 // Copyright (C) INRIA/ENPC
 //==========================================
-function libn = ilib_compile(lib_name,makename,files)
+function libn = ilib_compile(lib_name,makename,files, ..
+                                                        ldflags, ..
+                                                        cflags, ..
+                                                        fflags, ..
+                                                        cc)
+
 
   if ~haveacompiler() then
        error(_("A Fortran or C compiler is required."))
@@ -43,9 +48,11 @@ function libn = ilib_compile(lib_name,makename,files)
          oldPath = pwd();
          // Switch back to the TMPDIR where the mandatory files are
          chdir(TMPDIR);
-
-               // TODO : voir quoi faire du CFLAGS
-       [msg,ierr] = unix_g("make CFLAGS=-I"+SCI+"/modules/core/includes/");
+         cmd="make "
+         // CFLAGS 
+         cmd = cmd +" CFLAGS=""-I"+SCI+"/modules/core/includes/"""
+         
+         [msg,ierr] = unix_g(cmd)
        if ierr <> 0 then
          disp(msg);
          return;
index db1fac0..c5f6a2e 100644 (file)
@@ -7,12 +7,12 @@
 // are also available at    
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
-function Makename=ilib_gen_Make(name,tables,files,libs,makename,with_gateway,ldflags,cflags,fflags,flag)
+function Makename=ilib_gen_Make(name,tables,files,libs,makename,with_gateway,ldflags,cflags,fflags,flag,cc)
 // flag 'c' or 'f' used with lcc 
 //------------------------------------
 // generate a Makefile for gateway
 
-  if argn(2)<6 then with_gateway=%t,ldflags='',cflags='',fflags='';end
+  if argn(2)<6 then with_gateway=%t,ldflags='',cflags='',fflags='', cc='';end
   files=strsubst(strsubst(files,'.obj','') ,'.o',''); //compat
   // change table if necessary 
   if typeof(tables)<>'list' then 
@@ -54,7 +54,7 @@ function Makename=ilib_gen_Make(name,tables,files,libs,makename,with_gateway,ldf
     end
   else
      Makename = makename;
-     ilib_gen_Make_unix(name,files,libs,name,ldflags,cflags,fflags)
+     ilib_gen_Make_unix(name,files,libs,name,ldflags,cflags,fflags,cc)
   end
   end
 endfunction
diff --git a/scilab/modules/dynamic_link/macros/ilib_gen_Make_unix.sci b/scilab/modules/dynamic_link/macros/ilib_gen_Make_unix.sci
new file mode 100644 (file)
index 0000000..58e6980
--- /dev/null
@@ -0,0 +1,166 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ENPC
+// Copyright (C) 2007-2008 - INRIA - Sylvestre LEDRU
+// 
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at    
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+//==========================================
+// Generate a Makefile which can be used by ilib_*
+// Rewrited by Sylvestre Ledru in order to use autotools
+//==========================================
+function ilib_gen_Make_unix(names, ..
+                                 files, ..
+                                 libs, ..
+                                                                libname, ..
+                                                        ldflags, ..
+                                                        cflags, ..
+                                                        fflags, ..
+                                                        cc ..                                                   
+                                                        )
+if libname == "" then libname = names(1);end 
+
+if ( strncpy(libname,3) == "lib")
+  l=strsplit(libname,3); libname=l(2); 
+  clear l
+end
+
+warningmode = warning('query');
+
+originPath = pwd();
+linkpath = TMPDIR;
+//  if ldflags <> '' | cflags <> '' | fflags <> '' | cc <> '' then
+if ldflags == '' & cflags == '' & fflags == '' & cc == '' then
+  commandpath = SCI+"/modules/dynamic_link/src/scripts/";
+  // The normal configure in the standard path
+  generateConfigure(commandpath)
+end
+  
+       // Copy files => linkpath
+       chdir(linkpath);
+       if (warningmode == 'on') then
+         disp(msprintf(gettext("%s: Copy compilation files (Makefile*, libtool...) to TMPDIR\n"),"ilib_gen_Make"));
+       end
+
+       // List of the files mandatory to generate a lib with the detection of the env
+       mandatoryFiles = ["Makefile.orig", ..
+                         "configure.ac", ..
+                         "configure", ..
+                         "Makefile.am", ..
+                         "Makefile.in", ..
+                         "config.sub", ..
+                         "config.guess", ..
+                         "config.status", ..
+                         "depcomp", ..
+                         "install-sh", ..
+                         "ltmain.sh", ..
+                         "libtool", ..
+                         "missing", ..
+                         "aclocal.m4"];
+
+       // Copy files to the working tmpdir
+       for x = mandatoryFiles(:)' ;
+               [status,msg]=copyfile(commandpath+"/"+x,linkpath);
+               if (status <> 1)
+                 error(msprintf(gettext("%s: An error occurred: %s\n"), "ilib_gen_Make",msg));
+               end
+       end
+
+       filelist = "";  
+       for x = files(:)' ;  
+         // Pre added file in the list ... don't really know why
+         if (x <> "csci") then
+               // Old way: to compile a fun.c file, the user had to provide fun.o
+               filename = strsubst(x,'.o','');
+               chdir(originPath); // Switch back to the source dir in order to have only the filename
+               filesMatching = ls(filename+".*");
+               // The user provided the real filename
+               if filesMatching == [] then
+                 if (warningmode == 'on') then
+                       disp("Copy "+x+".* to TMPDIR")
+                 end
+                 copyfile(x, linkpath);
+                 filelist = filelist + " " + x ;
+               else
+               // Or copy the file matching to what we were looking for (this stuff
+               // could lead to bug if you have fun.c fun.f or fun.cxx but it was 
+               // already the case before ...
+               for f=filesMatching(:)' ;
+                 if (warningmode == 'on') then
+                       disp(msprintf("%s: Copy %s to TMPDIR\n","ilib_gen_Make",f));
+                 end
+                               copyfile(f, linkpath)
+                               filelist = filelist + " " + f;
+                       end
+               end
+               chdir(linkpath);
+
+
+               end
+         end
+         
+         if ldflags <> '' | cflags <> '' | fflags <> '' | cc <> '' then
+               // Rerun the ./configure with the flags
+               generateConfigure(linkpath, ldflags, cflags, fflags, cc)
+         end
+               
+       // Alter the Makefile in order to compile the right files
+       if (warningmode == 'on') then
+         disp(msprintf(gettext("%s: Modification of the Makefile in TMPDIR.\n"),"ilib_gen_Make"));
+       end
+       [msg,ierr] = unix_g("" + commandpath + "scicompile.sh " + libname + " " + filelist);
+
+       if ierr <> 0 then
+         disp(msg);
+         return;
+       end
+       
+       chdir(originPath);
+       
+endfunction
+
+
+function generateConfigure(workingPath, ldflags, ..
+                                                        cflags, ..
+                                                        fflags, ..
+                                                        cc)
+                                                
+                                                 
+  // We launch ./configure in order to produce a "generic" Makefile 
+  // for this computer
+  cmd=''
+         // CFLAGS
+         if cflags <> '' then
+               cmd = cmd +" CFLAGS="""+cflags+""""
+         end
+           
+         // LDFLAGS
+         if ldflags <> '' then
+               cmd = cmd +" LDFLAGS="""+ldflags+""""
+         end
+         
+         // FFLAGS
+         if fflags <> '' then
+               cmd = cmd +" FFLAGS="""+fflags+""""
+         end
+         
+         // CC
+         if cc <> '' then
+               cmd = cmd +" CC="""+cc+""""
+         end
+  
+  if (warningmode == 'on') then
+       disp(msprintf(gettext("%s: configure : Generate Makefile in %s\n"),"ilib_gen_Make",workingPath));
+  end
+  [msg,ierr] = unix_g(workingPath+"/compilerDetection.sh "+cmd);
+  
+  if ierr <> 0 then
+       disp(msg);
+       return %F;
+  end
+  return %T
+  
+endfunction