makefilet-download-ondemand.mk 1.5 KB

1234567891011121314151617181920212223242526272829303132
  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. # alternative version: "main" (the tip of the current development branch)
  6. MAKEFILET_DOWNLOAD_VERSION ?= v0.12.0
  7. MAKEFILET_DOWNLOAD_URL_TEMPLATE ?= https://notabug.org/sumpfralle/makefilet/archive/__VERSION__.tar.gz
  8. MAKEFILET_DOWNLOAD_URL ?= $(subst __VERSION__,$(MAKEFILET_DOWNLOAD_VERSION),$(MAKEFILET_DOWNLOAD_URL_TEMPLATE))
  9. # first attempt: system-wide installation (e.g. deb package) or submodule of this project?
  10. -include makefilet/main.mk
  11. ifndef DIR_MAKEFILET
  12. # we failed - it is not available globally or as a submodule
  13. # second attempt: include a downloaded makefilet archive
  14. DIR_BUILD ?= build
  15. DIR_MAKEFILET_DOWNLOAD = $(DIR_BUILD)/makefilet
  16. -include $(DIR_MAKEFILET_DOWNLOAD)/main.mk
  17. ifndef DIR_MAKEFILET
  18. # third attempt: download and extract a known release
  19. $(info Downloading 'makefilet' ...)
  20. $(shell mkdir -p "$(DIR_MAKEFILET_DOWNLOAD)" \
  21. && wget --no-verbose --output-document - "$(MAKEFILET_DOWNLOAD_URL)" \
  22. | tar -xz -C "$(DIR_MAKEFILET_DOWNLOAD)" --strip-components=1 -f -)
  23. # last include attempt
  24. -include $(DIR_MAKEFILET_DOWNLOAD)/main.mk
  25. ifndef DIR_MAKEFILET
  26. $(error Failed to initialize 'makefilet'. It seems like it is neither installed system-wide, as a submodule or available via download.)
  27. endif
  28. endif
  29. endif