Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / solenv / gbuild / Helper.mk
blobe1e5119b07ce5d9844b1fc7bde295b04082f30c4
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_MISC := $(WORKDIR)/Misc
31 # general purpose phony target
32 gb_Helper_PHONY := $(gb_Helper_MISC)/PHONY
34 # general purpose empty dummy target
35 gb_Helper_MISCDUMMY := $(gb_Helper_MISC)/DUMMY
37 .PHONY : $(WORKDIR)/Misc/PHONY
38 $(gb_Helper_MISCDUMMY) :
39 @mkdir -p $(dir $@) && touch $@
41 define gb_Helper_abbreviate_dirs
42 S=$(SRCDIR) && \
43 $(subst $(SRCDIR)/,$$S/,O=$(OUTDIR)) && \
44 $(subst $(SRCDIR)/,$$S/,W=$(WORKDIR)) && \
45 $(subst $(SRCDIR)/,$$S/,$(subst $(OUTDIR)/,$$O/,$(subst $(WORKDIR)/,$$W/,$(1))))
46 endef
48 define gb_Helper_abbreviate_dirs_native
49 $(call gb_Output_error,gb_Helper_abbreviate_dirs_native: use gb_Helper_abbreviate_dirs instead.)
50 endef
52 define gb_Helper_native_path
53 $(call gb_Output_error,gb_Helper_native_path: Do not use. Should not be necessary.)
54 endef
56 # cygwin seems to eat one backslash when executing command, thus replace with '\\'
57 define gb_Helper_windows_path
58 $(subst /,\\,$(1))
59 endef
61 define gb_Helper_make_clean_target
62 gb_$(1)_get_clean_target = $(WORKDIR)/Clean/$(1)/$$(1)
64 endef
66 define gb_Helper_make_outdir_clean_target
67 gb_$(1)_get_clean_target = $$(subst $(OUTDIR)/,$(WORKDIR)/Clean/OutDir/,$$(call gb_$(1)_get_target,$$(1)))
69 endef
71 define gb_Helper_make_dep_target
72 gb_$(1)_get_dep_target = $(WORKDIR)/Dep/$(1)/$$(1).d
74 endef
76 define gb_Helper_make_clean_targets
77 $(foreach targettype,$(1),\
78 $(call gb_Helper_make_clean_target,$(targettype)))
80 endef
82 define gb_Helper_make_outdir_clean_targets
83 $(foreach targettype,$(1),\
84 $(call gb_Helper_make_outdir_clean_target,$(targettype)))
86 endef
88 define gb_Helper_make_dep_targets
89 $(foreach targettype,$(1),\
90 $(call gb_Helper_make_dep_target,$(targettype)))
92 endef
94 define gb_Helper_get_outdir_clean_target
95 $$(subst $(OUTDIR)/,$(WORKDIR)/Clean/OutDir/,$(1))
96 endef
98 define gb_Helper_init_registries
99 gb_Executable_VALIDGROUPS := UREBIN SDK OOO NONE
100 gb_Library_VALIDGROUPS := OOOLIBS PLAINLIBS_NONE PLAINLIBS_URE PLAINLIBS_OOO RTLIBS RTVERLIBS UNOLIBS_URE UNOLIBS_OOO UNOVERLIBS EXTENSIONLIBS
101 gb_StaticLibrary_VALIDGROUPS := PLAINLIBS
102 gb_Jar_VALIDGROUPS := URE OOO OXT
104 $$(foreach group,$$(gb_Executable_VALIDGROUPS),$$(eval gb_Executable_$$(group) :=))
105 $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(eval gb_Library_$$(group) :=))
106 $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(eval gb_StaticLibrary_$$(group) :=))
107 $$(foreach group,$$(gb_Jar_VALIDGROUPS),$$(eval gb_Jar_$$(group) :=))
109 endef
111 define gb_Helper_collect_knownlibs
112 gb_Library_KNOWNLIBS := $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(gb_Library_$$(group)))
113 gb_StaticLibrary_KNOWNLIBS := $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(gb_StaticLibrary_$$(group)))
114 gb_Executable_KNOWN := $$(foreach group,$$(gb_Executable_VALIDGROUPS),$$(gb_Executable_$$(group)))
115 gb_Jar_KNOWN := $$(foreach group,$$(gb_Jar_VALIDGROUPS),$$(gb_Jar_$$(group)))
117 endef
119 define gb_Helper_register_executables
120 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS)),)
121 $$(eval $$(call gb_Output_error,$(1) is not a valid group for executables. Valid groups are: $$(gb_Executable_VALIDGROUPS)))
122 endif
123 $(foreach group,$(gb_Executable_VALIDGROUPS),\
124 $(foreach target,$(2),\
125 $(if $(filter $(target),$(gb_Executable_$(group))),\
126 $(call gb_Output_error,gb_Helper_register_executables: already registered: $(target)))))
127 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
128 $(call gb_Output_error,gb_Helper_register_executables: contains duplicates: $(2)))
130 gb_Executable_$(1) += $(2)
132 endef
134 define gb_Helper_register_libraries
135 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS)),)
136 $$(eval $$(call gb_Output_error,$(1) is not a valid group for libraries. Valid groups are: $$(gb_Library_VALIDGROUPS)))
137 endif
138 $(foreach group,$(gb_Library_VALIDGROUPS),\
139 $(foreach target,$(2),\
140 $(if $(filter $(target),$(gb_Library_$(group))),\
141 $(call gb_Output_error,gb_Helper_register_libraries: already registered: $(target)))))
142 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
143 $(call gb_Output_error,gb_Helper_register_libraries: contains duplicates: $(2)))
145 gb_Library_$(1) += $(2)
147 endef
149 define gb_Helper_register_static_libraries
150 ifeq ($$(filter $(1),$$(gb_StaticLibrary_VALIDGROUPS)),)
151 $$(eval $$(call gb_Output_error,$(1) is not a valid group for static libraries. Valid groups are: $$(gb_StaticLibrary_VALIDGROUPS)))
152 endif
153 $(foreach group,$(gb_StaticLibrary_VALIDGROUPS),\
154 $(foreach target,$(2),\
155 $(if $(filter $(target),$(gb_StaticLibrary_$(group))),\
156 $(call gb_Output_error,gb_Helper_register_static_libraries: already registered: $(target)))))
157 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
158 $(call gb_Output_error,gb_Helper_register_static_libraries: contains duplicates: $(2)))
160 gb_StaticLibrary_$(1) += $(2)
162 endef
164 define gb_Helper_register_jars
165 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS)),)
166 $$(eval $$(call gb_Output_error,$(1) is not a valid group for jars. Valid groups are: $$(gb_Jar_VALIDGROUPS)))
167 endif
168 $(foreach group,$(gb_Jar_VALIDGROUPS),\
169 $(foreach target,$(2),\
170 $(if $(filter $(target),$(gb_Jar_$(group))),\
171 $(call gb_Output_error,gb_Helper_register_jars: already registered: $(target)))))
172 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
173 $(call gb_Output_error,gb_Helper_register_jars: contains duplicates: $(2)))
175 gb_Jar_$(1) += $(2)
177 endef
179 define gb_Helper_define_if_set
180 $(foreach def,$(1),$(if $(filter TRUE YES,$($(def))),-D$(def)))
181 endef
183 define gb_Helper_execute
184 $(gb_Helper_set_ld_path) $(OUTDIR_FOR_BUILD)/bin/$(1)
185 endef
187 # gb_Helper_OUTDIRLIBDIR is set by the platform to the path the dynamic linker need to use
188 # for libraries from the OUTDIR
190 define gb_Helper_optional
191 $(if $(filter $(1),$(BUILD_TYPE)),$(2))
192 endef
194 # vim: set noet sw=4 ts=4: