blob: c45972a2ad7c554f932961d87e6c489f2ce6baaa (
plain)
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
|
#############################################################
# Compiles an instance of Metal targeted at $(TARGET)
#############################################################
METAL_SOURCE_PATH ?= freedom-metal
METAL_LDSCRIPT = $(BSP_DIR)/metal.$(LINK_TARGET).lds
METAL_HEADER = $(BSP_DIR)/metal.h
METAL_PREFIX = $(abspath $(BSP_DIR)/install)
METAL_BUILD_DIR = $(abspath $(BSP_DIR)/build/$(CONFIGURATION))
METAL_LIB_DIR = $(abspath $(BSP_DIR)/install/lib/$(CONFIGURATION))
.PHONY: metal
metal: $(METAL_LIB_DIR)/stamp
$(METAL_BUILD_DIR)/Makefile:
@rm -rf $(dir $@)
@mkdir -p $(dir $@)
cd $(dir $@) && \
CFLAGS="$(RISCV_CFLAGS)" \
$(abspath $(METAL_SOURCE_PATH)/configure) \
--host=$(CROSS_COMPILE) \
--prefix=$(METAL_PREFIX) \
--libdir=$(METAL_LIB_DIR) \
--disable-maintainer-mode \
--with-preconfigured \
--with-machine-name=$(TARGET) \
--with-machine-header=$(abspath $(METAL_HEADER)) \
--with-machine-ldscript=$(abspath $(METAL_LDSCRIPT)) \
--with-builtin-libgloss
touch -c $@
$(METAL_LIB_DIR)/stamp: $(BSP_DIR)/build/$(CONFIGURATION)/Makefile
$(MAKE) -C $(abspath $(BSP_DIR)/build/$(CONFIGURATION)) install
date > $@
$(METAL_LIB_DIR)/libriscv%.a: $(METAL_LIB_DIR)/stamp ;@:
$(METAL_LIB_DIR)/libmetal.a: $(METAL_LIB_DIR)/libriscv__mmachine__$(TARGET).a
cp $< $@
$(METAL_LIB_DIR)/libmetal-gloss.a: $(METAL_LIB_DIR)/libriscv__menv__metal.a
cp $< $@
# If we're cleaning the last Metal library for a TARGET, then remove
# the install directory, otherwise just remove the built libs for that
# CONFIGURATION.
ifeq ($(words $(wildcard $(METAL_PREFIX)/lib/*)),1)
METAL_CLEAN = $(METAL_PREFIX)
else
METAL_CLEAN = $(METAL_LIB_DIR)
endif
.PHONY: clean-metal
clean-metal:
rm -rf $(METAL_CLEAN)
rm -rf $(METAL_BUILD_DIR)
clean: clean-metal
metal_install: metal
$(MAKE) -C $(METAL_SOURCE_PATH) install
|