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.
 
 
 
 
 

66 lines
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. MODE = release
  14. BNRY = $(PROGRAM)
  15. SDRS = $(shell find $(SOURCES) -type d | xargs echo)
  16. SRCS = $(filter-out %.inc.c,$(foreach d,. $(SDRS),$(wildcard $(addprefix $(d)/*,.c))))
  17. OBJS = $(patsubst %.c,%.o,$(addprefix $(BUILD)/$(MODE)/,$(SRCS)))
  18. DEPS = $(OBJS:%.o=%.d)
  19. DIRS = $(sort $(dir $(OBJS)))
  20. ifdef DEBUG
  21. BNRY := $(BNRY)$(DEVEXT)
  22. FLAGS += -g -fsanitize=address -DDEBUG_MODE
  23. MODE = debug
  24. endif
  25. .PHONY: all clean test test-all test-z80 test-asm test-dasm
  26. all: $(BNRY)
  27. clean:
  28. $(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT)
  29. $(DIRS):
  30. $(MKDIR) $@
  31. $(BNRY): $(OBJS)
  32. $(CC) $(FLAGS) $(LIBS) $(OBJS) -o $@
  33. $(OBJS): | $(DIRS)
  34. $(BUILD)/$(MODE)/%.o: %.c
  35. $(CC) $(FLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
  36. -include $(DEPS)
  37. $(SOURCES)/assembler/instructions.inc.c: $(SOURCES)/assembler/instructions.yml
  38. python scripts/update_asm_instructions.py
  39. test: test-all test-z80 test-asm test-dasm
  40. test-all:
  41. @echo "running all tests"
  42. test-z80:
  43. @echo "running Z80 CPU tests"
  44. test-asm:
  45. @echo "running assembler tests"
  46. test-dasm:
  47. @echo "running disassembler tests"