0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 cddlibLocation = 'cddlib-094g';
0033 cddmexLocation = 'mpt-cddmex';
0034 compiler = 'gcc-4.4';
0035 zerotol = 1e-7;
0036
0037
0038
0039
0040 callLocation = pwd;
0041 myLocation = which('buildCddlib');
0042 myLocation = myLocation(1:find(myLocation == '/', 1, 'last'));
0043 logfile = [myLocation filesep 'buildCddlib.log'];
0044
0045
0046 cd(myLocation)
0047 fileId = fopen('zerotolCddlib.m', 'w+');
0048 fprintf(fileId, 'function zerotol = zerotolCddlib\n');
0049 fprintf(fileId, '%% return zerotol that is used for compilation of cddlib\n');
0050 fprintf(fileId, ['zerotol = ' num2str(zerotol) ';']);
0051 fclose(fileId);
0052
0053
0054 type legalNoticeCddlib
0055
0056 cd(cddlibLocation);
0057 callSystemFunction(['./configure CC=' compiler ' CFLAGS=-fPIC'], ...
0058 'logfile', logfile, ...
0059 'reset logfile', 1, ...
0060 'error type', 'elk:setup', ...
0061 'error message', 'Build of cddlib failed. See logfile above.');
0062
0063 cd('lib-src');
0064
0065
0066 command = ['sed ''s/\(#define dd_almostzero \)\([0-9]*.[0-9]*E*-*[0-9]*\)/' ...
0067 '\1' num2str(zerotol, '%G') '/g'' cdd.h.original > cdd.h'];
0068
0069 callSystemFunction(command, ...
0070 'error type', 'elk:setup', ...
0071 'error message', 'Build of cddlib failed. This error cannot be found in the logfile.');
0072
0073 callSystemFunction('make', ...
0074 'logfile', logfile, ...
0075 'error type', 'elk:setup', ...
0076 'error message', 'Build of cddlib failed. See logfile above.');
0077
0078
0079 cd(myLocation)
0080 type legalNoticeMpt
0081
0082 cd(fullfile(myLocation, cddlibLocation, 'lib-src'));
0083 callSystemFunction(['cp ' ...
0084 myLocation filesep cddmexLocation filesep 'cddmex.c .' filesep], ...
0085 'logfile', logfile, ...
0086 'error type', 'elk:setup', ...
0087 'error message', 'Build of cddlib failed. See logfile above.');
0088
0089 try
0090
0091 eval(['mex cddmex.c .libs/libcdd.a CC=' compiler]);
0092 catch thisError
0093 type(fullfile(myLocation, 'buildCddlib.log'));
0094 disp('Mex execution failed - see details far above the added log')
0095 throw(thisError);
0096 end
0097
0098
0099
0100
0101 callSystemFunction('rm cddmex.c', ...
0102 'logfile', logfile, ...
0103 'error type', 'elk:setup', ...
0104 'error message', 'Build of cddlib failed. See logfile above.');
0105 callSystemFunction(['mv cddmex.' mexext ' ../../callCddLib.' mexext], ...
0106 'logfile', logfile, ...
0107 'error type', 'elk:setup', ...
0108 'error message', 'Build of cddlib failed. See logfile above.');
0109
0110
0111 cd(myLocation);
0112 callSystemFunction(['cp ' cddmexLocation '/cddmex.m ' './callCddLib.m'], ...
0113 'logfile', logfile, ...
0114 'error type', 'elk:setup', ...
0115 'error message', 'Build of cddlib failed. See logfile above.');
0116
0117 disp('The log file of this process is stored in: ')
0118 disp(fullfile(myLocation, 'buildCddlib.log'));
0119
0120 cd(callLocation);