Bump for 3.6-28
[LibreOffice.git] / solenv / gbuild / Helper.mk
blob93a0ad7cb1e9f29816cb387e95b666e01c613135
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2 #*************************************************************************
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 #
6 # Copyright 2000, 2010 Oracle and/or its affiliates.
8 # OpenOffice.org - a multi-platform office productivity suite
10 # This file is part of OpenOffice.org.
12 # OpenOffice.org is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License version 3
14 # only, as published by the Free Software Foundation.
16 # OpenOffice.org is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU Lesser General Public License version 3 for more details
20 # (a copy is included in the LICENSE file that accompanied this code).
22 # You should have received a copy of the GNU Lesser General Public License
23 # version 3 along with OpenOffice.org. If not, see
24 # <http://www.openoffice.org/license.html>
25 # for a copy of the LGPLv3 License.
27 #*************************************************************************
29 gb_Helper_NULLFILE := /dev/null
31 gb_Helper_MISC := $(WORKDIR)/Misc
33 # general purpose phony target
34 gb_Helper_PHONY := $(gb_Helper_MISC)/PHONY
36 # general purpose empty dummy target
37 gb_Helper_MISCDUMMY := $(gb_Helper_MISC)/DUMMY
39 .PHONY : $(WORKDIR)/Misc/PHONY
40 $(gb_Helper_MISCDUMMY) :
41 @mkdir -p $(dir $@) && touch $@
43 define gb_Helper_abbreviate_dirs
44 S=$(SRCDIR) && \
45 $(subst $(SRCDIR)/,$$S/,O=$(OUTDIR)) && \
46 $(subst $(SRCDIR)/,$$S/,W=$(WORKDIR)) && \
47 $(subst $(SRCDIR)/,$$S/,$(subst $(OUTDIR)/,$$O/,$(subst $(WORKDIR)/,$$W/,$(1))))
48 endef
50 define gb_Helper_abbreviate_dirs_native
51 $(call gb_Output_error,gb_Helper_abbreviate_dirs_native: use gb_Helper_abbreviate_dirs instead.)
52 endef
54 define gb_Helper_native_path
55 $(call gb_Output_error,gb_Helper_native_path: Do not use. Should not be necessary.)
56 endef
58 define gb_Helper_make_clean_target
59 gb_$(1)_get_clean_target = $(WORKDIR)/Clean/$(1)/$$(1)
61 endef
63 define gb_Helper_make_outdir_clean_target
64 gb_$(1)_get_clean_target = $$(subst $(OUTDIR)/,$(WORKDIR)/Clean/OutDir/,$$(call gb_$(1)_get_target,$$(1)))
66 endef
68 define gb_Helper_make_dep_target
69 gb_$(1)_get_dep_target = $(WORKDIR)/Dep/$(1)/$$(1).d
71 endef
73 define gb_Helper_make_clean_targets
74 $(foreach targettype,$(1),\
75 $(call gb_Helper_make_clean_target,$(targettype)))
77 endef
79 define gb_Helper_make_outdir_clean_targets
80 $(foreach targettype,$(1),\
81 $(call gb_Helper_make_outdir_clean_target,$(targettype)))
83 endef
85 define gb_Helper_make_dep_targets
86 $(foreach targettype,$(1),\
87 $(call gb_Helper_make_dep_target,$(targettype)))
89 endef
91 define gb_Helper_get_outdir_clean_target
92 $$(subst $(OUTDIR)/,$(WORKDIR)/Clean/OutDir/,$(1))
93 endef
95 # RepositoryExternal.mk is optional
96 define gb_Helper_add_repository
97 include $(1)/Repository.mk
98 -include $(1)/RepositoryExternal.mk
100 endef
102 define gb_Helper_add_repositories
103 $(foreach repo,$(1),$(call gb_Helper_add_repository,$(repo)))
105 endef
107 define gb_Helper_init_registries
108 gb_Executable_VALIDGROUPS := UREBIN SDK OOO NONE
109 gb_Library_VALIDGROUPS := OOOLIBS PLAINLIBS_NONE PLAINLIBS_URE PLAINLIBS_OOO RTLIBS RTVERLIBS UNOLIBS_URE UNOLIBS_OOO UNOVERLIBS EXTENSIONLIBS
110 gb_StaticLibrary_VALIDGROUPS := PLAINLIBS
112 $$(foreach group,$$(gb_Executable_VALIDGROUPS),$$(eval gb_Executable_$$(group) :=))
113 $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(eval gb_Library_$$(group) :=))
114 $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(eval gb_StaticLibrary_$$(group) :=))
116 endef
118 define gb_Helper_collect_libtargets
119 gb_Library_TARGETS := $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(gb_Library_$$(group)))
120 gb_StaticLibrary_TARGETS := $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(gb_StaticLibrary_$$(group)))
122 endef
124 define gb_Helper_collect_knownlibs
125 gb_Library_KNOWNLIBS := $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(gb_Library_$$(group)))
126 gb_StaticLibrary_KNOWNLIBS := $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(gb_StaticLibrary_$$(group)))
127 gb_Executable_KNOWN := $$(foreach group,$$(gb_Executable_VALIDGROUPS),$$(gb_Executable_$$(group)))
129 endef
131 define gb_Helper_register_executables
132 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS)),)
133 $$(eval $$(call gb_Output_error,$(1) is not a valid group for executables. Valid groups are: $$(gb_Executable_VALIDGROUPS)))
134 endif
135 $(foreach group,$(gb_Executable_VALIDGROUPS),\
136 $(foreach target,$(2),\
137 $(if $(filter $(target),$(gb_Executable_$(group))),\
138 $(call gb_Output_error,gb_Helper_register_executables: already registered: $(target)))))
139 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
140 $(call gb_Output_error,gb_Helper_register_executables: contains duplicates: $(2)))
142 gb_Executable_$(1) += $(2)
144 endef
146 define gb_Helper_register_libraries
147 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS)),)
148 $$(eval $$(call gb_Output_error,$(1) is not a valid group for libraries. Valid groups are: $$(gb_Library_VALIDGROUPS)))
149 endif
150 $(foreach group,$(gb_Library_VALIDGROUPS),\
151 $(foreach target,$(2),\
152 $(if $(filter $(target),$(gb_Library_$(group))),\
153 $(call gb_Output_error,gb_Helper_register_libraries: already registered: $(target)))))
154 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
155 $(call gb_Output_error,gb_Helper_register_libraries: contains duplicates: $(2)))
157 gb_Library_$(1) += $(2)
159 endef
161 define gb_Helper_register_static_libraries
162 ifeq ($$(filter $(1),$$(gb_StaticLibrary_VALIDGROUPS)),)
163 $$(eval $$(call gb_Output_error,$(1) is not a valid group for static libraries. Valid groups are: $$(gb_StaticLibrary_VALIDGROUPS)))
164 endif
165 $(foreach group,$(gb_StaticLibrary_VALIDGROUPS),\
166 $(foreach target,$(2),\
167 $(if $(filter $(target),$(gb_StaticLibrary_$(group))),\
168 $(call gb_Output_error,gb_Helper_register_static_libraries: already registered: $(target)))))
169 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
170 $(call gb_Output_error,gb_Helper_register_static_libraries: contains duplicates: $(2)))
172 gb_StaticLibrary_$(1) += $(2)
174 endef
176 define gb_Helper_execute
177 $(gb_Helper_set_ld_path) $(OUTDIR_FOR_BUILD)/bin/$(1)
178 endef
180 # gb_Helper_OUTDIRLIBDIR is set by the platform to the path the dynamic linker need to use
181 # for libraries from the OUTDIR
183 # vim: set noet sw=4 ts=4: