cURL: follow redirects
[LibreOffice.git] / Makefile.fetch
blobca4d911dbbc9215e6c4024009d0e477bfbf08aaf
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 fetch_LOGFILE := $(TARFILE_LOCATION)/fetch.log
12 ifneq (,$(WGET))
13 define fetch_Download__wget_command
14 && bash -c '$(WGET) --progress=dot:mega -4 -Q 0 -P "." -l 0 -nd -nH -N --no-use-server-timestamps $1/$2 2>&1 | tee -a $(fetch_LOGFILE) && [ $$PIPESTATUS -eq 0 ]'
15 endef
17 else
18 define fetch_Download__wget_command
19 && echo fetching $2 && bash -c '$(CURL) -L -O $1/$2 2>&1 | tee -a $(fetch_LOGFILE) && [ $$PIPESTATUS -eq 0 ]'
20 endef
22 endif
24 ifneq (,$(MD5SUM))
25 define fetch_Download__checksum_command
26 && SUM=`$(MD5SUM) $1 | sed "s/ .*//"` \
27 && if test "$$SUM" != "$2"; then \
28         echo ERROR: expected checksum for $1 is $2 2>&1 | tee -a $(fetch_LOGFILE); \
29         false; \
31 endef
33 else
34 fetch_Download__checksum_command :=
36 endif
38 # fetch__Download_item url tarball-name md5sum
39 define fetch__Download_item
40 $(if $(wildcard $(TARFILE_LOCATION)/$2),, \
41 cd $(TARFILE_LOCATION)/tmp \
42 $(call fetch_Download__wget_command,$1,$2) \
43 $(if $3,$(call fetch_Download__checksum_command,$2,$3)) \
44 && mv $2 ../ \
47 endef
49 # fetch_Download__is_checksum checksum
50 define fetch_Download__is_checksum
51 $(filter 32,$(words $(shell echo $(1) | sed -e 's/./& /g')))
52 endef
54 define fetch_Download__subst_var
55 $(subst _DLL,_MD5SUM,$(subst _TARBALL,_MD5SUM,$(subst _PACK,_MD5SUM,$(subst _JAR,_MD5SUM,$(1)))))
56 endef
58 # fetch_Download_item url variable-name
59 define fetch_Download_item
60 $(if $(strip $($(2))),,$(error fetch__Download_item: $(2) is empty))
61 $(if $(filter undefined,$(origin $(call fetch_Download__subst_var,$(2)))),\
62         $(if $(call fetch_Download__is_checksum,$(firstword $(subst -, ,$($(2))))),\
63                 $(call fetch__Download_item,$1,$($2),$(firstword $(subst -, ,$($(2))))),\
64                 $(error "fetch_Download_item: no checksum found for $($(2)). Please define $(call fetch_Download__subst_var,$(2)) in download.lst.") \
65         ),\
66         $(call fetch__Download_item,$(1),$($2),$($(call fetch_Download__subst_var,$(2)))) \
69 endef
71 # fetch_Download_item url tarball-name
72 define fetch_Download_item_unchecked
73 $(call fetch__Download_item,$1,$2)
75 endef
77 fetch_BUILD_TYPE := $(sort $(BUILD_TYPE))
78 ifneq ($(CROSS_COMPILING),)
79 fetch_BUILD_TYPE := $(sort $(fetch_BUILD_TYPE) $(shell . $(SRCDIR)/bin/get_config_variables --build BUILD_TYPE && echo $$BUILD_TYPE))
80 endif
82 # Return variable-name if this tarball should be fetched.
84 # This function is used for tarballs predefined in download.lst.
86 # fetch_Optional build-type variable-name
87 define fetch_Optional
88 $(if $(filter ALL,$(DO_FETCH_TARBALLS))$(filter $1,$(fetch_BUILD_TYPE)),$2)
89 endef
91 # Return variable-name if this pack should be fetched.
93 # This function is used for packs defined by configure.
95 # fetch_Optional_pack variable-name
96 define fetch_Optional_pack
97 $(if $(strip $($(1))),$(1))
98 endef
100 download: $(WORKDIR)/download
102 $(WORKDIR)/download: $(BUILDDIR)/config_host.mk $(SRCDIR)/download.lst $(SRCDIR)/Makefile.fetch
103         -@mkdir -p $(TARFILE_LOCATION)/tmp
104         @date >> $(fetch_LOGFILE)
105         $(foreach item, \
106                 $(call fetch_Optional,ABW,ABW_TARBALL) \
107                 $(call fetch_Optional,APACHE_COMMONS,APACHE_COMMONS_LOGGING_TARBALL) \
108                 $(call fetch_Optional,APR,APR_TARBALL) \
109                 $(call fetch_Optional,APR,APR_UTIL_TARBALL) \
110                 $(call fetch_Optional,BOOST,BOOST_TARBALL) \
111                 $(call fetch_Optional,BREAKPAD,BREAKPAD_TARBALL) \
112                 $(call fetch_Optional,BSH,BSH_TARBALL) \
113                 $(call fetch_Optional,BZIP2,BZIP2_TARBALL) \
114                 $(call fetch_Optional,CAIRO,CAIRO_TARBALL) \
115                 $(call fetch_Optional,CAIRO,PIXMAN_TARBALL) \
116                 $(call fetch_Optional,CDR,CDR_TARBALL) \
117                 $(call fetch_Optional,CLUCENE,CLUCENE_TARBALL) \
118                 $(call fetch_Optional,CMIS,CMIS_TARBALL) \
119                 $(call fetch_Optional,COINMP,COINMP_TARBALL) \
120                 $(call fetch_Optional,COLLADA2GLTF,COLLADA2GLTF_TARBALL) \
121                 $(call fetch_Optional,CPPUNIT,CPPUNIT_TARBALL) \
122                 $(call fetch_Optional,CT2N,CT2N_TARBALL) \
123                 $(call fetch_Optional,CURL,CURL_TARBALL) \
124                 $(call fetch_Optional,EBOOK,EBOOK_TARBALL) \
125                 $(call fetch_Optional,EPM,EPM_TARBALL) \
126                 $(call fetch_Optional,ETONYEK,ETONYEK_TARBALL) \
127                 $(call fetch_Optional,EXPAT,EXPAT_TARBALL) \
128                 $(call fetch_Optional,FIREBIRD,FIREBIRD_TARBALL) \
129                 $(call fetch_Optional,FONTCONFIG,FONTCONFIG_TARBALL) \
130                 $(call fetch_Optional,FREEHAND,FREEHAND_TARBALL) \
131                 $(call fetch_Optional,FREETYPE,FREETYPE_TARBALL) \
132                 $(call fetch_Optional,GLEW,GLEW_TARBALL) \
133                 $(call fetch_Optional,GLM,GLM_TARBALL) \
134                 $(call fetch_Optional_pack,GOOGLE_DOCS_EXTENSION_PACK) \
135                 $(call fetch_Optional,GRAPHITE,GRAPHITE_TARBALL) \
136                 $(call fetch_Optional,HARFBUZZ,HARFBUZZ_TARBALL) \
137                 $(call fetch_Optional,HSQLDB,HSQLDB_TARBALL) \
138                 $(call fetch_Optional,HUNSPELL,HUNSPELL_TARBALL) \
139                 $(call fetch_Optional,HYPHEN,HYPHEN_TARBALL) \
140                 $(call fetch_Optional,ICU,ICU_TARBALL) \
141                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_FLOW_ENGINE_TARBALL) \
142                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_FLUTE_TARBALL) \
143                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_LIBBASE_TARBALL) \
144                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_LIBFONTS_TARBALL) \
145                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_LIBFORMULA_TARBALL) \
146                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_LIBLAYOUT_TARBALL) \
147                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_LIBLOADER_TARBALL) \
148                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_LIBREPOSITORY_TARBALL) \
149                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_LIBSERIALIZER_TARBALL) \
150                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_LIBXML_TARBALL) \
151                 $(call fetch_Optional,JFREEREPORT,JFREEREPORT_SAC_TARBALL) \
152                 $(call fetch_Optional,JPEG,JPEG_TARBALL) \
153                 $(call fetch_Optional,JPEG_TURBO,JPEG_TURBO_TARBALL) \
154                 $(call fetch_Optional,LANGUAGETOOL,LANGUAGETOOL_TARBALL) \
155                 $(call fetch_Optional,LCMS2,LCMS2_TARBALL) \
156                 $(call fetch_Optional,LIBATOMIC_OPS,LIBATOMIC_OPS_TARBALL) \
157                 $(call fetch_Optional,LIBEOT,LIBEOT_TARBALL) \
158                 $(call fetch_Optional,LIBEXTTEXTCAT,LIBEXTTEXTCAT_TARBALL) \
159                 $(call fetch_Optional,LIBLANGTAG,LANGTAGREG_TARBALL) \
160                 $(call fetch_Optional,LIBLANGTAG,LIBLANGTAG_TARBALL) \
161                 $(call fetch_Optional,LIBPNG,PNG_TARBALL) \
162                 $(call fetch_Optional,LIBTOMMATH,LIBTOMMATH_TARBALL) \
163                 $(call fetch_Optional,LIBXML2,LIBXML_TARBALL) \
164                 LIBXMLSEC_TARBALL \
165                 $(call fetch_Optional,LIBXSLT,LIBXSLT_TARBALL) \
166                 $(call fetch_Optional,LPSOLVE,LPSOLVE_TARBALL) \
167                 $(call fetch_Optional,MARIADB,MARIADB_TARBALL) \
168                 $(call fetch_Optional,MDDS,MDDS_TARBALL) \
169                 $(call fetch_Optional,MDNSRESPONDER,MDNSRESPONDER_TARBALL) \
170                 $(call fetch_Optional,MORE_FONTS,FONT_CALADEA_TARBALL) \
171                 $(call fetch_Optional,MORE_FONTS,FONT_CARLITO_TARBALL) \
172                 $(call fetch_Optional,MORE_FONTS,FONT_DEJAVU_TARBALL) \
173                 $(call fetch_Optional,MORE_FONTS,FONT_GENTIUM_TARBALL) \
174                 $(call fetch_Optional,MORE_FONTS,FONT_KARLA_TARBALL) \
175                 $(call fetch_Optional,MORE_FONTS,FONT_LIBERATION_NARROW_TARBALL) \
176                 $(call fetch_Optional,MORE_FONTS,FONT_LIBERATION_TARBALL) \
177                 $(call fetch_Optional,MORE_FONTS,FONT_LINLIBERTINEG_TARBALL) \
178                 $(call fetch_Optional,MORE_FONTS,FONT_OPENSANS_TARBALL) \
179                 $(call fetch_Optional,MORE_FONTS,FONT_PTSERIF_TARBALL) \
180                 $(call fetch_Optional,MORE_FONTS,FONT_SOURCECODE_TARBALL) \
181                 $(call fetch_Optional,MORE_FONTS,FONT_SOURCESANS_TARBALL) \
182                 $(call fetch_Optional,MORE_FONTS,FONT_EMOJIONE_COLOR_TARBALL) \
183                 $(call fetch_Optional,MSPUB,MSPUB_TARBALL) \
184                 $(call fetch_Optional,MWAW,MWAW_TARBALL) \
185                 $(call fetch_Optional,MYSQLCPPCONN,MYSQLCPPCONN_TARBALL) \
186                 $(call fetch_Optional,MYTHES,MYTHES_TARBALL) \
187                 $(call fetch_Optional,NEON,NEON_TARBALL) \
188                 $(call fetch_Optional,NSS,NSS_TARBALL) \
189                 $(call fetch_Optional_pack,NUMBERTEXT_EXTENSION_PACK) \
190                 $(call fetch_Optional,ODFGEN,ODFGEN_TARBALL) \
191                 $(call fetch_Optional,OPENCOLLADA,OPENCOLLADA_TARBALL) \
192                 $(call fetch_Optional,OPENLDAP,OPENLDAP_TARBALL) \
193                 $(call fetch_Optional,OPENSSL,OPENSSL_TARBALL) \
194                 $(call fetch_Optional,ORCUS,ORCUS_TARBALL) \
195                 $(call fetch_Optional,OWNCLOUD_ANDROID_LIB,OWNCLOUD_ANDROID_LIB_TARBALL) \
196                 $(call fetch_Optional,PAGEMAKER,PAGEMAKER_TARBALL) \
197                 $(call fetch_Optional,PDFIUM,PDFIUM_TARBALL) \
198                 $(call fetch_Optional,POPPLER,POPPLER_TARBALL) \
199                 $(call fetch_Optional,POSTGRESQL,POSTGRESQL_TARBALL) \
200                 $(call fetch_Optional,PYTHON,PYTHON_TARBALL) \
201                 $(call fetch_Optional,REDLAND,RAPTOR_TARBALL) \
202                 $(call fetch_Optional,REDLAND,RASQAL_TARBALL) \
203                 $(call fetch_Optional,REDLAND,REDLAND_TARBALL) \
204                 $(call fetch_Optional,REVENGE,REVENGE_TARBALL) \
205                 $(call fetch_Optional,RHINO,RHINO_TARBALL) \
206                 $(call fetch_Optional,RHINO,SWING_TARBALL) \
207                 $(call fetch_Optional,SERF,SERF_TARBALL) \
208                 $(call fetch_Optional,STAROFFICE,STAROFFICE_TARBALL) \
209                 $(call fetch_Optional,UCPP,UCPP_TARBALL) \
210                 $(call fetch_Optional,VISIO,VISIO_TARBALL) \
211                 $(call fetch_Optional,WPD,WPD_TARBALL) \
212                 $(call fetch_Optional,WPG,WPG_TARBALL) \
213                 $(call fetch_Optional,WPS,WPS_TARBALL) \
214                 $(call fetch_Optional,XSLTML,XSLTML_TARBALL) \
215                 $(call fetch_Optional,ZLIB,ZLIB_TARBALL) \
216                 $(call fetch_Optional,ZMF,ZMF_TARBALL) \
217         ,$(call fetch_Download_item,http://dev-www.libreoffice.org/src,$(item)))
218         $(foreach item, \
219                 $(call fetch_Optional,DBGHELP,DBGHELP_DLL) \
220                 $(call fetch_Optional,ODK,UNOWINREG_DLL) \
221                 $(call fetch_Optional,ODFVALIDATOR,ODFVALIDATOR_JAR) \
222                 $(call fetch_Optional,OFFICEOTRON,OFFICEOTRON_JAR) \
223         ,$(call fetch_Download_item,http://dev-www.libreoffice.org/extern,$(item)))
224         $(if $(call fetch_Optional,LIBGLTF,LIBGLTF_TARBALL) \
225         , $(call fetch_Download_item,http://dev-www.libreoffice.org/src/libgltf,$(call fetch_Optional,LIBGLTF,LIBGLTF_TARBALL)))
226         $(foreach item, \
227                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_TARBALL) \
228                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_SANS_JP_TARBALL) \
229                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_SANS_KR_TARBALL) \
230                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_SANS_SC_TARBALL) \
231                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_SANS_TC_TARBALL) \
232                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_SERIF_JP_TARBALL) \
233                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_SERIF_KR_TARBALL) \
234                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_SERIF_SC_TARBALL) \
235                 $(call fetch_Optional,NOTO_FONT,FONT_NOTO_SERIF_TC_TARBALL) \
236         ,$(call fetch_Download_item,https://noto-website-2.storage.googleapis.com/pkgs,$(item)))
237         @mkdir -p $(dir $@) && touch $@
239 # vim: set noet sw=4 ts=4: