17871dc3eSAndrew Rist#**************************************************************
2*3562d444Smseidel#
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
10*3562d444Smseidel#
117871dc3eSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12*3562d444Smseidel#
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.
19*3562d444Smseidel#
207871dc3eSAndrew Rist#**************************************************************
217871dc3eSAndrew Rist
227871dc3eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir.PHONY : setuplocal removelocal
25cdf0e10cSrcweirifneq ($(gb_LOCALBUILDDIR),)
26cdf0e10cSrcweirifneq ($(wildcard $(gb_LOCALBUILDDIR)/SetupLocal.mk),)
27cdf0e10cSrcweirsetuplocal :
28cdf0e10cSrcweir	$(eval $(call gb_Output_error,$(gb_LOCALBUILDDIR) exists already.))
29cdf0e10cSrcweir
30cdf0e10cSrcweirelse
31cdf0e10cSrcweir
32cdf0e10cSrcweirsetuplocal :
33cdf0e10cSrcweir	$(eval MODULE := $(firstword $(MODULE) $(lastword $(subst /, ,$(dir $(realpath $(firstword $(MAKEFILE_LIST))))))))
34cdf0e10cSrcweir	$(eval modulerepo := $(patsubst %/$(MODULE),%,$(foreach repo,$(gb_REPOS),$(wildcard $(repo)/$(MODULE)))))
35cdf0e10cSrcweir	$(eval $(call gb_Output_announce,setting up local build directory (module: $(MODULE)).,$(true),SYC,5))
36cdf0e10cSrcweir	mkdir -p $(gb_LOCALBUILDDIR)/srcdir $(gb_LOCALBUILDDIR)/workdir $(gb_LOCALBUILDDIR)/outdir
37cdf0e10cSrcweir	rsync --archive --exclude 'workdir/**' $(SOLARVERSION)/$(INPATH)/ $(gb_LOCALBUILDDIR)/outdir
38cdf0e10cSrcweir	cp $(modulerepo)/Repository.mk $(gb_LOCALBUILDDIR)/srcdir/Repository.mk
39cdf0e10cSrcweir	cp $(modulerepo)/RepositoryFixes.mk $(gb_LOCALBUILDDIR)/srcdir/RepositoryFixes.mk
40cdf0e10cSrcweir	rsync --archive $(modulerepo)/$(MODULE)/ $(gb_LOCALBUILDDIR)/srcdir/$(MODULE)
41cdf0e10cSrcweir	echo "gb_REPOS := $(gb_LOCALBUILDDIR)/srcdir $(filter-out $(patsubst %/$(MODULE),%,$(foreach repo,$(gb_REPOS),$(wildcard $(repo)/$(MODULE)))),$(gb_REPOS))" > $(gb_LOCALBUILDDIR)/SetupLocal.mk
42cdf0e10cSrcweir	echo "#original gb_REPOS was $(gb_REPOS)" >> $(gb_LOCALBUILDDIR)/SetupLocal.mk
43cdf0e10cSrcweir	echo "OUTDIR := $(gb_LOCALBUILDDIR)/outdir" >> $(gb_LOCALBUILDDIR)/SetupLocal.mk
44cdf0e10cSrcweir	echo "#original OUTDIR was $(OUTDIR)" >> $(gb_LOCALBUILDDIR)/SetupLocal.mk
45cdf0e10cSrcweir	echo "WORKDIR := $(gb_LOCALBUILDDIR)/workdir" >> $(gb_LOCALBUILDDIR)/SetupLocal.mk
46cdf0e10cSrcweir	echo "#original WORKDIR was $(WORKDIR)" >> $(gb_LOCALBUILDDIR)/SetupLocal.mk
47cdf0e10cSrcweir
48cdf0e10cSrcweirendif
49cdf0e10cSrcweir
50cdf0e10cSrcweirremovelocal :
51cdf0e10cSrcweir	$(eval $(call gb_Output_warn,removing directory $(gb_LOCALBUILDDIR).,SYC))
52cdf0e10cSrcweir	sleep 10
53cdf0e10cSrcweir	rm -rf $(gb_LOCALBUILDDIR)
54cdf0e10cSrcweir
55cdf0e10cSrcweirelse
56cdf0e10cSrcweirsetuplocal:
57cdf0e10cSrcweir	$(eval $(call gb_Output_error,setuplocal: gb_LOCALBUILDDIR is not set.))
58cdf0e10cSrcweir
59cdf0e10cSrcweirremovelocal:
60cdf0e10cSrcweir	$(eval $(call gb_Output_error,setuplocal: gb_LOCALBUILDDIR is not set.))
61cdf0e10cSrcweir
62cdf0e10cSrcweirendif
63cdf0e10cSrcweir
64cdf0e10cSrcweir# vim: set noet sw=4 ts=4:
65