Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
141 lines (118 loc) · 5.79 KB
/
Copy pathmakefile
File metadata and controls
141 lines (118 loc) · 5.79 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# ##############################################################################
# TISP top-level Makefile
# Orchestrates xlib builds then TISP for am62d and/or am275.
#
# Uses CMake presets throughout — same build args as:
# west build-tisp --soc am62d --platform target
# cmake -S . -B build --preset release-buildlib-am62d-target
#
# Usage:
# make # all xlibs + TISP, am62d+am275, release
# make SOCS=am62d # single SOC
# make PROFILE=debug # debug build
# make xlibs # xlibs only (skip TISP)
# make tisp # TISP only (assumes xlibs already built)
# make fftlib.am62d # one xlib, one SOC
# make audiolib.am275 # audiolib for am275 (builds dsplib first)
# make clean # clean build dirs (keep lib/)
# make scrub # full wipe including lib/
# make help # show this message
# ##############################################################################
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
# ---------------------------------------------------------------------------
# Knobs — override on the command line
# ---------------------------------------------------------------------------
SOCS ?= am62d am275
PROFILE ?= release
# ---------------------------------------------------------------------------
# Paths — derived from location of this Makefile so it works from any cwd
# ---------------------------------------------------------------------------
TISP_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
WORKSPACE := $(abspath $(TISP_DIR)/..)
FFTLIB_DIR := $(WORKSPACE)/xlib/fftlib
MATHLIB_DIR := $(WORKSPACE)/xlib/mathlib
DSPLIB_DIR := $(WORKSPACE)/xlib/dsplib
AUDIOLIB_DIR := $(WORKSPACE)/xlib/audiolib
# ---------------------------------------------------------------------------
# xlib makefile name, keyed by SOC
# ---------------------------------------------------------------------------
xlib_mk.am62d := makefile.am62dx.c75x.ti-c7000
xlib_mk.am275 := makefile.am275x.c75x.ti-c7000
# ---------------------------------------------------------------------------
# Top-level aggregates
# ---------------------------------------------------------------------------
.PHONY: all xlibs tisp clean scrub help
all: xlibs tisp
xlibs: $(foreach soc,$(SOCS), fftlib.$(soc) mathlib.$(soc) dsplib.$(soc) audiolib.$(soc))
tisp: $(foreach soc,$(SOCS), tisp.$(soc))
clean: $(foreach soc,$(SOCS), clean.$(soc))
scrub: $(foreach soc,$(SOCS), scrub.$(soc))
# ---------------------------------------------------------------------------
# Per-SOC rules, generated for both am62d and am275.
# $$(MAKE) preserves $(MAKE) in the recipe so jobserver flags are forwarded.
# $(1), $(FFTLIB_DIR), $(PROFILE) etc. are expanded at define-time.
# ---------------------------------------------------------------------------
define soc_rules
.PHONY: fftlib.$(1) mathlib.$(1) dsplib.$(1) audiolib.$(1) \
tisp.$(1) clean.$(1) scrub.$(1)
fftlib.$(1):
@echo ">>> fftlib [$(1)/$(PROFILE)/target]"
$$(MAKE) -C $(FFTLIB_DIR) -f $(xlib_mk.$(1)) PROFILE=$(PROFILE) all
mathlib.$(1):
@echo ">>> mathlib [$(1)/$(PROFILE)/target]"
$$(MAKE) -C $(MATHLIB_DIR) -f $(xlib_mk.$(1)) PROFILE=$(PROFILE) all
dsplib.$(1):
@echo ">>> dsplib [$(1)/$(PROFILE)/target]"
$$(MAKE) -C $(DSPLIB_DIR) -f $(xlib_mk.$(1)) PROFILE=$(PROFILE) all
# audiolib links against dsplib — always build dsplib first
audiolib.$(1): dsplib.$(1)
@echo ">>> audiolib [$(1)/$(PROFILE)/target]"
$$(MAKE) -C $(AUDIOLIB_DIR) -f $(xlib_mk.$(1)) PROFILE=$(PROFILE) all
# TISP: --preset is the single source of truth for all build flags
# Mirrors the convention used by west build-tisp and direct cmake usage.
tisp.$(1):
@echo ">>> tisp [preset=$(PROFILE)-buildlib-$(1)-target]"
cmake -S $(TISP_DIR) \
-B $(TISP_DIR)/build/$(1)/target/$(PROFILE) \
--preset $(PROFILE)-buildlib-$(1)-target \
--fresh
cmake --build $(TISP_DIR)/build/$(1)/target/$(PROFILE) -j
clean.$(1):
$$(MAKE) -C $(FFTLIB_DIR) -f $(xlib_mk.$(1)) clean
$$(MAKE) -C $(MATHLIB_DIR) -f $(xlib_mk.$(1)) clean
$$(MAKE) -C $(DSPLIB_DIR) -f $(xlib_mk.$(1)) clean
$$(MAKE) -C $(AUDIOLIB_DIR) -f $(xlib_mk.$(1)) clean
rm -rf $(TISP_DIR)/build/$(1)/
scrub.$(1):
$$(MAKE) -C $(FFTLIB_DIR) -f $(xlib_mk.$(1)) scrub
$$(MAKE) -C $(MATHLIB_DIR) -f $(xlib_mk.$(1)) scrub
$$(MAKE) -C $(DSPLIB_DIR) -f $(xlib_mk.$(1)) scrub
$$(MAKE) -C $(AUDIOLIB_DIR) -f $(xlib_mk.$(1)) scrub
rm -rf $(TISP_DIR)/build/$(1)/
endef
$(foreach soc,am62d am275, $(eval $(call soc_rules,$(soc))))
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
help:
@echo ""
@echo "TISP top-level Makefile — xlibs + TISP via CMake presets"
@echo "Same build args as: west build-tisp / cmake --preset <name>"
@echo ""
@echo " make [SOCS='am62d am275'] [PROFILE=release|debug]"
@echo ""
@printf " %-22s %s\n" "all" "xlibs + TISP for all SOCS (default)"
@printf " %-22s %s\n" "xlibs" "all four xlibs for all SOCS"
@printf " %-22s %s\n" "tisp" "TISP for all SOCS (xlibs must exist)"
@printf " %-22s %s\n" "fftlib.{soc}" "fftlib for one SOC"
@printf " %-22s %s\n" "mathlib.{soc}" "mathlib for one SOC"
@printf " %-22s %s\n" "dsplib.{soc}" "dsplib for one SOC"
@printf " %-22s %s\n" "audiolib.{soc}" "audiolib for one SOC (dsplib built first)"
@printf " %-22s %s\n" "tisp.{soc}" "TISP for one SOC"
@printf " %-22s %s\n" "clean[.{soc}]" "remove build dirs, keep lib/"
@printf " %-22s %s\n" "scrub[.{soc}]" "remove build dirs and lib/"
@echo ""
@echo " Defaults: SOCS='$(SOCS)' PROFILE=$(PROFILE)"
@echo " Workspace: $(WORKSPACE)"
@echo ""