artiq/artiq/runtime/Makefile

89 lines
2.4 KiB
Makefile
Raw Normal View History

2015-11-04 00:35:03 +08:00
include ../include/generated/variables.mak
include $(MISOC_DIRECTORY)/software/common.mak
PYTHON ?= python3.5
2015-11-04 00:35:03 +08:00
2016-10-17 00:24:25 +08:00
OBJECTS := flash_storage.o main.o
OBJECTS_KSUPPORT := ksupport_glue.o artiq_personality.o rtio.o dds.o i2c.o
2015-11-07 14:44:20 +08:00
2016-10-17 00:24:25 +08:00
RUSTOUT_DIRECTORY := cargo/or1k-unknown-none/debug
CORE_IO_COMMIT := d40c593f42fafbac1ff3d827f6df96338b5b7d8b
export CORE_IO_COMMIT
2016-10-17 00:24:25 +08:00
CFLAGS += \
-I$(LIBALLOC_DIRECTORY) \
-I$(MISOC_DIRECTORY)/software/include/dyld \
2015-11-07 14:44:20 +08:00
-I$(LIBDYLD_DIRECTORY)/include \
-I$(LIBUNWIND_DIRECTORY) \
-I$(LIBUNWIND_DIRECTORY)/../unwinder/include \
-I$(LIBLWIP_DIRECTORY)/../lwip/src/include \
-I$(LIBLWIP_DIRECTORY)
CFLAGS += -DNDEBUG
2015-11-04 00:35:03 +08:00
2016-10-17 00:24:25 +08:00
LDFLAGS += --gc-sections \
-L../libcompiler-rt \
-L../libbase \
-L../libm \
-L../liballoc \
-L../libunwind \
-L../libdyld \
-L../liblwip
2015-11-04 00:35:03 +08:00
2016-10-17 00:24:25 +08:00
all: runtime.bin runtime.fbi
2015-11-04 00:35:03 +08:00
2016-10-17 00:24:25 +08:00
.PHONY: $(RUSTOUT_DIRECTORY)/libruntime.a
$(RUSTOUT_DIRECTORY)/libruntime.a: ksupport.elf
CARGO_TARGET_DIR=$(realpath .)/cargo \
2016-10-17 00:24:25 +08:00
cargo rustc --verbose \
--manifest-path $(realpath $(RUNTIME_DIRECTORY)/../runtime.rs/Cargo.toml) \
--target=or1k-unknown-none -- \
$(shell cat $(BUILDINC_DIRECTORY)/generated/rust-cfg) \
-C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s \
-L../libcompiler-rt
2015-11-04 00:35:03 +08:00
2016-10-17 00:24:25 +08:00
runtime.elf: $(OBJECTS) $(RUSTOUT_DIRECTORY)/libruntime.a
2015-11-04 00:35:03 +08:00
$(LD) $(LDFLAGS) \
2015-11-07 14:44:20 +08:00
-T $(RUNTIME_DIRECTORY)/runtime.ld \
2016-10-17 00:24:25 +08:00
-o $@ \
2015-11-04 00:35:03 +08:00
$^ \
2016-10-17 00:24:25 +08:00
-lbase-nofloat -lcompiler-rt -lalloc -llwip
2015-11-04 00:35:03 +08:00
@chmod -x $@
2016-10-17 00:24:25 +08:00
.PHONY: $(RUSTOUT_DIRECTORY)/libksupport.a
$(RUSTOUT_DIRECTORY)/libksupport.a:
CARGO_TARGET_DIR=$(realpath .)/cargo \
2016-08-17 16:39:05 +08:00
cargo rustc --verbose \
2016-10-17 00:24:25 +08:00
--manifest-path $(realpath $(RUNTIME_DIRECTORY)/../runtime.rs/libksupport/Cargo.toml) \
2016-08-17 16:39:05 +08:00
--target=or1k-unknown-none -- \
$(shell cat $(BUILDINC_DIRECTORY)/generated/rust-cfg) \
--cfg ksupport \
2016-08-17 16:39:05 +08:00
-C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s \
-L../libcompiler-rt
2016-10-17 00:24:25 +08:00
ksupport.elf: $(OBJECTS_KSUPPORT) $(RUSTOUT_DIRECTORY)/libksupport.a
$(LD) $(LDFLAGS) \
--eh-frame-hdr \
-T $(RUNTIME_DIRECTORY)/ksupport.ld \
-o $@ \
$^ \
-lbase -lm -lcompiler-rt -ldyld -lunwind
@chmod -x $@
2015-11-04 00:35:03 +08:00
%.o: $(RUNTIME_DIRECTORY)/%.c
$(compile)
2016-10-17 00:24:25 +08:00
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
@chmod -x $@
%.fbi: %.bin
@echo " MSCIMG " $@ && $(PYTHON) -m misoc.tools.mkmscimg -f -o $@ $<
2015-11-04 00:35:03 +08:00
clean:
$(RM) $(OBJECTS) $(OBJECTS_KSUPPORT)
$(RM) runtime.elf runtime.bin runtime.fbi .*~ *~
2015-11-07 14:44:20 +08:00
$(RM) ksupport.elf ksupport.bin
2016-10-17 00:24:25 +08:00
$(RM) -rf cargo
2015-11-04 00:35:03 +08:00
2015-11-07 14:44:20 +08:00
.PHONY: all clean