🎨 将shell独立成单独的app

This commit is contained in:
fslongjin
2022-05-24 14:36:24 +08:00
parent 1eb9a299b6
commit afeca18206
8 changed files with 41 additions and 18 deletions

View File

@ -1,4 +1,4 @@
user_sub_dirs = libs
user_sub_dirs = libs apps
SUBDIR_ROOTS := .
DIRS := . $(shell find $(SUBDIR_ROOTS) -type d)
@ -6,9 +6,11 @@ GARBAGE_PATTERNS := *.o *.s~ *.s *.S~ *.c~ *.h~ sys_api_lib
GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
objs :=
CFLAGS := $(GLOBAL_CFLAGS)
current_CFLAGS := $(CFLAGS) -I $(shell pwd)/libs
tmp_output_dir=$(ROOT_PATH)/bin/tmp/user
output_dir=$(ROOT_PATH)/bin/user
CFLAGS := $(GLOBAL_CFLAGS) -I $(shell pwd)/libs
current_CFLAGS := $(CFLAGS)
all:
@list='$(user_sub_dirs)'; for subdir in $$list; do \
@ -17,18 +19,25 @@ all:
$(MAKE) all CFLAGS="$(CFLAGS)";\
cd ..;\
done
$(MAKE) init.o
$(MAKE) sys_api_lib
$(shell if [ ! -e $(tmp_output_dir) ];then mkdir -p $(tmp_output_dir); fi)
$(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi)
$(MAKE) sys_api_lib
$(MAKE) shell
# objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary sys_api_lib $(ROOT_PATH)/bin/user/init.bin
objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O elf64-x86-64 sys_api_lib $(ROOT_PATH)/bin/user/init.bin
#objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O elf64-x86-64 sys_api_lib $(ROOT_PATH)/bin/user/init.bin
sys_api_lib: init.o
sys_api_lib:
ld -b elf64-x86-64 -z muldefs -o sys_api_lib $(shell find . -name "*.o")
ld -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/sys_api_lib $(shell find ./libs -name "*.o")
#ld -b elf64-x86-64 -z muldefs -o sys_api_lib init.o $(shell find . -name "*.o") -T init.lds
init.o: init.c
gcc $(current_CFLAGS) -c init.c -o init.o
shell:
ld -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/shell $(shell find ./apps/shell -name "*.o") $(shell find ./libs -name "*.o")
objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O elf64-x86-64 $(tmp_output_dir)/shell $(output_dir)/shell.elf
clean:
rm -rf $(GARBAGE)
rm -rf $(GARBAGE)

10
user/apps/Makefile Normal file
View File

@ -0,0 +1,10 @@
user_apps_sub_dirs=shell
all:
@list='$(user_apps_sub_dirs)'; for subdir in $$list; do \
echo "make all in $$subdir";\
cd $$subdir;\
$(MAKE) all CFLAGS="$(CFLAGS) -I $(shell pwd)";\
cd ..;\
done

4
user/apps/shell/Makefile Normal file
View File

@ -0,0 +1,4 @@
all: shell.o
shell.o: shell.c
gcc $(CFLAGS) -c shell.c -o shell.o

View File

@ -5,7 +5,6 @@
#include <libKeyboard/keyboard.h>
int main()
{
char string[] = "/333.txt";
uint8_t buf[128] = {0};
char tips_str[] = "The first application 'init.bin' started successfully!\n";