Makefile 551 B

12345678910111213141516171819
  1. all: kernel
  2. objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary kernel ../bin/kernel/kernel.bin
  3. kernel: head.o main.o
  4. ld -b elf64-x86-64 -o kernel head.o main.o -T link.lds
  5. main.o: main.c
  6. # -fno-builtin: 不使用C语言内建函数
  7. # The -m64 option sets int to 32bits and long and pointer to 64 bits and generates code for AMD’s x86-64 architecture.
  8. gcc -mcmodel=large -fno-builtin -m64 -c main.c
  9. head.o: head.S
  10. gcc -E head.S > head.s # 预处理
  11. as --64 -o head.o head.s
  12. clean:
  13. rm -rf *.o *.s~ *.s *.S~ *.c~ *.h~ kernel