2
0

Makefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. TARGET?=
  2. BUILD=target
  3. ifneq ($(TARGET),)
  4. BUILD="target/$(TARGET)"
  5. CARGOFLAGS+="--target=$(TARGET)"
  6. endif
  7. ifeq ($(TARGET),aarch64-unknown-linux-gnu)
  8. CC="aarch64-linux-gnu-gcc"
  9. endif
  10. ifeq ($(TARGET),x86_64-unknown-redox)
  11. CC="x86_64-unknown-redox-gcc"
  12. endif
  13. SRC=\
  14. src/* \
  15. src/*/* \
  16. src/*/*/* \
  17. src/*/*/*/*
  18. .PHONY: all clean fmt install libc libm test
  19. all: libc libm
  20. clean:
  21. cargo clean
  22. make -C tests clean
  23. fmt:
  24. ./fmt.sh
  25. install: all
  26. mkdir -pv "$(DESTDIR)/lib"
  27. mkdir -pv "$(DESTDIR)/include"
  28. cp -rv "include"/* "$(DESTDIR)/include"
  29. cp -rv "target/include"/* "$(DESTDIR)/include"
  30. cp -v "$(BUILD)/debug/libc.a" "$(DESTDIR)/lib"
  31. cp -v "$(BUILD)/debug/crt0.o" "$(DESTDIR)/lib"
  32. cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
  33. libc: $(BUILD)/debug/libc.a $(BUILD)/debug/crt0.o
  34. libm: $(BUILD)/openlibm/libopenlibm.a
  35. test: all
  36. make -C tests run
  37. $(BUILD)/debug/libc.a: $(SRC)
  38. cargo build $(CARGOFLAGS)
  39. touch $@
  40. $(BUILD)/debug/crt0.o: $(SRC)
  41. cargo rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
  42. touch $@
  43. $(BUILD)/release/libc.a: $(SRC)
  44. cargo build --release $(CARGOFLAGS)
  45. touch $@
  46. $(BUILD)/release/crt0.o: $(SRC)
  47. cargo rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
  48. touch $@
  49. $(BUILD)/openlibm: openlibm
  50. rm -rf $@ [email protected]
  51. mkdir -p $(BUILD)
  52. cp -r $< [email protected]
  53. mv [email protected] $@
  54. touch $@
  55. $(BUILD)/openlibm/libopenlibm.a: $(BUILD)/openlibm
  56. make CC=$(CC) CFLAGS=-fno-stack-protector -C $< libopenlibm.a