~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychOneliners/AssertMex.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
% missing or dysfunctional Screen mex files properly.
16
16
%  _________________________________________________________________________
17
17
%
18
 
% See also: AssertOpenGL, COMPUTER, IsOSX, IsOS9, IsWin
 
18
% See also: AssertOpenGL, COMPUTER, IsOSX, IsWin
19
19
 
20
20
% HISTORY:
21
 
%  
 
21
%
22
22
% mm/dd/yy
23
 
%   
 
23
%
24
24
% 12/14/03  awi     Wrote it
25
25
% 07/02/04  awi     Improved documentation: Added See also, explained
26
26
%                   behavior when no arguments are supplied.
27
27
%                   Changed name to AssertMex from PsychAssertMex
28
28
% 10/03/04  awi     Modified to accept 'WINDOWS', 'OS9', 'OSX'
29
29
% 01/08/05  fwc     fixed little bug, see comments
30
 
% 01/11/05  awi     Merged fwc fix into psychtoolbox.org master copy.      
 
30
% 01/11/05  awi     Merged fwc fix into psychtoolbox.org master copy.
31
31
% 01/29/05  dgp     Cosmetic.
32
32
% 03/07/05  fwc     Fixed bugs due to which failed Assertmex to accept 'OSX', 'OS9' as valid input.
33
33
%                                       In line 80/81 badNames was often {''} which is not empty for isempty().
34
34
%                                       Also changed || into | in line 90
35
35
% 03/08/05  dgp     Add support for 'WIN'.
36
 
% 10/06/05      awi     Fixed bug: Changed "okSupNameMatches"  to match addition of  'WIN' to 
 
36
% 10/06/05      awi     Fixed bug: Changed "okSupNameMatches"  to match addition of  'WIN' to
37
37
%                                                               to "okSupNames"
38
38
% 3/3/06    awi     Rewrote help for improved clarity.
39
39
% 6/13/09    mk     Update to handle execution failures and missing files
40
40
%                   on Octave-3.2 et al. as well.
 
41
% 5/28/12    mk     Update: 64-Bit OSX and Linux supported, but OSX PowerPC
 
42
%                   and Matlab < V7.4 (aka R2007a) no longer supported.
41
43
 
42
44
persistent okNames mexExtensions;
43
45
 
44
46
% Different processing on Octave build.
45
47
if IsOctave
46
48
    myName = char(varargin{1});
47
 
    if isempty(findstr(myName, '.m'))
 
49
    if isempty(strfind(myName, '.m'))
48
50
        return;
49
51
    end
50
 
 
 
52
    
51
53
    octFilename = [ myName(1:end-1) 'mex'];
52
54
    fprintf('\nIn place of the expected Octave .mex binary plugin file this placeholder file was executed:\n\n');
53
55
    fprintf(['  ' myName '\n\n']);
54
56
    fprintf('This MEX file seems to be missing or inaccessible on your Octave path or it is dysfunctional:\n\n')
55
57
    fprintf(['  ' octFilename '\n\n']);
56
 
 
 
58
    
57
59
    fpath = which(myName(1:end-2));
58
60
    if isempty(fpath)
59
61
        fprintf('Hmm. I cannot find the file on your Octave path?!?\n\n');
63
65
        fprintf('Make sure that the path is readable by you as well...\n');
64
66
    else
65
67
        % Some file with such a function exists on the Octave path:
66
 
        [dum1, dum2, fpathext] = fileparts(fpath);
 
68
        [dum1, dum2, fpathext] = fileparts(fpath); %#ok<ASGLU>
67
69
        % Proper extension for the .mex file?
68
70
        if isempty(strfind(fpathext, '.mex'))
69
71
            % Nope, wrong file bound:
 
72
            if Is64Bit
 
73
                oext = ['64' filesep];
 
74
            else
 
75
                oext = filesep;
 
76
            end
 
77
            
70
78
            if IsLinux
71
 
                fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic/Octave3LinuxFiles/']);
 
79
                fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic/Octave3LinuxFiles' oext]);
72
80
            end
