1#===============================================================================
2# CHOLMOD/Lib/Makefile: for compiling the CHOLMOD library
3#===============================================================================
4
5LIBRARY = libcholmod
6VERSION = 3.0.14
7SO_VERSION = 3
8
9default: library
10
11ccode: all
12
13include ../../SuiteSparse_config/SuiteSparse_config.mk
14
15# CHOLMOD depends on AMD, SuiteSparse_config, LAPACK, BLAS,
16# and optionally METIS, CAMD, and CCOLAMD if the Partition Module is in use
17LDLIBS += -lamd -lcolamd -lsuitesparseconfig \
18	$(LIB_WITH_PARTITION) $(LAPACK) $(BLAS)
19
20SO_OPTS += $(CFOPENMP)
21
22#-------------------------------------------------------------------------------
23# With the CUDA BLAS:
24ifneq ($(GPU_CONFIG),)
25LDLIBS += $(CUDART_LIB) $(CUBLAS_LIB)
26endif
27#-------------------------------------------------------------------------------
28
29# compile and install in SuiteSparse/lib
30library:
31	$(MAKE) install INSTALL=$(SUITESPARSE)
32
33#-------------------------------------------------------------------------------
34
35I = -I../../AMD/Include -I../../AMD/Source -I../../COLAMD/Include \
36	$(I_WITH_PARTITION) -I../Include -I../../SuiteSparse_config \
37	$(CUDA_INC)
38
39#-------------------------------------------------------------------------------
40
41C = $(CC) $(CF) $(CHOLMOD_CONFIG) $(CONFIG_PARTITION)
42
43all: library
44
45purge: distclean
46
47distclean: clean
48	- $(RM) -r $(PURGE)
49
50clean:
51	- $(RM) -r $(CLEAN)
52
53#-------------------------------------------------------------------------------
54# ../Include/ directory contains all include files:
55#-------------------------------------------------------------------------------
56
57INC =   ../Include/cholmod.h \
58	../Include/cholmod_blas.h \
59	../Include/cholmod_check.h \
60	../Include/cholmod_cholesky.h \
61	../Include/cholmod_complexity.h \
62	../Include/cholmod_config.h \
63	../Include/cholmod_core.h \
64	../Include/cholmod_internal.h \
65	../Include/cholmod_matrixops.h \
66	../Include/cholmod_modify.h \
67	../Include/cholmod_partition.h \
68	../Include/cholmod_supernodal.h \
69	../Include/cholmod_template.h \
70	../Include/cholmod_gpu.h
71
72#-------------------------------------------------------------------------------
73# The 7 CHOLMOD library modules (int, double)
74#-------------------------------------------------------------------------------
75
76CORE = cholmod_aat.o cholmod_add.o cholmod_band.o \
77	cholmod_change_factor.o cholmod_common.o cholmod_complex.o \
78	cholmod_copy.o cholmod_dense.o cholmod_error.o cholmod_factor.o \
79	cholmod_memory.o cholmod_sparse.o \
80	cholmod_transpose.o cholmod_triplet.o \
81        cholmod_version.o
82
83CHECK = cholmod_check.o cholmod_read.o cholmod_write.o
84
85CHOLESKY = cholmod_amd.o cholmod_analyze.o cholmod_colamd.o \
86	cholmod_etree.o cholmod_factorize.o cholmod_postorder.o \
87	cholmod_rcond.o cholmod_resymbol.o cholmod_rowcolcounts.o \
88	cholmod_rowfac.o cholmod_solve.o cholmod_spsolve.o
89
90MATRIXOPS = cholmod_drop.o cholmod_horzcat.o cholmod_norm.o \
91	cholmod_scale.o cholmod_sdmult.o cholmod_ssmult.o \
92	cholmod_submatrix.o cholmod_vertcat.o cholmod_symmetry.o
93
94PARTITION = cholmod_ccolamd.o cholmod_csymamd.o \
95	cholmod_metis.o cholmod_nesdis.o cholmod_camd.o
96
97MODIFY = cholmod_rowadd.o cholmod_rowdel.o cholmod_updown.o
98
99SUPERNODAL = cholmod_super_numeric.o cholmod_super_solve.o \
100	cholmod_super_symbolic.o
101
102ifneq ($(GPU_CONFIG),)
103GPU = cholmod_gpu.o cholmod_gpu_kernels.o
104else
105GPU =
106endif
107
108DI = $(CORE) $(CHECK) $(CHOLESKY) $(MATRIXOPS) $(MODIFY) $(SUPERNODAL) \
109	$(GPU) $(PARTITION)
110
111#-------------------------------------------------------------------------------
112# CHOLMOD library modules (long, double)
113#-------------------------------------------------------------------------------
114
115LCORE = cholmod_l_aat.o cholmod_l_add.o cholmod_l_band.o \
116	cholmod_l_change_factor.o cholmod_l_common.o cholmod_l_complex.o \
117	cholmod_l_copy.o cholmod_l_dense.o cholmod_l_error.o \
118	cholmod_l_factor.o cholmod_l_memory.o \
119	cholmod_l_sparse.o cholmod_l_transpose.o cholmod_l_triplet.o \
120        cholmod_l_version.o
121
122LCHECK = cholmod_l_check.o cholmod_l_read.o cholmod_l_write.o
123
124LCHOLESKY = cholmod_l_amd.o cholmod_l_analyze.o cholmod_l_colamd.o \
125	cholmod_l_etree.o cholmod_l_factorize.o cholmod_l_postorder.o \
126	cholmod_l_rcond.o cholmod_l_resymbol.o cholmod_l_rowcolcounts.o \
127	cholmod_l_rowfac.o cholmod_l_solve.o cholmod_l_spsolve.o
128
129LMATRIXOPS = cholmod_l_drop.o cholmod_l_horzcat.o cholmod_l_norm.o \
130	cholmod_l_scale.o cholmod_l_sdmult.o cholmod_l_ssmult.o \
131	cholmod_l_submatrix.o cholmod_l_vertcat.o cholmod_l_symmetry.o
132
133LPARTITION = cholmod_l_ccolamd.o cholmod_l_csymamd.o \
134	cholmod_l_metis.o cholmod_l_nesdis.o cholmod_l_camd.o
135
136LMODIFY = cholmod_l_rowadd.o cholmod_l_rowdel.o cholmod_l_updown.o
137
138LSUPERNODAL = cholmod_l_super_numeric.o cholmod_l_super_solve.o \
139	cholmod_l_super_symbolic.o
140
141ifneq ($(GPU_CONFIG),)
142LGPU = cholmod_l_gpu.o cholmod_gpu_kernels.o
143else
144LGPU =
145endif
146
147DL = $(LCORE) $(LCHECK) $(LCHOLESKY) $(LMATRIXOPS) $(LMODIFY) $(LSUPERNODAL) \
148	$(LPARTITION) $(LGPU)
149
150#-------------------------------------------------------------------------------
151
152# to compile just the double/int version, use OBJ = $(DI)
153OBJ = $(DI) $(DL)
154
155static: $(AR_TARGET)
156
157$(AR_TARGET): $(OBJ)
158	$(ARCHIVE) $@ $^
159	- $(RANLIB) $@
160
161$(OBJ): $(INC)
162
163#-------------------------------------------------------------------------------
164# Check Module:
165#-------------------------------------------------------------------------------
166
167cholmod_check.o: ../Check/cholmod_check.c
168	$(C) -c $(I) $<
169
170cholmod_read.o: ../Check/cholmod_read.c
171	$(C) -c $(I) $<
172
173cholmod_write.o: ../Check/cholmod_write.c
174	$(C) -c $(I) $<
175
176#-------------------------------------------------------------------------------
177
178cholmod_l_check.o: ../Check/cholmod_check.c
179	$(C) -DDLONG -c $(I) $< -o $@
180
181cholmod_l_read.o: ../Check/cholmod_read.c
182	$(C) -DDLONG -c $(I) $< -o $@
183
184cholmod_l_write.o: ../Check/cholmod_write.c
185	$(C) -DDLONG -c $(I) $< -o $@
186
187
188#-------------------------------------------------------------------------------
189# Core Module:
190#-------------------------------------------------------------------------------
191
192cholmod_common.o: ../Core/cholmod_common.c
193	$(C) -c $(I) $<
194
195cholmod_dense.o: ../Core/cholmod_dense.c ../Core/t_cholmod_dense.c
196	$(C) -c $(I) $<
197
198cholmod_factor.o: ../Core/cholmod_factor.c
199	$(C) -c $(I) $<
200
201cholmod_change_factor.o: ../Core/cholmod_change_factor.c \
202	../Core/t_cholmod_change_factor.c
203	$(C) -c $(I) $<
204
205cholmod_memory.o: ../Core/cholmod_memory.c
206	$(C) -c $(I) $<
207
208cholmod_sparse.o: ../Core/cholmod_sparse.c
209	$(C) -c $(I) $<
210
211cholmod_complex.o: ../Core/cholmod_complex.c
212	$(C) -c $(I) $<
213
214cholmod_transpose.o: ../Core/cholmod_transpose.c ../Core/t_cholmod_transpose.c
215	$(C) -c $(I) $<
216
217cholmod_band.o: ../Core/cholmod_band.c
218	$(C) -c $(I) $<
219
220cholmod_copy.o: ../Core/cholmod_copy.c
221	$(C) -c $(I) $<
222
223cholmod_triplet.o: ../Core/cholmod_triplet.c ../Core/t_cholmod_triplet.c
224	$(C) -c $(I) $<
225
226cholmod_error.o: ../Core/cholmod_error.c
227	$(C) -c $(I) $<
228
229cholmod_aat.o: ../Core/cholmod_aat.c
230	$(C) -c $(I) $<
231
232cholmod_add.o: ../Core/cholmod_add.c
233	$(C) -c $(I) $<
234
235cholmod_version.o: ../Core/cholmod_version.c
236	$(C) -c $(I) $<
237
238#-------------------------------------------------------------------------------
239
240cholmod_l_common.o: ../Core/cholmod_common.c
241	$(C) -DDLONG -c $(I) $< -o $@
242
243cholmod_l_dense.o: ../Core/cholmod_dense.c ../Core/t_cholmod_dense.c
244	$(C) -DDLONG -c $(I) $< -o $@
245
246cholmod_l_factor.o: ../Core/cholmod_factor.c
247	$(C) -DDLONG -c $(I) $< -o $@
248
249cholmod_l_change_factor.o: ../Core/cholmod_change_factor.c \
250	../Core/t_cholmod_change_factor.c
251	$(C) -DDLONG -c $(I) $< -o $@
252
253cholmod_l_memory.o: ../Core/cholmod_memory.c
254	$(C) -DDLONG -c $(I) $< -o $@
255
256cholmod_l_sparse.o: ../Core/cholmod_sparse.c
257	$(C) -DDLONG -c $(I) $< -o $@
258
259cholmod_l_complex.o: ../Core/cholmod_complex.c
260	$(C) -DDLONG -c $(I) $< -o $@
261
262cholmod_l_transpose.o: ../Core/cholmod_transpose.c ../Core/t_cholmod_transpose.c
263	$(C) -DDLONG -c $(I) $< -o $@
264
265cholmod_l_band.o: ../Core/cholmod_band.c
266	$(C) -DDLONG -c $(I) $< -o $@
267
268cholmod_l_copy.o: ../Core/cholmod_copy.c
269	$(C) -DDLONG -c $(I) $< -o $@
270
271cholmod_l_triplet.o: ../Core/cholmod_triplet.c ../Core/t_cholmod_triplet.c
272	$(C) -DDLONG -c $(I) $< -o $@
273
274cholmod_l_error.o: ../Core/cholmod_error.c
275	$(C) -DDLONG -c $(I) $< -o $@
276
277cholmod_l_aat.o: ../Core/cholmod_aat.c
278	$(C) -DDLONG -c $(I) $< -o $@
279
280cholmod_l_add.o: ../Core/cholmod_add.c
281	$(C) -DDLONG -c $(I) $< -o $@
282
283cholmod_l_version.o: ../Core/cholmod_version.c
284	$(C) -DDLONG -c $(I) $< -o $@
285
286
287#-------------------------------------------------------------------------------
288# Cholesky Module:
289#-------------------------------------------------------------------------------
290
291cholmod_amd.o: ../Cholesky/cholmod_amd.c
292	$(C) -c $(I) $<
293
294cholmod_analyze.o: ../Cholesky/cholmod_analyze.c
295	$(C) -c $(I) $<
296
297cholmod_colamd.o: ../Cholesky/cholmod_colamd.c
298	$(C) -c $(I) $<
299
300cholmod_etree.o: ../Cholesky/cholmod_etree.c
301	$(C) -c $(I) $<
302
303cholmod_factorize.o: ../Cholesky/cholmod_factorize.c
304	$(C) -c $(I) $<
305
306cholmod_postorder.o: ../Cholesky/cholmod_postorder.c
307	$(C) -c $(I) $<
308
309cholmod_rcond.o: ../Cholesky/cholmod_rcond.c
310	$(C) -c $(I) $<
311
312cholmod_resymbol.o: ../Cholesky/cholmod_resymbol.c
313	$(C) -c $(I) $<
314
315cholmod_rowcolcounts.o: ../Cholesky/cholmod_rowcolcounts.c
316	$(C) -c $(I) $<
317
318cholmod_solve.o: ../Cholesky/cholmod_solve.c ../Cholesky/t_cholmod_lsolve.c \
319	../Cholesky/t_cholmod_ltsolve.c ../Cholesky/t_cholmod_solve.c
320	$(C) -c $(I) $<
321
322cholmod_spsolve.o: ../Cholesky/cholmod_spsolve.c
323	$(C) -c $(I) $<
324
325cholmod_rowfac.o: ../Cholesky/cholmod_rowfac.c ../Cholesky/t_cholmod_rowfac.c
326	$(C) -c $(I) $<
327
328#-------------------------------------------------------------------------------
329
330cholmod_l_amd.o: ../Cholesky/cholmod_amd.c
331	$(C) -DDLONG -c $(I) $< -o $@
332
333cholmod_l_analyze.o: ../Cholesky/cholmod_analyze.c
334	$(C) -DDLONG -c $(I) $< -o $@
335
336cholmod_l_colamd.o: ../Cholesky/cholmod_colamd.c
337	$(C) -DDLONG -c $(I) $< -o $@
338
339cholmod_l_etree.o: ../Cholesky/cholmod_etree.c
340	$(C) -DDLONG -c $(I) $< -o $@
341
342cholmod_l_factorize.o: ../Cholesky/cholmod_factorize.c
343	$(C) -DDLONG -c $(I) $< -o $@
344
345cholmod_l_postorder.o: ../Cholesky/cholmod_postorder.c
346	$(C) -DDLONG -c $(I) $< -o $@
347
348cholmod_l_rcond.o: ../Cholesky/cholmod_rcond.c
349	$(C) -DDLONG -c $(I) $< -o $@
350
351cholmod_l_resymbol.o: ../Cholesky/cholmod_resymbol.c
352	$(C) -DDLONG -c $(I) $< -o $@
353
354cholmod_l_rowcolcounts.o: ../Cholesky/cholmod_rowcolcounts.c
355	$(C) -DDLONG -c $(I) $< -o $@
356
357cholmod_l_solve.o: ../Cholesky/cholmod_solve.c ../Cholesky/t_cholmod_lsolve.c \
358	../Cholesky/t_cholmod_ltsolve.c ../Cholesky/t_cholmod_solve.c
359	$(C) -DDLONG -c $(I) $< -o $@
360
361cholmod_l_spsolve.o: ../Cholesky/cholmod_spsolve.c
362	$(C) -DDLONG -c $(I) $< -o $@
363
364cholmod_l_rowfac.o: ../Cholesky/cholmod_rowfac.c ../Cholesky/t_cholmod_rowfac.c
365	$(C) -DDLONG -c $(I) $< -o $@
366
367#-------------------------------------------------------------------------------
368# Partition Module:
369#-------------------------------------------------------------------------------
370
371cholmod_ccolamd.o: ../Partition/cholmod_ccolamd.c
372	$(C) -c $(I) $<
373
374cholmod_csymamd.o: ../Partition/cholmod_csymamd.c
375	$(C) -c $(I) $<
376
377cholmod_camd.o: ../Partition/cholmod_camd.c
378	$(C) -c $(I) $<
379
380cholmod_metis.o: ../Partition/cholmod_metis.c
381	$(C) -c $(I) $<
382
383cholmod_nesdis.o: ../Partition/cholmod_nesdis.c
384	$(C) -c $(I) $<
385
386#-------------------------------------------------------------------------------
387
388cholmod_l_ccolamd.o: ../Partition/cholmod_ccolamd.c
389	$(C) -DDLONG -c $(I) $< -o $@
390
391cholmod_l_csymamd.o: ../Partition/cholmod_csymamd.c
392	$(C) -DDLONG -c $(I) $< -o $@
393
394cholmod_l_camd.o: ../Partition/cholmod_camd.c
395	$(C) -DDLONG -c $(I) $< -o $@
396
397cholmod_l_metis.o: ../Partition/cholmod_metis.c
398	$(C) -DDLONG -c $(I) $< -o $@
399
400cholmod_l_nesdis.o: ../Partition/cholmod_nesdis.c
401	$(C) -DDLONG -c $(I) $< -o $@
402
403
404#-------------------------------------------------------------------------------
405# MatrixOps Module:
406#-------------------------------------------------------------------------------
407
408cholmod_horzcat.o: ../MatrixOps/cholmod_horzcat.c
409	$(C) -c $(I) $<
410
411cholmod_norm.o: ../MatrixOps/cholmod_norm.c
412	$(C) -c $(I) $<
413
414cholmod_scale.o: ../MatrixOps/cholmod_scale.c
415	$(C) -c $(I) $<
416
417cholmod_drop.o: ../MatrixOps/cholmod_drop.c
418	$(C) -c $(I) $<
419
420cholmod_sdmult.o: ../MatrixOps/cholmod_sdmult.c \
421	../MatrixOps/t_cholmod_sdmult.c
422	$(C) -c $(I) $<
423
424cholmod_ssmult.o: ../MatrixOps/cholmod_ssmult.c
425	$(C) -c $(I) $<
426
427cholmod_submatrix.o: ../MatrixOps/cholmod_submatrix.c
428	$(C) -c $(I) $<
429
430cholmod_vertcat.o: ../MatrixOps/cholmod_vertcat.c
431	$(C) -c $(I) $<
432
433cholmod_symmetry.o: ../MatrixOps/cholmod_symmetry.c
434	$(C) -c $(I) $<
435
436#-------------------------------------------------------------------------------
437
438cholmod_l_horzcat.o: ../MatrixOps/cholmod_horzcat.c
439	$(C) -DDLONG -c $(I) $< -o $@
440
441cholmod_l_norm.o: ../MatrixOps/cholmod_norm.c
442	$(C) -DDLONG -c $(I) $< -o $@
443
444cholmod_l_scale.o: ../MatrixOps/cholmod_scale.c
445	$(C) -DDLONG -c $(I) $< -o $@
446
447cholmod_l_drop.o: ../MatrixOps/cholmod_drop.c
448	$(C) -DDLONG -c $(I) $< -o $@
449
450cholmod_l_sdmult.o: ../MatrixOps/cholmod_sdmult.c \
451	../MatrixOps/t_cholmod_sdmult.c
452	$(C) -DDLONG -c $(I) $< -o $@
453
454cholmod_l_ssmult.o: ../MatrixOps/cholmod_ssmult.c
455	$(C) -DDLONG -c $(I) $< -o $@
456
457cholmod_l_submatrix.o: ../MatrixOps/cholmod_submatrix.c
458	$(C) -DDLONG -c $(I) $< -o $@
459
460cholmod_l_vertcat.o: ../MatrixOps/cholmod_vertcat.c
461	$(C) -DDLONG -c $(I) $< -o $@
462
463cholmod_l_symmetry.o: ../MatrixOps/cholmod_symmetry.c
464	$(C) -DDLONG -c $(I) $< -o $@
465
466#-------------------------------------------------------------------------------
467# Modify Module:
468#-------------------------------------------------------------------------------
469
470cholmod_rowadd.o: ../Modify/cholmod_rowadd.c
471	$(C) -c $(I) $<
472
473cholmod_rowdel.o: ../Modify/cholmod_rowdel.c
474	$(C) -c $(I) $<
475
476cholmod_updown.o: ../Modify/cholmod_updown.c \
477	../Modify/t_cholmod_updown.c ../Modify/t_cholmod_updown_numkr.c
478	$(C) -c $(I) $<
479
480#-------------------------------------------------------------------------------
481
482cholmod_l_rowadd.o: ../Modify/cholmod_rowadd.c
483	$(C) -DDLONG -c $(I) $< -o $@
484
485cholmod_l_rowdel.o: ../Modify/cholmod_rowdel.c
486	$(C) -DDLONG -c $(I) $< -o $@
487
488cholmod_l_updown.o: ../Modify/cholmod_updown.c \
489	../Modify/t_cholmod_updown.c ../Modify/t_cholmod_updown_numkr.c
490	$(C) -DDLONG -c $(I) $< -o $@
491
492
493#-------------------------------------------------------------------------------
494# Supernodal Module:
495#-------------------------------------------------------------------------------
496
497cholmod_super_numeric.o: ../Supernodal/cholmod_super_numeric.c \
498        ../GPU/t_cholmod_gpu.c \
499	../Supernodal/t_cholmod_super_numeric.c
500	$(C) -c $(I) $<
501
502cholmod_super_symbolic.o: ../Supernodal/cholmod_super_symbolic.c
503	$(C) -c $(I) $<
504
505cholmod_super_solve.o: ../Supernodal/cholmod_super_solve.c \
506	../Supernodal/t_cholmod_super_solve.c
507	$(C) -c $(I) $<
508
509#-------------------------------------------------------------------------------
510
511cholmod_l_super_numeric.o: ../Supernodal/cholmod_super_numeric.c \
512	../Supernodal/t_cholmod_super_numeric.c
513	$(C) -DDLONG -c $(I) $< -o $@
514
515cholmod_l_super_symbolic.o: ../Supernodal/cholmod_super_symbolic.c
516	$(C) -DDLONG -c $(I) $< -o $@
517
518cholmod_l_super_solve.o: ../Supernodal/cholmod_super_solve.c \
519	../Supernodal/t_cholmod_super_solve.c
520	$(C) -DDLONG -c $(I) $< -o $@
521
522#-------------------------------------------------------------------------------
523# GPU module
524#-------------------------------------------------------------------------------
525
526cholmod_gpu_kernels.o: ../GPU/cholmod_gpu_kernels.cu
527	$(NVCC) $(I) $(NVCCFLAGS) -c ../GPU/cholmod_gpu_kernels.cu
528
529cholmod_gpu.o: ../GPU/cholmod_gpu.c
530	$(C) -c $(I) $<
531
532cholmod_l_gpu.o: ../GPU/cholmod_gpu.c
533	$(C) -DDLONG -c $(I) $< -o $@
534
535#-------------------------------------------------------------------------------
536
537# install CHOLMOD
538install: $(AR_TARGET) $(INSTALL_LIB)/$(SO_TARGET)
539
540$(INSTALL_LIB)/$(SO_TARGET): $(OBJ)
541	@mkdir -p $(INSTALL_LIB)
542	@mkdir -p $(INSTALL_INCLUDE)
543	@mkdir -p $(INSTALL_DOC)
544	$(CXX) $(SO_OPTS) $^ -o $@ $(LDLIBS)
545	( cd $(INSTALL_LIB) ; ln -sf $(SO_TARGET) $(SO_PLAIN) )
546	( cd $(INSTALL_LIB) ; ln -sf $(SO_TARGET) $(SO_MAIN) )
547	$(CP) ../Include/cholmod*.h $(INSTALL_INCLUDE)
548	$(RM) $(INSTALL_INCLUDE)/cholmod_internal.h
549	$(CP) ../Doc/CHOLMOD_UserGuide.pdf $(INSTALL_DOC)
550	$(CP) ../README.txt $(INSTALL_DOC)/CHOLMOD_README.txt
551	chmod 755 $(INSTALL_LIB)/$(SO_TARGET)
552	chmod 644 $(INSTALL_INCLUDE)/cholmod*.h
553	chmod 644 $(INSTALL_DOC)/CHOLMOD_UserGuide.pdf
554	chmod 644 $(INSTALL_DOC)/CHOLMOD_README.txt
555
556# uninstall CHOLMOD
557uninstall:
558	$(RM) $(INSTALL_LIB)/$(SO_TARGET)
559	$(RM) $(INSTALL_LIB)/$(SO_PLAIN)
560	$(RM) $(INSTALL_LIB)/$(SO_MAIN)
561	$(RM) $(INSTALL_INCLUDE)/cholmod*.h
562	$(RM) $(INSTALL_DOC)/CHOLMOD_UserGuide.pdf
563	$(RM) $(INSTALL_DOC)/CHOLMOD_README.txt
564
565