-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparent-makefile.makefile
More file actions
22 lines (19 loc) · 1.06 KB
/
parent-makefile.makefile
File metadata and controls
22 lines (19 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
###
##. Parent Makefile
###
PARENT_MAKEFILE_DIRECTORY?=..
PARENT_MAKEFILES?=$(realpath $(dir $(firstword $(MAKEFILE_LIST)))/$(PARENT_MAKEFILE_DIRECTORY))/makefile $(PARENT_MAKEFILE_DIRECTORY)/makefile
#. Create a parent makefile to redirect commands to the current directory
$(filter-out $(PARENT_MAKEFILE_DIRECTORY)/makefile,$(PARENT_MAKEFILES)) $(PARENT_MAKEFILE_DIRECTORY)/makefile: force-recreate-makefile
@printf "%s\n" "# Generated to redirect" > "$(@)"
@printf "%s\n" ".SUFFIXES:" >> "$(@)"
@printf "%s\n" "MAKEFLAGS+=--no-print-directory --no-builtin-rules --no-builtin-variables" >> "$(@)"
@printf "%s\n" ".PHONY: force" >> "$(@)"
@printf "%s\n" ".DEFAULT_GOAL:=$(.DEFAULT_GOAL)" >> "$(@)"
@printf "%s\n" "\$$(MAKEFILE_LIST): ; @true" >> "$(@)"
@printf "%s\n" "%: force; @cd \"$(notdir $(patsubst %/,%,$(dir $(realpath $(firstword $(MAKEFILE_LIST))))))\" && \$$(MAKE) --file=\"$(firstword $(MAKEFILE_LIST))\" \$$(*)" >> "$(@)"
@printf "%s\n" "force:" >> "$(@)"
#. Force the makefile to be recreated
force-recreate-makefile:
@true
.PHONY: force-recreate-makefile