1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2 #*************************************************************************
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 # Copyright 2000, 2011 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 #*************************************************************************
30 # Overview of dependencies and tasks of Module
32 # target task depends on
33 # Module build the product all product targets
34 # excluding tests recursive Modules
35 # Module/unitcheck run unit tests all unit tests
36 # recursive Module/checks
37 # Module/subsequentcheck run system tests all system tests
38 # recursive Module/subsequentchecks
39 # all (global) build the product top-level Module
40 # unitcheck (global) run unit tests top-level Module/unitcheck
41 # subsequentcheck (global) run system tests top-level Module/subsequentcheck
42 # allandcheck (global) default goal all unitcheck
47 gb_Module_ALLMODULES
:=
48 gb_Module_MODULELOCATIONS
:=
49 gb_Module_TARGETSTACK
:=
50 gb_Module_CHECKTARGETSTACK
:=
51 gb_Module_SUBSEQUENTCHECKTARGETSTACK
:=
52 gb_Module_CLEANTARGETSTACK
:=
54 .PHONY
: $(call gb_Module_get_clean_target
,%)
55 $(call gb_Module_get_clean_target
,%) :
56 $(call gb_Output_announce
,$*,$(false
),MOD
,5)
57 $(call gb_Output_announce_title
,module
$* cleared.
)
58 -$(call gb_Helper_abbreviate_dirs
,\
59 rm -f
$(call gb_Module_get_target
,$*) $(call gb_Module_get_check_target
,$*) $(call gb_Module_get_subsequentcheck_target
,$*))
61 $(call gb_Module_get_check_target
,%) :
62 $(call gb_Output_announce
,$*,$(true
),CHK
,5)
63 $(call gb_Output_announce_title
,module
$* checks done.
)
64 -$(call gb_Helper_abbreviate_dirs
,\
65 mkdir
-p
$(dir $@
) && \
68 $(call gb_Module_get_subsequentcheck_target
,%) :
69 $(call gb_Output_announce
,$*,$(true
),SCK
,5)
70 $(call gb_Output_announce_title
,module
$* subsequentchecks done.
)
71 -$(call gb_Helper_abbreviate_dirs
,\
72 mkdir
-p
$(dir $@
) && \
75 $(call gb_Module_get_target
,%) :
76 $(call gb_Output_announce
,$*,$(true
),MOD
,5)
77 $(call gb_Output_announce_title
,module
$* done.
)
78 -$(call gb_Helper_abbreviate_dirs
,\
79 mkdir
-p
$(dir $@
) && \
82 .PHONY
: all allandcheck
clean unitcheck subsequentcheck
83 .DEFAULT_GOAL
:= allandcheck
85 allandcheck
: all unitcheck
87 # compatibility with the old build system
88 ifneq ($(strip $(OOO_SUBSEQUENT_TESTS
)),)
89 .DEFAULT_GOAL
:= subsequentcheck
93 $(call gb_Output_announce
,top level modules
: $(foreach module
,$(filter-out deliverlog
,$^
),$(notdir $(module
))),$(true
),ALL
,6)
94 $(call gb_Output_announce
,loaded modules
: $(sort $(gb_Module_ALLMODULES
)),$(true
),ALL
,6)
95 $(call gb_Output_announce_title
,all done.
)
96 $(call gb_Output_announce_bell
)
99 $(call gb_Output_announce
,loaded modules
: $(sort $(gb_Module_ALLMODULES
)),$(true
),CHK
,6)
100 $(call gb_Output_announce_title
,all tests checked.
)
101 $(call gb_Output_announce_bell
)
103 # removing the dependency on all for now until we can make a full build with gbuild
104 #subsequentcheck : all
106 $(call gb_Output_announce
,loaded modules
: $(sort $(gb_Module_ALLMODULES
)),$(true
),SCK
,6)
107 $(call gb_Output_announce_title
,all subsequent tests checked.
)
108 $(call gb_Output_announce_bell
)
111 $(call gb_Output_announce
,top level modules
: $(foreach module
,$^
,$(notdir $(module
))),$(false
),ALL
,6)
112 $(call gb_Output_announce
,loaded modules
: $(sort $(gb_Module_ALLMODULES
)),$(false
),ALL
,6)
113 $(call gb_Output_announce_title
,all cleared.
)
114 $(call gb_Output_announce_bell
)
116 define gb_Module_Module
117 gb_Module_ALLMODULES
+= $(1)
118 gb_Module_MODULELOCATIONS
+= $(1):$(dir $(realpath
$(lastword
$(MAKEFILE_LIST
))))
119 gb_Module_TARGETSTACK
:= $(call gb_Module_get_target
,$(1)) $(gb_Module_TARGETSTACK
)
120 gb_Module_CHECKTARGETSTACK
:= $(call gb_Module_get_check_target
,$(1)) $(gb_Module_CHECKTARGETSTACK
)
121 gb_Module_SUBSEQUENTCHECKTARGETSTACK
:= $(call gb_Module_get_subsequentcheck_target
,$(1)) $(gb_Module_SUBSEQUENTCHECKTARGETSTACK
)
122 gb_Module_CLEANTARGETSTACK
:= $(call gb_Module_get_clean_target
,$(1)) $(gb_Module_CLEANTARGETSTACK
)
126 # This is called inside the included file and pushes one target on each stack.
127 # This has to be called with full late evaluation ($$(eval $$(call ))) and
128 # should never be inlined ($(call )) as the calls defining it might be sourced
130 define gb_Module_register_target
131 gb_Module_CURRENTTARGET
:= $(1)
132 gb_Module_CURRENTCLEANTARGET
:= $(2)
136 # Here we include the file (in it there will be a call to gb_Module_register_target)
137 define gb_Module__read_targetfile
138 gb_Module_CURRENTTARGET
:=
139 gb_Module_CURRENTCLEANTARGET
:=
140 include $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS
)))$(2).mk
141 ifneq ($$(words $$(gb_Module_CURRENTTARGET
)) $$(words $$(gb_Module_CURRENTCLEANTARGET
)),1 1)
142 $$(eval
$$(call gb_Output_error
,No
$(3) registered while reading
$(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS
)))$(2).mk
!))
147 define gb_Module_add_target
148 $(call gb_Module__read_targetfile
,$(1),$(2),target
)
150 $(call gb_Module_get_target
,$(1)) : $$(gb_Module_CURRENTTARGET
)
151 $(call gb_Module_get_clean_target
,$(1)) : $$(gb_Module_CURRENTCLEANTARGET
)
155 # We don't build normal unit test dynamic libraries (CppUnit
156 # "plugins") for iOS, but instead statically linked unit test
157 # executables, so make gb_Module_add_check_target a no-op for iOS.
159 # As such we could build normal "plugins", as dynamic loading of
160 # modules presumably does work on iOS, it is just not allowed in apps
161 # distributed through the App Store. Unit testing at LO development
162 # time obviously is not anything that would be distributed as
163 # apps. But let's not, as we have to make this stuff work without
164 # dynamic loading anyway if the App Store is an eventual target, and
165 # why shouldn't it be.
167 define gb_Module_add_check_target
168 $(if
$(filter-out IOS
,$(OS
)),\
169 $(call gb_Module__read_targetfile
,$(1),$(2),check target
)
171 $(call gb_Module_get_check_target
,$(1)) : $$(gb_Module_CURRENTTARGET
)
172 $(call gb_Module_get_clean_target
,$(1)) : $$(gb_Module_CURRENTCLEANTARGET
)
177 define gb_Module_add_subsequentcheck_target
178 $(call gb_Module__read_targetfile
,$(1),$(2),subsequentcheck target
)
180 $(call gb_Module_get_subsequentcheck_target
,$(1)) : $$(gb_Module_CURRENTTARGET
)
181 $(call gb_Module_get_clean_target
,$(1)) : $$(gb_Module_CURRENTCLEANTARGET
)
185 define gb_Module_add_moduledir
186 include $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS
)))/$(2)/Module_
$(2).mk
187 $(call gb_Module_get_target
,$(1)) : $$(firstword $$(gb_Module_TARGETSTACK
))
188 $(call gb_Module_get_check_target
,$(1)) : $$(firstword $$(gb_Module_CHECKTARGETSTACK
))
189 $(call gb_Module_get_subsequentcheck_target
,$(1)) : $$(firstword $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK
))
190 $(call gb_Module_get_clean_target
,$(1)) : $$(firstword $$(gb_Module_CLEANTARGETSTACK
))
191 gb_Module_TARGETSTACK
:= $$(wordlist
2,$$(words $$(gb_Module_TARGETSTACK
)),$$(gb_Module_TARGETSTACK
))
192 gb_Module_CHECKTARGETSTACK
:= $$(wordlist
2,$$(words $$(gb_Module_CHECKTARGETSTACK
)),$$(gb_Module_CHECKTARGETSTACK
))
193 gb_Module_SUBSEQUENTCHECKTARGETSTACK
:= $$(wordlist
2,$$(words $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK
)),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK
))
194 gb_Module_CLEANTARGETSTACK
:= $$(wordlist
2,$$(words $$(gb_Module_CLEANTARGETSTACK
)),$$(gb_Module_CLEANTARGETSTACK
))
198 define gb_Module_add_targets
199 $(foreach target
,$(2),$(call gb_Module_add_target
,$(1),$(target
)))
203 define gb_Module_add_check_targets
204 $(foreach target
,$(2),$(call gb_Module_add_check_target
,$(1),$(target
)))
208 define gb_Module_add_subsequentcheck_targets
209 $(foreach target
,$(2),$(call gb_Module_add_subsequentcheck_target
,$(1),$(target
)))
213 define gb_Module_add_moduledirs
214 $(foreach target
,$(2),$(call gb_Module_add_moduledir
,$(1),$(target
)))
217 define gb_Module_make_global_targets
218 ifneq ($$(gb_Module_TARGETSTACK
),)
219 $$(eval
$$(call gb_Output_error
,Corrupted module target stack
!1))
224 all : $$(firstword $$(gb_Module_TARGETSTACK
))
225 unitcheck
: $$(firstword $$(gb_Module_CHECKTARGETSTACK
))
226 subsequentcheck
: $$(firstword $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK
))
227 clean : $$(firstword $$(gb_Module_CLEANTARGETSTACK
))
229 ifneq ($$(words $$(gb_Module_TARGETSTACK
)),1)
230 $$(eval
$$(call gb_Output_error
,Corrupted module target stack
! $(gb_Module_TARGETSTACK
)))
233 gb_Module_TARGETSTACK
:= $$(wordlist
2,$$(words $$(gb_Module_TARGETSTACK
)),$$(gb_Module_TARGETSTACK
))
234 gb_Module_CHECKTARGETSTACK
:= $$(wordlist
2,$$(words $$(gb_Module_CHECKTARGETSTACK
)),$$(gb_Module_CHECKTARGETSTACK
))
235 gb_Module_SUBSEQUENTCHECKTARGETSTACK
:= $$(wordlist
2,$$(words $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK
)),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK
))
236 gb_Module_CLEANTARGETSTACK
:= $$(wordlist
2,$$(words $$(gb_Module_CLEANTARGETSTACK
)),$$(gb_Module_CLEANTARGETSTACK
))
238 ifneq ($$(and
$$(gb_Module_TARGETSTACK
),$$(gb_Module_CHECKTARGETSTACK
),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK
)),)
239 $$(eval
$$(call gb_Output_error
,Corrupted module target stack
!3))
242 $$(eval
$$(gb_Extensions_final_hook
))
245 # vim: set noet sw=4: