Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / odk / build-examples_common.mk
blob50ea40ec905ed8c1a18b714b475b3f8be973e81e
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*-
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 define odk_build-examples_test
12 $(eval $(call gb_CustomTarget_CustomTarget,$(1)))
14 # System-provided shells on macOS are known to unset DYLD_LIBRARY_PATH, so we need some sort of hack
15 # to provided the invocation of make below with a shell that preserves DYLD_LIBRARY_PATH. Until
16 # macOS 10.14, what apparently worked is to use a copy of /bin/sh in some temp dir. However, with
17 # macOS 10.15, that hack appears to no longer work, the only known workaround is to use e.g. bash
18 # built from upstream source and pass it into the toplevel make invocation as SHELL=... command line
19 # argument (which is also needed when building external/firebird and needing to preserve a global
20 # DYLD_LIBRARY_PATH, see comment 17 at
21 # <https://bugs.documentfoundation.org/show_bug.cgi?id=101789#c17> "FIREBIRD 3 - fails to build on
22 # OSX 10.11.6 with clang"). When building on macOS <= 10.14 and not passing SHELL=... on the
23 # command line, MACOSX_SHELL_HACK will kick in and do the "use a copy of /bin/sh" workaround. When
24 # passing in a self-built SHELL=... (which is necessary now on macOS >= 10.15), the
25 # MACOSX_SHELL_HACK will not kick in, but the below invocation of make will automatically inherit
26 # SHELL from the currently running invocation of make. (At least with GNU Make 4.2.1, the origin of
27 # a default SHELL setting is, somewhat unintuitively, reported as "file" rather than "default". To
28 # avoid surprises, use an explicit check for an origin of "command line" here.)
29 MACOSX_SHELL_HACK := $(and $(filter MACOSX,$(OS)),$(filter-out command line,$(origin SHELL)))
31 $(call gb_CustomTarget_get_target,$(1)): \
32 $(call gb_CustomTarget_get_workdir,$(1))/setsdkenv
33 ifneq ($(gb_SUPPRESS_TESTS),)
34 @true
35 else
36 $$(call gb_Output_announce,$(subst $(WORKDIR)/,,$(1)),$(true),CHK,1)
37 rm -fr $(call gb_CustomTarget_get_workdir,$(1))/{out,user}
38 ifneq ($(MACOSX_SHELL_HACK),)
39 $(eval ODK_BUILD_SHELL := $(shell $(gb_MKTEMP)))
40 cp /bin/sh "$(ODK_BUILD_SHELL)"
41 chmod 0700 "$(ODK_BUILD_SHELL)"
42 endif
43 (saved_library_path=$$$${$(gb_Helper_LIBRARY_PATH_VAR)} && . $$< \
44 $(if $(filter MACOSX,$(OS)),, \
45 && $(gb_Helper_LIBRARY_PATH_VAR)=$$$$saved_library_path) \
46 && export \
47 UserInstallation=$(call gb_Helper_make_url,$(call gb_CustomTarget_get_workdir,$(1))/user) \
48 $(foreach my_dir,$(2), \
49 && (cd $(INSTDIR)/$(SDKDIRNAME)/examples/$(my_dir) \
50 && printf 'yes\n' | LC_ALL=C make \
51 CC="$(CXX)" LINK="$(CXX)" LIB="$(CXX)" \
52 $(if $(MACOSX_SHELL_HACK), SHELL=$(ODK_BUILD_SHELL), )))) \
53 >$(call gb_CustomTarget_get_workdir,$(1))/log 2>&1 \
54 || (RET=$$$$? \
55 $(if $(MACOSX_SHELL_HACK), && rm -f $(ODK_BUILD_SHELL) , ) \
56 && cat $(call gb_CustomTarget_get_workdir,$(1))/log \
57 && exit $$$$RET)
58 ifneq ($(MACOSX_SHELL_HACK),)
59 -rm -f $(ODK_BUILD_SHELL)
60 endif
61 endif
63 $(call gb_CustomTarget_get_workdir,$(1))/setsdkenv: \
64 $(SRCDIR)/odk/config/setsdkenv_unix.sh.in \
65 $(BUILDDIR)/config_$(gb_Side).mk | \
66 $(call gb_CustomTarget_get_workdir,$(1))/.dir
67 $$(call gb_Output_announce,$(subst $(WORKDIR)/,,$(1)),$(true),SED,1)
68 sed -e 's!@OO_SDK_NAME@!sdk!' \
69 -e 's!@OO_SDK_HOME@!$(INSTDIR)/$(SDKDIRNAME)!' \
70 -e 's!@OFFICE_HOME@!$(INSTROOTBASE)!' -e 's!@OO_SDK_MAKE_HOME@!!' \
71 -e 's!@OO_SDK_ZIP_HOME@!!' -e 's!@OO_SDK_CAT_HOME@!!' \
72 -e 's!@OO_SDK_SED_HOME@!!' -e 's!@OO_SDK_CPP_HOME@!!' \
73 -e 's!@OO_SDK_JAVA_HOME@!$(JAVA_HOME)!' \
74 -e 's!@OO_SDK_OUTPUT_DIR@!$(call gb_CustomTarget_get_workdir,$(1))/out!' \
75 -e 's!@SDK_AUTO_DEPLOYMENT@!YES!' $$< > $$@
77 .PHONY: $(call gb_CustomTarget_get_target,$(1))
79 endef
81 # vim: set noet sw=4 ts=4: