better detection of LCC-Win32 and easier to use with scilab
[scilab.git] / scilab / modules / dynamic_link / macros / VCtoLCCLib.sci
1 //==========================================
2 // Allan CORNET
3 // INRIA 2008
4 // Export Libraries of Scilab for LCC compiler
5 //==========================================
6 function VCtoLCCLib()
7   // LCC-Win32 only on Windows
8   if (findlcccompiler() == %t) then
9                 DirCur = pwd();
10                 chdir(WSCI+'\bin');
11                 mkdir('lcclib');
12
13                 Exportalibrary('LibScilab');
14                 Exportalibrary('libf2c');
15                 ExportAtlasLibrary();
16                 Exportalibrary('lapack');
17                 Exportalibrary('scicos');
18                 Exportalibrary('intersci');
19                 Exportalibrary('dynamic_link');
20                 Exportalibrary('scioutput_stream');
21                 Exportalibrary('MALLOC');
22         
23                 chdir(DirCur);
24         end
25         
26 end
27
28 endfunction
29 //==========================================
30 function bOK = Exportalibrary(libraryname)
31   printf('\nExports from '+libraryname+'.dll\n');
32         unix('pedump /exp '+libraryname+'.dll >'+TMPDIR+filesep()+libraryname+'.lcc');
33         printf('Converting Library');
34         
35         fw = mopen(TMPDIR+filesep()+libraryname+'.exp',"w");
36         fr = mopen(TMPDIR+filesep()+libraryname+'.lcc',"r");
37         
38         if (meof(fr) == 0) then 
39                 line = mfscanf(1,fr,"%s");
40                 mfprintf(fw,"%s\n",line);
41                 printf('.');
42         end
43
44         while ( meof(fr) == 0)
45                 line = mfscanf(1,fr,"%s");
46                 if (line ~= []) then
47                         mfprintf(fw,"_%s\n",line);
48                 end
49         end
50
51         mclose(fw);
52         mclose(fr);
53         
54         printf('\nBuild '+libraryname+'.lib (Please waiting).\n');
55         command = 'buildLib ""'+TMPDIR+filesep()+libraryname+'.exp""'+' ""'+WSCI+'\bin\lcclib\'+libraryname+'.lib""';
56         unix(command);
57         bOK=%T;
58 endfunction
59 //==========================================
60 function ExportAtlasLibrary()
61         
62         printf('\nExports from blasplus.dll\n')
63         unix('pedump /exp blasplus.dll >'+TMPDIR+'\blasplus.lcc');
64         printf('Converting Library');
65         
66         fw = mopen(TMPDIR+'\blaspluslcc.exp',"w");
67         fr = mopen(TMPDIR+'\blasplus.lcc',"r");
68
69         if (meof(fr) == 0) then 
70                 line = mfscanf(1,fr,"%s");
71                 mfprintf(fw,"blasplus.dll\n");
72         end
73
74         i=1;
75         // TO DO : update this part
76         // see MKL compatibility
77         while ( meof(fr) == 0)
78                 line = mfscanf(1,fr,"%s");
79                 if (line ~= []) then
80                         mfprintf(fw,"_%s_  %s @%d\n",line,line,i);
81                         i=i+1;
82                         end
83         end
84
85         mclose(fw);
86         mclose(fr);
87         
88         printf('\nBuild Atlas.lib\n');
89         unix('buildLib ""'+TMPDIR+'\Atlaslcc.exp""'+' ""'+WSCI+'\bin\lcclib\'+'blasplus.lib""');
90 endfunction
91 //==========================================