1############################################################################
2# This file is part of FreeFEM.                                            #
3#                                                                          #
4# FreeFEM is free software: you can redistribute it and/or modify          #
5# it under the terms of the GNU Lesser General Public License as           #
6# published by the Free Software Foundation, either version 3 of           #
7# the License, or (at your option) any later version.                      #
8#                                                                          #
9# FreeFEM is distributed in the hope that it will be useful,               #
10# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
12# GNU Lesser General Public License for more details.                      #
13#                                                                          #
14# You should have received a copy of the GNU Lesser General Public License #
15# along with FreeFEM. If not, see <http://www.gnu.org/licenses/>.          #
16############################################################################
17# SUMMARY : Downloading and compiling extra libraries for Umfpack
18# LICENSE : LGPLv3
19# ORG     : LJLL Universite Pierre et Marie Curie, Paris, FRANCE
20# AUTHORS : ...
21# E-MAIL  : ...
22
23# see [[file:../../configure.ac::DOWNLOAD_UMFPACK]]
24all-local: $(DOWNLOAD_UMFPACK)
25EXTRA_DIST= SuiteSparse_config.mk.in
26
27# Downloading and compiling UMFPACK
28# ---------------------------------
29
30DIRPKG=../pkg
31SUITESPARSE_TGZ=$(DIRPKG)/SuiteSparse-4.5.5.tar.gz
32
33UMFPACKLIB=../lib/libumfpack.a
34AMDLIB=../lib/libamd.a
35CAMDLIB=../lib/libcamd.a
36CHOLMODLIB=../lib/libcholmod.a
37COLAMDLIB=../lib/libcolamd.a
38KLULIB=../lib/libklu.a
39BTFLIB=../lib/libbtf.a
40SUITESPARSECONFIGLIB=../lib/libsuitesparseconfig.a
41
42# ALH - 4/9/13 - parallel make crashes ("pipe from processes is a directory"?). make sure that everything is run
43# sequentially
44
45umfpack:
46	$(MAKE)  $(AMDLIB)
47	$(MAKE)  $(UMFPACKLIB)
48	$(MAKE)  $(SUITESPARSECONFIGLIB)
49#
50# ALH - 19/9/13 - cholmod part built sequentially
51#
52	$(MAKE)  $(CAMDLIB)
53	$(MAKE)  $(COLAMDLIB)
54	$(MAKE)  $(CHOLMODLIB)
55	$(MAKE) $(BTFLIB)
56	$(MAKE)  $(KLULIB)
57	$(MAKE)  $(SUITESPARSECONFIGLIB)
58	$(MAKE) install.done
59
60# FFCS: SuiteSparse/*/Source are not able to compile in parallel from scratch ("pipe from processes is a
61# directory"?). But specifying "make -j 1" is not enough (another error pops up). Use "$(MAKE) MAKEFLAGS=" instead
62# (using "make MAKEFLAGS=" still produces an error on Cygwin).
63
64$(SUITESPARSECONFIGLIB): SuiteSparse/FF
65	cd SuiteSparse/SuiteSparse_config && $(MAKE) MAKEFLAGS=
66	mkdir -p ../include ../lib
67	cp -f SuiteSparse/SuiteSparse_config/SuiteSparse_config.h  ../include
68	cp  SuiteSparse/SuiteSparse_config/libsuitesparseconfig.a ../lib/libsuitesparseconfig.a
69	$(RANLIB) ../lib/libsuitesparseconfig.a
70
71$(UMFPACKLIB): SuiteSparse/FF
72	cd SuiteSparse/UMFPACK/Lib && $(MAKE) MAKEFLAGS=
73	mkdir -p ../include ../lib
74	cp -f  SuiteSparse/UMFPACK/Include/*.h ../include
75	cp -f SuiteSparse/SuiteSparse_config/SuiteSparse_config.h  ../include
76	cp  SuiteSparse/UMFPACK/Lib/libumfpack.a ../lib/libumfpack.a
77	$(RANLIB) ../lib/libumfpack.a
78
79$(AMDLIB): SuiteSparse/FF
80	cd SuiteSparse/AMD/Lib && $(MAKE) MAKEFLAGS=
81	mkdir -p ../include ../lib
82	cp -f  SuiteSparse/AMD/Include/*.h ../include
83	cp  SuiteSparse/AMD/Lib/libamd.a ../lib/libamd.a
84	$(RANLIB) ../lib/libamd.a
85
86$(CAMDLIB): SuiteSparse/FF
87	cd SuiteSparse/CAMD/Lib && $(MAKE) MAKEFLAGS=
88	mkdir -p ../include ../lib
89	cp -f  SuiteSparse/CAMD/Include/*.h ../include
90	cp  SuiteSparse/CAMD/Lib/libcamd.a ../lib/libcamd.a
91	$(RANLIB) ../lib/libcamd.a
92
93$(CHOLMODLIB): SuiteSparse/FF
94	cd SuiteSparse/CHOLMOD/Lib && $(MAKE) MAKEFLAGS=
95	mkdir -p ../include ../lib
96	cp -f  SuiteSparse/CHOLMOD/Include/*.h ../include
97	cp  SuiteSparse/CHOLMOD/Lib/libcholmod.a ../lib/libcholmod.a
98	$(RANLIB) ../lib/libcholmod.a
99
100$(COLAMDLIB): SuiteSparse/FF
101	cd SuiteSparse/COLAMD/Lib && $(MAKE) MAKEFLAGS=
102	mkdir -p ../include ../lib
103	cp -f  SuiteSparse/COLAMD/Include/*.h ../include
104	cp  SuiteSparse/COLAMD/Lib/libcolamd.a ../lib/libcolamd.a
105	$(RANLIB) ../lib/libcolamd.a
106$(KLULIB): SuiteSparse/FF
107	cd SuiteSparse/KLU/Lib && $(MAKE) MAKEFLAGS=
108	mkdir -p ../include ../lib
109	cp -f  SuiteSparse/KLU/Include/*.h ../include
110	cp  SuiteSparse/KLU/Lib/libklu.a ../lib/libklu.a
111	$(RANLIB) ../lib/libklu.a
112$(BTFLIB): SuiteSparse/FF
113	cd SuiteSparse/BTF/Lib && $(MAKE) MAKEFLAGS=
114	mkdir -p ../include ../lib
115	cp -f  SuiteSparse/BTF/Include/*.h ../include
116	cp  SuiteSparse/BTF/Lib/libbtf.a ../lib/libbtf.a
117	$(RANLIB) ../lib/libbtf.a
118
119UMFPACKv4.4:
120	tar xzf UMFPACKv4.4.tar.gz
121
122# The 'lib' goal is replaced with 'libb' to avoid problems with the existing 'Lib' subdirectory on case-insensitive file
123# systems the lib depend of the Makefile to force the reconstruction if the parameter change
124
125UMFPACKv4.4/AMD/Makefile2 UMFPACKv4.4/UMFPACK/Makefile2: UMFPACKv4.4
126	sed 's/lib:/libb:/' < UMFPACKv4.4/UMFPACK/`basename $@ 2`  >$@
127
128SuiteSparse/DATE:$(SUITESPARSE_TGZ)
129	tar zxvf $(SUITESPARSE_TGZ)
130	touch SuiteSparse/DATE
131
132SuiteSparse/FF:SuiteSparse/DATE  SuiteSparse/SuiteSparse_config/SuiteSparse_config.mk
133	touch SuiteSparse/FF
134
135SuiteSparse/SuiteSparse_config/SuiteSparse_config.mk:SuiteSparse/DATE Makefile SuiteSparse_config.mk.in
136	../../config.status  --file="SuiteSparse_config.mk:SuiteSparse_config.mk.in"
137	-if  diff SuiteSparse_config.mk SuiteSparse/SuiteSparse_config/SuiteSparse_config.mk  2>&1 >/dev/null; then \
138	    echo " same flags => no recompilation !  " ; \
139	else \
140	   echo "  recompile umfpack (some flags change) => clean umfpack colmod amd " ;\
141	   mkdir -p SuiteSparse/SuiteSparse_config ;\
142	   cp SuiteSparse_config.mk SuiteSparse/SuiteSparse_config/SuiteSparse_config.mk ; \
143	   (cd SuiteSparse/UMFPACK && make clean); \
144	   (cd SuiteSparse/CHOLMOD && make clean); \
145	   (cd SuiteSparse/COLAMD && make clean); \
146	   (cd SuiteSparse/CAMD && make clean); \
147	   (cd SuiteSparse/AMD && make clean); \
148	   (cd SuiteSparse/BTF && make clean); \
149	   (cd SuiteSparse/KLU && make clean); \
150	   find . -name '*.exe'|xargs rm;  \
151	fi;
152	touch SuiteSparse/SuiteSparse_config/SuiteSparse_config.mk
153
154UMFPACK_Make.m4: Makefile UMFPACKv4.4
155	m4   -DFF_CC="$(CC)" \
156             -DFF_CFLAGS="@CPPFLAGS@ @CFLAGS@ @BLASINC@" \
157             -DFF_LIB="@BLASLIB@ @LIBS@" \
158	     -DFF_CONFIG="@FF_UMFPACK_CONFIG@" \
159              UMFPACK_Make.m4 >Make.include
160	-if  diff Make.include UMFPACKv4.4/UMFPACK/Make/Make.include 2>&1 >/dev/null; then \
161	    echo " same flags => no recompilation !  " ; \
162	else \
163	   echo "  recompile umfpack (some flags change) => clean umfpack" ;\
164	   cp Make.include  UMFPACKv4.4/UMFPACK/Make/Make.include; \
165	   cd UMFPACKv4.4/UMFPACK && make clean; \
166	   find . -name '*.exe'|xargs rm; \
167	fi;
168UMFPACKv4.4.tar.gz:
169	@WGET@ -N http://www.cise.ufl.edu/research/sparse/umfpack/v4.4/UMFPACKv4.4.tar.gz
170$(SUITESPARSE_TGZ):
171	../getall -o SuiteSparse -a
172
173../lib/WHERE.suitesparse:
174	echo suitesparse  LD -L@DIR@/lib -lumfpack -lklu -lcholmod -lbtf -lccolamd -lcolamd -lcamd -lamd -lsuitesparseconfig  > $@
175	echo suitesparse INCLUDE -I@DIR@/include  >> $@
176install.done:../lib/WHERE.suitesparse
177	touch install.done
178
179clean-local:
180	-rm $(AMDLIB) $(CAMDLIB) $(CHOLMODLIB) $(COLAMDLIB) $(SUITESPARSECONFIGLIB) $(KLULIB)  $(BTFLIB)
181	-rm ../include/amd*.h
182	-rm ../include/umfpack*.h
183	-rm ../include/colmod*.h
184	-rm ../include/camd*.h
185	-rm ../include/amd*.h
186	-rm ../include/klu*.h
187	-rm ../include/btf*.h
188	-rm ../include/SuiteSparse_config.h
189	-rm -rf UMFPACKv4.?.tar.gz UMFPACKv4.?
190	-rm SuiteSparse*gz
191	-rm -rf SuiteSparse
192#	-rm ../pkg/SuiteSparse-*
193	-rm SuiteSparse_config.mk
194
195# Local Variables:
196# mode:makefile
197# ispell-local-dictionary:"british"
198# coding:utf-8
199# End:
200