73
81
            if IsOSX
74
 
                fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic/Octave3OSXFiles/']);
 
82
                fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic/Octave3OSXFiles' oext]);
75
83
            end
76
84
            if IsWindows
77
 
                fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic\Octave3WindowsFiles\']);
 
85
                fprintf('The following directory should be the *first one* on your Octave path:\n %s \n\n', [PsychtoolboxRoot 'PsychBasic\Octave3WindowsFiles' oext]);
78
86
            end
79
87
            
80
88
            fprintf('\n\nIf you have just installed Psychtoolbox, it worked properly and suddenly stopped working\n');
85
93
            % Correct file with correct extension, still load failure:
86
94
            % Check for supported Octave version:
87
95
            curversion = sscanf(version, '%i.%i.%i');
88
 
            if curversion(1) < 3 | curversion(2) < 2 %#ok<OR2>
 
96
            if curversion(1) < 3 || curversion(2) < 2
89
97
                fprintf('Your version of Octave (%s) is incompatible with Psychtoolbox: We support Octave 3.2.0 or later.\n', version);
90
98
                error('Tried to run Psychtoolbox on an incompatible Octave version.\n');
91
99
            end
92
 
 
 
100
            
93
101
            fprintf('A reason could be some missing 3rd party dynamic link shared libraries on your system.\n');
94
102
            fprintf('Our default installation also only supports 32 bit versions of operating system and Octave.\n');
95
103
            fprintf('Another reason could be some binary incompatibility. You would need to recompile Psychtoolbox from source!\n\n');
100
108
 
101
109
% Initialize the persistent variables.
102
110
if isempty(okNames)
103
 
    okNames = {'PCWIN', 'PCWIN64', 'SOL2', 'HPUX', 'HP700', 'ALPHA', 'IBM_RS', 'SGI', 'GLNX86', 'MAC',    'MAC2', 'MACI', 'i486-pc-linux-gnu', 'MACI64', 'GLNXA64' };
104
 
    mexExtensions = {'dll', 'dll',  '*',    '*',    '*',     '*',     '*',      '*',   '*',     'mexmac', 'mex', 'mexmaci', 'oct', 'mexmaci64', '*' };
 
111
    okNames = {      'PCWIN',  'PCWIN64', 'SOL2', 'HPUX', 'HP700', 'ALPHA', 'IBM_RS', 'SGI', 'GLNX86', 'MAC',    'MAC2', 'MACI',    'i486-pc-linux-gnu', 'MACI64',    'GLNXA64' };
 
112
    mexExtensions = {'mexw32', 'mexw64',  '*',    '*',    '*',     '*',     '*',      '*',   'mexglx', 'mexmac', 'mex',  'mexmaci', 'mex',               'mexmaci64', 'mexa64' };
105
113
end
106
114
 
107
115
inputNames = [];
108
116
 
109
117
% Check to see if there should be a mex file for our platform.
110
 
if isempty(inputNames) | ismember(computer, inputNames) %#ok<OR2>
 
118
if isempty(inputNames) || ismember(computer, inputNames)
111
119
    % Element 1 will always be AssertMex. Element 2 will be the calling
112
120
    % function unless it is invoked from the commnand line.
113
121
    callStack = dbstack;
114
 
 
 
122
    
115
123
    if length(callStack) > 1
116
124
        callerName = callStack(2).name;
117
125
    else
118
126
        error('AssertMex was invoked from the command line.');
119
127
    end
120
 
 
 
128
    
121
129
    % Generate error strings
122
130
    extensionNameIndex=find(streq(computer,okNames));
123
 
    extensionName=mexExtensions{extensionNameIndex};
124
 
    mExtensionIndices=findstr('.m',callerName);
 
131
    extensionName=mexExtensions{extensionNameIndex}; %#ok<FNDSB>
 
132
    mExtensionIndices=strfind('.m',callerName);
125
133
    if ~isempty(mExtensionIndices)
126
134
        termExtension=mExtensionIndices(end);
127
135
        mexFilenameHead=callerName(1:termExtension-1);
