Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #
  2. # Copyright (C) 2020 bzt (bztsrc@github)
  3. #
  4. # Permission is hereby granted, free of charge, to any person
  5. # obtaining a copy of this software and associated documentation
  6. # files (the "Software"), to deal in the Software without
  7. # restriction, including without limitation the rights to use, copy,
  8. # modify, merge, publish, distribute, sublicense, and/or sell copies
  9. # of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be
  13. # included in all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  19. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  20. # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. # DEALINGS IN THE SOFTWARE.
  23. #
  24. #
  25. CFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib -nostartfiles
  26. LDFLAGS = -nostdlib -nostartfiles
  27. all: clean rpi4
  28. ARM32CHAIN ?= aarch32-elf-
  29. ARM64CHAIN ?= aarch64-elf-
  30. rpi1: start32.S imgrecv.c
  31. $(ARM32CHAIN)gcc -DMMIO_BASE=0x20000000 -D__WORDSIZE=32 $(CFLAGS) -c imgrecv.c -o imgrecv.o
  32. @make --no-print-directory kernel7.img
  33. rpi2: start32.S imgrecv.c
  34. $(ARM32CHAIN)gcc -DMMIO_BASE=0x3F000000 -D__WORDSIZE=32 $(CFLAGS) -c imgrecv.c -o imgrecv.o
  35. @make --no-print-directory kernel7.img
  36. rpi3: start64.S imgrecv.c
  37. $(ARM64CHAIN)gcc -DMMIO_BASE=0x3F000000 -D__WORDSIZE=64 $(CFLAGS) -c imgrecv.c -o imgrecv.o
  38. @make --no-print-directory kernel8.img
  39. rpi3_32: rpi2
  40. rpi4: start64.S imgrecv.c
  41. $(ARM64CHAIN)gcc -DMMIO_BASE=0xFE000000 -D__WORDSIZE=64 $(CFLAGS) -c imgrecv.c -o imgrecv.o
  42. @make --no-print-directory kernel8.img
  43. rpi4_32: start32.S imgrecv.c
  44. $(ARM32CHAIN)gcc -DMMIO_BASE=0xFE000000 -D__WORDSIZE=32 $(CFLAGS) -c imgrecv.c -o imgrecv.o
  45. @make --no-print-directory kernel7.img
  46. kernel7.img: imgrecv.o
  47. $(ARM32CHAIN)gcc $(CFLAGS) -c start32.S -o start.o
  48. $(ARM32CHAIN)ld $(LDFLAGS) start.o imgrecv.o -T link32.ld -o kernel7.elf
  49. $(ARM32CHAIN)objcopy -O binary kernel7.elf kernel7.img
  50. kernel8.img: imgrecv.o
  51. $(ARM64CHAIN)gcc $(CFLAGS) -c start64.S -o start.o
  52. $(ARM64CHAIN)ld $(LDFLAGS) start.o imgrecv.o -T link64.ld -o kernel8.elf
  53. $(ARM64CHAIN)objcopy -O binary kernel8.elf kernel8.img
  54. clean:
  55. rm *.elf *.img *.o >/dev/null 2>/dev/null || true