From ae137dbc03166b1051aee92b3b4b45096fc2317a Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Mon, 26 Mar 2018 18:50:51 -0600 Subject: [PATCH] Prepare for cross compiled openlibm --- Makefile | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d145e2019..ab51c7406 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,36 @@ +TARGET?= + +BUILD=target/debug +ifneq ($(TARGET),) + BUILD=target/$(TARGET)/debug + CARGOFLAGS+="--target=$(TARGET)" + CC=$(TARGET)-gcc +endif + .PHONY: all clean fmt test -all: openlibm/libopenlibm.a target/debug/libc.a target/debug/libcrt0.a - cargo build +all: $(BUILD)/libc.a $(BUILD)/libcrt0.a $(BUILD)/openlibm/libopenlibm.a clean: cargo clean - make -C openlibm clean make -C tests clean fmt: ./fmt.sh -test: openlibm/libopenlibm.a +test: all make -C tests run -target/debug/libc.a: - cargo build +$(BUILD)/libc.a: + cargo build $(CARGOFLAGS) + +$(BUILD)/libcrt0.a: + cargo build --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -target/debug/libcrt0.a: - cargo build --manifest-path src/crt0/Cargo.toml +$(BUILD)/openlibm: openlibm + rm -rf $@ $@.partial + cp -r $< $@.partial + mv $@.partial $@ -openlibm/libopenlibm.a: - CFLAGS=-fno-stack-protector make -C openlibm libopenlibm.a +$(BUILD)/openlibm/libopenlibm.a: $(BUILD)/openlibm + CC=$(CC) CFLAGS=-fno-stack-protector make -C $< libopenlibm.a -- GitLab