xref: /aoo42x/main/solenv/gbuild/CustomTarget.mk (revision 05b23b56)
17871dc3eSAndrew Rist#**************************************************************
27871dc3eSAndrew Rist#
37871dc3eSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
47871dc3eSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
57871dc3eSAndrew Rist#  distributed with this work for additional information
67871dc3eSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
77871dc3eSAndrew Rist#  to you under the Apache License, Version 2.0 (the
87871dc3eSAndrew Rist#  "License"); you may not use this file except in compliance
97871dc3eSAndrew Rist#  with the License.  You may obtain a copy of the License at
107871dc3eSAndrew Rist#
117871dc3eSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
127871dc3eSAndrew Rist#
137871dc3eSAndrew Rist#  Unless required by applicable law or agreed to in writing,
147871dc3eSAndrew Rist#  software distributed under the License is distributed on an
157871dc3eSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
167871dc3eSAndrew Rist#  KIND, either express or implied.  See the License for the
177871dc3eSAndrew Rist#  specific language governing permissions and limitations
187871dc3eSAndrew Rist#  under the License.
197871dc3eSAndrew Rist#
207871dc3eSAndrew Rist#**************************************************************
217871dc3eSAndrew Rist
227871dc3eSAndrew 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
35b63233d8Sdamjan$(call gb_CustomTarget_get_target,%) :
36b63233d8Sdamjan	$(call gb_Output_announce,$*,$(true),MAK,3)
37b63233d8Sdamjan	$(call gb_CustomTarget__command,$@,$*)
38cdf0e10cSrcweir
39cdf0e10cSrcweir.PHONY: $(call gb_CustomTarget_get_clean_target,%)
40cdf0e10cSrcweir$(call gb_CustomTarget_get_clean_target,%) :
41cdf0e10cSrcweir	$(call gb_Output_announce,$*,$(false),MAK,3)
42cdf0e10cSrcweir	$(call gb_Helper_abbreviate_dirs,\
43cdf0e10cSrcweir		rm -rf $(call gb_CustomTarget_get_workdir,$*) && \
44b63233d8Sdamjan		rm -f $(call gb_CustomTarget_get_target,$*))
45cdf0e10cSrcweir
46cdf0e10cSrcweirdefine gb_CustomTarget__get_makefile
47cdf0e10cSrcweir$(1)/$(2)/Makefile
48cdf0e10cSrcweirendef
49cdf0e10cSrcweir
50cdf0e10cSrcweirdefine gb_CustomTarget_CustomTarget
51b63233d8Sdamjan$(if $(filter $(2),$(gb_CustomTarget_REPOSITORYNAMES)),,\
52b63233d8Sdamjan $(error CustomTarget: no or invalid repository given; known repositories: \
53b63233d8Sdamjan  $(gb_JavaClassSet_REPOSITORYNAMES)))
54b63233d8Sdamjangb_CustomTarget_REPO_$(1) := $(2)
55b63233d8Sdamjan$(call gb_CustomTarget_get_target,$(1)) : \
56b63233d8Sdamjan  $(call gb_CustomTarget__get_makefile,$($(2)),$(1))
57b63233d8Sdamjan$(call gb_CustomTarget_get_workdir,$(1))/% : \
58b63233d8Sdamjan  $(call gb_CustomTarget_get_target,$(1))
59*05b23b56SDamjan Jovanovic$(eval $(call gb_Module_register_target,$(call gb_CustomTarget_get_target,$(1)),$(call gb_CustomTarget_get_clean_target,$(1))))
60cdf0e10cSrcweirendef
61cdf0e10cSrcweir
62cdf0e10cSrcweir
63cdf0e10cSrcweirdefine gb_CustomTarget_add_dependency
64b63233d8Sdamjan$(eval $(call gb_CustomTarget_get_target,$(1)) : \
65b63233d8Sdamjan	$($(gb_CustomTarget_REPO_$(1)))/$(2))
66cdf0e10cSrcweirendef
67cdf0e10cSrcweir
68cdf0e10cSrcweirdefine gb_CustomTarget_add_dependencies
69cdf0e10cSrcweir$(foreach dependency,$(2),$(call gb_CustomTarget_add_dependency,$(1),$(dependency)))
70cdf0e10cSrcweirendef
71cdf0e10cSrcweir
72cdf0e10cSrcweirdefine gb_CustomTarget_add_outdir_dependency
73b63233d8Sdamjan$(eval $(call gb_CustomTarget_get_target,$(1)) : $(2))
74cdf0e10cSrcweirendef
75cdf0e10cSrcweir
76cdf0e10cSrcweirdefine gb_CustomTarget_add_outdir_dependencies
77cdf0e10cSrcweir$(foreach dependency,$(2),$(call gb_CustomTarget_add_outdir_dependency,$(1),$(dependency)))
78cdf0e10cSrcweir
79cdf0e10cSrcweirendef
80cdf0e10cSrcweir
81cdf0e10cSrcweir# vim: set noet sw=4 ts=4:
82