Makefile 788 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. GARBAGE_PATTERNS := *.o *.s~ *.s *.S~ *.c~ *.h~ kernel
  2. GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
  3. all: libc
  4. CFLAGS += -I .
  5. libc_sub_dirs=math sys
  6. ifeq ($(ARCH), __x86_64__)
  7. libc_sub_dirs += arch/x86_64
  8. endif
  9. $(libc_sub_dirs): ECHO
  10. $(MAKE) -C $@ all CFLAGS="$(CFLAGS)" ASFLAGS="$(ASFLAGS) -I $(shell pwd)"
  11. libc_objs:= $(shell find ./*.c)
  12. ECHO:
  13. @echo "$@"
  14. $(libc_objs): ECHO
  15. $(CC) $(CFLAGS) -c $@ -o $@.o
  16. clean:
  17. cargo clean
  18. rm -rf $(GARBAGE)
  19. @list='$(libc_sub_dirs)'; for subdir in $$list; do \
  20. echo "Clean in dir: $$subdir";\
  21. cd $$subdir && $(MAKE) clean;\
  22. cd .. ;\
  23. done
  24. libc: $(libc_objs) $(libc_sub_dirs) libc_rust
  25. libc_rust:
  26. rustup default nightly
  27. cargo +nightly build --release --target ./arch/x86_64/x86_64-unknown-none.json