This repository has been archived by the owner on Aug 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
make.m
56 lines (48 loc) · 1.85 KB
/
make.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function make(varargin)
mexargs_common = [{'-g'} varargin];
mexargs_json = [mexargs_common {'-ljson-c'}];
matlab_json_base = fileparts(mfilename('fullpath'));
if ispc
% Windows7/Visual Studio 2010
% Assume json-c and matlab-json are checked out in the same directory
% (Not required if pre-built libraries are used)
json_c_path = fullfile(fileparts(pwd), 'json-c');
json_lib_path = fullfile(matlab_json_base, 'lib');
if exist(fullfile(json_lib_path, 'json-c.lib'), 'file')
% Assume json-c.lib is in lib directory
else
% Assume json-c has been built with default VS settings
json_lib_path = json_c_path;
if strcmp(computer('arch'), 'win64')
json_lib_path = fullfile(json_lib_path, 'x64');
end
if any(strcmp(mexargs_json, '-g'))
json_lib_path = fullfile(json_lib_path, 'Debug');
else
json_lib_path = fullfile(json_lib_path, 'Release');
end
end
json_inc_path = fullfile(matlab_json_base, 'include', 'json-c');
if exist(json_inc_path, 'dir')
% Assume json-c headers are in include\json-c directory
else
json_inc_path = json_c_path;
end
mexargs_json = [{
['-I' json_inc_path], ['-L' json_lib_path], '-Dinline=__inline', ...
... % 'LINKFLAGS="$LINKFLAGS' '/NODEFAULTLIB:MSVSRT' '/NODEFAULTLIB:MSVCRTD' '/NODEFAULTLIB:LIBCMT' '/NODEFAULTLIB:LIBCMTD"', ...
} mexargs_json];
mex(mexargs_json{:}, 'fromjson.c')
mex(mexargs_json{:}, 'tojson.c')
else
% Unix
if ismac
mexargs_json = ['-I/usr/local/include/json-c' mexargs_json];
else
% Linux/Ubuntu/GCC
mexargs_json = ['-D JSON_C_DIR_PREFIXED ' mexargs_json];
end
mex(mexargs_json{:}, 'fromjson.c')
mex(mexargs_json{:}, '-lm', 'tojson.c')
end
mex(mexargs_common{:}, 'setjsonfield.c')