Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #############################################################
  2. # Options
  3. #
  4. FSSOURCE ?= ../local/fs
  5. LUASOURCE ?= ../local/lua
  6. FLASHSIZE ?= 4mb 32mb 8mb
  7. FLASH_SW = -S
  8. SUBDIRS =
  9. APP_DIR = ../app
  10. OBJDUMP = $(or $(shell which objdump),xtensa-lx106-elf-objdump)
  11. #############################################################
  12. # Get the files to pack into the spiffs image
  13. #
  14. SPIFFSFILES ?= $(patsubst $(FSSOURCE)/%,%,$(shell find $(FSSOURCE)/ -name '*' '!' -name .gitignore ))
  15. #################################################################
  16. # Get the filesize of /bin/0x10000.bin and SPIFFS sizing
  17. #
  18. FLASH_FS_SIZE := $(shell $(CC) -E -dM - <$(APP_DIR)/include/user_config.h | grep SPIFFS_MAX_FILESYSTEM_SIZE| cut -d ' ' -f 3)
  19. ifneq ($(strip $(FLASH_FS_SIZE)),)
  20. FLASHSIZE = $(shell printf "0x%x" $(FLASH_FS_SIZE))
  21. FLASH_SW = -c
  22. endif
  23. FLASH_FS_LOC := $(shell $(CC) -E -dM - <$(APP_DIR)/include/user_config.h | grep SPIFFS_FIXED_LOCATION| cut -d ' ' -f 3)
  24. ifeq ($(strip $(FLASH_FS_LOC)),)
  25. FLASH_FS_LOC := $(shell printf "0x%x" $$((0x$(shell $(OBJDUMP) -t $(APP_DIR)/.output/eagle/debug/image/eagle.app.v6.out |grep " _flash_used_end" |cut -f1 -d" ") - 0x40200000)))
  26. else
  27. FLASH_FS_LOC := $(shell printf "0x%x" $(FLASH_FS_LOC))
  28. endif
  29. LFSSOURCES := $(wildcard $(LUASOURCE)/*.lua)
  30. BUILD_TYPE := $(shell $(CC) $(EXTRA_CCFLAGS) -E -dM - <$(APP_DIR)/include/user_config.h | grep LUA_NUMBER_INTEGRAL | wc -l)
  31. ifeq ($(BUILD_TYPE),0)
  32. LUAC_CROSS := ../luac.cross
  33. else
  34. LUAC_CROSS := ../luac.cross.int
  35. endif
  36. #############################################################
  37. # Rules base
  38. #
  39. #
  40. all: spiffsscript
  41. .PHONY: TEST
  42. TEST:
  43. @echo $(FLASHSIZE)
  44. @echo $(FLASH_FS_SIZE)
  45. @echo $(FLASH_FS_LOC)
  46. @echo $(FLASH_USED_END)
  47. spiffsimg/spiffsimg:
  48. .PHONY: spiffsimg
  49. .PHONY: spiffsimg/spiffsimg
  50. spiffsimg: spiffsimg/spiffsimg
  51. @echo Built spiffsimg in spiffsimg/spiffsimg
  52. spiffsimg/spiffsimg:
  53. @$(MAKE) -C spiffsimg
  54. spiffsscript: remove-image LFSimage spiffsimg/spiffsimg
  55. rm -f ./spiffsimg/spiffs.lst
  56. @echo "" >> ./spiffsimg/spiffs.lst
  57. @$(foreach f, $(SPIFFSFILES), echo "import $(FSSOURCE)/$(f) $(f)" >> ./spiffsimg/spiffs.lst ;)
  58. $(foreach sz, $(FLASHSIZE), spiffsimg/spiffsimg -f ../bin/0x%x-$(sz).img $(FLASH_SW) $(sz) -U $(FLASH_FS_LOC) -r ./spiffsimg/spiffs.lst -d; )
  59. @$(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then echo Built $$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  60. ifneq ($(LFSSOURCES),)
  61. LFSimage: $(LFSSOURCES)
  62. $(LUAC_CROSS) -f -o $(FSSOURCE)/LFS.img $(LFSSOURCES)
  63. else
  64. LFSimage:
  65. rm -f $(FSSOURCE)/LFS.img
  66. endif
  67. remove-image:
  68. $(foreach sz, $(FLASHSIZE), if [ -r ../bin/spiffs-$(sz).dat ]; then rm -f ../bin/$$(cat ../bin/spiffs-$(sz).dat)-$(sz).bin; fi; )
  69. rm -f ../bin/spiffs*.dat
  70. spiffsclean: remove-image
  71. rm -f ./spiffsimg/spiffsimg
  72. rm -f ./spiffsimg/spiffs.lst