-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.m
53 lines (48 loc) · 1.39 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
% Basic script for local installation
%
% Add directories to path
copyfile ('PKG_ADD','PKG_ADD.m');
run (fullfile(pwd,'PKG_ADD.m'));
dirlist = cell(2,1); % dir list needs to be in increasing order of length
dirlist{1} = fullfile (pwd,'inst','');
dirlist{2} = fullfile (pwd,'inst','helper');
n = numel (dirlist);
% 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 iboot package');
if isempty(strfind(S,comment))
S = strcat (S, comment);
end
for i=1:n
if isempty(strfind(S,dirlist{i}))
S = strcat (S, sprintf ('\r\naddpath (''%s'', ''-end'')', dirlist{i}));
end
end
fseek (fid, 0);
fputs (fid, S);
fclose (fid);
else
% Assumming install for Matlab instead
if exist('savepath')
savepath;
else
% backwards compatibility
path2rc;
end
end
% Notify user that installation is complete
disp ('The iboot package has been installed at the current location ')
% Clean up
clear info isoctave dirlist S comment i ii octaverc fid n msg
delete ('PKG_ADD.m');