135
143
    fprintf(['  ' mexFilename '\n\n']);
136
144
    
137
145
    if isempty(which(mexFilename))
138
 
        fprintf('Hmm. I cannot find the file on your Matlab path?!?\n\n');
139
 
        fprintf('One reason could be that your Matlab path is wrong or not up to date\n');
140
 
        fprintf('for the current Psychtoolbox. You may want to run SetupPsychtoolbox to \n');
141
 
        fprintf('fix possible path problems.\n\n');
 
146
        if strcmp(computer, 'MAC')
 
147
            % Mac PowerPC:
 
148
            fprintf('Matlab running on MacOSX on a PowerPC based Apple Macintosh computer is no longer supported.\n');
 
149
            fprintf('You would need to get a version 3.0.9 or earlier Psychtoolbox for this to work on your computer.\n');
 
150
            fprintf('Or upgrade your computer to run a modern version of GNU/Linux and use the Psychtoolbox for Linux on PowerPC.\n\n');
 
151
        elseif (IsWin && exist('mexext') && strcmp(mexext, 'dll')) %#ok<EXIST>
 
152
            % Windows with Matlab pre-R2007a:
 
153
            fprintf('Matlab versions older than V7.4 aka R2007a running on MS-Windows are no longer supported by this release.\n');
 
154
            fprintf('Install GNU/Octave or a more modern Matlab version instead. Or downgrade to Psychtoolbox version 3.0.9 or earlier.\n\n');
 
155
        else
 
156
            fprintf('Hmm. I cannot find the file on your Matlab path?!?\n\n');
 
157
            fprintf('One reason could be that your Matlab path is wrong or not up to date\n');
 
158
            fprintf('for the current Psychtoolbox. You may want to run SetupPsychtoolbox to \n');
 
159
            fprintf('fix possible path problems.\n\n');
 
160
        end
142
161
    else
143
162
        if IsWin
144
 
            fprintf('It is important that the folder which contains the Screen.dll file is located *before*\n');
145
 
            fprintf('the PsychBasic folder on your Matlab path. On Matlab prior to V7.4, the folder\n');
146
 
            fprintf('%sPsychBasic\\MatlabWindowsFilesR11\\ must be before the folder\n%sPsychBasic\\ \n\n', PsychtoolboxRoot, PsychtoolboxRoot);
 
163
            fprintf('It is important that the folder which contains the Screen mex file is located *before*\n');
 
164
            fprintf('the PsychBasic folder on your Matlab path.\n');
147
165
            fprintf('On Matlab V7.4 (R2007a) or later versions, the folder\n');
148
166
            fprintf('%sPsychBasic\\MatlabWindowsFilesR2007a\\ must be before the folder\n%sPsychBasic\\ \n\n', PsychtoolboxRoot, PsychtoolboxRoot);
149
167
            fprintf('type path to display the current path and check for this condition.\nIf the order is wrong, ');
150
168
            fprintf('simply cd into your Psychtoolbox root folder\n%s and then run SetupPsychtoolbox again.\n', PsychtoolboxRoot);
151
169
            fprintf('That is the simplest way of fixing such path problems - Or to get more diagnostic output.\n\n');
152
170
        end
153
 
 
 
171
        
154
172
        fprintf('Another reason could be insufficient access permissions or \n');
155
173
        fprintf('some missing 3rd party libraries on your system.\n\n');
156
 
 
 
174
        
157
175
        if IsWin
158
 
            fprintf('On Microsoft Windows with recent Matlab versions (>= V7.4) it could also be that\n');
159
 
            fprintf('the required Visual C++ 2005 runtime libraries are missing on your system.\n');
160
 
            fprintf('Visit http://www.mathworks.com/support/solutions/data/1-2223MW.html for instructions how to\n');
161
 
            fprintf('fix this problem. Make sure you follow the download link to Visual Studio SERVICE PACK 1,\n');
162
 
            fprintf('(the latter links), *not* Visual Studio without the SP1.\n\nAfter fixing the problem, retry.\n\n');
