Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Created October 15, 2024 04:59
Show Gist options
  • Save jordansissel/23b15c7fed9dad48017283fd65d068a5 to your computer and use it in GitHub Desktop.
Save jordansissel/23b15c7fed9dad48017283fd65d068a5 to your computer and use it in GitHub Desktop.
Non-file dependencies in a Makefile
# 'gem list -i foo' will print 'true' if a gem is already installed. 'false' otherwise
GEMS=clamp rake
# From the GEMS list, generate a list of make targets
TARGETS=$(foreach gem,$(GEMS),gem-$(shell gem list -i $(gem))-$(gem))
build: $(TARGETS)
build:
@echo "=> OK to build"
.PHONY: gem-false-%
gem-false-%: GEM=$(@:gem-false-%=%)
gem-false-%:
@echo Installing "$(GEM)"
gem install $(GEM)
.PHONY: gem-true-%
gem-true-%: GEM=$(@:gem-true-%=%)
gem-true-%:
@echo "Found $(GEM)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment