1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24 25# Module class 26 27gb_Module_ALLMODULES := 28gb_Module_MODULELOCATIONS := 29gb_Module_TARGETSTACK := 30gb_Module_CHECKTARGETSTACK := 31gb_Module_SUBSEQUENTCHECKTARGETSTACK := 32gb_Module_CLEANTARGETSTACK := 33 34.PHONY : $(call gb_Module_get_clean_target,%) 35$(call gb_Module_get_clean_target,%) : 36 $(call gb_Output_announce,$*,$(false),MOD,5) 37 $(call gb_Output_announce_title,module $* cleared.) 38 -$(call gb_Helper_abbreviate_dirs,\ 39 rm -f $(call gb_Module_get_target,$*) $(call gb_Module_get_check_target,$*) $(call gb_Module_get_subsequentcheck_target,$*)) 40 41$(call gb_Module_get_check_target,%) : 42 $(call gb_Output_announce,$*,$(true),CHK,5) 43 $(call gb_Output_announce_title,module $* checks done.) 44 -$(call gb_Helper_abbreviate_dirs,\ 45 mkdir -p $(dir $@) && \ 46 touch $@) 47 48$(call gb_Module_get_subsequentcheck_target,%) : 49 $(call gb_Output_announce,$*,$(true),SCK,5) 50 $(call gb_Output_announce_title,module $* subsequentchecks done.) 51 -$(call gb_Helper_abbreviate_dirs,\ 52 mkdir -p $(dir $@) && \ 53 touch $@) 54 55$(call gb_Module_get_target,%) : 56 $(call gb_Output_announce,$*,$(true),MOD,5) 57 $(call gb_Output_announce_title,module $* done.) 58 -$(call gb_Helper_abbreviate_dirs,\ 59 mkdir -p $(dir $@) && \ 60 touch $@) 61 62.PHONY : all allandcheck clean check subsequentcheck 63.DEFAULT_GOAL := allandcheck 64 65allandcheck : all check 66 67# compatibility with the old build system 68ifneq ($(strip $(OOO_SUBSEQUENT_TESTS)),) 69.DEFAULT_GOAL := subsequentcheck 70endif 71 72all : 73 $(call gb_Output_announce,top level modules: $(foreach module,$(filter-out deliverlog,$^),$(notdir $(module))),$(true),ALL,6) 74 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),ALL,6) 75 $(call gb_Output_announce_title,all done.) 76 $(call gb_Output_announce_bell) 77 78check : 79 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),CHK,6) 80 $(call gb_Output_announce_title,all tests checked.) 81 $(call gb_Output_announce_bell) 82 83subsequentcheck : all 84 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),SCK,6) 85 $(call gb_Output_announce_title,all subsequent tests checked.) 86 $(call gb_Output_announce_bell) 87 88clean : 89 $(call gb_Output_announce,top level modules: $(foreach module,$^,$(notdir $(module))),$(false),ALL,6) 90 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(false),ALL,6) 91 $(call gb_Output_announce_title,all cleared.) 92 $(call gb_Output_announce_bell) 93 94define gb_Module_Module 95gb_Module_ALLMODULES += $(1) 96gb_Module_MODULELOCATIONS += $(1):$(dir $(realpath $(lastword $(MAKEFILE_LIST)))) 97gb_Module_TARGETSTACK := $(call gb_Module_get_target,$(1)) $(gb_Module_TARGETSTACK) 98gb_Module_CHECKTARGETSTACK := $(call gb_Module_get_check_target,$(1)) $(gb_Module_CHECKTARGETSTACK) 99gb_Module_SUBSEQUENTCHECKTARGETSTACK := $(call gb_Module_get_subsequentcheck_target,$(1)) $(gb_Module_SUBSEQUENTCHECKTARGETSTACK) 100gb_Module_CLEANTARGETSTACK := $(call gb_Module_get_clean_target,$(1)) $(gb_Module_CLEANTARGETSTACK) 101 102endef 103 104# This is called inside the included file and pushes one target on each stack. 105# This has to be called with full late evaluation ($$(eval $$(call ))) and 106# should never be inlined ($(call )) as the calls defining it might be sourced 107# before gb_Module. 108define gb_Module_register_target 109gb_Module_CURRENTTARGET := $(1) 110gb_Module_CURRENTCLEANTARGET := $(2) 111 112endef 113 114# Here we include the file (in it there will be a call to gb_Module_register_target) 115define gb_Module__read_targetfile 116gb_Module_CURRENTTARGET := 117gb_Module_CURRENTCLEANTARGET := 118include $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS)))$(2).mk 119ifneq ($$(words $$(gb_Module_CURRENTTARGET)) $$(words $$(gb_Module_CURRENTCLEANTARGET)),1 1) 120$$(eval $$(call gb_Output_error,No $(3) registered while reading $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS)))$(2).mk!)) 121endif 122 123endef 124 125define gb_Module_add_target 126$(call gb_Module__read_targetfile,$(1),$(2),target) 127 128$(call gb_Module_get_target,$(1)) : $$(gb_Module_CURRENTTARGET) 129$(call gb_Module_get_clean_target,$(1)) : $$(gb_Module_CURRENTCLEANTARGET) 130 131endef 132 133define gb_Module_add_check_target 134$(call gb_Module__read_targetfile,$(1),$(2),check target) 135 136$(call gb_Module_get_check_target,$(1)) : $$(gb_Module_CURRENTTARGET) 137$(call gb_Module_get_clean_target,$(1)) : $$(gb_Module_CURRENTCLEANTARGET) 138 139endef 140 141define gb_Module_add_subsequentcheck_target 142$(call gb_Module__read_targetfile,$(1),$(2),subsequentcheck target) 143 144$(call gb_Module_get_subsequentcheck_target,$(1)) : $$(gb_Module_CURRENTTARGET) 145$(call gb_Module_get_clean_target,$(1)) : $$(gb_Module_CURRENTCLEANTARGET) 146 147endef 148 149define gb_Module_add_moduledir 150include $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS)))/$(2)/Module_$(2).mk 151$(call gb_Module_get_target,$(1)) : $$(firstword $$(gb_Module_TARGETSTACK)) 152$(call gb_Module_get_check_target,$(1)) : $$(firstword $$(gb_Module_CHECKTARGETSTACK)) 153$(call gb_Module_get_subsequentcheck_target,$(1)) : $$(firstword $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)) 154$(call gb_Module_get_clean_target,$(1)) : $$(firstword $$(gb_Module_CLEANTARGETSTACK)) 155gb_Module_TARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_TARGETSTACK)),$$(gb_Module_TARGETSTACK)) 156gb_Module_CHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_CHECKTARGETSTACK)),$$(gb_Module_CHECKTARGETSTACK)) 157gb_Module_SUBSEQUENTCHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)) 158gb_Module_CLEANTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_CLEANTARGETSTACK)),$$(gb_Module_CLEANTARGETSTACK)) 159 160endef 161 162define gb_Module_add_targets 163$(foreach target,$(2),$(call gb_Module_add_target,$(1),$(target))) 164 165endef 166 167define gb_Module_add_check_targets 168$(foreach target,$(2),$(call gb_Module_add_check_target,$(1),$(target))) 169 170endef 171 172define gb_Module_add_subsequentcheck_targets 173$(foreach target,$(2),$(call gb_Module_add_subsequentcheck_target,$(1),$(target))) 174 175endef 176 177define gb_Module_add_moduledirs 178$(foreach target,$(2),$(call gb_Module_add_moduledir,$(1),$(target))) 179endef 180 181define gb_Module_make_global_targets 182ifneq ($$(gb_Module_TARGETSTACK),) 183$$(eval $$(call gb_Output_error,Corrupted module target stack!1)) 184endif 185 186include $(1) 187 188all : $$(firstword $$(gb_Module_TARGETSTACK)) 189check : $$(firstword $$(gb_Module_CHECKTARGETSTACK)) 190subsequentcheck : $$(firstword $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)) 191clean : $$(firstword $$(gb_Module_CLEANTARGETSTACK)) 192 193ifneq ($$(words $$(gb_Module_TARGETSTACK)),1) 194$$(eval $$(call gb_Output_error,Corrupted module target stack! $(gb_Module_TARGETSTACK))) 195endif 196 197gb_Module_TARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_TARGETSTACK)),$$(gb_Module_TARGETSTACK)) 198gb_Module_CHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_CHECKTARGETSTACK)),$$(gb_Module_CHECKTARGETSTACK)) 199gb_Module_SUBSEQUENTCHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)) 200gb_Module_CLEANTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_CLEANTARGETSTACK)),$$(gb_Module_CLEANTARGETSTACK)) 201 202ifneq ($$(and $$(gb_Module_TARGETSTACK),$$(gb_Module_CHECKTARGETSTACK),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)),) 203$$(eval $$(call gb_Output_error,Corrupted module target stack!3)) 204endif 205 206endef 207 208# vim: set noet sw=4 ts=4: 209