163
 
 
164
 
            if strcmp(computer,'PCWIN64')
165
 
                % 64 bit Matlab running on 64 bit Windows?!? That won't work.
166
 
                fprintf('And another possible reason for failure:\n\n');
167
 
                fprintf('It seems that you are running a 64-bit version of Matlab on your system.\n');
168
 
                fprintf('That won''t work at all! Psychtoolbox currently only supports 32-bit versions\n');
169
 
                fprintf('of Matlab.\n');
170
 
                fprintf('You can try to exit Matlab and then restart it in 32-bit emulation mode to\n');
171
 
                fprintf('make Psychtoolbox work on your 64 bit Windows. You do this by adding the\n');
172
 
                fprintf('startup option -win32 to the matlab.exe start command, ie.\n');
173
 
                fprintf('matlab.exe -win32\n');
174
 
                fprintf('If you do not know how to do this, consult the Matlab help about startup\n');
175
 
                fprintf('options for Windows.\n\n');
 
176
            fprintf('On Microsoft Windows with supported Matlab versions (>= V7.4) it could also be that\n');
 
177
            fprintf('the required Visual C++ 2010 runtime libraries are missing on your system.\n');
 
178
            fprintf('The Psychtoolbox/PsychContributed/ subfolder contains installer files for them, which\n');
 
179
            fprintf('you can execute after quitting Matlab. The name of the file is ');
 
180
            if IsWin(1)
 
181
                fprintf('vcredist_x64.exe\n');
 
182
            else
 
183
                fprintf('vcredist_x86.exe\n');
176
184
            end
177
185
        end
178
 
        
179
 
        if IsOSX & strcmp(computer,'MACI64') %#ok<AND2>
180
 
            % 64 bit Matlab running on 64 bit OS/X?!? That won't work.
181
 
            fprintf('And another possible reason for failure:\n\n');
182
 
            fprintf('It seems that you are running a 64-bit version of Matlab on your system.\n');
183
 
            fprintf('That won''t work at all! Psychtoolbox currently only supports 32-bit versions\n');
184
 
            fprintf('of Matlab.\n');
185
 
            fprintf('You can try to exit Matlab and then restart it in 32-bit emulation mode to\n');
186
 
            fprintf('make Psychtoolbox work on your 64 bit OS/X. You do this by adding the\n');
187
 
            fprintf('startup option -maci to the matlab start command, ie.\n');
188
 
            fprintf('matlab -maci\n');
189
 
            fprintf('If you do not know how to do this, consult the Matlab help about startup\n');
190
 
            fprintf('options for OS/X.\n\n');
191
 
        end
192
 
 
193
 
        if IsLinux & strcmp(computer,'GLNXA64') %#ok<AND2>
194
 
            % 64 bit Matlab running on 64 bit Linux?!? That won't work.
195
 
            fprintf('And another possible reason for failure:\n\n');
196
 
            fprintf('It seems that you are running a 64-bit version of Matlab on your system.\n');
197
 
            fprintf('That won''t work at all! Psychtoolbox currently only supports 32-bit versions\n');
198
 
            fprintf('of Matlab. One exception is if you got this Psychtoolbox from the NeuroDebian\n');
199
 
            fprintf('project repository: http://neuro.debian.net, in which case 64 bit Matlab and Octave\n');
200
 
            fprintf('should be fully supported, so the reason for failure is not 64 bit problems.\n');
201
 
            fprintf('You can try to exit Matlab and then restart it in 32-bit emulation mode to\n');
202
 
            fprintf('make Psychtoolbox work on your 64 bit Linux.\n'); % You do this by adding the\n');
203
 
            %             fprintf('startup option -maci to the matlab start command, ie.\n');
204
 
            %             fprintf('matlab -maci\n');
205
 
            fprintf('If you do not know how to do this, consult the Matlab help about startup\n');
206
 
            fprintf('options for Linux.\n\n');
207
 
        end
208
 
 
209
186
    end
210
187
    error('Missing or dysfunctional Psychtoolbox Mex file for this operating system. Read the help text above carefully!!');
211
188
end