Makefile 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. user_sub_dirs = libs
  2. SUBDIR_ROOTS := .
  3. DIRS := . $(shell find $(SUBDIR_ROOTS) -type d)
  4. GARBAGE_PATTERNS := *.o *.s~ *.s *.S~ *.c~ *.h~ sys_api_lib
  5. GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
  6. objs :=
  7. CFLAGS := $(GLOBAL_CFLAGS)
  8. current_CFLAGS := $(CFLAGS) -I $(shell pwd)/libs
  9. all:
  10. @list='$(user_sub_dirs)'; for subdir in $$list; do \
  11. echo "make all in $$subdir";\
  12. cd $$subdir;\
  13. $(MAKE) all CFLAGS="$(CFLAGS)";\
  14. cd ..;\
  15. done
  16. $(MAKE) init.o
  17. $(MAKE) sys_api_lib
  18. # objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary sys_api_lib $(ROOT_PATH)/bin/user/init.bin
  19. objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O elf64-x86-64 sys_api_lib $(ROOT_PATH)/bin/user/init.bin
  20. sys_api_lib: init.o
  21. ld -b elf64-x86-64 -z muldefs -o sys_api_lib $(shell find . -name "*.o")
  22. #ld -b elf64-x86-64 -z muldefs -o sys_api_lib init.o $(shell find . -name "*.o") -T init.lds
  23. init.o: init.c
  24. gcc $(current_CFLAGS) -c init.c -o init.o
  25. clean:
  26. rm -rf $(GARBAGE)