blob: fa45475a2ded2739875d2f20e7c7113d6e98d445 [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 rule to expand for each component
8# definition file found
9
10
11define def_file_rule
12
13 # Clear out all possible variables a component definition file
14 # may define
15 def_file :=
16 def_path :=
17 def_deps :=
18 def_include_subdir :=
19 def_source_subdir :=
20 def_resource_subdir :=
21 name :=
22 type :=
23 lang :=
24 header_list :=
25 resource_list :=
26 source_list :=
27 definition_list :=
28 source_lib_list :=
29 lib_list :=
30 static_lib_list :=
31 lib_path_list :=
32 include_path_list :=
33 compiler_flag_list :=
34 link_flag_list :=
35
36
37 $$(call debug_info,including def: $(1))
38
39 def_file := $(1)
40 def_path := $$(call def_file_to_root_path,$$(def_file))
41 def_deps := $$(def_file) $$(config_file) $$(def_deps)
42
43
44 ifeq ($$(def_include_subdir),)
45 def_include_subdir := $$(include_subdir)
46 endif
47
48 ifeq ($$(def_source_subdir),)
49 def_source_subdir := $$(source_subdir)
50 endif
51
52 ifeq ($$(def_resource_subdir),)
53 def_resource_subdir := $$(resource_subdir)
54 endif
55
56
57 # Include the found component definition file
58 include $$(def_file)
59
60 # Custom component definition files might not bother with a name so skip the below stuff if
61 # that's the case'
62 ifneq ($$(name),)
63 ifneq ($$(filter $$(name), $$(build_target_list)),)
64 $$(call def_error,duplicate component name used here: $$($$(name).def_file))
65 endif
66
67 $$(name).def_file := $$(def_file)
68
69 # Include the config file again after including the definition file.
70 # This way a config file could specify component-specific settings
71 -include $$(config_file)
72
73
74 # If a header list was specified, include header rules
75 ifneq ($$(header_list),)
76 include $$(weld_path)/headers.mk
77 endif
78
79 # If a resource list was specified, include resourcerules
80 ifneq ($$(resource_list),)
81 include $$(weld_path)/resources.mk
82 endif
83
84 # If the type is set to bin or lib include the compilation rules for the
85 # specified language
86 ifneq ($$(filter bin lib,$$(type)),)
87 include $$(weld_path)/lang/$$(lang).mk
88 endif
89
90 # Add the found component to the standard set of build targets
91 build_target_list := $$(name) $$(build_target_list)
92 headers_target_list := $$(name)_headers $$(headers_target_list)
93 clean_target_list := clean_$$(name) $$(clean_target_list)
94 clean_headers_target_list := clean_$$(name)_headers
95
96
97 # Declare default targets for this component. Various component rules
98 # may add build steps as dependencies to these targets
99 .PHONY : $$(name)_headers
100 $$(name)_headers : $$(name)_def_headers
101 $$(name)_headers :
102
103 .PHONY : $$(name)_def_headers
104 $$(name)_def_headers :
105
106 .PHONY : clean_$$(name)_headers
107 clean_$$(name)_headers : clean_$$(name)_def_headers
108 clean_$$(name)_headers :
109
110 .PHONY : clean_$$(name)_def_headers
111 clean_$$(name)_def_headers :
112
113 .PHONY : $$(name)_compile
114 $$(name)_compile : $$(name)_def_compile
115 $$(name)_compile :
116
117 .PHONY : $$(name)_def_compile
118 $$(name)_def_compile :
119
120 .PHONY : clean_$$(name)_compile
121 clean_$$(name)_compile : clean_$$(name)_def_compile
122 clean_$$(name)_compile :
123
124 .PHONY : clean_$$(name)_def_compile
125 clean_$$(name)_def_compile :
126
127 .PHONY : $$(name)_resources
128 $$(name)_resources : $$(name)_def_resources
129 $$(name)_resources :
130
131 .PHONY : $$(name)_def_resources
132 $$(name)_def_resources :
133
134 .PHONY : clean_$$(name)_resources
135 clean_$$(name)_resources : clean_$$(name)_def_resources
136 clean_$$(name)_resources :
137
138 .PHONY : clean_$$(name)_def_resources
139 clean_$$(name)_def_resources :
140
141 # Define the "make <name>" target for the component. This target
142 # should build the entire component
143 .PHONY : $$(name)
144 $$(name) : $$(name)_headers
145 $$(name) : $$(name)_compile
146 $$(name) : $$(name)_resources
147 $$(name) :
148
149 .PHONY : clean_$$(name)
150 clean_$$(name) : clean_$$(name)_headers
151 clean_$$(name) : clean_$$(name)_compile
152 clean_$$(name) : clean_$$(name)_resources
153 clean_$$(name) :
154 endif
155
156endef