Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. user_sub_dirs = libs apps
  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. tmp_output_dir=$(ROOT_PATH)/bin/tmp/user
  7. output_dir=$(ROOT_PATH)/bin/user
  8. CFLAGS := $(GLOBAL_CFLAGS) -I $(shell pwd)/libs
  9. current_CFLAGS := $(CFLAGS)
  10. all:
  11. @list='$(user_sub_dirs)'; for subdir in $$list; do \
  12. echo "make all in $$subdir";\
  13. cd $$subdir;\
  14. $(MAKE) all CFLAGS="$(CFLAGS)";\
  15. cd ..;\
  16. done
  17. $(shell if [ ! -e $(tmp_output_dir) ];then mkdir -p $(tmp_output_dir); fi)
  18. $(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi)
  19. $(MAKE) sys_api_lib
  20. $(MAKE) shell
  21. # objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary sys_api_lib $(ROOT_PATH)/bin/user/init.bin
  22. #objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O elf64-x86-64 sys_api_lib $(ROOT_PATH)/bin/user/init.bin
  23. sys_api_lib:
  24. ld -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/sys_api_lib $(shell find ./libs -name "*.o")
  25. #ld -b elf64-x86-64 -z muldefs -o sys_api_lib init.o $(shell find . -name "*.o") -T init.lds
  26. shell:
  27. ld -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/shell $(shell find ./apps/shell -name "*.o") $(shell find ./libs -name "*.o")
  28. objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O elf64-x86-64 $(tmp_output_dir)/shell $(output_dir)/shell.elf
  29. clean:
  30. rm -rf $(GARBAGE)