An emulator, assembler, and disassembler for the Sega Game Gear
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

68 line
1.4 KiB

  1. # Copyright (C) 2014 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. # Released under the terms of the MIT License. See LICENSE for details.
  3. PROGRAM = crater
  4. SOURCES = src
  5. BUILD = build
  6. DEVEXT = -dev
  7. CC = clang
  8. FLAGS = -O2 -Wall -Wextra -pedantic -std=c11
  9. CFLAGS = $(shell sdl2-config --cflags)
  10. LIBS = $(shell sdl2-config --libs)
  11. MKDIR = mkdir -p
  12. RM = rm -rf
  13. ASM_UP = scripts/update_asm_instructions.py
  14. MODE = release
  15. BNRY = $(PROGRAM)
  16. SDRS = $(shell find $(SOURCES) -type d | xargs echo)
  17. SRCS = $(filter-out %.inc.c,$(foreach d,. $(SDRS),$(wildcard $(addprefix $(d)/*,.c))))
  18. OBJS = $(patsubst %.c,%.o,$(addprefix $(BUILD)/$(MODE)/,$(SRCS)))
  19. DEPS = $(OBJS:%.o=%.d)
  20. DIRS = $(sort $(dir $(OBJS)))
  21. ifdef DEBUG
  22. BNRY := $(BNRY)$(DEVEXT)
  23. FLAGS += -g -fsanitize=address -DDEBUG_MODE
  24. MODE = debug
  25. endif
  26. .PHONY: all clean test test-all test-z80 test-asm test-dasm
  27. all: $(BNRY)
  28. clean:
  29. $(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT)
  30. $(DIRS):
  31. $(MKDIR) $@
  32. $(BNRY): $(OBJS)
  33. $(CC) $(FLAGS) $(LIBS) $(OBJS) -o $@
  34. $(OBJS): | $(DIRS)
  35. $(BUILD)/$(MODE)/%.o: %.c
  36. $(CC) $(FLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
  37. -include $(DEPS)
  38. ASM_INST = $(SOURCES)/assembler/instructions
  39. $(ASM_INST).inc.c: $(ASM_INST).yml $(ASM_UP)
  40. python $(ASM_UP)
  41. test: test-all test-z80 test-asm test-dasm
  42. test-all:
  43. @echo "running all tests"
  44. test-z80:
  45. @echo "running Z80 CPU tests"
  46. test-asm:
  47. @echo "running assembler tests"
  48. test-dasm:
  49. @echo "running disassembler tests"