blob: fcb7247c10fc9b8852ca0a8c2af39389311f6ceb [file] [log] [blame]
Matthias Andreas Benkardf59e0972018-04-10 22:01:34 +02001# Copyright 2015 Andrew Gottemoller.
2#
3# This software is a copyrighted work licensed under the terms of the
4# Weld license. Please consult the file "WELD_LICENSE" for
5# details.
6
7# This makefile defines the set of rules for a resource list
8
9
10# This makefile is included for each component definition so clear out
11# any variables used by this makefile
12def_resource_path :=
13resource_file :=
14def_resource_file :=
15resource_alias :=
16dest_path :=
17resource_goal_list :=
18
19
20# Figure out the resource path for this component definition
21def_resource_path := $(def_path)/$(def_resource_subdir)
22
23define resource_file_rule
24
25 $$(call debug_info,resource specified: $(1))
26
27 resource_file := $(1)
28 def_resource_file := $$(def_resource_path)/$$(resource_file)
29 resource_alias := $$(resource_file)
30
31 dest_path := $$(dir $$(resource_output_path)/$$(resource_file))
32
33 resource_goal_list := $$(resource_alias) $$(resource_goal_list)
34
35 directory_list := $$(dest_path) $$(directory_list)
36
37 # Define an alias for the resource file so the user can do
38 # "make path/to/resource" on the command line
39 vpath $$(resource_alias) $$(resource_output_path)
40
41 # Set the target specific variables and dependencies for this resource
42 $$(resource_alias) : resource_output_path := $$(resource_output_path)
43 $$(resource_alias) : def_resource_file := $$(def_resource_file)
44 $$(resource_alias) : resource_alias := $$(resource_alias)
45 $$(resource_alias) : $$(def_deps)
46 $$(resource_alias) : $$(def_resource_file)
47 $$(resource_alias) : | $$(dest_path)
48
49endef
50
51
52# Expand the resource rule for each resource specified
53$(foreach file,$(resource_list),$(eval $(call resource_file_rule,$(file))))
54
55
56# Add the list of resource goals as a dependency of the component definition's
57# headers target
58$(name)_def_resources : $(resource_goal_list)
59
60# Define the actual recipe for a resource
61$(resource_goal_list) :
62 $(call print_progress,$(resource_alias))
63 $(call soft_copy,$(def_resource_file),$(resource_output_path)/$(resource_alias))
64
65.PHONY : clean_$(name)_resources
66clean_$(name)_resources : resource_output_path := $(resource_output_path)
67clean_$(name)_resources : resource_goal_list := $(resource_goal_list)
68clean_$(name)_resources :
69 $(call print_progress,$@)
70 $(call remove_files,$(addprefix $(resource_output_path)/,$(resource_goal_list)))