19
19
% (1) Create a source code file CSparse/Source/cs_mynewfunc.c.
20
20
% (2) Create a help file, CSparse/MATLAB/CSparse/cs_mynewfunc.m.
21
21
% This is very useful, but not strictly required.
22
% (3) Add the prototype of cs_mynewfunc to CSparse/Source/cs.h.
22
% (3) Add the prototype of cs_mynewfunc to CSparse/Include/cs.h.
23
23
% (4) Create its MATLAB mexFunction, CSparse/MATLAB/cs_mynewfunc_mex.c.
24
24
% (5) Edit cs_make.m, and add 'cs_mynewfunc' to the 'cs' and 'csm' lists.
25
25
% (6) Type 'cs_make' in the CSparse/MATLAB/CSparse directory.
42
% Copyright 2006, Timothy A. Davis.
42
% Copyright 2006-2007, Timothy A. Davis.
43
43
% http://www.cise.ufl.edu/research/sparse
45
fprintf ('Compiling CSparse\n') ;
45
47
% CSparse source files, in ../../Source, such as ../../Source/cs_add.c.
46
48
% Note that not all CSparse source files have their own mexFunction.
47
49
cs = { 'cs_add', 'cs_amd', 'cs_chol', 'cs_cholsol', 'cs_counts', ...
72
details = details | (force > 1) ; %#ok
73
if (force & details) %#ok
69
74
fprintf ('cs_make: re-compiling everything\n') ;
78
fprintf ('Compiling CSparse\n') ;
74
82
% mexFunctions, of the form cs_add_mex.c, etc, in this directory
81
89
% add cs_mynewfunc to the above list
93
% ispc does not appear in MATLAB 5.3
96
% if ispc fails, assume we are on a Windows PC if it's not unix
90
srcdir = sprintf ('..%s..%sSource%s', filesep, filesep, filesep) ;
91
hfile = [srcdir 'cs.h'] ;
106
srcdir = '../../Source/' ;
107
hfile = '../../Include/cs.h' ;
93
109
% compile each CSparse source file
94
[anysrc timestamp] = compile_source ('', 'cs_mex', obj, hfile, force) ;
110
[anysrc timestamp kk] = compile_source ('', 'cs_mex', obj, hfile, force, ...
95
112
CS = ['cs_mex' obj] ;
97
114
objfiles = ['..' filesep 'CSparse' filesep 'cs_mex' obj] ;
99
116
for i = 1:length (cs)
100
[s t] = compile_source (srcdir, cs {i}, obj, hfile, force) ;
117
[s t kk] = compile_source (srcdir, cs {i}, obj, hfile, force, kk, details) ;
101
118
timestamp = max (timestamp, t) ;
102
anysrc = anysrc || s ;
103
CS = [CS ' ' cs{i} obj] ; %#ok
119
anysrc = anysrc | s ; %#ok
120
CS = [CS ' ' cs{i} obj] ; %#ok
105
122
objfiles = [objfiles ' ..' filesep 'CSparse' filesep cs{i} obj] ; %#ok
111
128
for i = 1:length (csm)
112
129
[s t] = cs_must_compile ('', csm{i}, '_mex', obj, hfile, force) ;
113
130
timestamp = max (timestamp, t) ;
115
cmd = sprintf ('mex -O -I../../Source %s_mex.c %s -output %s\n', ...
132
cmd = sprintf ('mex -O -I../../Include %s_mex.c %s -output %s', ...
116
133
csm{i}, CS, csm{i}) ;
117
fprintf ('%s', cmd) ;
134
kk = do_cmd (cmd, kk, details) ;
140
timestamp_out = timestamp ;
144
fprintf ('CSparse successfully compiled.\n') ;
122
147
%-------------------------------------------------------------------------------
123
function [s,t] = compile_source (srcdir, f, obj, hfile, force)
148
function [s,t,kk] = compile_source (srcdir, f, obj, hfile, force, kk, details)
124
149
% compile a source code file in ../../Source, leaving object file in
125
150
% this directory.
126
151
[s t] = cs_must_compile (srcdir, f, '', obj, hfile, force) ;
128
cmd = sprintf ('mex -O -c -I../../Source %s%s.c\n', srcdir, f) ;
129
fprintf ('%s', cmd) ;
153
cmd = sprintf ('mex -O -c -I../../Include %s%s.c', srcdir, f) ;
154
kk = do_cmd (cmd, kk, details) ;
157
%-------------------------------------------------------------------------------
158
function kk = do_cmd (s, kk, details)
159
%DO_CMD: evaluate a command, and either print it or print a "."
161
fprintf ('%s\n', s) ;
163
if (mod (kk, 60) == 0)