xref: /aoo42x/main/solenv/gbuild/CustomTarget.mk (revision 7871dc3e)
1*7871dc3eSAndrew Rist#**************************************************************
2*7871dc3eSAndrew Rist#
3*7871dc3eSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4*7871dc3eSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5*7871dc3eSAndrew Rist#  distributed with this work for additional information
6*7871dc3eSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7*7871dc3eSAndrew Rist#  to you under the Apache License, Version 2.0 (the
8*7871dc3eSAndrew Rist#  "License"); you may not use this file except in compliance
9*7871dc3eSAndrew Rist#  with the License.  You may obtain a copy of the License at
10*7871dc3eSAndrew Rist#
11*7871dc3eSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12*7871dc3eSAndrew Rist#
13*7871dc3eSAndrew Rist#  Unless required by applicable law or agreed to in writing,
14*7871dc3eSAndrew Rist#  software distributed under the License is distributed on an
15*7871dc3eSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*7871dc3eSAndrew Rist#  KIND, either express or implied.  See the License for the
17*7871dc3eSAndrew Rist#  specific language governing permissions and limitations
18*7871dc3eSAndrew Rist#  under the License.
19*7871dc3eSAndrew Rist#
20*7871dc3eSAndrew Rist#**************************************************************
21*7871dc3eSAndrew Rist
22*7871dc3eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirgb_CustomTarget_REPOSITORYNAMES := $(gb_Helper_REPOSITORYNAMES)
25cdf0e10cSrcweir
26cdf0e10cSrcweir# N.B.: putting the "+" there at the start activates the GNU make job server
27cdf0e10cSrcweirdefine gb_CustomTarget__command
28cdf0e10cSrcweir+$(call gb_Helper_abbreviate_dirs,\
29cdf0e10cSrcweir	mkdir -p $(call gb_CustomTarget_get_workdir,$(2)) && \
30cdf0e10cSrcweir	$(MAKE) -C $(call gb_CustomTarget_get_workdir,$(2)) -f $< && \
31cdf0e10cSrcweir	touch $(1))
32cdf0e10cSrcweir
33cdf0e10cSrcweirendef
34cdf0e10cSrcweir
35cdf0e10cSrcweirdefine gb_CustomTarget__rules
36cdf0e10cSrcweir$$(call gb_CustomTarget_get_repo_target,$(1),%) :
37cdf0e10cSrcweir	$$(call gb_Output_announce,$$*,$$(true),MAK,3)
38cdf0e10cSrcweir	$$(call gb_CustomTarget__command,$$@,$$*)
39cdf0e10cSrcweir
40cdf0e10cSrcweir$$(call gb_CustomTarget_get_target,%) : $$(call gb_CustomTarget_get_repo_target,$(1),%)
41cdf0e10cSrcweir	$$(call gb_Helper_abbreviate_dirs,\
42cdf0e10cSrcweir		touch $$@)
43cdf0e10cSrcweir
44cdf0e10cSrcweirendef
45cdf0e10cSrcweir
46cdf0e10cSrcweir.PHONY: $(call gb_CustomTarget_get_clean_target,%)
47cdf0e10cSrcweir$(call gb_CustomTarget_get_clean_target,%) :
48cdf0e10cSrcweir	$(call gb_Output_announce,$*,$(false),MAK,3)
49cdf0e10cSrcweir	$(call gb_Helper_abbreviate_dirs,\
50cdf0e10cSrcweir		rm -rf $(call gb_CustomTarget_get_workdir,$*) && \
51cdf0e10cSrcweir		rm -f $(call gb_CustomTarget_get_target,$*) \
52cdf0e10cSrcweir			$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),$(call gb_CustomTarget_get_repo_target,$(reponame),$*)))
53cdf0e10cSrcweir
54cdf0e10cSrcweir
55cdf0e10cSrcweir$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),$(eval $(call gb_CustomTarget__rules,$(reponame))))
56cdf0e10cSrcweir
57cdf0e10cSrcweirdefine gb_CustomTarget__get_makefile
58cdf0e10cSrcweir$(1)/$(2)/Makefile
59cdf0e10cSrcweirendef
60cdf0e10cSrcweir
61cdf0e10cSrcweirdefine gb_CustomTarget_CustomTarget
62cdf0e10cSrcweir$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),\
63cdf0e10cSrcweir	$(eval $(call gb_CustomTarget_get_repo_target,$(reponame),$(1)) : $(call gb_CustomTarget__get_makefile,$($(reponame)),$(1))))
64cdf0e10cSrcweir
65cdf0e10cSrcweir$(call gb_CustomTarget_get_workdir,$(1))/% : $(call gb_CustomTarget_get_target,$(1))
66cdf0e10cSrcweir
67cdf0e10cSrcweirendef
68cdf0e10cSrcweir
69cdf0e10cSrcweir
70cdf0e10cSrcweirdefine gb_CustomTarget_add_dependency
71cdf0e10cSrcweir$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),\
72cdf0e10cSrcweir	$(eval $(call gb_CustomTarget_get_repo_target,$(reponame),$(1)) : $($(reponame))/$(2)))
73cdf0e10cSrcweir
74cdf0e10cSrcweirendef
75cdf0e10cSrcweir
76cdf0e10cSrcweirdefine gb_CustomTarget_add_dependencies
77cdf0e10cSrcweir$(foreach dependency,$(2),$(call gb_CustomTarget_add_dependency,$(1),$(dependency)))
78cdf0e10cSrcweir
79cdf0e10cSrcweirendef
80cdf0e10cSrcweir
81cdf0e10cSrcweirdefine gb_CustomTarget_add_outdir_dependency
82cdf0e10cSrcweir$(foreach reponame,$(gb_CustomTarget_REPOSITORYNAMES),\
83cdf0e10cSrcweir	$(eval $(call gb_CustomTarget_get_repo_target,$(reponame),$(1)) : $(2)))
84cdf0e10cSrcweir
85cdf0e10cSrcweirendef
86cdf0e10cSrcweir
87cdf0e10cSrcweirdefine gb_CustomTarget_add_outdir_dependencies
88cdf0e10cSrcweir$(foreach dependency,$(2),$(call gb_CustomTarget_add_outdir_dependency,$(1),$(dependency)))
89cdf0e10cSrcweir
90cdf0e10cSrcweirendef
91cdf0e10cSrcweir
92cdf0e10cSrcweir# vim: set noet sw=4 ts=4:
93