xref: /aoo41x/main/solenv/gbuild/CustomTarget.mk (revision cdf0e10c)
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28gb_CustomTarget_REPOSITORYNAMES := $(gb_Helper_REPOSITORYNAMES)
29
30# N.B.: putting the "+" there at the start activates the GNU make job server
31define gb_CustomTarget__command
32+$(call gb_Helper_abbreviate_dirs,\
33	mkdir -p $(call gb_CustomTarget_get_workdir,$(2)) && \
34	$(MAKE) -C $(call gb_CustomTarget_get_workdir,$(2)) -f $< && \
35	touch $(1))
36
37endef
38
39define gb_CustomTarget__rules
40$$(call gb_CustomTarget_get_repo_target,$(1),%) :
41	$$(call gb_Output_announce,$$*,$$(true),MAK,3)
42	$$(call gb_CustomTarget__command,$$@,$$*)
43
44$$(call gb_CustomTarget_get_target,%) : $$(call gb_CustomTarget_get_repo_target,$(1),%)
45	$$(call gb_Helper_abbreviate_dirs,\
46		touch $$@)
47
48endef
49
50.PHONY: $(call gb_CustomTarget_get_clean_target,%)
51$(call gb_CustomTarget_get_clean_target,%) :
52	$(call gb_Output_announce,$*,$(false),MAK,3)
53	$(call gb_Helper_abbreviate_dirs,\
54		rm -rf $(call gb_CustomTarget_get_workdir,$*) && \
55		rm -f $(call gb_CustomTarget_get_target,$*) \
56			$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),$(call gb_CustomTarget_get_repo_target,$(reponame),$*)))
57
58
59$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),$(eval $(call gb_CustomTarget__rules,$(reponame))))
60
61define gb_CustomTarget__get_makefile
62$(1)/$(2)/Makefile
63endef
64
65define gb_CustomTarget_CustomTarget
66$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),\
67	$(eval $(call gb_CustomTarget_get_repo_target,$(reponame),$(1)) : $(call gb_CustomTarget__get_makefile,$($(reponame)),$(1))))
68
69$(call gb_CustomTarget_get_workdir,$(1))/% : $(call gb_CustomTarget_get_target,$(1))
70
71endef
72
73
74define gb_CustomTarget_add_dependency
75$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),\
76	$(eval $(call gb_CustomTarget_get_repo_target,$(reponame),$(1)) : $($(reponame))/$(2)))
77
78endef
79
80define gb_CustomTarget_add_dependencies
81$(foreach dependency,$(2),$(call gb_CustomTarget_add_dependency,$(1),$(dependency)))
82
83endef
84
85define gb_CustomTarget_add_outdir_dependency
86$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),\
87	$(eval $(call gb_CustomTarget_get_repo_target,$(reponame),$(1)) : $(2)))
88
89endef
90
91define gb_CustomTarget_add_outdir_dependencies
92$(foreach dependency,$(2),$(call gb_CustomTarget_add_outdir_dependency,$(1),$(dependency)))
93
94endef
95
96# vim: set noet sw=4 ts=4:
97