Makefile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Cross-compiling (e.g., on Mac OS X)
  2. #TOOLPREFIX = i386-jos-elf-
  3. # Using native tools (e.g., on X86 Linux)
  4. TOOLPREFIX =
  5. # The intermediate directory for compiled object files.
  6. BUILD = build/
  7. CC = $(TOOLPREFIX)gcc
  8. AS = $(TOOLPREFIX)as
  9. LD = $(TOOLPREFIX)ld
  10. OBJCOPY = $(TOOLPREFIX)objcopy
  11. OBJDUMP = $(TOOLPREFIX)objdump
  12. CFLAGS := -fno-pic -static -fno-builtin -fno-strict-aliasing -fshort-wchar -O2 -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -fno-stack-protector -Wa,-march=armv6 -Wa,-mcpu=arm1176jzf-s
  13. initcode: initcode.S
  14. $(CC) $(CFLAGS) -nostdinc -I. -c initcode.S
  15. $(LD) $(LDFLAGS) -N -e start -Ttext 0 -o initcode.out initcode.o
  16. $(OBJCOPY) -S -O binary initcode.out initcode
  17. $(OBJDUMP) -S initcode.o > initcode.asm
  18. ULIB = ulib.o usys.o printf.o umalloc.o
  19. _%: %.o $(ULIB)
  20. $(LD) $(LDFLAGS) -N -e main -Ttext 0 -o $@ $^
  21. $(OBJDUMP) -S $@ > $*.asm
  22. $(OBJDUMP) -t $@ | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $*.sym
  23. _forktest: forktest.o $(ULIB)
  24. # forktest has less library code linked in - needs to be small
  25. # in order to be able to max out the proc table.
  26. $(LD) $(LDFLAGS) -N -e main -Ttext 0 -o _forktest forktest.o ulib.o usys.o
  27. $(OBJDUMP) -S _forktest > forktest.asm
  28. mkfs: mkfs.c ../include/fs.h
  29. gcc -Werror -Wall -o mkfs mkfs.c
  30. # Prevent deletion of intermediate files, e.g. cat.o, after first build, so
  31. # that disk image changes after first build are persistent until clean. More
  32. # details:
  33. # http://www.gnu.org/software/make/manual/html_node/Chained-Rules.html
  34. .PRECIOUS: %.o
  35. UPROGS=\
  36. _cat\
  37. _echo\
  38. _forktest\
  39. _grep\
  40. _init\
  41. _kill\
  42. _ln\
  43. _ls\
  44. _mkdir\
  45. _rm\
  46. _sh\
  47. _stressfs\
  48. _usertests\
  49. _wc\
  50. _zombie\
  51. fs.img: mkfs README $(UPROGS)
  52. ./mkfs fs.img README $(UPROGS)
  53. clean:
  54. rm -f *.o *.d fs.img mkfs $(UPROGS)