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