Makefile 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. CC = gcc -O0 -m32 -fno-builtin -fno-stack-protector -nostdinc -nostdlib
  2. LD = ld -melf_i386 -nostdlib
  3. all: rtthread rtsym exe dll floppy.img
  4. @mkdir -p tmp
  5. @sudo mount -t vfat floppy.img tmp -o loop
  6. @sudo cp -fv rtthread.elf tmp/boot/oskernel
  7. @sudo rm tmp/bin/* -fr
  8. @sudo cp out/*.mo tmp/bin/ -fv
  9. @sudo umount tmp
  10. rtthread:
  11. @scons
  12. rtsym:
  13. @./src/extract.sh ./rtthread-ia32.map ./src/rt_thread_sym.h
  14. obj:
  15. mkdir -p obj
  16. out:
  17. mkdir -p out
  18. dll: obj out
  19. $(CC) -c -fPIC -Isrc src/hello.c -o out/hello.o
  20. $(CC) -s -Wl,-shared,-melf_i386,--entry=main -o out/hello.mo out/hello.o
  21. disasm: obj out
  22. $(CC) -shared -S -fPIC -Isrc src/hello.c -o obj/hello.s
  23. cat obj/hello.s
  24. objdump --disassemble out/hello.mo
  25. exe: obj out
  26. clean:
  27. scons -c clean
  28. rm -fr build rtthread* out obj
  29. floppy.img:
  30. wget https://github.com/bajdcc/tinix/raw/master/floppy.img
  31. # https://en.wikibooks.org/wiki/QEMU/Devices/Network
  32. run:
  33. qemu-system-i386 -fda floppy.img -boot a -m 64M -serial stdio -net nic,model=ne2k_pci