-
Notifications
You must be signed in to change notification settings - Fork 135
/
Makefile
198 lines (153 loc) · 8.37 KB
/
Makefile
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# MAKEFILE for scs
include scs.mk
SCS_OBJECTS = src/util.o src/cones.o src/exp_cone.o src/aa.o src/rw.o src/linalg.o src/ctrlc.o src/scs_version.o src/normalize.o
SCS_O = src/scs.o
SCS_INDIR_O = src/scs_indir.o
SRC_FILES = $(wildcard src/*.c)
INC_FILES = $(wildcard include/*.h)
AMD_SOURCE = $(wildcard $(EXTSRC)/amd/*.c)
LDL_SOURCE = $(EXTSRC)/qdldl/qdldl.c
AMD_OBJS = $(AMD_SOURCE:.c=.o)
LDL_OBJS = $(LDL_SOURCE:.c=.o)
TARGETS = $(OUT)/demo_socp_indirect $(OUT)/demo_socp_direct $(OUT)/run_from_file_indirect $(OUT)/run_from_file_direct
.PHONY: default
default: $(TARGETS) $(OUT)/libscsdir.a $(OUT)/libscsindir.a $(OUT)/libscsdir.$(SHARED) $(OUT)/libscsindir.$(SHARED)
@echo "****************************************************************************************"
@echo "Successfully compiled scs, copyright Brendan O'Donoghue 2012."
@echo "To test, run 'make test' and then '$(OUT)/run_tests_direct'."
@echo "**********************************************************************************"
ifneq ($(USE_LAPACK), 0)
@echo "Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs"
else
@echo "NOT compiled with blas/lapack, cannot solve SDPs (can solve LPs, SOCPs, ECPs, and PCPs)."
@echo "To solve SDPs, install blas and lapack, then edit scs.mk to set USE_LAPACK=1"
@echo "and point to the library install locations, and recompile with 'make purge', 'make'."
endif
@echo "****************************************************************************************"
$(SCS_O): src/scs.c $(INC_FILES)
$(CC) $(CFLAGS) -c $< -o $@
$(SCS_INDIR_O): src/scs.c $(INC_FILES)
$(CC) $(CFLAGS) -DINDIRECT=1 -c $< -o $@
%.o : src/%.c
$(CC) $(CFLAGS) -c $< -o $@
src/util.o : src/util.c $(INC_FILES)
src/cones.o : src/cones.c $(INC_FILES)
src/exp_cone.o : src/exp_cone.c $(INC_FILES)
src/aa.o : src/aa.c $(INC_FILES)
src/rw.o : src/rw.c $(INC_FILES)
src/linalg.o: src/linalg.c $(INC_FILES)
src/ctrl.o : src/ctrl.c $(INC_FILES)
src/scs_version.o: src/scs_version.c $(INC_FILES)
$(DIRSRC)/private.o: $(DIRSRC)/private.c $(DIRSRC)/private.h
$(INDIRSRC)/indirect/private.o: $(INDIRSRC)/private.c $(INDIRSRC)/private.h
$(MKLSRC)/private.o: $(MKLSRC)/private.c $(MKLSRC)/private.h
$(LINSYS)/scs_matrix.o: $(LINSYS)/scs_matrix.c $(LINSYS)/scs_matrix.h
$(LINSYS)/csparse.o: $(LINSYS)/csparse.c $(LINSYS)/csparse.h
$(OUT)/libscsdir.a: $(SCS_O) $(SCS_OBJECTS) $(DIRSRC)/private.o $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
mkdir -p $(OUT)
$(ARCHIVE) $@ $^
- $(RANLIB) $@
$(OUT)/libscsindir.a: $(SCS_INDIR_O) $(SCS_OBJECTS) $(INDIRSRC)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
mkdir -p $(OUT)
$(ARCHIVE) $@ $^
- $(RANLIB) $@
$(OUT)/libscsmkl.a: $(SCS_O) $(SCS_OBJECTS) $(MKLSRC)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
mkdir -p $(OUT)
$(ARCHIVE) $@ $^
- $(RANLIB) $@
$(OUT)/libscsdir.$(SHARED): $(SCS_O) $(SCS_OBJECTS) $(DIRSRC)/private.o $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
mkdir -p $(OUT)
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS)
$(OUT)/libscsindir.$(SHARED): $(SCS_INDIR_O) $(SCS_OBJECTS) $(INDIRSRC)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
mkdir -p $(OUT)
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS)
$(OUT)/libscsmkl.$(SHARED): $(SCS_O) $(SCS_OBJECTS) $(MKLSRC)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
mkdir -p $(OUT)
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(MKLFLAGS)
$(OUT)/demo_socp_direct: test/random_socp_prob.c $(OUT)/libscsdir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS)
$(OUT)/demo_socp_indirect: test/random_socp_prob.c $(OUT)/libscsindir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS)
$(OUT)/demo_socp_mkl: test/random_socp_prob.c $(OUT)/libscsmkl.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(MKLFLAGS)
$(OUT)/run_from_file_direct: test/run_from_file.c $(OUT)/libscsdir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS)
$(OUT)/run_from_file_indirect: test/run_from_file.c $(OUT)/libscsindir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS)
$(OUT)/run_from_file_gpu_indirect: test/run_from_file.c $(OUT)/libscsgpuindir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) $(CULDFLAGS)
# basic testing
.PHONY: test
test: $(OUT)/run_tests_indirect $(OUT)/run_tests_direct
$(OUT)/run_tests_indirect: test/run_tests.c $(OUT)/libscsindir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) -Itest
$(OUT)/run_tests_direct: test/run_tests.c $(OUT)/libscsdir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) -Itest
$(OUT)/run_tests_mkl: test/run_tests.c $(OUT)/libscsmkl.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(MKLFLAGS) -Itest
.PHONY: test_gpu
test_gpu: $(OUT)/run_tests_gpu_indirect # $(OUT)/run_tests_gpu_direct
.PHONY: mkl
mkl: mklroot $(OUT)/libscsmkl.a $(OUT)/libscsmkl.$(SHARED) $(OUT)/run_tests_mkl $(OUT)/demo_socp_mkl
mklroot:
ifndef MKLROOT
$(error MKLROOT is undefined, set MKLROOT to the MKL install location)
endif
$(OUT)/run_tests_gpu_indirect: test/run_tests.c $(OUT)/libscsgpuindir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) $(CULDFLAGS) -Itest
# $(OUT)/run_tests_gpu_direct: test/run_tests.c $(OUT)/libscsgpudir.a
# $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) $(CULDFLAGS) -Itest
# REQUIRES GPU AND CUDA INSTALLED
gpu: gpu_indirect # gpu_direct
# gpu_direct: $(OUT)/demo_socp_gpu_direct $(OUT)/libscsgpudir.$(SHARED) $(OUT)/libscsgpudir.a $(OUT)/run_from_file_gpu_direct
gpu_indirect: $(OUT)/demo_socp_gpu_indirect $(OUT)/libscsgpuindir.$(SHARED) $(OUT)/libscsgpuindir.a $(OUT)/run_from_file_gpu_indirect
$(LINSYS)/gpu/gpu.o: $(LINSYS)/gpu/gpu.c
$(CUCC) -c -o $@ $^ $(CUDAFLAGS)
# $(GPUDIR)/private.o: $(GPUDIR)/private.c
# $(CUCC) -c -o $(GPUDIR)/private.o $^ $(CUDAFLAGS)
$(GPUINDIR)/private.o: $(GPUINDIR)/private.c
$(CUCC) -c -o $@ $^ $(CUDAFLAGS)
# $(OUT)/libscsgpudir.$(SHARED): $(SCS_O) $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/gpu/gpu.o
# mkdir -p $(OUT)
# $(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) $(CULDFLAGS)
# $(OUT)/libscsgpudir.a: $(SCS_INDIR_O) $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/gpu/gpu.o
# mkdir -p $(OUT)
# $(ARCHIVE) $@ $^
# - $(RANLIB) $@
$(OUT)/libscsgpuindir.$(SHARED): $(SCS_INDIR_O) $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o $(LINSYS)/gpu/gpu.o
mkdir -p $(OUT)
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) $(CULDFLAGS)
$(OUT)/libscsgpuindir.a: $(SCS_INDIR_O) $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o $(LINSYS)/gpu/gpu.o
mkdir -p $(OUT)
$(ARCHIVE) $@ $^
- $(RANLIB) $@
# $(OUT)/demo_socp_gpu_direct: test/random_socp_prob.c $(OUT)/libscsgpudir.a
# $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) $(CULDFLAGS)
$(OUT)/demo_socp_gpu_indirect: test/random_socp_prob.c $(OUT)/libscsgpuindir.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(BLASLDFLAGS) $(CULDFLAGS)
.PHONY: clean purge
clean:
@rm -rf $(TARGETS) $(SCS_O) $(SCS_INDIR_O) $(SCS_OBJECTS) $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/*.o $(DIRSRC)/*.o $(INDIRSRC)/*.o $(MKLSRC)/*.o $(GPUDIR)/*.o $(GPUINDIR)/*.o $(LINSYS)/gpu/*.o
@rm -rf $(OUT)/*.dSYM
@rm -rf matlab/*.mex*
@rm -rf .idea
@rm -rf python/*.pyc
@rm -rf python/build
purge: clean
@rm -rf $(OUT)
INSTALL_INC_FILES = $(INC_FILES)
INSTALL_TARGETS = $(OUT)/libscsdir.a $(OUT)/libscsindir.a $(OUT)/libscsdir.$(SHARED) $(OUT)/libscsindir.$(SHARED)
INSTALL_GPU_TARGETS = $(OUT)/libscsgpuindir.a $(OUT)/libscsgpuindir.$(SHARED) # $(OUT)/libscsgpudir.a $(OUT)/libscsgpudir.$(SHARED)
INSTALL_INC_DIR = $(DESTDIR)$(PREFIX)/include/scs/
INSTALL_LIB_DIR = $(DESTDIR)$(PREFIX)/lib/
.PHONY: install install_gpu direct indirect
install: $(INSTALL_INC_FILES) $(INSTALL_TARGETS)
$(INSTALL) -d $(INSTALL_INC_DIR) $(INSTALL_LIB_DIR)
$(INSTALL) -m 644 $(INSTALL_INC_FILES) $(INSTALL_INC_DIR)
$(INSTALL) -m 644 $(INSTALL_TARGETS) $(INSTALL_LIB_DIR)
install_gpu: $(INSTALL_INC_FILES) $(INSTALL_GPU_TARGETS)
$(INSTALL) -d $(INSTALL_INC_DIR) $(INSTALL_LIB_DIR)
$(INSTALL) -m 644 $(INSTALL_INC_FILES) $(INSTALL_INC_DIR)
$(INSTALL) -m 644 $(INSTALL_GPU_TARGETS) $(INSTALL_LIB_DIR)
direct:$(OUT)/libscsdir.$(SHARED) $(OUT)/demo_socp_direct $(OUT)/run_from_file_direct $(OUT)/run_tests_direct
indirect:$(OUT)/libscsindir.$(SHARED) $(OUT)/demo_socp_indirect $(OUT)/run_from_file_indirect $(OUT)/run_tests_indirect