Advertisement
Guest User

Untitled

a guest
Apr 19th, 2022
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.83 KB | None | 0 0
  1.  
  2. #
  3. # Makefile
  4. #
  5.  
  6. RGBDS               := C:/rgbds
  7.  
  8. RGBDS_ASM           := $(RGBDS)/rgbasm
  9. RGBDS_LINK          := $(RGBDS)/rgblink
  10. RGBDS_FIX           := $(RGBDS)/rgbfix
  11.  
  12. LINK_FLAGS          :=
  13. FIX_FLAGS           := -v -p 0
  14.  
  15. PROJECT_NAME        := ASMProject
  16. PROJECT_EXT         := gbc
  17. SRC_DIR             := source
  18. INC_DIR             := include
  19. BUILD_DIR           := build
  20. FINAL_DIR           := final
  21. FINAL_TARGET        := $(FINAL_DIR)/$(PROJECT_NAME)
  22.  
  23. $(info "Building : $(FINAL_TARGET).$(PROJECT_EXT)")
  24.  
  25. ########################################
  26.  
  27. # list all source .asm files    : source/main.asm source/player.asm source/battle.asm
  28. SOURCE_FILES        := $(wildcard $(SRC_DIR)/*.asm)
  29.  
  30. # list all include .inc files   : -iinclude/hardware.inc -iinclude/temp.inc
  31. INCLUDE_FILES       := $(addprefix -i, $(wildcard $(INC_DIR)/*.inc))
  32.  
  33. # list all objects to input     : source/main.o source/player.o source/battle.o
  34. OBJECTS_INPUT       := $(SOURCE_FILES:.asm=.o)
  35.  
  36. # list all objects that output  : build/main.o build/player.o build/battle.o
  37. # note they are placed into the build folder by removing the previous directory
  38. # using notdir, then a new directory is prefixed
  39. OBJECTS_OUTPUT      := $(addprefix $(BUILD_DIR)/, $(notdir $(SOURCE_FILES:%.asm=/%.o)))
  40.  
  41. $(info "SOURCE_FILES = $(SOURCE_FILES)")
  42. $(info "INCLUDE_FILES = $(INCLUDE_FILES)")
  43. $(info "OBJECTS_INPUT = $(OBJECTS_INPUT)")
  44. $(info "OBJECTS_OUTPUT = $(OBJECTS_OUTPUT)")
  45.  
  46. ########################################
  47.  
  48. %.o : %.asm
  49.     $(RGBDS_ASM) $(INCLUDE_FILES) -o $(BUILD_DIR)/$(notdir $@) $<
  50.  
  51. $(FINAL_TARGET) : $(OBJECTS_INPUT)
  52.     @$(RGBDS_LINK) $(LINK_FLAGS) -o $@.$(PROJECT_EXT) -n $@.sym $(OBJECTS_OUTPUT)
  53.     @$(RGBDS_FIX) $(FIX_FLAGS) $(FINAL_TARGET).$(PROJECT_EXT)
  54.  
  55. ########################################
  56.  
  57. prepare:
  58.     mkdir -p $(FINAL_DIR)
  59.     mkdir -p $(BUILD_DIR)
  60.  
  61. all: $(FINAL_TARGET)
  62.  
  63. clean:
  64.     rm -rf  $(FINAL_DIR)/*.*
  65.     rm -rf  $(BUILD_DIR)
  66.  
  67. run: $(TARGET)
  68.     $(EMULATOR) $(TARGET)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement