forked from acp29/iboot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.m
executable file
·64 lines (57 loc) · 1.67 KB
/
install.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
57
58
59
60
61
62
63
% Basic script for local installation.
% Make sure you run the 'make' function first for optimum performance.
%
% Add inst directory to path
inst_dir = fullfile (fileparts (mfilename ('fullpath')), 'inst');
addpath (inst_dir)
% Check if running in Octave (else assume Matlab)
info = ver;
isoctave = any (ismember ({info.Name}, 'Octave'));
% Save the newly added paths so that they will be loaded each time we start Octave or Matlab
if isoctave
% Install for Octave
octaverc = '~/.octaverc';
if exist(octaverc,'file')
[fid, msg] = fopen (octaverc, 'r+t');
else
[fid, msg] = fopen (octaverc, 'w+t');
end
S = (fread (fid, '*char')).';
comment = sprintf ('\r\n\r\n%s', '% Load statistics-resampling package');
S = strcat (S, comment);
S = strcat (S, sprintf ('\r\naddpath (''%s'', ''-end'')', inst_dir));
fseek (fid, 0);
fputs (fid, S);
fclose (fid);
else
% Assuming install for Matlab instead
if exist('savepath')
savepath;
else
% backwards compatibility
path2rc;
end
end
% Notify user that installation is complete
d = struct;
d.dir = inst_dir;
post_install (d);
% Check if the user has run the make script
inst_files = dir (inst_dir);
if (all (arrayfun (@(name) ismember (sprintf ('%s.%s', name{:}, mexext), ...
{inst_files.name}), {'boot', 'smoothmedian'})))
try
boot (1, 1);
smoothmedian (1);
make_done = true;
catch
make_done = false;
end
else
make_done = false;
end
if (~ make_done)
warning ('For optimal performance, run the ''make'' command to copy or compile the appropriate binaries')
end
% Clean up
clear info isoctave S comment octaverc fid msg inst_dir inst_files d make_done