makefilet-download-ondemand.mk 1.3 KB

123456789101112131415161718192021222324252627282930
  1. # include this makefile snippet for automatic discovery of a:
  2. # * system-wide 'makefilet' installation (e.g. via the deb package)
  3. # * project-wide inclusion as a git-submodule (or code copy)
  4. # * on-demand download (temporarily stored in the local 'build/' directory)
  5. MAKEFILET_DOWNLOAD_VERSION = 0.2.4
  6. MAKEFILET_DOWNLOAD_URL ?= https://notabug.org/sumpfralle/makefilet/archive/v$(MAKEFILET_DOWNLOAD_VERSION).tar.gz
  7. # first attempt: system-wide installation (e.g. deb package) or submodule of this project?
  8. -include makefilet/main.mk
  9. ifeq ($(DIR_MAKEFILET), )
  10. # we failed - it is not available globally or as a submodule
  11. # second attempt: include a downloaded makefilet archive
  12. DIR_BUILD ?= build
  13. DIR_MAKEFILET_DOWNLOAD = $(DIR_BUILD)/makefilet
  14. -include $(DIR_MAKEFILET_DOWNLOAD)/main.mk
  15. ifeq ($(DIR_MAKEFILET), )
  16. # third attempt: download and extract a known release
  17. $(info Downloading 'makefilet' ...)
  18. $(shell mkdir -p "$(DIR_MAKEFILET_DOWNLOAD)" \
  19. && wget -q -O - "$(MAKEFILET_DOWNLOAD_URL)" \
  20. | tar -xz -C "$(DIR_MAKEFILET_DOWNLOAD)" --strip-components=1)
  21. # last include attempt
  22. -include $(DIR_MAKEFILET_DOWNLOAD)/main.mk
  23. ifeq ($(DIR_MAKEFILET), )
  24. $(error Failed to initialize 'makefilet'. It seems like it is neither installed system-wide, as a submodule or available via download.)
  25. endif
  26. endif
  27. endif