File: GNUmakefile.subdir

package info (click to toggle)
lapackpp 2024.10.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,500 kB
  • sloc: cpp: 80,181; ansic: 27,660; python: 4,838; xml: 182; perl: 99; makefile: 53; sh: 23
file content (43 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Subdirectories include this makefile to forward rules to the top level makefile.
# Define ${top} for where the top level is.
# Example: src/GNUmakefile:
#     top = ..
#     include ${top}/GNUmakefile.subdir

.SUFFIXES:

pwd     = ${shell pwd}
abs_top = ${abspath ${top}}/
abs_pwd = ${abspath ${pwd}}
cdir    = ${subst ${abs_top},,${abs_pwd}}

# ------------------------------------------------------------------------------
ifneq (${MAKECMDGOALS},)

# If arguments are given, presumably files like test.o, forward them to top
# with cdir prefix.
# All files are forwarded as one rule, based on first; rest are quietly ignored.
goals   := ${filter-out echo ${DONT_FORWARD}, ${MAKECMDGOALS}}
forward := ${addprefix ${cdir}/, ${goals}}
first   := ${firstword ${goals}}
rest    := ${wordlist 2, ${words ${goals}}, ${goals}}

${first}: force
	cd ${top} && ${MAKE} ${forward}

${rest}: force
	@echo > /dev/null

# ------------------------------------------------------------------------------
else

# Otherwise, forward subdirectory name as target.
.PHONY: ${cdir}

${cdir}:
	cd ${top} && ${MAKE} $@

endif
# ------------------------------------------------------------------------------

force: ;