Skip to content

Commit 453d3dd

Browse files
committed
make: Precompiled: add rules for picolib
1 parent 645cd32 commit 453d3dd

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

Precompiled.mk

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,39 @@ $(foreach arch,$(RISCV_ARCHS),$(eval $(call PRECOMPILED_NEWLIB_RULES,riscv,riscv
6060
$(TOCK_NEWLIB_TARGETS):
6161
cd $(TOCK_USERLAND_BASE_DIR)/lib; ./fetch-newlib.sh $(patsubst libtock-newlib-%,%,$*)
6262

63+
################################################################################
64+
# Picolib Rules
65+
#
66+
# These pre-compiled archives were created using the libtock-c/picolib folder.
67+
################################################################################
68+
69+
# Rule to ensure that the picolib libraries for an architecture exist.
70+
#
71+
# Need to list all libraries which are possible targets to tell make that one
72+
# invocation of this build rule will make all the target files.
73+
#
74+
# Arguments:
75+
# - $(1): Family
76+
# - $(2): Toolchain
77+
# - $(3): Arch
78+
define PRECOMPILED_PICOLIB_RULES
79+
80+
TOCK_PICOLIB_TARGETS += $$(TOCK_USERLAND_BASE_DIR)/lib/%/$(1)/$(2)/lib/$(3)/libc.a
81+
TOCK_PICOLIB_TARGETS += $$(TOCK_USERLAND_BASE_DIR)/lib/%/$(1)/$(2)/lib/$(3)/libm.a
82+
83+
endef
84+
85+
TOCK_PICOLIB_TARGETS :=
86+
$(foreach arch,$(ARM_ARCHS),$(eval $(call PRECOMPILED_PICOLIB_RULES,arm,arm-none-eabi,$(arch))))
87+
$(foreach arch,$(RISCV_ARCHS),$(eval $(call PRECOMPILED_PICOLIB_RULES,riscv,riscv64-unknown-elf,$(arch))))
88+
89+
# Target to download and extract picolib.
90+
#
91+
# % will match something like "libtock-picolib-1.8.5" which we then strip down
92+
# to just the version with some string manipulation.
93+
$(TOCK_PICOLIB_TARGETS):
94+
cd $(TOCK_USERLAND_BASE_DIR)/lib; ./fetch-picolib.sh $(patsubst libtock-picolib-%,%,$*)
95+
6396
################################################################################
6497
# LIBC++ Rules
6598
#
@@ -75,7 +108,7 @@ TOCK_CXXLIB_TARGETS += $$(TOCK_USERLAND_BASE_DIR)/lib/%/$(1)/$(2)/lib/$(3)/libsu
75108
# So this is supremely frustrating. The issue boils down to limitations of
76109
# pattern rules in make.
77110
#
78-
# First: pattern rules are implicitly groups, and you aren't allowed to
111+
# First: pattern rules are implicitly groups, and you aren't allowed to
79112
# use the :g operator to merge groups. What this means in practice is that
80113
# if you have many targets that are all generated by the same rule (i.e.,
81114
# our unzip creates all the library archive targets), all of the targets

0 commit comments

Comments
 (0)