Bump for 3.6-28
[LibreOffice.git] / solenv / gbuild / ExternalLib.mk
blobcb8eb017659bceddbf4fd02a506a8fcd55ec2c82
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
4 # Version: MPL 1.1 / GPLv3+ / LGPLv3+
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
16 # Major Contributor(s):
17 # Copyright (C) 2011 Norbert Thiebaud <nthiebaud@gmail.com>
19 # All Rights Reserved.
21 # For minor contributions see the git repository.
23 # Alternatively, the contents of this file may be used under the terms of
24 # either the GNU General Public License Version 3 or later (the "GPLv3+"), or
25 # the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
26 # in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
27 # instead of those above.
29 gb_ExternalLib_get_src_package = $(TARFILE_LOCATION)/$(1)
31 define gb_ExternalLib_ExternalLib
32 $(call gb_ExternalLib_get_target,$(1)): T_PATCHES:=
33 $(call gb_ExternalLib_get_target,$(1)): T_POST_PATCHES:=
34 $(call gb_ExternalLib_get_target,$(1)): T_CONF_ARGS:=
35 $(call gb_ExternalLib_get_target,$(1)): T_BUILD_MODE:=$(2)
36 $$(eval $$(call gb_Module_register_target,$(call gb_ExternalLib_get_target,$(1)),$(call gb_ExternalLib_get_clean_target,$(1))))
38 ifeq ($(strip $(2)),autotools)
39 $(call gb_ExternalLib_get_target,$(1)) :
40 $$(call gb_Output_announce,$*,$(true),MAK,3)
41 $$(call gb_ExternalLib__command_autotools,$(1));
42 touch $(call gb_ExternalLib_get_target,$(1));
44 .PHONY: $(call gb_ExternalLib_get_clean_target,$(1))
45 $(call gb_ExternalLib_get_clean_target,$(1)) :
46 $$(call gb_Output_announce,$(1),$(false),MAK,3)
47 $$(call gb_Helper_abbreviate_dirs,\
48 if test -f $(call gb_ExternalLib_get_builddir,$(1))/Makefile ; then cd $$(call gb_ExternalLib_get_builddir,$(1)) && make uninstall ; fi ; \
49 rm -rf $(call gb_ExternalLib_get_target,$(1)) \
50 $(call gb_ExternalLib_get_workdir,$(1)))
52 else
53 $$(call gb_Output_error,$(2) is not a supported ExternalLib mode)
54 endif
56 endef
58 define gb_ExternalLib_set_src_package
59 $(call gb_ExternalLib_get_target,$(1)): $(call gb_ExternalLib_get_src_package,$(2))
61 endef
63 define gb_ExternalLib_add_patch
64 $(call gb_ExternalLib_get_target,$(1)): T_PATCHES+=$(2)
66 endef
68 define gb_ExternalLib_add_patches
69 $(foreach patch,$(2),$(call gb_ExternalLib_add_patch,$(1),$(patch)))
71 endef
73 define gb_ExternalLib_add_post_patch
74 $(call gb_ExternalLib_get_target,$(1)): T_POST_PATCHES+=$(2)
76 endef
78 define gb_ExternalLib_add_post_patches
79 $(foreach patch,$(2),$(call gb_ExternalLib_add_patch,$(1),$(patch)))
81 endef
83 define gb_ExternalLib_add_conf_arg
84 $(call gb_ExternalLib_get_target,$(1)): T_CONF_ARGS+=$(2)
86 endef
88 define gb_ExternalLib_add_cxxflags
89 $(call gb_ExternalLib_get_target,$(1)) : T_CXXFLAGS += $(2)
91 endef
93 define gb_ExternalLib_add_cflags
94 $(call gb_ExternalLib_get_target,$(1)) : T_CFLAGS += $(2)
96 endef
99 define gb_ExternalLib__command_autotools
100 rm -fr $(call gb_ExternalLib_get_workdir,$(1)) && \
101 mkdir -p $(call gb_ExternalLib_get_builddir,$(1)) && \
102 $(GNUTAR) -x -C $(call gb_ExternalLib_get_builddir,$(1)) --strip-components=1 -f $< && \
103 cd $(call gb_ExternalLib_get_builddir,$(1)) && for p in $(T_PATCHES) ; do patch -p 1 < $(SRCDIR)/$$p || exit 1; done && \
104 CC="$(gb_CC)" CXX="$(gb_CXX)" CFLAGS="$(T_CFLAGS)" CXXFLAGS="$(T_CXXFLAGS)" PKG_CONFIG_PATH="$(PKG_CONFIG_PATH) $(OUTDIR)/lib/pkgconfig" ./configure $(if $(findstring YES,$(CROSS_COMPILING)),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) --prefix=$(OUTDIR) $(T_CONF_ARGS) && \
105 for p in $(T_POST_PATCHES) ; do patch -p 1 < $(SRCDIR)/$p || exit 1; done
106 #we don't want a deployed rpath pointing into our solver, to-do, set correct ORIGIN-foo ?
107 cd $(call gb_ExternalLib_get_builddir,$(1)) && if test -e libtool ; then sed -i -e 's,^hardcode_libdir_flag_spec=.*,hardcode_libdir_flag_spec="",g' libtool && sed -i -e 's,^runpath_var=LD_RUN_PATH,runpath_var=DIE_RPATH_DIE,g' libtool; fi
108 +MAKEFLAGS=$(filterout r,$(MAKEFLAGS)) $(MAKE) -C $(call gb_ExternalLib_get_builddir,$(1))
109 +$(MAKE) -C $(call gb_ExternalLib_get_builddir,$(1)) install
110 endef