move windows part in macros/windows (prepares to add vs project generation) 09/4609/2
Allan CORNET [Wed, 27 Jul 2011 08:12:56 +0000 (10:12 +0200)]
Change-Id: I75d8fc28dbe945907f6787bffe3a86b2762a34e6

scilab/modules/dynamic_link/macros/ilib_compile.sci
scilab/modules/dynamic_link/macros/ilib_gen_cleaner.sci
scilab/modules/dynamic_link/macros/windows/dlwCompile.sci [new file with mode: 0644]
scilab/modules/dynamic_link/macros/windows/dlwGenerateCleaner.sci [new file with mode: 0644]
scilab/modules/dynamic_link/macros/windows/dlwGenerateMakefile.sci
scilab/modules/dynamic_link/macros/windows/dlwGetScilabIncludes.sci [new file with mode: 0644]
scilab/modules/dynamic_link/macros/windows/dlwGetScilabLibraries.sci [new file with mode: 0644]
scilab/modules/dynamic_link/src/scripts/Makedll.incl
scilab/modules/dynamic_link/src/scripts/Makefile.incl.mak
scilab/modules/dynamic_link/src/scripts/TEMPLATE_MAKEFILE.VC

index 8f56af9..c3a928c 100644 (file)
@@ -62,32 +62,14 @@ function libn = ilib_compile(lib_name, ..
 
   if getos() == "Windows" then
     //** ----------- Windows section  -----------------
-    msgs_make = "";
-    nf = size(files,"*");
-
-    for i=1:nf
-      if ( ilib_verbose() <> 0 ) then
-        mprintf(_("   Compilation of ") + string(files(i)) +"\n");
-      end
-    end
-
-    // then the shared library
-    if ( ilib_verbose() <> 0 ) then
-      mprintf(_("   Building shared library (be patient)\n"));
-    end
-
-    [msg, stat] = unix_g(make_command + makename + " all 2>&0");
-    if stat <> 0 then
-      // more feedback when compilation fails
-      [msg, stat, stderr] = unix_g(make_command + makename + " all 1>&2"); 
-      disp(stderr);
-      error(msprintf(gettext("%s: Error while executing %s.\n"), "ilib_compile", makename));
-    else
-      if ilib_verbose() > 1 then
-        disp(msg);
-      end
+    
+    // Load dynamic_link Internal lib if it"s not already loaded
+    if ~ exists("dynamic_linkwindowslib") then
+      load("SCI/modules/dynamic_link/macros/windows/lib");
     end
-
+    
+    dlwCompile(files, make_command, makename);
+    
   else
     //** ---------- Linux/MacOS/Unix section ---------------------
 
index 4ddf036..49bcb42 100644 (file)
@@ -1,5 +1,5 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) DIGITEO - 2009-2010 - Allan CORNET
+// Copyright (C) DIGITEO - 2009-2011 - Allan CORNET
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
@@ -40,12 +40,12 @@ function ilib_gen_cleaner(makename,loadername,files)
   mfprintf(fd,"// ------------------------------------------------------\n");
 
   if getos() == 'Windows' then
-    make_command = get_make_command(makename);
-    mfprintf(fd,"if fileinfo(''%s%s'') <> [] then\n",makename,get_makefile_ext());
-    mfprintf(fd,"  unix_s(''%s'');\n",make_command);
-    mfprintf(fd,"  mdelete(''%s%s'');\n",makename,get_makefile_ext());
-    mfprintf(fd,"end\n");
-    mfprintf(fd,"// ------------------------------------------------------\n");
+    // Load dynamic_link Internal lib if it"s not already loaded
+    if ~ exists("dynamic_linkwindowslib") then
+      load("SCI/modules/dynamic_link/macros/windows/lib");
+    end
+
+    dlwGenerateCleaner(fd, makename);
   end
 
   if files <> [] then
@@ -68,27 +68,3 @@ function ilib_gen_cleaner(makename,loadername,files)
   end
 endfunction
 //=============================================================================
