Makefile.fpc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #
  2. # Makefile.fpc for Free Pascal libndsfpc 2.x.y Examples
  3. #
  4. [target]
  5. loaders=
  6. programs=backgrounds
  7. [require]
  8. packages=libndsfpc
  9. tools=bin2s mmutil grit rmdir mv
  10. nortl=y
  11. [install]
  12. fpcpackage=y
  13. [default]
  14. cpu=arm
  15. target=nds
  16. fpcdir=
  17. [compiler]
  18. options=-g -Xm
  19. [clean]
  20. files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \
  21. $(BUILD)/* \
  22. $(INC)/*
  23. units=*
  24. [prerules]
  25. BUILD = build
  26. DATA = data
  27. GFX = gfx
  28. INC = inc
  29. AUDIO_FILES = $(foreach dir, $(notdir $(wildcard audio/*.*)), $(CURDIR)/audio/$(dir))
  30. GFX_FILES = $(foreach dir, $(GFX), $(notdir $(wildcard $(dir)/*.bmp $(dir)/*.png)))
  31. BIN_FILES = $(foreach dir, $(DATA), $(notdir $(wildcard $(dir)/*)))
  32. [rules]
  33. .NOTPARALLEL:
  34. clean: dir_delete fpc_clean fpc_cleanall
  35. all: dir_make $(BIN_FILES) $(GFX_FILES) fpc_all
  36. #
  37. # Delete temp directories
  38. #
  39. dir_delete:
  40. @$(DELTREE) $(CURDIR)/$(BUILD)
  41. @$(DELTREE) $(CURDIR)/$(INC)
  42. #
  43. # Create temp directories
  44. #
  45. dir_make:
  46. ifneq ($(BUILD), $(CURDIR))
  47. @$(MKDIR) $(BUILD)
  48. endif
  49. ifneq ($(INC), $(CURDIR))
  50. @$(MKDIR) $(INC)
  51. endif
  52. #
  53. # Audio files processing rule
  54. #
  55. soundbank.bin.o : $(AUDIO_FILES)
  56. @$(MMUTIL) $^ -d -o$(BUILD)/soundbank.bin -h$(BUILD)/soundbank.h
  57. $(BIN2S) $(BUILD)/soundbank.bin > $(BUILD)/soundbank.bin.s
  58. $(AS) -o $(BUILD)/soundbank.bin.o $(BUILD)/soundbank.bin.s
  59. #
  60. # Png files processing rule
  61. #
  62. $(GFX_FILES): $(wildcard %.bmp %.png)
  63. @echo 'Converting $(@) file to asm...'
  64. $(GRIT) $(GFX)/$(@) -fp -fts -ff $(GFX)/$(basename $(@)).grit -o$(BUILD)/$(@)
  65. @echo 'Assembling $(@).s file...'
  66. $(AS) -o $(BUILD)/$(basename $(@)).o $(BUILD)/$(basename $(@)).s
  67. $(MV) -f $(BUILD)/$(basename $(@)).inc $(INC)/$(basename $(@)).inc
  68. @echo 'Done!'
  69. #
  70. # Binary files processing rule
  71. #
  72. $(BIN_FILES): $(wildcard %.*)
  73. @echo 'Converting $(@) file to asm...'
  74. @$(BIN2S) $(DATA)/$(@) > $(BUILD)/$(@).s
  75. @echo 'Creating $(@).inc include file...'
  76. @echo "var" > `(echo "$(INC)/"$(@F) | tr . .)`.inc
  77. @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "$(INC)/"$(@F) | tr . .)`.inc
  78. @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "$(INC)/"$(@F) | tr . .)`.inc
  79. @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "$(INC)/"$(@F) | tr . .)`.inc
  80. @echo 'Assembling $(@).s file...'
  81. @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
  82. @echo 'Done!'