|
2 | 2 | % For Octave on Linux, you need the package liboctave-dev installed |
3 | 3 | % You also need the liblsl64 binary in the bin folder and a configured |
4 | 4 | % C compiler (mex -setup) |
5 | | -libs = {}; |
| 5 | + |
| 6 | +orig_path = pwd(); % Will change back to this when done. |
| 7 | +ext = ['.' mexext]; |
| 8 | +script_dir = fileparts(mfilename('fullpath')); |
| 9 | +files = dir('mex/*.c'); |
| 10 | + |
| 11 | +% Find liblsl, possibly downloading it if it can't be found locally. |
6 | 12 | lsl_fname = lsl_get_dll(); |
| 13 | + |
| 14 | +% Build cell array of libray dependencies (liblsl and maybe others) |
| 15 | +libs = {}; |
7 | 16 | if contains(lsl_fname, '32') |
8 | 17 | libs{end+1} = '-llsl32'; |
9 | 18 | elseif contains(lsl_fname, '64') |
|
15 | 24 | libs{end+1} = '-ldl'; |
16 | 25 | end |
17 | 26 |
|
18 | | -ext = ['.' mexext]; |
19 | | - |
20 | | -files = dir('mex/*.c'); |
| 27 | +% Find liblsl headers. If liblsl was downloaded above then check there. |
| 28 | +% Otherwise assume they are in a sister directory. |
| 29 | +if exist(fullfile(script_dir, 'bin', 'liblsl_archive', 'include'), 'dir') |
| 30 | + incl_dir = fullfile(script_dir, 'bin', 'liblsl_archive', 'include'); |
| 31 | +else |
| 32 | + incl_dir = fullfile(script_dir, '..', 'liblsl', 'include'); |
| 33 | +end |
21 | 34 |
|
22 | | -orig_path = pwd(); |
23 | 35 | disp('Building mex files. This may take a few minutes.'); |
24 | | -binarypath = fullfile(fileparts(mfilename('fullpath')), 'bin'); |
| 36 | +binarypath = fullfile(script_dir, 'bin'); |
25 | 37 | cd(binarypath); |
26 | 38 | for i = 1:length(files) |
27 | 39 | f = files(i); |
28 | 40 | [~, base, ~] = fileparts(f.name); |
29 | 41 | targetstats = dir([base, ext]); |
30 | 42 | if isempty(targetstats) || f.datenum > targetstats.datenum |
31 | | - mex('-I../../liblsl/include','-L.', libs{:}, ['../mex/', f.name]); |
| 43 | + mex(['-I', incl_dir], '-L.', libs{:}, ['../mex/', f.name]); |
32 | 44 | else |
33 | 45 | disp([base, ext, ' up to date']); |
34 | 46 | end |
35 | 47 | end |
36 | 48 | if ismac |
37 | 49 | system('install_name_tool -add_rpath "@loader_path/" lsl_loadlib_.mexmaci64') |
38 | 50 | end |
| 51 | + |
39 | 52 | cd(orig_path); |
0 commit comments