An emulator, assembler, and disassembler for the Sega Game Gear
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

makefile 1.6 KiB

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