Makefile.fpc 2.7 KB

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