Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / Deliver.mk
blobca609d9f771efb4c9c76630982f0c60cf0754756
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/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 gb_Deliver_GNUCOPY := $(GNUCOPY)
22 # if ($true) then old files will get removed from the target location before
23 # they are copied there. In multi-user environments, if this is needed you need
24 # to be the owner of the target file to be able to modify timestamps
25 ifeq ($(strip gb_Deliver_HARDLINK),)
26 gb_Deliver_CLEARONDELIVER := $(false)
27 else
28 gb_Deliver_CLEARONDELIVER := $(true)
29 endif
32 define gb_Deliver_init
33 gb_Deliver_DELIVERABLES :=
34 gb_Deliver_DELIVERABLES_INDEX :=
36 endef
38 define gb_Deliver_register_deliverable
39 gb_Deliver_DELIVERABLES_$(notdir $(3)) += $(2):$(1)
40 gb_Deliver_DELIVERABLES_INDEX := $$(sort $$(gb_Deliver_DELIVERABLES_INDEX) $(notdir $(3)))
41 $(if $(gb_LOWRESTIME),.LOW_RESOLUTION_TIME : $(1),)
43 endef
45 define gb_Deliver_add_deliverable
46 $$(if $(3),,$$(error - missing third parameter for deliverable $(1)))
47 ifeq ($(MAKECMDGOALS),showdeliverables)
48 $(call gb_Deliver_register_deliverable,$(1),$(2),$(3))
49 endif
51 endef
53 define gb_Deliver__deliver
54 $(if $(gb_Deliver_CLEARONDELIVER),rm -f $(2) &&) $(if $(gb_Deliver_HARDLINK),ln,cp -P -f) $(1) $(2) && $(TOUCH) -hr $(1) $(2)
55 endef
57 ifneq ($(strip $(gb_Deliver_GNUCOPY)),)
58 ifeq ($(strip $(gb_Deliver_HARDLINK)),)
59 define gb_Deliver__deliver
60 $(gb_Deliver_GNUCOPY) $(if $(gb_Deliver_CLEARONDELIVER),--remove-destination) --no-dereference --force --preserve=timestamps $(1) $(2)
61 endef
62 endif
63 endif
65 define gb_Deliver_deliver
66 $(if $(1),$(call gb_Deliver__deliver,$(1),$(2)),\
67 $(error gb_Deliver_deliver:\
68 file does not exist in instdir, and cannot be delivered: $(2)))
69 endef
71 define gb_Deliver_print_deliverable
72 $(info $(1) $(2))
73 endef
75 showdeliverables :
76 $(eval MAKEFLAGS := s)
77 $(foreach deliverable,$(sort $(foreach list,$(gb_Deliver_DELIVERABLES_INDEX),$(gb_Deliver_DELIVERABLES_$(list)))),\
78 $(call gb_Deliver_print_deliverable,$(firstword $(subst :, ,$(deliverable))),$(lastword $(subst :, ,$(deliverable)))))
79 @true
81 # vim: set noet sw=4: