blob: 2e8032d266d1ba06514cbe3d8e4b1d47411b880e [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 header list
8
9
10# This makefile is included for each component definition so clear out
11# any variables used by this makefile
12def_header_path :=
13def_header_output_path :=
14header_file :=
15header_name :=
16def_header_file :=
17header_alias :=
18dest_path :=
19header_goal_list :=
20
21
22# Figure out the include path for this component definition
23def_header_path := $(def_path)/$(def_include_subdir)
24def_header_output_path := $(header_output_path)/$(name)
25
26define header_file_rule
27
28 $$(call debug_info,header specified: $(1))
29
30 header_file := $(1)
31 header_name := $$(notdir $$(header_file))
32 def_header_file := $$(def_header_path)/$$(header_file)
33 header_alias := $$(name)/$$(header_name)
34
35 header_goal_list := $$(header_alias) $$(header_goal_list)
36
37 directory_list := $$(dest_path) $$(directory_list)
38
39 # Define an alias for the header file so the user can do
40 # "make name/header.h" on the command line
41 vpath $$(header_alias) $$(header_output_path)
42
43 # Set the target specific variables and dependencies for this header
44 $$(header_alias) : header_path := $$(header_path)
45 $$(header_alias) : def_header_file := $$(def_header_file)
46 $$(header_alias) : header_alias := $$(header_alias)
47 $$(header_alias) : $$(def_deps)
48 $$(header_alias) : $$(def_header_file)
49
50endef
51
52
53# Expand the header file rule for each header specified
54$(foreach file,$(header_list),$(eval $(call header_file_rule,$(file))))
55
56# Add the output header directory to the list of directories we need to build
57directory_list := $(def_header_output_path) $(directory_list)
58
59
60# Add the list of header goals as a dependency of the component definition's
61# headers target
62$(name)_def_headers : $(header_goal_list)
63
64# Define the actual recipe for a header
65$(header_goal_list) : | $(def_header_output_path)
66 $(call print_progress,$(header_alias))
67 $(call soft_copy,$(def_header_file),$(header_output_path)/$(header_alias))
68
69.PHONY : clean_$(name)_def_headers
70clean_$(name)_def_headers : header_output_path := $(header_output_path)
71clean_$(name)_def_headers : header_goal_list := $(header_goal_list)
72clean_$(name)_def_headers :
73 $(call print_progress,$@)
74 $(call remove_files,$(addprefix $(header_output_path)/,$(header_goal_list)))