|
18 | 18 | % along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 | % |
20 | 20 |
|
21 | | -clear all; clc; |
| 21 | +clear all; % clc; |
22 | 22 |
|
23 | 23 | %% MATLAB API Builder |
24 | 24 | % This script will build the basic template file for the MATLAB bindings |
25 | 25 | % however since the library processor isn't perfect manual modifications |
26 | 26 | % need to be done with the generated interface file |
27 | 27 |
|
| 28 | +includepath = fullfile(pwd, 'libm2k', 'include'); |
| 29 | +hppPath = fullfile(pwd, 'libm2k', 'include', 'libm2k'); |
| 30 | + |
28 | 31 | %% |
29 | | -% Full path to files in the library |
30 | | -if isunix |
31 | | -hppPath = fullfile('/usr','local','include','libm2k'); |
32 | | -libs = fullfile('/usr','local','lib','libm2k.so'); |
33 | | -myPkg = 'libm2k'; |
| 32 | +% check if we have an unix based system but not macos |
| 33 | +if isunix && not(ismac) |
| 34 | + % Full path to files in the library |
| 35 | + libs = fullfile(pwd, 'libm2k', 'libm2k.so'); |
| 36 | + myPkg = 'libm2k'; |
| 37 | + |
| 38 | +elseif ismac |
| 39 | + % on mac pc we need to specify the compiler |
| 40 | + mex -setup C++ |
| 41 | + libs = fullfile(pwd, 'libm2k', 'libm2k.dylib'); |
| 42 | + myPkg = 'libm2k'; |
| 43 | + |
| 44 | +elseif ispc |
| 45 | + % on windows pc we need to specify the compiler |
| 46 | + mex -setup C++ -v |
| 47 | + % Full path to files in the library |
| 48 | + libs = fullfile(pwd, 'libm2k', 'libm2k.lib'); |
| 49 | + myPkg = 'libm2k'; |
| 50 | + |
34 | 51 | else |
35 | | -error('Unix builds only tested so far'); |
| 52 | + error('Build did not find any recognized system'); |
36 | 53 | end |
37 | 54 |
|
38 | 55 | %% Add related headers |
39 | 56 | h = {}; |
40 | 57 |
|
41 | | -h1 = fullfile(hppPath,'m2kcalibration.hpp'); h = [{h1},h(:)']; |
42 | | -h1 = fullfile(hppPath,'m2kexceptions.hpp'); h = [{h1},h(:)']; |
43 | | -h1 = fullfile(hppPath,'logger.hpp'); h = [{h1},h(:)']; |
44 | | -h1 = fullfile(hppPath,'digital','genericdigital.hpp'); h = [{h1},h(:)']; |
45 | | -h1 = fullfile(hppPath,'digital','m2kdigital.hpp'); h = [{h1},h(:)']; |
46 | | -h1 = fullfile(hppPath,'analog','m2kanalogout.hpp'); h = [{h1},h(:)']; |
47 | | -h1 = fullfile(hppPath,'analog','m2kanalogin.hpp'); h = [{h1},h(:)']; |
48 | | -h1 = fullfile(hppPath,'m2kcalibration.hpp'); h = [{h1},h(:)']; |
49 | | -h1 = fullfile(hppPath,'analog','m2khardwaretrigger.hpp'); h = [{h1},h(:)']; |
50 | | -h1 = fullfile(hppPath,'analog','m2kpowersupply.hpp'); h = [{h1},h(:)']; |
51 | | -h1 = fullfile(hppPath,'analog','powersupply.hpp'); h = [{h1},h(:)']; |
52 | | -h1 = fullfile(hppPath,'utils','utils.hpp'); h = [{h1},h(:)']; |
53 | | -h1 = fullfile(hppPath,'utils','enums.hpp'); h = [{h1},h(:)']; |
54 | | -h1 = fullfile(hppPath,'contextbuilder.hpp'); h = [{h1},h(:)']; |
55 | | -h1 = fullfile(hppPath,'m2k.hpp'); h = [{h1},h(:)']; |
56 | | -h1 = fullfile(hppPath,'context.hpp'); h = [{h1},h(:)']; |
57 | | -h1 = fullfile(hppPath,'m2kglobal.hpp'); h = [{h1},h(:)']; |
58 | | -h1 = fullfile(hppPath,'digital','enums.hpp'); h = [{h1},h(:)']; |
59 | | -h1 = fullfile(hppPath,'analog','enums.hpp'); h = [{h1},h(:)']; |
60 | | -h1 = fullfile(hppPath,'enums.hpp'); h = [{h1},h(:)']; |
61 | | -h1 = fullfile('/usr','include','iio.h'); h = [{h1},h(:)']; |
| 58 | +h1 = fullfile(hppPath, 'digital', 'm2kdigital.hpp'); h = [{h1}, h(:)']; |
| 59 | +h1 = fullfile(hppPath, 'digital', 'enums.hpp'); h = [{h1}, h(:)']; |
| 60 | + |
| 61 | +h1 = fullfile(hppPath, 'analog', 'm2kanalogout.hpp'); h = [{h1}, h(:)']; |
| 62 | +h1 = fullfile(hppPath, 'analog', 'm2kanalogin.hpp'); h = [{h1}, h(:)']; |
| 63 | +h1 = fullfile(hppPath, 'analog', 'm2kpowersupply.hpp'); h = [{h1}, h(:)']; |
| 64 | +h1 = fullfile(hppPath, 'analog', 'dmm.hpp'); h = [{h1}, h(:)']; |
| 65 | +h1 = fullfile(hppPath, 'analog', 'enums.hpp'); h = [{h1}, h(:)']; |
| 66 | + |
| 67 | +h1 = fullfile(hppPath, 'utils', 'utils.hpp'); h = [{h1}, h(:)']; |
| 68 | +h1 = fullfile(hppPath, 'utils', 'enums.hpp'); h = [{h1}, h(:)']; |
| 69 | + |
| 70 | +h1 = fullfile(hppPath, 'm2khardwaretrigger.hpp'); h = [{h1}, h(:)']; |
| 71 | +h1 = fullfile(hppPath, 'contextbuilder.hpp'); h = [{h1}, h(:)']; |
| 72 | +h1 = fullfile(hppPath, 'm2k.hpp'); h = [{h1}, h(:)']; |
| 73 | +h1 = fullfile(hppPath, 'm2kglobal.hpp'); h = [{h1}, h(:)']; |
| 74 | +h1 = fullfile(hppPath, 'context.hpp'); h = [{h1}, h(:)']; |
| 75 | +h1 = fullfile(hppPath, 'logger.hpp'); h = [{h1}, h(:)']; |
| 76 | +h1 = fullfile(hppPath, 'm2kcalibration.hpp'); h = [{h1}, h(:)']; |
| 77 | +h1 = fullfile(hppPath, 'm2kexceptions.hpp'); h = [{h1}, h(:)']; |
| 78 | +h1 = fullfile(hppPath, 'enums.hpp'); h = [{h1}, h(:)']; |
62 | 79 | headers = h; |
63 | 80 |
|
64 | 81 | %% Build interface file |
65 | | -clibgen.generateLibraryDefinition(headers,... |
66 | | - 'IncludePath', hppPath,... |
67 | | - 'Libraries', libs,... |
68 | | - 'PackageName', myPkg,... |
69 | | - 'Verbose',true) |
70 | | -delete definelibm2k.mlx |
71 | | - |
72 | | -%% Build library once manually updated |
73 | | -% pkg = definelibm2k; |
74 | | -% build(pkg); |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
| 82 | +% delete definelibm2k.m |
| 83 | + |
| 84 | +if isunix && not(ismac) |
| 85 | + clibgen.generateLibraryDefinition(headers, ... |
| 86 | + 'IncludePath', includepath, ... |
| 87 | + 'Libraries', libs, ... |
| 88 | + 'PackageName', myPkg, ... |
| 89 | + 'Verbose', true) |
| 90 | + delete definelibm2k.mlx |
| 91 | + |
| 92 | +elseif ismac |
| 93 | + %% Add 'DefinedMacros' to fix bugs related to compiler versions used by matlab |
| 94 | + clibgen.generateLibraryDefinition(headers, ... |
| 95 | + 'IncludePath', includepath, ... |
| 96 | + 'Libraries', libs, ... |
| 97 | + 'InterfaceName', myPkg, ... |
| 98 | + 'Verbose', true, ... |
| 99 | + 'DefinedMacros', ["_HAS_CONDITIONAL_EXPLICIT=0", "_USE_EXTENDED_LOCALES_"]) |
| 100 | + delete definelibm2k.mlx |
| 101 | + |
| 102 | +elseif ispc |
| 103 | + %% Add 'DefinedMacros' to fix builds using Visual Studio 16 2019 |
| 104 | + clibgen.generateLibraryDefinition(headers, ... |
| 105 | + 'IncludePath', includepath, ... |
| 106 | + 'Libraries', libs, ... |
| 107 | + 'PackageName', myPkg, ... |
| 108 | + 'Verbose', true, ... |
| 109 | + 'DefinedMacros', ["_HAS_CONDITIONAL_EXPLICIT=0"]) |
| 110 | + delete definelibm2k.mlx |
| 111 | +end |
83 | 112 |
|
| 113 | +if isunix && not(ismac) |
| 114 | + pkg = definelibm2k_linux64; |
84 | 115 |
|
| 116 | +elseif ismac |
| 117 | + if strcmp(computer('arch'), 'maca64') |
| 118 | + pkg = definelibm2k_macM1; |
| 119 | + else |
| 120 | + pkg = definelibm2k_mac86; |
| 121 | + end |
85 | 122 |
|
| 123 | +elseif ispc |
| 124 | + pkg = definelibm2k_win64; |
| 125 | +end |
86 | 126 |
|
| 127 | +%% Build library once manually updated |
| 128 | +% build(pkg); |
0 commit comments