cb046c78e4
These prerequisites are GNU Make terminology. This change forces the libc rule to be executed first so that the headers that the libm rule needs are available. The original setup was using 'normal' prerequisites which occasionally resulted in bizarre build breakage, especially on multi-core build hosts. Seen often on my 8-way SMP build host. Note that this doesn't impede parallelisation of each rule indepent of the other. It just serializes the rules themselves. This fixes: https://gitlab.redox-os.org/redox-os/relibc/issues/127
77 lines
1.7 KiB
Makefile
77 lines
1.7 KiB
Makefile
TARGET?=
|
|
|
|
BUILD=target
|
|
ifneq ($(TARGET),)
|
|
BUILD="target/$(TARGET)"
|
|
CARGOFLAGS+="--target=$(TARGET)"
|
|
endif
|
|
|
|
ifeq ($(TARGET),aarch64-unknown-linux-gnu)
|
|
CC=aarch64-linux-gnu-gcc
|
|
endif
|
|
|
|
ifeq ($(TARGET),x86_64-unknown-redox)
|
|
CC=x86_64-unknown-redox-gcc
|
|
endif
|
|
|
|
SRC=\
|
|
src/* \
|
|
src/*/* \
|
|
src/*/*/* \
|
|
src/*/*/*/*
|
|
|
|
.PHONY: all clean fmt install libc libm test
|
|
|
|
all: | libc libm
|
|
|
|
clean:
|
|
cargo clean
|
|
make -C tests clean
|
|
|
|
fmt:
|
|
./fmt.sh
|
|
|
|
install: all
|
|
mkdir -pv "$(DESTDIR)/lib"
|
|
mkdir -pv "$(DESTDIR)/include"
|
|
cp -rv "include"/* "$(DESTDIR)/include"
|
|
cp -rv "target/include"/* "$(DESTDIR)/include"
|
|
cp -v "$(BUILD)/debug/libc.a" "$(DESTDIR)/lib"
|
|
cp -v "$(BUILD)/debug/crt0.o" "$(DESTDIR)/lib"
|
|
cp -rv "openlibm/include"/* "$(DESTDIR)/include"
|
|
cp -rv "openlibm/src"/*.h "$(DESTDIR)/include"
|
|
cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
|
|
|
|
libc: $(BUILD)/debug/libc.a $(BUILD)/debug/crt0.o
|
|
|
|
libm: $(BUILD)/openlibm/libopenlibm.a
|
|
|
|
test: all
|
|
make -C tests run
|
|
|
|
$(BUILD)/debug/libc.a: $(SRC)
|
|
cargo build $(CARGOFLAGS)
|
|
touch $@
|
|
|
|
$(BUILD)/debug/crt0.o: $(SRC)
|
|
CARGO_INCREMENTAL=0 cargo rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
|
|
touch $@
|
|
|
|
$(BUILD)/release/libc.a: $(SRC)
|
|
cargo build --release $(CARGOFLAGS)
|
|
touch $@
|
|
|
|
$(BUILD)/release/crt0.o: $(SRC)
|
|
CARGO_INCREMENTAL=0 cargo rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
|
|
touch $@
|
|
|
|
$(BUILD)/openlibm: openlibm
|
|
rm -rf $@ $@.partial
|
|
mkdir -p $(BUILD)
|
|
cp -r $< $@.partial
|
|
mv $@.partial $@
|
|
touch $@
|
|
|
|
$(BUILD)/openlibm/libopenlibm.a: $(BUILD)/openlibm
|
|
make CC=$(CC) CPPFLAGS="-fno-stack-protector -I$(shell pwd)/include -I $(shell pwd)/target/include" -C $< libopenlibm.a
|