-
Notifications
You must be signed in to change notification settings - Fork 45
/
common.mk
51 lines (38 loc) · 1.05 KB
/
common.mk
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
.PHONY: default
default: all
nop :=
space := $(nop) $(nop)
comma := ,
ARCH ?= amd64
ifeq ($(ARCH),amd64)
TRIPLE ?= x86_64-none-elf
else ifeq ($(ARCH),armv7)
TRIPLE ?= arm-elf-eabi
else ifeq ($(ARCH),armv8)
TRIPLE ?= aarch64-none-elf
else ifeq ($(ARCH),riscv64)
TRIPLE ?= riscv64-unknown-elf
else ifeq ($(ARCH),native)
TRIPLE ?=
else
$(error Unknown architecture $(ARCH) in common.mk)
endif
ifeq ($(RUSTC_DATE),)
RUSTUP_VER := nightly
else
RUSTUP_VER := nightly-$(RUSTC_DATE)
endif
ROOTDIR := $(dir $(lastword $(MAKEFILE_LIST)))
PREFIX := $(ROOTDIR).prefix/
PATH := $(PATH):$(PREFIX)bin
CC := $(TRIPLE)-gcc
LD := $(TRIPLE)-ld
AS := $(TRIPLE)-as
OBJDUMP := $(TRIPLE)-objdump
OBJCOPY := $(TRIPLE)-objcopy
STRIP := $(TRIPLE)-strip
fn_getdeps = $(shell cat $1 | sed -nr 's/.*extern crate ([a-zA-Z_0-9]+)( as .*)?;.*/\1/p' | tr '\n' ' ')
fn_rustcmd = RUSTUP_HOME=$(abspath $(PREFIX)) CARGO_HOME=$(abspath $(PREFIX)) $(abspath $(PREFIX)bin/$1)
RUSTC := $(call fn_rustcmd,rustc)
RUSTDOC := $(call fn_rustcmd,rustdoc)
CARGO := $(call fn_rustcmd,cargo)