Skip to content

Instantly share code, notes, and snippets.

@rafaelfuchsbr
Created March 25, 2022 11:00
Show Gist options
  • Save rafaelfuchsbr/7d10d177c7ca5458bf9ccfe2b11ebd78 to your computer and use it in GitHub Desktop.
Save rafaelfuchsbr/7d10d177c7ca5458bf9ccfe2b11ebd78 to your computer and use it in GitHub Desktop.
Get make targets in order based on dependencies
IMAGE_DIRS = $(wildcard services/* bases/*)
# All targets are `.PHONY` ie allways need to be rebuilt
.PHONY: all ${IMAGE_DIRS}
# Build all images
all: ${IMAGE_DIRS}
# Build and tag a single image
${IMAGE_DIRS}:
$(eval FOLDER := $@)
@echo "${FOLDER}"
bases/golang-1.17.2: bases/tools
# For folders...
# bases/golang-1.17.2
# bases/terraform-0.14.5
# bases/tools
#
# It will echo the following:
# bases/tools
# bases/golang-1.17.2
# bases/terraform-0.14.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment