1
function klu_make (with_cholmod)
2
%KLU_MAKE compiles the KLU mexFunctions
5
% klu_make % compiles KLU without CHOLMOD
6
% klu_make (1) % with CHOLMOD, CCAMD, CCOLAMD, and METIS
8
% KLU relies on AMD, COLAMD, and BTF for its ordering options, and can
9
% optionally use CHOLMOD, CCOLAMD, CAMD, and METIS as well. By default,
10
% CHOLMOD, CCOLAMD, CAMD, and METIS are not used.
12
% See http://www-users.cs.umn.edu/~karypis/metis for a copy of METIS 4.0.1.
14
% You must type the klu_make command while in the KLU/MATLAB directory.
18
% Copyright 2004-2007 Timothy A. Davis, Univ. of Florida
19
% http://www.cise.ufl.edu/research/sparse
25
details = 0 ; % if 1, print details of each command
27
% modify this if your copy of METIS is not in SuiteSparse/metis-4.0:
28
metis_path = '../../metis-4.0' ;
31
if (~isempty (strfind (computer, '64')))
33
d = '-largeArrayDims' ;
36
fprintf ('Compiling KLU ') ;
39
include = '-I. -I../../AMD/Include -I../../COLAMD/Include -I../Include -I../../UFconfig -I../../BTF/Include' ;
42
include = [include ' -I../../CCOLAMD/Include -I../../CAMD/Include -I../../CHOLMOD/Include -I../../UFconfig -I' metis_path '/Lib -I../User'] ;
45
% do not attempt to compile CHOLMOD with large file support (not needed)
46
include = [include ' -DNLARGEFILE'] ;
48
% fix the METIS 4.0.1 rename.h file
50
fprintf ('with CHOLMOD, CCAMD, CCOLAMD, and METIS\n') ;
51
f = fopen ('rename.h', 'w') ;
53
error ('unable to create rename.h in current directory') ;
55
fprintf (f, '/* do not edit this file; generated by klu_make */\n') ;
56
fprintf (f, '#undef log2\n') ;
57
fprintf (f, '#include "%s/Lib/rename.h"\n', metis_path) ;
58
fprintf (f, '#undef log2\n') ;
59
fprintf (f, '#define log2 METIS__log2\n') ;
60
fprintf (f, '#include "mex.h"\n') ;
61
fprintf (f, '#define malloc mxMalloc\n') ;
62
fprintf (f, '#define free mxFree\n') ;
63
fprintf (f, '#define calloc mxCalloc\n') ;
64
fprintf (f, '#define realloc mxRealloc\n') ;
66
include = ['-DNSUPERNODAL -DNMODIFY -DNMATRIXOPS -DNCHECK ' include] ;
68
fprintf ('without CHOLMOD, CCAMD, CCOLAMD, and METIS\n') ;
69
include = ['-DNCHOLMOD ' include] ;
72
include = strrep (include, '/', filesep) ;
75
'../../AMD/Source/amd_1', ...
76
'../../AMD/Source/amd_2', ...
77
'../../AMD/Source/amd_aat', ...
78
'../../AMD/Source/amd_control', ...
79
'../../AMD/Source/amd_defaults', ...
80
'../../AMD/Source/amd_dump', ...
81
'../../AMD/Source/amd_global', ...
82
'../../AMD/Source/amd_info', ...
83
'../../AMD/Source/amd_order', ...
84
'../../AMD/Source/amd_postorder', ...
85
'../../AMD/Source/amd_post_tree', ...
86
'../../AMD/Source/amd_preprocess', ...
87
'../../AMD/Source/amd_valid' } ;
90
'../../CAMD/Source/camd_1', ...
91
'../../CAMD/Source/camd_2', ...
92
'../../CAMD/Source/camd_aat', ...
93
'../../CAMD/Source/camd_control', ...
94
'../../CAMD/Source/camd_defaults', ...
95
'../../CAMD/Source/camd_dump', ...
96
'../../CAMD/Source/camd_global', ...
97
'../../CAMD/Source/camd_info', ...
98
'../../CAMD/Source/camd_order', ...
99
'../../CAMD/Source/camd_postorder', ...
100
'../../CAMD/Source/camd_preprocess', ...
101
'../../CAMD/Source/camd_valid' } ;
104
'../../COLAMD/Source/colamd', ...
105
'../../COLAMD/Source/colamd_global' } ;
108
'../../CCOLAMD/Source/ccolamd', ...
109
'../../CCOLAMD/Source/ccolamd_global' } ;
113
'Lib/bucketsort', ...
127
'Lib/kwayrefine', ...
129
'Lib/kwayvolrefine', ...
140
'Lib/minitpart2', ...
144
'Lib/mkwayrefine', ...
161
'Lib/subdomains', ...
165
for i = 1:length (metis_src)
166
metis_src {i} = [metis_path '/' metis_src{i}] ;
170
'../../CHOLMOD/Core/cholmod_aat', ...
171
'../../CHOLMOD/Core/cholmod_add', ...
172
'../../CHOLMOD/Core/cholmod_band', ...
173
'../../CHOLMOD/Core/cholmod_change_factor', ...
174
'../../CHOLMOD/Core/cholmod_common', ...
175
'../../CHOLMOD/Core/cholmod_complex', ...
176
'../../CHOLMOD/Core/cholmod_copy', ...
177
'../../CHOLMOD/Core/cholmod_dense', ...
178
'../../CHOLMOD/Core/cholmod_error', ...
179
'../../CHOLMOD/Core/cholmod_factor', ...
180
'../../CHOLMOD/Core/cholmod_memory', ...
181
'../../CHOLMOD/Core/cholmod_sparse', ...
182
'../../CHOLMOD/Core/cholmod_transpose', ...
183
'../../CHOLMOD/Core/cholmod_triplet', ...
184
'../../CHOLMOD/Cholesky/cholmod_amd', ...
185
'../../CHOLMOD/Cholesky/cholmod_analyze', ...
186
'../../CHOLMOD/Cholesky/cholmod_colamd', ...
187
'../../CHOLMOD/Cholesky/cholmod_etree', ...
188
'../../CHOLMOD/Cholesky/cholmod_postorder', ...
189
'../../CHOLMOD/Cholesky/cholmod_rowcolcounts', ...
190
'../../CHOLMOD/Partition/cholmod_ccolamd', ...
191
'../../CHOLMOD/Partition/cholmod_csymamd', ...
192
'../../CHOLMOD/Partition/cholmod_camd', ...
193
'../../CHOLMOD/Partition/cholmod_metis', ...
194
'../../CHOLMOD/Partition/cholmod_nesdis' } ;
197
'../../BTF/Source/btf_maxtrans', ...
198
'../../BTF/Source/btf_order', ...
199
'../../BTF/Source/btf_strongcomp' } ;
202
'../Source/klu_free_symbolic', ...
203
'../Source/klu_defaults', ...
204
'../Source/klu_analyze_given', ...
205
'../Source/klu_analyze', ...
206
'../Source/klu_memory' } ;
209
klu_src = [klu_src { '../User/klu_l_cholmod' }] ; %#ok
214
'../Source/klu_kernel', ...
215
'../Source/klu_dump', ...
216
'../Source/klu_factor', ...
217
'../Source/klu_free_numeric', ...
218
'../Source/klu_solve', ...
219
'../Source/klu_scale', ...
220
'../Source/klu_refactor', ...
221
'../Source/klu_tsolve', ...
222
'../Source/klu_diagnostics', ...
223
'../Source/klu_sort', ...
224
'../Source/klu_extract', ...
232
'klu_l_free_numeric', ...
235
'klu_l_refactor', ...
237
'klu_l_diagnostics', ...
247
'klu_zl_free_numeric', ...
250
'klu_zl_refactor', ...
252
'klu_zl_diagnostics', ...
254
'klu_zl_extract', ...
258
% ispc does not appear in MATLAB 5.3
261
% if ispc fails, assume we are on a Windows PC if it's not unix
266
% Windows does not have drand48 and srand48, required by METIS. Use
267
% drand48 and srand48 in CHOLMOD/MATLAB/Windows/rand48.c instead.
268
obj_extension = '.obj' ;
269
cholmod_src = [cholmod_src {'../../CHOLMOD/MATLAB/Windows/rand48'}] ;
270
include = [include ' -I../../CHOLMOD/MATLAB/Windows'] ;
272
obj_extension = '.o' ;
275
% compile each library source file
278
source = [amd_src btf_src klu_src colamd_src] ;
280
source = [metis_src ccolamd_src camd_src cholmod_src source] ;
284
fs = strrep (f {1}, '/', filesep) ;
285
slash = strfind (fs, filesep) ;
289
slash = slash (end) + 1 ;
292
obj = [obj ' ' o obj_extension] ; %#ok
293
s = sprintf ('mex %s -DDLONG -O %s -c %s.c', d, include, fs) ;
294
kk = do_cmd (s, kk, details) ;
297
for k = 1:length(klu_zlsrc)
298
ff = strrep (klu_zlsrc {k}, '/', filesep) ;
299
slash = strfind (ff, filesep) ;
303
slash = slash (end) + 1 ;
306
s = sprintf ('mex %s -DDLONG -O %s -c %s.c', d, include, ff) ;
307
kk = do_cmd (s, kk, details) ;
308
lobj = klu_lobj {k} ;
309
obj = [obj ' ' lobj obj_extension] ; %#ok
310
mvfile ([o obj_extension], [lobj obj_extension]) ;
311
s = sprintf ('mex %s -DDLONG -DCOMPLEX -O %s -c %s.c', d, include, ff) ;
312
kk = do_cmd (s, kk, details) ;
313
zlobj = klu_zlobj {k} ;
314
obj = [obj ' ' zlobj obj_extension] ; %#ok
315
mvfile ([o obj_extension], [zlobj obj_extension]) ;
318
% compile the KLU mexFunction
319
s = sprintf ('mex %s -DDLONG -O %s -output klu klu_mex.c', d, include) ;
321
kk = do_cmd (s, kk, details) ;
324
s = ['delete ' obj] ;
325
do_cmd (s, kk, details) ;
327
fprintf ('\nKLU successfully compiled\n') ;
329
%-------------------------------------------------------------------------------
331
function rmfile (file)
332
% rmfile: delete a file, but only if it exists
333
if (length (dir (file)) > 0) %#ok
337
%-------------------------------------------------------------------------------
339
function cpfile (src, dst)
340
% cpfile: copy the src file to the filename dst, overwriting dst if it exists
342
if (length (dir (src)) == 0) %#ok
343
fprintf ('File does not exist: %s\n', src) ;
344
error ('File does not exist') ;
346
copyfile (src, dst) ;
348
%-------------------------------------------------------------------------------
350
function mvfile (src, dst)
351
% mvfile: move the src file to the filename dst, overwriting dst if it exists
355
%-------------------------------------------------------------------------------
356
function kk = do_cmd (s, kk, details)
357
%DO_CMD: evaluate a command, and either print it or print a "."
359
fprintf ('%s\n', s) ;
361
if (mod (kk, 60) == 0)