JIMS: plug extraction
[scilab.git] / scilab / modules / external_objects_java / src / cpp / builder_cpp.sce
1 // Copyright (C) 2010 - 2011 - Calixte DENIZET <calixte@contrib.scilab.org>
2 // Copyright (C) 2011 - Allan CORNET
3 //
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution.  The terms
7 // are also available at
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9 //
10 function build_cpp()
11     LDFLAGS = "";
12     CFLAGS = "";
13     if getos() == "Windows" then
14         CFLAGS = "-D_MSC_VER";
15     end
16     here = get_absolute_file_path("builder_cpp.sce");
17
18     src_cpp = ["WrapAsDirectBuffer.cpp"; ..
19     "ScilabObjectsCPP.cpp"; ..
20     "NoMoreScilabMemoryException.cpp"; ..
21     "OptionsHelper.cpp"];
22
23     src_jni = ["ScilabJavaObject.cpp"; ..
24     "ScilabJavaCompiler.cpp"; ..
25     "ScilabJavaClass.cpp"; ..
26     "ScilabJavaArray.cpp"; ..
27     "ScilabClassLoader.cpp"; ..
28     "GiwsException.cpp"];
29
30     if (getos() == "Windows") then
31         src_cpp = [src_cpp; ..
32         "dllMain.cpp"];
33     end
34
35     jdk_home = getenv("JAVA_HOME", "");
36     if (getos() <> "Windows") then
37         if jdk_home <> "" then
38             if ~isdir(fullpath(jdk_home + "/include")) then
39                 jdk_home = jdk_home + "/../";
40             end
41         end
42     end
43
44     if jdk_home == "" then
45         if getos() <> "Darwin" then
46             jdk_home = fullpath(system_getproperty("java.home") + "/../");
47         else
48             jdk_home = fullpath(system_getproperty("java.home"));
49         end
50     end
51
52
53     if ~isdir(fullpath(jdk_home + "/include")) then
54         error("JDK include directory not found.")
55     end
56
57     if (getos() == "Windows") then
58         CFLAGS = "-I" + jdk_home + "\include" + " -I" + jdk_home + "\include\win32";
59     elseif (getos() == "Linux") then
60         CFLAGS = "-I" + jdk_home + "/include" + " -I" + jdk_home + "/include/linux";
61     else
62         CFLAGS = "-I" + jdk_home + "/include";
63     end
64
65     if getos() <> "Windows" then
66         LDFLAGS = "-L" + fullpath(here + "../c/") + " " + ..
67         "-L" + fullpath(here + "../../sci_gateway/c");
68     end
69     CFLAGS = CFLAGS + " -I" + fullpath(here) + " -I" + fullpath(here + "../jni");
70     CFLAGS = CFLAGS + " -I" + fullpath(here + "../include/") + " -I"  + fullpath(jdk_home + "/include") + " -I" + fullpath(SCI + "/modules/jvm/includes");
71
72     tbx_build_src("jims_cpp", [src_cpp; src_jni], "cpp", here, "", LDFLAGS, CFLAGS);
73 endfunction
74
75 build_cpp();
76 clear build_cpp