-function cmd = get_make_command(makename)
-  if getos() == 'Windows' then // WINDOWS
-    // Load dynamic_link Internal lib if it's not already loaded
-    if ~ exists("dynamic_linkwindowslib") then
-      load("SCI/modules/dynamic_link/macros/windows/lib");
-    end
-    cmd = dlwGetMakefileCmdCleaner(makename);
-  else // LINUX
-    cmd = 'make ' + makename + ' clean';
-  end
-endfunction
-//=============================================================================
-function ext = get_makefile_ext()
-  if getos() == 'Windows' then // WINDOWS
-    // Load dynamic_link Internal lib if it's not already loaded
-    if ~ exists("dynamic_linkwindowslib") then
-      load("SCI/modules/dynamic_link/macros/windows/lib");
-    end
-    ext = dlwGetMakefileExt();
-  else // LINUX
-    ext = '';
-  end
-endfunction
-//=============================================================================
diff --git a/scilab/modules/dynamic_link/macros/windows/dlwCompile.sci b/scilab/modules/dynamic_link/macros/windows/dlwCompile.sci
new file mode 100644 (file)
index 0000000..0b7d1e6
--- /dev/null
@@ -0,0 +1,37 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) DIGITEO - 2011  - Allan CORNET
+//
+// 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
+//=============================================================================
+function dlwCompile(files, make_command, makename)
+
+    nf = size(files,"*");
+
+    for i=1:nf
+      if ( ilib_verbose() <> 0 ) then
+        mprintf(_("   Compilation of ") + string(files(i)) +"\n");
+      end
+    end
+
+    // then the shared library
+    if ( ilib_verbose() <> 0 ) then
+      mprintf(_("   Building shared library (be patient)\n"));
+    end
+
+    [msg, stat] = unix_g(make_command + makename + " all 2>&0");
+    if stat <> 0 then
+      // more feedback when compilation fails
+      [msg, stat, stderr] = unix_g(make_command + makename + " all 1>&2"); 
+      disp(stderr);
+      error(msprintf(gettext("%s: Error while executing %s.\n"), "ilib_compile", makename));
+    else
+      if ilib_verbose() > 1 then
+        disp(msg);
+      end
+    end
+endfunction
+//=============================================================================
diff --git a/scilab/modules/dynamic_link/macros/windows/dlwGenerateCleaner.sci b/scilab/modules/dynamic_link/macros/windows/dlwGenerateCleaner.sci
new file mode 100644 (file)
index 0000000..55f9107
--- /dev/null
@@ -0,0 +1,18 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) DIGITEO - 2011  - Allan CORNET
+//
+// 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
+//=============================================================================
+function dlwGenerateCleaner(fd, makename)
+  make_command = dlwGetMakefileCmdCleaner(makename);
+  mfprintf(fd,"if fileinfo(''%s%s'') <> [] then\n", makename, dlwGetMakefileExt());
+  mfprintf(fd,"  unix_s(''%s'');\n", make_command);
+  mfprintf(fd,"  mdelete(''%s%s'');\n", makename, dlwGetMakefileExt());
+  mfprintf(fd,"end\n");
+  mfprintf(fd,"// ------------------------------------------------------\n");
+endfunction
+//=============================================================================
index 40c82b7..f383e13 100644 (file)
@@ -87,7 +87,6 @@ function ilib_gen_Make_win32(name, ..
   managed_ext = ['.cxx', '.cpp', '.c', '.f90', '.f'];
 
   SCIDIR = SCI;
-  SCIDIR1 = pathconvert(SCI,%f,%f,'w');
   LIBRARY = name;
   FILES_SRC = '';
   OBJS = '';
@@ -100,6 +99,16 @@ function ilib_gen_Make_win32(name, ..
   FFLAGS = fflags;
   MEXFFLAGS = '';
   LDFLAGS = ldflags;
+  
+  SCILAB_INCLUDES = dlwGetScilabIncludes();
+  SCILAB_INCLUDES = "-I""" + SCILAB_INCLUDES + """";
+  SCILAB_INCLUDES = [SCILAB_INCLUDES(1:$-1) + " \"; SCILAB_INCLUDES($)];
+  SCILAB_INCLUDES = strcat(SCILAB_INCLUDES, ascii(10));
+  
+  SCILAB_LIBS = dlwGetScilabLibraries();
+  SCILAB_LIBS = """$(SCIDIR)/bin/" + SCILAB_LIBS + """";
+  SCILAB_LIBS = [SCILAB_LIBS(1:$-1) + " \"; SCILAB_LIBS($)];
+  SCILAB_LIBS = strcat(SCILAB_LIBS, ascii(10));
 
   if isempty(libname) then
     LIBRARY = name;
@@ -213,7 +222,8 @@ function ilib_gen_Make_win32(name, ..
   end
 
   MAKEFILE_VC = strsubst(MAKEFILE_VC, "__SCI__", SCIDIR);
-  MAKEFILE_VC = strsubst(MAKEFILE_VC, "__SCIDIR1__", SCIDIR1);
+  MAKEFILE_VC = strsubst(MAKEFILE_VC, "__SCILAB_INCLUDES__", SCILAB_INCLUDES);
+  MAKEFILE_VC = strsubst(MAKEFILE_VC, "__SCILAB_LIBS__",SCILAB_LIBS);
   MAKEFILE_VC = strsubst(MAKEFILE_VC, "__LIBNAME__", LIBRARY);
   MAKEFILE_VC = strsubst(MAKEFILE_VC, "__FILES_SRC__", FILES_SRC);
   MAKEFILE_VC = strsubst(MAKEFILE_VC, "__OBJS__", OBJS);
diff --git a/scilab/modules/dynamic_link/macros/windows/dlwGetScilabIncludes.sci b/scilab/modules/dynamic_link/macros/windows/dlwGetScilabIncludes.sci
new file mode 100644 (file)
index 0000000..f6bb6e6
--- /dev/null
@@ -0,0 +1,28 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) DIGITEO - 2011 - Allan CORNET
+//
+// 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
+
+//=============================================================================
+function scilabincludeslist = dlwGetScilabIncludes()
+
+  scilabincludeslist = ["$(SCIDIR)/libs/MALLOC/includes"; ..
+                      "$(SCIDIR)/libs/f2c"; ..
+                      "$(SCIDIR)/libs/hashtable"; ..
+                      "$(SCIDIR)/libs/intl"; ..
+                      "$(SCIDIR)/modules/core/includes"; ..
+                      "$(SCIDIR)/modules/api_scilab/includes"; ..
+                      "$(SCIDIR)/modules/call_scilab/includes"; ..
+                      "$(SCIDIR)/modules/output_stream/includes"; ..
+                      "$(SCIDIR)/modules/jvm/includes"; ..
+                      "$(SCIDIR)/modules/localization/includes"; ..
+                      "$(SCIDIR)/modules/dynamic_link/includes"; ..
+                      "$(SCIDIR)/modules/mexlib/includes"; ..
+                      "$(SCIDIR)/modules/time/includes"; ..
+                      "$(SCIDIR)/modules/windows_tools/includes"];
+endfunction
+//=============================================================================
\ No newline at end of file
diff --git a/scilab/modules/dynamic_link/macros/windows/dlwGetScilabLibraries.sci b/scilab/modules/dynamic_link/macros/windows/dlwGetScilabLibraries.sci
new file mode 100644 (file)
index 0000000..7b27da9
--- /dev/null
@@ -0,0 +1,32 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) DIGITEO - 2011 - Allan CORNET
+//
+// 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
+//=============================================================================
+function scilablibrarieslist = dlwGetScilabLibraries()
+
+  scilablibrarieslist = ["MALLOC.lib"; ..
+                        "blasplus.lib"; ..
+                        "libf2c.lib"; ..
+                        "lapack.lib"; ..
+                        "libintl.lib"; ..
+                        "hashtable.lib"; ..
+                        "intersci.lib"; ..
+                        "output_stream.lib"; ..
+                        "dynamic_link.lib"; ..
+                        "integer.lib"; ..
+                        "optimization_f.lib"; ..
+                        "libjvm.lib"; ..
+                        "scilocalization.lib"; ..
+                        "linpack_f.lib"; ..
+                        "call_scilab.lib"; ..
+                        "time.lib"; ..
+                        "api_scilab.lib"; ..
+                        "scilab_windows.lib"]; 
+
+endfunction
+//=============================================================================
\ No newline at end of file
index f5ae382..5866491 100644 (file)
@@ -1,5 +1,5 @@
 
-DUMPEXTS="$(SCIDIR1)\bin\dumpexts"
+DUMPEXTS="$(SCIDIR)\bin\dumpexts"
 SCIIMPLIB="$(SCIDIR)/bin/LibScilab.lib"
 
 all :: $(LIBRARY).dll
index db20287..7498f96 100644 (file)
@@ -33,22 +33,6 @@ CC__OPTIMISATION_MODE=-Z7 -O2 -MT
 CC_COMMON=-D__MSC__ -DFORDLL $(DWIN) -c -DSTRICT -D_CRT_SECURE_NO_DEPRECATE -D__MAKEFILEVC__ -nologo $(INCLUDES)
 LINKER_FLAGS=/NOLOGO $(MACHINE) /DYNAMICBASE:NO /NXCOMPAT:NO $(LINKER_OPTIMISATION_MODE)
 CC_OPTIONS = $(CC_COMMON) -W3 -Gd $(CC__OPTIMISATION_MODE) /Fo"$(DIR_OBJ)/" /Fd"$(DIR_OBJ)/"
-
-# include options 
-INCLUDES=-I"$(SCIDIR)/libs/MALLOC/includes" \
--I"$(SCIDIR)/modules/core/includes" \
--I"$(SCIDIR)/modules/api_scilab/includes" \
--I"$(SCIDIR)/modules/call_scilab/includes" \
--I"$(SCIDIR)/modules/output_stream/includes" \
--I"$(SCIDIR)/modules/jvm/includes" \
--I"$(SCIDIR)/modules/localization/includes" \
--I"$(SCIDIR)/modules/dynamic_link/includes" \
--I"$(SCIDIR)/modules/mexlib/includes" \
--I"$(SCIDIR)/modules/time/includes" \
--I"$(SCIDIR)/modules/windows_tools/includes" \
--I"$(SCIDIR)/libs/f2c" \
--I"$(SCIDIR)/libs/hashtable" \
--I"$(SCIDIR)/libs/intl"
 #==================================================
 CC_LDFLAGS = 
 #==================================================
@@ -82,7 +66,7 @@ FC_OPTIONS_COMMON=/nologo /DFORDLL /assume:underscore \
 /noaltparam /f77rtl /fpscomp:nolibs /names:lowercase \
 /iface:cref /threads /c /Qvc9 \
 /Fo"$(DIR_OBJ)/" /Fd"$(DIR_OBJ)/" \
-/include:"$(SCIDIR1)/modules/core/includes"
+/include:"$(SCIDIR)/modules/core/includes"
 #==================================================
 !IF "$(DEBUG_SCILAB_DYNAMIC_LINK)" == "YES"
 FC_OPTIONS=$(FC_OPTIONS_COMMON) /Zi /Od /debug /dbglibs
@@ -99,20 +83,6 @@ LINKER_FLAGS=$(LINKER_FLAGS) /force:multiple
 RC=rc
 RCVARS=-r -DWIN32
 #==================================================
-# Libraries 
-#==================================================
-# SCILAB_LIBS is used by the binary version of Scilab for linking external codes
-SCILAB_LIBS="$(SCIDIR1)/bin/MALLOC.lib" "$(SCIDIR1)/bin/blasplus.lib" \
-"$(SCIDIR1)/bin/libf2c.lib" "$(SCIDIR1)/bin/lapack.lib" \
-"$(SCIDIR1)/bin/intersci.lib" \
-"$(SCIDIR1)/bin/output_stream.lib" "$(SCIDIR1)/bin/dynamic_link.lib" \
-"$(SCIDIR1)/bin/integer.lib" "$(SCIDIR1)/bin/optimization_f.lib" \
-"$(SCIDIR1)/bin/libjvm.lib" "$(SCIDIR1)/bin/scilocalization.lib" \
-"$(SCIDIR1)/bin/libintl.lib" "$(SCIDIR1)/bin/linpack_f.lib" \
-"$(SCIDIR1)/bin/call_scilab.lib" "$(SCIDIR1)/bin/time.lib" \
-"$(SCIDIR1)/bin/api_scilab.lib" "$(SCIDIR1)/bin/hashtable.lib" \
-"$(SCIDIR1)/bin/scilab_windows.lib" 
-#==================================================
 # default rules for Fortran 77 & 90 Compilation 
 #==================================================
 !IF "$(USE_F2C)" == "YES"
@@ -122,9 +92,9 @@ SCILAB_LIBS="$(SCIDIR1)/bin/MALLOC.lib" "$(SCIDIR1)/bin/blasplus.lib" \
 .f{$(DIR_OBJ)}.obj     :
        @echo ----------- Compile file $< (using f2c) -------------
 !IF "$(F2C_IMPORT_COMMON)" == "YES"    
-       @"$(SCIDIR1)/bin/f2c.exe" -E -I"$(SCIDIR1)/modules/core/includes" $(FFLAGS) $< 2>NUL
+       @"$(SCIDIR)/bin/f2c.exe" -E -I"$(SCIDIR)/modules/core/includes" $(FFLAGS) $< 2>NUL
 !ELSE
-       @"$(SCIDIR1)/bin/f2c.exe" -I"$(SCIDIR1)/modules/core/includes" $(FFLAGS) $< 2>NUL
+       @"$(SCIDIR)/bin/f2c.exe" -I"$(SCIDIR)/modules/core/includes" $(FFLAGS) $< 2>NUL
 !ENDIF
        -IF NOT EXIST  $(DIR_OBJ) mkdir $(DIR_OBJ)
 
index 4f24de9..db42eb4 100644 (file)
@@ -4,7 +4,12 @@
 # see SCI/modules/dynamic_link/src/scripts/TEMPLATE_MAKEFILE.VC
 # ------------------------------------------------------
 SCIDIR = __SCI__
-SCIDIR1 = __SCIDIR1__
+# ------------------------------------------------------
+# default include options 
+INCLUDES = __SCILAB_INCLUDES__
+# ------------------------------------------------------
+# SCILAB_LIBS is used by the binary version of Scilab for linking external codes
+SCILAB_LIBS = __SCILAB_LIBS__
 # ------------------------------------------------------
 # name of the dll to be built
 LIBRARY = __LIBNAME__
@@ -20,7 +25,7 @@ OBJS_WITH_PATH = __OBJS_WITH_PATH__
 FORTRAN_RUNTIME_LIBRARIES = __FORTRAN_RUNTIME__
 OTHERLIBS = __OTHERSLIBS__
 # ------------------------------------------------------
-!include $(SCIDIR1)\modules\dynamic_link\src\scripts\Makefile.incl.mak
+!include $(SCIDIR)\modules\dynamic_link\src\scripts\Makefile.incl.mak
 # ------------------------------------------------------
 CC = __CC__
 # ------------------------------------------------------
@@ -30,5 +35,5 @@ FFLAGS = $(FC_OPTIONS) -DFORDLL __FFLAGS__ __MEXFFLAGS__
 # ------------------------------------------------------
 EXTRA_LDFLAGS = __LDFLAGS__
 # ------------------------------------------------------
-!include $(SCIDIR1)\modules\dynamic_link\src\scripts\Makedll.incl
+!include $(SCIDIR)\modules\dynamic_link\src\scripts\Makedll.incl
 # ------------------------------------------------------