xref: /aoo41x/main/solenv/gbuild/Helper.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_Helper_NULLFILE := /dev/null
29
30gb_Helper_MISC := $(WORKDIR)/Misc
31
32ifeq ($(JAVACOMPILER),)
33JAVACOMPILER := javac
34endif
35
36ifeq ($(JAVAINTERPRETER),)
37JAVAINTERPRETER := java
38endif
39
40# general propose phony target
41gb_Helper_PHONY := $(gb_Helper_MISC)/PHONY
42
43# general propose empty dummy target
44gb_Helper_MISCDUMMY := $(gb_Helper_MISC)/DUMMY
45
46gb_Helper_REPOSITORYNAMES :=
47
48.PHONY : $(WORKDIR)/Misc/PHONY
49$(gb_Helper_MISCDUMMY) :
50	@mkdir -p $(dir $@) && touch $@
51
52define gb_Helper_abbreviate_dirs
53R=$(REPODIR) && \
54$(subst $(REPODIR)/,$$R/,S=$(SRCDIR) && \
55$(subst $(SRCDIR)/,$$S/,O=$(OUTDIR)) && \
56$(subst $(SRCDIR)/,$$S/,$(subst $(OUTDIR)/,$$O/,W=$(WORKDIR) && $(subst $(WORKDIR)/,$$W/,$(1)))))
57endef
58
59define gb_Helper_make_clean_target
60gb_$(1)_get_clean_target = $(WORKDIR)/Clean/$(1)/$$(1)
61
62endef
63
64define gb_Helper_make_outdir_clean_target
65gb_$(1)_get_clean_target = $$(subst $(OUTDIR)/,$(WORKDIR)/Clean/OutDir/,$$(call gb_$(1)_get_target,$$(1)))
66
67endef
68
69define gb_Helper_make_dep_target
70gb_$(1)_get_dep_target = $(WORKDIR)/Dep/$(1)/$$(1).d
71
72endef
73
74define gb_Helper_make_clean_targets
75$(foreach targettype,$(1),\
76	$(call gb_Helper_make_clean_target,$(targettype)))
77
78endef
79
80define gb_Helper_make_outdir_clean_targets
81$(foreach targettype,$(1),\
82	$(call gb_Helper_make_outdir_clean_target,$(targettype)))
83
84endef
85
86define gb_Helper_make_dep_targets
87$(foreach targettype,$(1),\
88	$(call gb_Helper_make_dep_target,$(targettype)))
89
90endef
91
92define gb_Helper_get_outdir_clean_target
93$$(subst $(OUTDIR)/,$(WORKDIR)/Clean/OutDir/,$(1))
94endef
95
96define gb_Helper_register_repository
97gb_Helper_CURRENTREPOSITORY := $(1)
98gb_Helper_REPOSITORYNAMES += $(1)
99
100endef
101
102define gb_Helper_add_repository
103gb_Helper_CURRENTREPOSITORY :=
104include $(1)/Repository.mk
105ifeq ($$(gb_Helper_CURRENTREPOSITORY),)
106$$(eval $$(call gb_Output_error,No call to gb_Helper_register_repository in Repository.mk for repository $(1)))
107endif
108$$(gb_Helper_CURRENTREPOSITORY) := $(1)
109
110endef
111
112define gb_Helper_add_repositories
113$(foreach repo,$(1),$(call gb_Helper_add_repository,$(repo)))
114
115endef
116
117define gb_Helper_init_registries
118gb_Executable_VALIDGROUPS := UREBIN SDK OOO BRAND NONE
119gb_Library_VALIDGROUPS := OOOLIBS PLAINLIBS_NONE PLAINLIBS_URE PLAINLIBS_OOO RTLIBS RTVERLIBS STLLIBS UNOLIBS_URE UNOLIBS_OOO UNOVERLIBS
120gb_StaticLibrary_VALIDGROUPS := PLAINLIBS
121
122$$(foreach group,$$(gb_Executable_VALIDGROUPS),$$(eval gb_Executable_$$(group) :=))
123$$(foreach group,$$(gb_Library_VALIDGROUPS),$$(eval gb_Library_$$(group) :=))
124$$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(eval gb_StaticLibrary_$$(group) :=))
125
126endef
127
128define gb_Helper_collect_libtargets
129gb_Library_TARGETS := $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(gb_Library_$$(group)))
130gb_StaticLibrary_TARGETS := $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(gb_StaticLibrary_$$(group)))
131
132endef
133
134define gb_Helper_collect_knownlibs
135gb_Library_KNOWNLIBS := $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(gb_Library_$$(group)))
136gb_StaticLibrary_KNOWNLIBS := $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(gb_StaticLibrary_$$(group)))
137
138endef
139
140define gb_Helper_register_executables
141ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS)),)
142$$(eval $$(call gb_Output_error,$(1) is not a valid group for executables. Valid groups are: $$(gb_Executable_VALIDGROUPS)))
143endif
144
145gb_Executable_$(1) += $(2)
146
147endef
148
149define gb_Helper_register_libraries
150ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS)),)
151$$(eval $$(call gb_Output_error,$(1) is not a valid group for libraries. Valid groups are: $$(gb_Library_VALIDGROUPS)))
152endif
153
154gb_Library_$(1) += $(2)
155
156endef
157
158define gb_Helper_register_static_libraries
159ifeq ($$(filter $(1),$$(gb_StaticLibrary_VALIDGROUPS)),)
160$$(eval $$(call gb_Output_error,$(1) is not a valid group for static libraries. Valid groups are: $$(gb_StaticLibrary_VALIDGROUPS)))
161endif
162
163gb_StaticLibrary_$(1) += $(2)
164
165endef
166
167# vim: set noet sw=4 ts=4:
168