Makefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # This now assumes GNU make or equivalent
  2. MAKEFLAGS += -R -r
  3. Z80ASM = z80asm # Get rid of these...
  4. PERL = perl
  5. Z80_CPP = gcc -E -x assembler-with-cpp
  6. CROSS = ../../../tools/gnu/bin/z80-none-elf-
  7. Z80_AS = $(CROSS)as
  8. Z80_LD = $(CROSS)ld
  9. Z80_OBJCOPY = $(CROSS)objcopy
  10. Z80_OBJDUMP = $(CROSS)objdump
  11. Z80_NM = $(CROSS)nm
  12. INCLUDE = -I$(O) -I./abc80 -I.
  13. SFLAGS = $(INCLUDE) -undef -nostdinc -D__ASSEMBLER__ -D__Z80__
  14. ASFLAGS = $(INCLUDE) -ahlsgm=$*.lst --no-pad-sections -g
  15. LDFLAGS =
  16. # Used for make clean
  17. AUXRAM = abc80/nvram_20k abc80/nvram_22k abc80/no_nvram
  18. UFDDOS = ../$(O)/ufddos80.rom
  19. PRINT = ../$(O)/print80_29.rom ../$(O)/print80_30.rom ../$(O)/print80_28.rom
  20. ROMS = $(UFDDOS) $(PRINT)
  21. HDRS80 = $(O)/nvram.inc abc80/abc80.inc abc80/auxram.inc abc80/print80.inc
  22. HDRS = z80.inc $(HDRS80)
  23. .SUFFIXES:
  24. .SECONDARY:
  25. .DELETE_ON_ERROR:
  26. all:
  27. set -e; for r in $(AUXRAM); do $(MAKE) O=$$r all_O; done
  28. all_O: $(ROMS)
  29. # .asm rather than .S to avoid problems on monocase filesystems
  30. $(O)/%.s: $(O)/../%.asm $(HDRS)
  31. $(Z80_CPP) $(SFLAGS) -o $@ $<
  32. %.o: %.s
  33. $(Z80_AS) $(ASFLAGS) -o $@ $<
  34. %.elf: %.o z80.ld z80ld.conf
  35. $(Z80_LD) @z80ld.conf -T z80.ld $(LDFLAGS) \
  36. -Map=$*.map --cref -o $@ $<
  37. %.bin: %.elf
  38. $(Z80_OBJCOPY) -O binary $< $@
  39. # Default rule
  40. ../$(O)/%.rom: $(O)/%.bin
  41. mkdir -p $(@D) && cp -f $< $@
  42. clean:
  43. find . -type f \
  44. -name '*.o' -o -name '*.lst' -o -name '*.map' -o \
  45. -name '*.s' -o -name '*.elf' -o -name '*.bin' \
  46. | xargs rm -f
  47. spotless: clean
  48. $(MAKE) O=*/* spotless_O
  49. spotless_O:
  50. rm -f $(ROMS)