1CC=x86_64-elf-gcc
2LD=x86_64-elf-ld
3OBJCOPY=x86_64-dragonos-objcopy
4# 修改这里,把它改为你的relibc的sysroot路径
5RELIBC_SYSROOT=/home/longjin/relibc/sysroot
6CFLAGS=-I $(RELIBC_SYSROOT)/usr/include
7# 修改这里,把它改为你的DragonOS的根目录
8ROOT_PATH=/home/longjin/code/DragonOS
9tmp_output_dir=$(ROOT_PATH)/bin/tmp/user
10output_dir=$(ROOT_PATH)/bin/user
11
12LIBC_OBJS:=$(shell find $(RELIBC_SYSROOT)/usr/lib -name "*.o")
13LIBC_OBJS+=$(RELIBC_SYSROOT)/usr/lib/libc.a
14
15all: main.o
16
17	$(LD) -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/test  $(shell find . -name "*.o") $(LIBC_OBJS) -T link.lds
18
19	$(OBJCOPY) -I elf64-x86-64 -R ".eh_frame" -R ".comment" -O elf64-x86-64 $(tmp_output_dir)/test $(output_dir)/test.elf
20main.o: main.c
21	$(CC) $(CFLAGS) -c main.c  -o main.o
22