-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmake.m
142 lines (127 loc) · 4.39 KB
/
make.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
function make(installflag)
% MAKE Make file for MetisMex
% MAKE, MAKE(0) produce the mex files for METIS under 'build'
% folder.
%
% MAKE(1) produces the mex files for METIS under 'build' folder
% and install MetisMex under the userpath/methismex. The path to
% installed MetisMex will be added in 'startup.m' such that the
% MetisMex will be included automatically..
%
% MAKE(-1) uninstall MetisMex and delete all the files under
% 'build' folder.
%
% Copyright (c) 2015-2016 Yingzhou Li, Stanford University
if( nargin == 0 )
installflag = 0;
end
src_path = ['src' filesep];
build_path = ['build' filesep];
build_src_path = [build_path 'src' filesep];
build_mex_path = [build_path 'mex' filesep];
install_path = strsplit(userpath,pathsep);
matlab_startup_file = [install_path{1} filesep 'startup.m'];
install_path = [install_path{1} filesep 'metismex' filesep];
% make clear, installflag<0
if(installflag < 0)
if(exist(build_path, 'dir'))
rmdir(build_path,'s');
end
if(exist(install_path, 'dir'))
rmpath([install_path 'src' filesep]);
rmpath([install_path 'mex' filesep]);
rmdir(install_path,'s');
end
if(exist(matlab_startup_file, 'file'))
startup_path_data = importdata(matlab_startup_file);
fid = fopen(matlab_startup_file, 'w+');
for i=1:length(startup_path_data)
if(~strcmp(startup_path_data{i}, ...
['run ' install_path 'METIS_startup.m']))
fprintf(fid,'%s\n',startup_path_data{i});
end
end
fclose(fid);
end
return;
end
% make
if(~exist(build_path, 'dir'))
mkdir(build_path);
end
if(~exist(build_src_path, 'dir'))
mkdir(build_src_path);
end
if(~exist(build_mex_path, 'dir'))
mkdir(build_mex_path);
end
copyfile([src_path '*'],build_src_path);
mex_files = dir([build_src_path '*.c']);
c = computer;
switch c
case 'GLNXA64'
path_to_metis = './external/metis/';
for i=1:length(mex_files)
eval(['mex -largeArrayDims -lmetis ' ...
'CFLAGS="\$CFLAGS -std=c99" ' ...
'-I' path_to_metis 'include ' ...
'-I' path_to_metis 'GKlib ' ...
'-I' path_to_metis 'libmetis ' ...
'-L' path_to_metis 'build/Linux-x86_64/libmetis ' ...
'-I' build_src_path ' '...
build_src_path mex_files(i).name ...
' -outdir ' build_mex_path]);
end
case 'MACI64'
path_to_metis = './external/metis/';
for i=1:length(mex_files)
eval(['mex -largeArrayDims -lmetis -Dchar16_t=uint16_T '...
'CFLAGS="\$CFLAGS -std=c99" ' ...
'-I' path_to_metis 'include ' ...
'-I' path_to_metis 'GKlib ' ...
'-I' path_to_metis 'libmetis ' ...
'-L' path_to_metis 'build/Darwin-x86_64/libmetis ' ...
'-I' build_src_path ' '...
build_src_path mex_files(i).name ...
' -outdir ' build_mex_path]);
end
case 'PCWIN64'
path_to_metis = './external/metis/';
for i=1:length(mex_files)
eval(['mex -largeArrayDims -lmetis '...
'CFLAGS="$CFLAGS -std=c99" ' ...
'-I' path_to_metis 'include ' ...
'-I' path_to_metis 'GKlib ' ...
'-I' path_to_metis 'libmetis ' ...
'-L' path_to_metis 'build/Win-x86_64/libmetis/Release ' ...
'-I' build_src_path ' '...
build_src_path mex_files(i).name ...
' -outdir ' build_mex_path]);
end
end
% make install
if(installflag == 1)
if(~exist(install_path, 'dir'))
mkdir(install_path);
end
copyfile('METIS_startup.m',install_path);
copyfile([build_path '*'],install_path);
flagexist = 0;
if exist(matlab_startup_file,'file')
startup_path_data = importdata(matlab_startup_file);
for i=1:length(startup_path_data)
if(strcmp(startup_path_data{i},...
['run ' install_path 'METIS_startup.m']))
flagexist = 1;
end
end
end
if(~flagexist)
fid = fopen(matlab_startup_file, 'at');
fprintf(fid, '%s\n', ['run ' install_path 'METIS_startup.m']);
fclose(fid);
end
run([install_path 'METIS_startup.m']);
return;
end
end