42
44
% 10/31/2011 Add call to SwitchToNewPsychtoolboxHoster for switch to
43
45
% GoogleCode, if needed. (MK)
44
46
% 01/06/2012 Add support for calling PsychLinuxConfiguration on Linux. (MK)
47
% 04/30/2012 Add support for 64-Bit OSX. (MK)
48
% 06/13/2012 Removed call to SwitchToNewPsychtoolboxHoster, no longer needed (DN)
49
% 07/10/2012 Use textscan() on R2012a+ and verLessThan() to detect R2007a+ (MK)
50
% 09/05/2012 Update support for 64-Bit Octave and versions > 3.2. (MK)
51
% 09/13/2012 Add startup.m setup for 64-Bit Matlab + 64-Bit Windows. (MK)
52
% 09/14/2012 Cancel support for Octave on MS-Windows. (MK)
53
% 09/14/2012 Cancel support for 32-Bit Octave on OSX. (MK)
54
% 11/11/2012 More cleanup. E.g., don't warn about Octave > 3.2 anymore. (MK)
55
% 04/16/2013 Use javaclasspath.txt instead of classpath.txt on R2013a and later. (MK)
56
% 05/13/2013 Factor out Java classpath setup to call to PsychJaveTrouble(1). (MK)
57
% 07/02/2013 Drop support for 32-Bit Matlab on OSX, and thereby for 32-Bit OSX. (MK)
58
% 07/02/2013 Drop support for OSX versions older than 10.6 "Snow Leopard". (MK)
59
% 09/12/2013 Setup PsychStartup.m in startup.m for 32-Bit Windows as well. (MK)
47
61
fprintf('\n\nRunning post-install routine...\n\n');
49
if exist('SwitchToNewPsychtoolboxHoster.m', 'file')
50
clear SwitchToNewPsychtoolboxHoster;
52
% Check if we are still hosted on Berlios, switch to GoogleCode, if so:
53
SwitchToNewPsychtoolboxHoster;
57
64
error('PsychtoolboxPostInstallRoutine: Required argument isUpdate missing!');
136
143
fprintf('Info: Failed to remove .svn subfolders from path. Not a big deal...\n');
139
% Check for operating system minor version on Mac OS/X when running under
146
% Octave on Windows? This is unsupported as of Version 3.0.10.
148
error('Use of GNU/Octave on MS-Windows with Psychtoolbox 3.0.10 is no longer supported. Aborted.');
151
% 32-Bit Octave or 32-Bit Matlab on OSX? This is unsupported as of Version 3.0.11.
153
fprintf('Psychtoolbox 3.0.11 and later do no longer work with 32-Bit versions of Octave or Matlab on OSX.\n');
154
fprintf('You need to upgrade to a 64-Bit version of Octave or Matlab on OSX, which is fully supported.\n');
155
fprintf('You can also use the alternate download function DownloadLegacyPsychtoolbox() to download\n');
156
fprintf('an old legacy copy of Psychtoolbox-3.0.9, which did support 32-Bit Octave 3.2 on OSX, or use\n');
157
fprintf('DownloadPsychtoolbox() with flavor ''Psychtoolbox-3.0.10'', which does support 32-Bit Matlab on OSX.\n');
158
error('Tried to setup on 32-Bit Octave, which is no longer supported on OSX.');
161
% Check if our own startup function is part of the startup file and add it,
162
% if it isn't already part of it. Currently we only need this for MS-Windows.
164
% Is it already implanted? Then we ain't nothing to do:
165
if ~IsPsychStartupImplantedInStartup
166
% Nope. Does a proper file already exist?
167
whereisit = which('startup.m');
168
if isempty(whereisit)
169
% No: Create our own one.
170
whereisit = [PsychtoolboxRoot 'PsychInitialize' filesep 'startup.m'];
171
fprintf('Creating a startup.m file for Psychtoolbox at %s\n', whereisit);
173
fprintf('Adding PsychStartup() call to Matlab startup.m file for Psychtoolbox at %s\n', whereisit);
176
% whereisit points to the location of the existing or to be created
177
% file. Open (or create) it in append mode:
179
fd = fopen(whereisit, 'a');
181
fprintf(fd, '%% Call Psychtoolbox-3 specific startup function:\n');
182
fprintf(fd, 'if exist(''PsychStartup''), PsychStartup; end;\n');
186
fprintf('WARNING: Failed to update or create startup.m file to add a call to PsychStartup()! Trouble ahead.\n');
190
% Execute our startup function once manually, so it works already for
195
% Check for operating system minor version on Mac OS/X.
142
if ~IsOctave %#ok<AND2>
143
% Running on Matlab + OS/X. Find the operating system minor version,
144
% i.e., the 'y' in the x.y.z number, e.g., y=3 for 10.3.7:
146
% Get 32-digit binary encoded minor version from Gestalt() MEX file:
147
binminor = Gestalt('sys2');
149
% Decode into decimal digit:
152
minorver = minorver + binminor(i) * 2^(32-i);
197
% Query kernel version via system() call:
198
[s, did]=system('uname -r');
200
% Parse string for kernel major number, then translate to OS
201
% minor version by subtracting 4:
202
minorver = sscanf(did, '%i') - 4;
155
% Running on Octave + OS/X: Query kernel version via system() call:
156
[s, did]=system('uname -r');
158
% Parse string for kernel major number, then translate to OS
159
% minor version by subtracting 4:
160
minorver = sscanf(did, '%i') - 4;
162
% Failed to query: Assume we're good for now...
204
% Failed to query: Assume we're good for now...
167
% Is the operating system minor version 'minorver' < 4?
169
% Yes. This is MacOS/X 10.3 or earlier, i.e., older than 10.4
170
% Tiger. In all likelihood, this current PTB release won't work on
171
% such a system anymore, because some of the binary MEX files are
172
% linked against incompatible runtimes and frameworks. Output a
173
% clear warning message about this, with tips on how to resolve the
208
% Is the operating system minor version 'minorver' < 6?
210
% Yes. This is MacOSX 10.5 or earlier, i.e., older than 10.6
211
% Snow Leopard. PTB will not work on such an old system:
175
212
fprintf('\n\n\n\n\n\n\n\n==== WARNING WARNING WARNING WARNING ====\n\n');
176
213
fprintf('Your operating system is Mac OS/X version 10.%i.\n\n', minorver);
177
fprintf('This release of Psychtoolbox-3 is likely no longer compatible\n');
178
fprintf('to OS/X versions older than 10.4 "Tiger".\n\n');
179
fprintf('That means that some or many crucial functions will fail.\n');
180
fprintf('You may encounter errors or failures during the remainder of\n');
181
fprintf('this installation procedure, or later on during use of the toolkit.\n\n');
182
fprintf('You can fix this problem by switching to the last Psychtoolbox version\n');
183
fprintf('that was known to (mostly) work on your old operating system:\n\n');
184
fprintf('1. Type clear all on the Matlab command prompt.\n\n');
185
fprintf('2. Run the downloader script DownloadPsychtoolbox again,\n');
186
fprintf(' (see help DownloadPsychtoolbox for usage information),\n');
187
fprintf(' but specify the optional "flavor" argument as:\n\n');
188
fprintf(' ''Psychtoolbox-3.0.8-PreTiger''\n\n');
189
fprintf(' Example for a standard installation in standard location:\n\n');
190
fprintf(' DownloadPsychtoolbox([],[],[],''Psychtoolbox-3.0.8-PreTiger'');\n\n\n');
191
fprintf('This will delete your current copy of Psychtoolbox-3 and replace it\n');
192
fprintf('by the last known good version for your system.\n\n');
193
fprintf('Please note that we will no longer provide support, bug fixes or enhancements\n');
194
fprintf('for this old release on your old and obsolete operating system - You are on your own.\n\n');
195
fprintf('We strongly recommend that you upgrade your system to a more recent OS/X version soon.\n\n');
196
fprintf('Thanks for your attention and good luck!');
214
fprintf('This release of Psychtoolbox-3 is not compatible\n');
215
fprintf('to OSX versions older than 10.6 "Snow Leopard".\n');
216
fprintf('That means that almost all functionality will not work!\n\n');
217
fprintf('You can either download an older version of Psychtoolbox\n');
218
fprintf('onto your system to get better results. See our Wiki for help.\n');
219
fprintf('Better though, update your operating system to at least version\n');
220
fprintf('10.6.8 "Snow Leopard" or later.\n');
197
221
fprintf('\n\n\n==== WARNING WARNING WARNING WARNING ====\n\n\n');
198
fprintf('Press any key on keyboard to continue with setup...\n');
222
fprintf('Press any key on keyboard to try to continue with setup, although\n');
223
fprintf('this will likely fail soon and leave you with a dysfunctional toolbox.\n\n');
203
228
% Matlab specific setup:
205
% Check if this is Matlab of version prior to V 6.5:
230
% Check if this is Matlab of version prior to V 7.4:
206
231
v = ver('matlab');
208
233
v = v(1).Version; v = sscanf(v, '%i.%i.%i');
209
if (v(1) < 6) | ((v(1) == 6) & (v(2) < 5)) %#ok<AND2,OR2>
210
% Matlab version < 6.5 detected. This is no longer
234
if (v(1) < 7) || ((v(1) == 7) && (v(2) < 4))
235
% Matlab version < 7.4 detected. This is no longer
212
fprintf('\n\nYou are using a Matlab version older than Version 6.5.\n');
237
fprintf('\n\nYou are using a Matlab version older than Version 7.4.\n');
213
238
fprintf('The current "beta" flavor is no longer compatible with your version of Matlab.\n');
214
fprintf('Current "beta" only works on Matlab Version 6.5 or later.\n\n');
239
fprintf('Current "beta" only works on Matlab Version 7.4 (R2007a) or later.\n\n');
215
240
fprintf('I will try to finish setup, but most functions will not work for you.\n');
216
fprintf('Please run the DownloadPsychtoolbox downloader now to download an outdated,\n');
217
fprintf('but functional older version of Psychtoolbox for your Matlab setup or to\n');
241
fprintf('Please run the legacy DownloadLegacyPsychtoolbox() downloader to download an outdated,\n');
242
fprintf('but functional older version of Psychtoolbox (e.g., V3.0.9) for your Matlab setup or to\n');
218
243
fprintf('receive further instructions.\n');
219
244
fprintf('\n\nPress any key to continue after you have read and understood above message completely.\n\n');
348
378
% Special case handling for different Matlab releases on MS-Windoze:
349
if IsWin & ~IsOctave %#ok<AND2>
350
380
rc = 0; %#ok<NASGU>
352
382
if strfind(cd,'system32')
353
% the below code fails i've the current directory is system32 (e.g.
383
% the below code fails if the current directory is system32 (e.g.
354
384
% C:\Windows\system32), as it contains dlls like version.dll, which
355
385
% get called instead of the built-in functions....
356
386
cd(PsychtoolboxRoot);
359
390
% Remove DLL folders from path:
360
rmpath([PsychtoolboxRoot 'PsychBasic\MatlabWindowsFilesR11\']);
361
391
rmpath([PsychtoolboxRoot 'PsychBasic\MatlabWindowsFilesR2007a\']);
363
% Is this a Release2007a or later Matlab?
364
if ~isempty(strfind(version, '2007')) | ~isempty(strfind(version, '2008')) | ...
365
~isempty(strfind(version, '2009')) | ~isempty(strfind(version, '2010')) | ...
366
~isempty(strfind(version, '2011')) | ~isempty(strfind(version, '2012')) | ...
367
~isempty(strfind(version, '2013')) | ~isempty(strfind(version, '2014')) %#ok<OR2>
393
% Is this a Release2007a (Version 7.4.0) or later Matlab?
394
if ~exist('verLessThan') || verLessThan('matlab', '7.4.0') %#ok<EXIST>
395
% This is a pre-R2007a Matlab: No longer supported by V 3.0.10+
396
fprintf('Matlab release prior to R2007a detected. This version is no longer\n');
397
fprintf('supported by Psychtoolbox 3.0.10 and later. Aborted.');
398
fprintf('\n\nInstallation aborted. Fix the reported problem and retry.\n\n');
369
401
% This is a R2007a or post R2007a Matlab:
370
402
% Add PsychBasic/MatlabWindowsFilesR2007a/ subfolder to Matlab
418
438
% Try if WaitSecs MEX file works...
419
439
WaitSecs('YieldSecs', 0.1)
421
% Failed! Either screwed setup of path or missing VC++ 2005 runtime
423
% fprintf('ERROR: WaitSecs-MEX does not work, most likely other MEX files will not work either.\n');
424
% fprintf('ERROR: Most likely cause: The Visual C++ 2005 runtime libraries are missing on your system.\n\n');
425
% fprintf('ERROR: Visit http://www.mathworks.com/support/solutions/data/1-2223MW.html for instructions how to\n');
426
% fprintf('ERROR: fix this problem. That document tells you how to download and install the required runtime\n');
427
% fprintf('ERROR: libraries. It is important that you download the libraries for Visual C++ 2005 SP1\n');
428
% fprintf('ERROR: - The Service Pack 1! Follow the link under the text "For VS 2005 SP1 vcredist_x86.exe:"\n');
429
% fprintf('ERROR: If you install the wrong runtime, it will still not work.\n\n');
430
% fprintf('ERROR: After fixing the problem, restart this installation/update routine.\n\n');
432
fprintf('ERROR: Most likely cause: The most recent security updates to the Visual C++ 2005 runtime libraries\n');
433
fprintf('ERROR: are missing on your system. Go to the following URL:\n\n');
434
fprintf('http://www.microsoft.com/downloads/details.aspx?familyid=766A6AF7-EC73-40FF-B072-9112BAB119C2&displaylang=en#filelist\n\n');
435
fprintf('ERROR: Download and install the required runtime libraries.\n\n');
436
fprintf('ERROR: Use the download button right to vcredist_x86.exe - The file with a size of 2.6 MB.\n');
437
fprintf('ERROR: Then double-click and run the downloaded vcredist_x86.exe installer to update your system.\n');
438
fprintf('ERROR: If you install the wrong runtime, it will still not work.\n\n');
441
% Failed! Either screwed setup of path or missing VC++ 2010 runtime libraries.
442
fprintf('ERROR: Most likely cause: The Microsoft Visual C++ 2010 runtime libraries\n');
443
fprintf('ERROR: are missing on your system.\n\n');
445
% Need 64-Bit runtime:
446
fprintf('ERROR: Execute the installer file vcredist_x64.exe, which is located in your Psychtoolbox/PsychContributed/ folder.\n');
448
% Need 32-Bit runtime:
449
fprintf('ERROR: Execute the installer file vcredist_x86.exe, which is located in your Psychtoolbox/PsychContributed/ folder.\n');
451
fprintf('ERROR: You must execute that installer as an administrator user. Exit Matlab before the installation, then restart it.\n');
439
452
fprintf('ERROR: After fixing the problem, restart this installation/update routine.\n\n');
440
fprintf('ERROR: You can also just do a: cd(PsychtoolboxRoot); SetupPsychtoolbox;\n\n');
453
fprintf('ERROR: You can also just do a: cd(PsychtoolboxRoot); SetupPsychtoolbox; PsychtoolboxRegistration(%i, ''%s'');\n\n', isUpdate, flavor);
441
454
fprintf('ERROR: This will avoid a full download of Psychtoolbox over the internet and just finish the setup.\n');
443
if strcmp(computer,'PCWIN64')
444
% 64 bit Matlab running on 64 bit Windows?!? That won't work.
446
fprintf('ERROR: It seems that you are running a 64-bit version of Matlab on your system.\n');
447
fprintf('ERROR: That won''t work at all! Psychtoolbox currently only supports 32-bit versions\n');
448
fprintf('ERROR: of Matlab.\n');
449
fprintf('ERROR: You can try to exit Matlab and then restart it in 32-bit emulation mode to\n');
450
fprintf('ERROR: make Psychtoolbox work on your 64 bit Windows. You do this by adding the\n');
451
fprintf('ERROR: startup option -win32 to the matlab.exe start command, ie.\n');
452
fprintf('ERROR: matlab.exe -win32\n');
453
fprintf('ERROR: If you do not know how to do this, consult the Matlab help about startup\n');
454
fprintf('ERROR: options for Windows.\n');
455
fprintf('ERROR: See also http://psychtoolbox.org/wikka.php?wakka=Faq64BitSupport.\n\n');
458
456
fprintf('\n\nInstallation aborted. Fix the reported problem and retry.\n\n');
463
461
% If we're using Matlab then add the PsychJava stuff to the static
464
462
% Java classpath.
467
% Figure out the PsychJava path we need to add to the static Java
469
path_PsychJava = [PsychtoolboxRoot, 'PsychJava'];
471
% Open up the classpath.txt file and find any PsychJava entries. If
472
% they exist, remove them, and put the current one in the file. This
473
% only allows on PsychJava to be on the path.
474
classpathFile = which('classpath.txt');
475
bakclasspathFile = [classpathFile '.bak'];
477
fileContents = textread(classpathFile, '%s');
479
newFileContents = {};
481
for i = 1:length(fileContents)
482
% Look for the first instance of PsychJava in the classpath and
483
% replace it with the new one. All other instances will be
485
if isempty(findstr('PsychJava', fileContents{i}))
486
newFileContents{j, 1} = fileContents{i}; %#ok<AGROW>
488
elseif ~isempty(findstr('PsychJava', fileContents{i})) & ~pathInserted %#ok<AND2>
489
newFileContents{j, 1} = path_PsychJava; %#ok<AGROW>
495
% If the PsychJava path wasn't inserted, then this must be a new
496
% installation, so we append it to the classpath.
498
newFileContents{end + 1, 1} = path_PsychJava;
501
% Now compare to see if the new and old classpath are the same. If
502
% they are, then there's no need to do anything.
504
if length(fileContents) == length(newFileContents)
505
if strcmp(fileContents, newFileContents)
511
% Make a backup of the old classpath.
514
[s, w] = copyfile(classpathFile, bakclasspathFile, 'f');
517
error(['Could not make a backup copy of Matlab''s JAVA path definition file ''classpath.txt''.\n' ...
518
'The system reports: ', w]);
520
madeBackup = 1; %#ok<NASGU>
522
% Write out the new contents.
523
FID = fopen(classpathFile, 'w');
525
error('Could not open Matlab''s JAVA path definition file ''classpath.txt'' for write access.');
527
for i = 1:length(newFileContents)
528
fprintf(FID, '%s\n', newFileContents{i});
533
disp('*** Matlab''s Static Java classpath definition file modified. You will have to restart Matlab to enable use of the new Java components. ***');
534
fprintf('\nPress RETURN or ENTER to confirm you read and understood the above message.\n');
538
lerr = psychlasterror;
539
fprintf('Could not update the Matlab JAVA classpath.txt file due to the following error:\n');
540
fprintf('%s\n\n', lerr.message);
541
fprintf('Either you have a very old Matlab version which does not support JAVA or, most\n');
542
fprintf('likely, you do not have sufficient access permissions for the Matlab application folder\n');
543
fprintf('or file itself to change the file %s .\n', classpathFile);
544
fprintf('Please ask the system administrator to enable write-access to that file and its\n');
545
fprintf('containing folder and then repeat the update procedure.\n');
546
fprintf('Alternatively, ask the administrator to add the following line:\n');
547
fprintf('%s\n', path_PsychJava);
548
fprintf('to the file: %s\n\n', classpathFile);
549
fprintf('If you skip this step, Psychtoolbox will still be mostly functional, \n');
550
fprintf('but the Java-based commands ListenChar, CharAvail, GetChar and FlushEvents\n');
551
fprintf('on Linux, MacOS-X and M$-Windows in Java mode will work less efficiently.\n');
552
fprintf('For more info see ''help PsychJavaTrouble''.\n\n');
553
fprintf('\nPress RETURN or ENTER to confirm you read and understood the above message.\n');
556
% Restore the old classpath file if necessary.
557
if exist('madeBackup', 'var')
558
[s, w] = copyfile(bakclasspathFile, classpathFile, 'f'); %#ok<NASGU>
464
% Try to setup Matlab static Java class path:
563
468
% Check if Screen is functional:
596
501
fprintf('If you receive an installation failure soon, then please read the output of\n');
597
502
fprintf('"help GStreamer" first and follow the installation instructions for GStreamer\n');
598
503
fprintf('on Linux. Psychtoolbox''s Screen() command will not work without GStreamer!\n\n');
505
% Additional setup instructions for embedded/mobile devices with ARM cpu required?
507
fprintf('Additionally, as this is a device with ARM processor, the helper library\n');
508
fprintf('libwaffle-1.so needs to be installed in a system library folder for Screen\n');
509
fprintf('to work. You can find a copy of the library in the PsychContributed/ArmArch/\n');
510
fprintf('subfolder of your Psychtoolbox main folder. Rename it to libwaffle-1.so.0 during\n');
511
fprintf('the copy.\n');
512
fprintf('Another requirement, at least as of April 2013 and Ubuntu 13.04 for the Nexus-7,\n');
513
fprintf('is that you must start octave from the command line, or via some script, like this:\n');
514
fprintf('LD_PRELOAD=/usr/lib/libGLESv1_CM.so octave\n');
515
fprintf('This is a workaround for a small bug in octave for Nexus-7, which would cause Screen()\n');
516
fprintf('to crash shortly after opening an onscreen window.\n\n');
518
fprintf('If you run PTB on the Nexus7 make sure you do not use the "Unity" desktop since\n');
519
fprintf('this might lead to unforeseen problems. Use a desktop without 3D desktop compositor instead.\n');
520
fprintf('E.g. install and use XFCE (sudo apt-get install xfce4).\n');
605
% Setup Desktop compositor ("Compiz") to un-redirect fullscreen windows.
606
% This allows to bypass desktop composition for PTB fullscreen onscreen windows,
607
% so we get the deterministic timing and high performance we want for visual
608
% stimulus presentation. The command is a no-op
609
PsychGPUControl('FullScreenWindowDisablesCompositor', 1);
528
% Setup Desktop compositor ("Compiz") to un-redirect fullscreen windows.
529
% This allows to bypass desktop composition for PTB fullscreen onscreen windows,
530
% so we get the deterministic timing and high performance we want for visual
531
% stimulus presentation. The command is a no-op
532
PsychGPUControl('FullScreenWindowDisablesCompositor', 1);
612
535
% Try to execute online registration routine: This should be fail-safe in case