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.

makefile 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (C) 2014-2016 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. TESTS = cpu vdp psg asm dis integrate
  8. CC = clang
  9. FLAGS = -Wall -Wextra -pedantic -std=c11
  10. CFLAGS = $(shell sdl2-config --cflags)
  11. LIBS = $(shell sdl2-config --libs)
  12. DFLAGS = -g
  13. RFLAGS = -O2
  14. MKDIR = mkdir -p
  15. RM = rm -rf
  16. ASM_UP = scripts/update_asm_instructions.py
  17. SDRS = $(shell find $(SOURCES) -type d | xargs echo)
  18. SRCS = $(filter-out %.inc.c,$(foreach d,. $(SDRS),$(wildcard $(addprefix $(d)/*,.c))))
  19. OBJS = $(patsubst %.c,%.o,$(addprefix $(BUILD)/$(MODE)/,$(SRCS)))
  20. DEPS = $(OBJS:%.o=%.d)
  21. DIRS = $(sort $(dir $(OBJS)))
  22. TCPS = $(addprefix test-,$(TESTS))
  23. ifdef DEBUG
  24. BNRY := $(PROGRAM)$(DEVEXT)
  25. FLGS += $(DFLAGS) $(FLAGS)
  26. MODE = debug
  27. else
  28. BNRY := $(PROGRAM)
  29. FLGS += $(RFLAGS) $(FLAGS)
  30. MODE = release
  31. endif
  32. export CC
  33. export FLAGS
  34. export RM
  35. .PHONY: all clean test tests test-prereqs test-make-prereqs $(TCPS)
  36. all: $(BNRY)
  37. clean:
  38. $(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT)
  39. @$(MAKE) -C tests clean
  40. $(DIRS):
  41. $(MKDIR) $@
  42. $(BNRY): $(OBJS)
  43. $(CC) $(FLGS) $(LIBS) $(OBJS) -o $@
  44. $(OBJS): | $(DIRS)
  45. $(BUILD)/$(MODE)/%.o: %.c
  46. $(CC) $(FLGS) $(CFLAGS) -MMD -MP -c $< -o $@
  47. -include $(DEPS)
  48. ASM_INST = $(SOURCES)/assembler/instructions
  49. $(ASM_INST).inc.c: $(ASM_INST).yml $(ASM_UP)
  50. python $(ASM_UP)
  51. test-prereqs: $(PROGRAM)
  52. @: # No-op; prevents make from cluttering output with "X is up to date"
  53. test-make-prereqs:
  54. @$(MAKE) test-prereqs DEBUG=
  55. test: test-make-prereqs
  56. @$(MAKE) -C tests -s all
  57. tests: test
  58. $(TCPS): test-make-prereqs
  59. @$(MAKE) -C tests -s $(subst test-,,$@)