Skip to content

Commit

Permalink
software: add first-class cargo support.
Browse files Browse the repository at this point in the history
whitequark committed Feb 3, 2017
1 parent 421b197 commit 40e9940
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion misoc/software/common.mak
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@ TARGET_PREFIX=$(TRIPLE)-
RM ?= rm -f
PYTHON ?= python3

CARGO_TRIPLE=$(subst or1k-linux,or1k-unknown-none,$(TRIPLE))

ifeq ($(CLANG),1)
CC_normal := clang -target $(TRIPLE) -integrated-as
CX_normal := clang++ -target $(TRIPLE) -integrated-as
@@ -13,25 +15,29 @@ endif
AR_normal := $(TARGET_PREFIX)ar
LD_normal := $(TARGET_PREFIX)ld
OBJCOPY_normal := $(TARGET_PREFIX)objcopy
CARGO_normal := env CARGO_TARGET_DIR=$(realpath .)/cargo cargo build --target $(CARGO_TRIPLE)

CC_quiet = @echo " CC " $@ && $(CC_normal)
CX_quiet = @echo " CX " $@ && $(CX_normal)
AR_quiet = @echo " AR " $@ && $(AR_normal)
LD_quiet = @echo " LD " $@ && $(LD_normal)
OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(OBJCOPY_normal)
CARGO_quiet = @echo " CARGO " $@ && $(CARGO_normal)

ifeq ($(V),1)
CC = $(CC_normal)
CX = $(CX_normal)
AR = $(AR_normal)
LD = $(LD_normal)
OBJCOPY = $(OBJCOPY_normal)
CARGO = $(CARGO_normal) --verbose
else
CC = $(CC_quiet)
CX = $(CX_quiet)
AR = $(AR_quiet)
LD = $(LD_quiet)
OBJCOPY = $(OBJCOPY_quiet)
CARGO = $(CARGO_quiet)
.SILENT:
endif

@@ -41,7 +47,9 @@ INCLUDES = -I$(MISOC_DIRECTORY)/software/include/base -I$(MISOC_DIRECTORY)/softw
COMMONFLAGS = -Os $(CPUFLAGS) -fomit-frame-pointer -ffunction-sections -Wall -fno-builtin -nostdinc $(INCLUDES)
CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Werror=incompatible-pointer-types
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(MISOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
LDFLAGS = -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY)
LDFLAGS = --gc-sections -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY)
RUSTOUT = cargo/$(CARGO_TRIPLE)/debug
export RUSTFLAGS = -Ctarget-feature=+mul,+div,+ffl1,+cmov,+addc -Crelocation-model=static -Copt-level=s

define compilexx
$(CX) -c $(CXXFLAGS) $(1) $< -o $@
@@ -54,3 +62,7 @@ endef
define assemble
$(CC) -c $(CFLAGS) -o $@ $<
endef

define cargo
$(CARGO)
endef

0 comments on commit 40e9940

Please sign in to comment.